20% rule for max pillar 2 voluntary purchase when salary changed during the year

Suppose you moved to Switzerland within the last 5 years. In that case you can only pay a max of 20% of the insured salary into the pillar 2, even if the pension certificate says a larger amount can be paid in.

Is this max 20% based on the salary at the time of the purchase, or based on the income throughout the whole tax year?

e.g. suppose you earn 100k CHF working at 100% for the first 6 months of the year, and then go to 50k@50% halfway through, so the total earned in the year is 75k. At the end of the year you want to make a payment: is the max allowed 10k (20% of 50k) or 15k (20% of 75k)?