diff --git a/changelog.d/2237.fixed.md b/changelog.d/2237.fixed.md new file mode 100644 index 0000000000..4c4c48d226 --- /dev/null +++ b/changelog.d/2237.fixed.md @@ -0,0 +1 @@ +- Limited pension contributions relief by relevant UK earnings (or the £3,600 basic amount through relief at source) instead of the annual allowance. Calculated the annual allowance charge across UK or Scottish tax bands with unused allowance carried forward, applying the statutory named-rate ordinary-income condition to the RAS band extension and preserving Gift Aid's separate gross band extension. Separate savings and UK property rates do not establish RAS eligibility. diff --git a/docs/engineering/gift-aid.md b/docs/engineering/gift-aid.md index 2437e5efa2..5c6098a0c4 100644 --- a/docs/engineering/gift-aid.md +++ b/docs/engineering/gift-aid.md @@ -85,3 +85,44 @@ additional relief. Changing tax band can also increase the Personal Savings Allowance discretely under s. 12B, so its relief cannot be bounded by a constant times a very small gift. Tests of the continuous band-extension bound must allow for that allowance change or hold the zero-rate allowance fixed. + +## Pension annual allowance charge + +The annual allowance charge uses reduced net income after ITA 2007 s. 23 +Step 3 ([FA 2004 s. 227(4B)](https://www.legislation.gov.uk/ukpga/2004/12/section/227)). +It starts from `net_income`, before the s. 58 gross Gift Aid deduction, and +subtracts `allowances` after removing relieved relief-at-source pension +contributions. Gift Aid is already excluded from those allowances. The charge +then stacks the excess pension input amount on this base. Gross Gift Aid +extends the rate limits under s. 227(4C), independently of pension relief. +This keeps the Gift Aid adjustment to adjusted net income separate from the +amount charged to tax. + +The pension extension is conditional. [FA 2004 s. 192(4)/(4A)](https://www.legislation.gov.uk/ukpga/2004/12/section/192) +requires ordinary income, apart from relief under that section, to attract +higher/additional-rate tax, or a Scottish rate above basic. The charge uses +only limits increased under s. 192; s. 227(5) excludes the pension excess from +income, so that excess cannot satisfy the condition. The model tests ordinary +liability before RAS relief, retaining Gift Aid's extension and the existing +allowance allocation. Scottish liability uses non-savings income, including +property income. The UK condition names the higher and additional rates: +separate dividend rates, savings rates from 2017-18 and property rates from +2027-28 do not satisfy it. [FA 2016 s. 6](https://www.legislation.gov.uk/ukpga/2016/24/section/6/enacted) +introduced savings rates and expressly added them to some other higher-rate +tests, without expanding s. 192(4). [FA 2026 s. 6](https://www.legislation.gov.uk/ukpga/2026/11/section/6/enacted) +and [Schedule 1](https://www.legislation.gov.uk/ukpga/2026/11/schedule/1/enacted) +introduce property rates without expanding s. 192 either. Before those +changes, income charged at ordinary higher/additional rates can qualify. +Scottish property remains subject to Scottish rates under ITA 2007 +s. 11CA(4), so it can still meet s. 192(4A). + +[HMRC PTM056120](https://www.gov.uk/hmrc-internal-manuals/pensions-tax-manual/ptm056120) +describes the RAS extension for the annual allowance charge without stating +this condition. Its examples do not resolve low-income contributors whose +pension excess crosses a band. The model follows the statutory condition; +the [2018/459 explanatory memorandum, paragraph 7.4](https://www.legislation.gov.uk/uksi/2018/459/pdfs/uksiem_20180459_en.pdf) +also describes an above-basic Scottish liability requirement. Assessment +practice under the broader manual description remains a methodology question. +The charge can exceed relief on the contribution when ordinary income fails +the condition, so contribution and Gift Aid tax-monotonicity comparisons must +hold eligibility for the RAS extension fixed. diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_for_annual_allowance.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_for_annual_allowance.yaml index bc247412d8..a68044e979 100644 --- a/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_for_annual_allowance.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_for_annual_allowance.yaml @@ -76,5 +76,5 @@ pension_contributions_via_salary_sacrifice: 0 output: # Total: 10_000 + 5_000 + 50_000 = 65_000 - # This exceeds the 2024 AA of 40_000 (verified separately by AA tax charge test) + # This exceeds the 2024 AA of 60_000 (verified separately by AA tax charge test) pension_contributions_for_annual_allowance: 65_000 diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_relief.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_relief.yaml index dc3dc27731..7ea1ec526f 100644 --- a/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_relief.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/pension_contributions_relief.yaml @@ -6,14 +6,20 @@ personal_pension_contributions: 40000 output: pension_contributions_relief: 40000 -- name: Pension relief excessive +- name: Pension relief is not capped at the (tapered) annual allowance period: 2020 - absolute_error_margin: 0 + absolute_error_margin: 0.01 input: employment_income: 2000000 personal_pension_contributions: 400000 output: - pension_contributions_relief: 4000 + # FA 2004 s. 190: relief up to relevant UK earnings, so all 400,000 is + # relieved even though the tapered annual allowance is 4,000. + pension_contributions_relief: 400000 + # The annual allowance charge recovers the relief on the excess: + # (400,000 - 4,000) at 45% on top of reduced net income of 1,600,000. + pension_annual_allowance_chargeable_amount: 396000 + personal_pension_contributions_tax: 396000 * 0.45 - name: £30k self-employment income, no private pension contributions period: 2023 absolute_error_margin: 0.01 @@ -49,3 +55,64 @@ output: pension_contributions_relief: 6_000 income_tax: 11432 - 6000 * 0.4 + +- name: Relief on the basic amount when relevant earnings are lower (s. 190(2)) + period: 2024 + absolute_error_margin: 0.01 + input: + employment_income: 2_000 + personal_pension_contributions: 5_000 + output: + pension_contributions_relief: 3_600 + +- name: A net pay arrangement cannot give the basic-amount increase (s. 191(7)) + period: 2024 + absolute_error_margin: 0.01 + input: + employment_income: 2_000 + employee_pension_contributions_reported: 3_000 + output: + pension_contributions_relief: 2_000 + +- name: Only relief at source fills the basic-amount increase (s. 191(7)) + period: 2024 + absolute_error_margin: 0.01 + input: + employment_income: 2_000 + employee_pension_contributions_reported: 1_500 + personal_pension_contributions: 1_000 + output: + # 2_000 of earnings relieves all 2_500 up to earnings; the increase to + # 3_600 can only come from the 1_000 of relief at source, of which 500 is + # left after earnings: 2_000 + 500. + pension_contributions_relief: 2_500 + +- name: Relief up to relevant earnings, not beyond (s. 190(1)) + period: 2024 + absolute_error_margin: 0.01 + input: + employment_income: 40_000 + self_employment_income: 10_000 + personal_pension_contributions: 70_000 + output: + pension_contributions_relief: 50_000 + +- name: A trading loss does not reduce relevant earnings from employment + period: 2024 + absolute_error_margin: 0.01 + input: + employment_income: 40_000 + self_employment_income: -10_000 + personal_pension_contributions: 45_000 + output: + pension_contributions_relief: 40_000 + +- name: No relief on contributions paid at 75 or over (s. 188(3)(a)) + period: 2024 + absolute_error_margin: 0.01 + input: + age: 75 + employment_income: 40_000 + personal_pension_contributions: 10_000 + output: + pension_contributions_relief: 0 diff --git a/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/personal_pension_contributions_tax.yaml b/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/personal_pension_contributions_tax.yaml index efee04245b..78c4d24cf9 100644 --- a/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/personal_pension_contributions_tax.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/hmrc/pensions/personal_pension_contributions_tax.yaml @@ -7,6 +7,11 @@ # # The pension annual allowance is £60,000 from 2023-04-06 (FA 2004 s.228, # as amended by Finance (No. 2) Act 2023). +# Relief and the annual allowance charge are separate: FA 2004 ss.188-190 +# cap individual relief at relevant UK earnings (or the £3,600 basic amount), +# while ss.227-238 govern pension input amounts and the annual allowance charge. +# https://www.legislation.gov.uk/ukpga/2004/12/section/190 +# https://www.legislation.gov.uk/ukpga/2004/12/part/4/chapter/5/crossheading/annual-allowance-charge - name: Contributions within annual allowance - no tax charge period: 2024 @@ -28,10 +33,11 @@ employee_pension_contributions_reported: 70_000 output: # Total for AA: 70_000, excess = 70_000 - 60_000 = 10_000 - # pension_contributions_relief = min(100k, 70k) then min(70k, 60k) = 60_000 - # taxed_income = 100_000 - 12_570 - 60_000 = 27_430 - # Marginal rate at 27_430 = 20% (basic rate) + # pension_contributions_relief = 70_000 (within relevant earnings) + # reduced net income = 100_000 - 12_570 - 70_000 = 17_430 + # 17_430 + 10_000 = 27_430 is within the basic rate band # Tax charge: 10_000 * 0.2 = 2_000 + pension_contributions_relief: 70_000 personal_pension_contributions_tax: 2_000 - name: Employer contributions push total over AA @@ -44,8 +50,8 @@ output: # Total for AA: 20_000 + 50_000 = 70_000, excess = 70_000 - 60_000 = 10_000 # pension_contributions_relief = min(100k, 20k) = 20_000 - # taxed_income = 100_000 - 12_570 - 20_000 = 67_430 - # Marginal rate at 67_430 = 40% (higher rate) + # reduced net income = 100_000 - 12_570 - 20_000 = 67_430 + # 67_430 to 77_430 is within the higher rate band # Tax charge: 10_000 * 0.4 = 4_000 personal_pension_contributions_tax: 4_000 @@ -58,7 +64,477 @@ output: # Total for AA: 70_000 (all employer), excess = 70_000 - 60_000 = 10_000 # pension_contributions_relief = 0 (no employee/personal contributions) - # taxed_income = 100_000 - 12_570 = 87_430 - # Marginal rate at 87_430 = 40% (higher rate) + # reduced net income = 100_000 - 12_570 = 87_430 + # 87_430 to 97_430 is within the higher rate band # Tax charge: 10_000 * 0.4 = 4_000 personal_pension_contributions_tax: 4_000 + +# Issue #2237 reproducer: one adult, £150,000 earnings, London, 2024. Before +# the fix, relief stopped at the £60,000 allowance and the charge was also +# levied on the excess, so £80,000 of contributions cost £8,000 more income +# tax than £60,000. Relief now runs to relevant earnings and the charge +# recovers it once, so income tax is the same. +- name: Issue 2237 - contributions at the annual allowance + period: 2024 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 150_000 + personal_pension_contributions: 60_000 + region: LONDON + output: + pension_contributions_relief: 60_000 + personal_pension_contributions_tax: 0 + income_tax: 28_460 + +- name: Issue 2237 - contributions £20,000 above the annual allowance + period: 2024 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 150_000 + personal_pension_contributions: 80_000 + region: LONDON + output: + pension_contributions_relief: 80_000 + pension_annual_allowance_chargeable_amount: 20_000 + # Model reduced net income £150,000, with the basic and higher limits + # extended by £80,000. The entire charge is at the higher rate. + # The omitted RAS adjustment to the personal-allowance taper does not + # change the charge's band in this case. + personal_pension_contributions_tax: 8_000 + income_tax: 28_460 + +- name: Charge spans bands as the top slice of reduced net income (s. 227(4A)) + period: 2024 + absolute_error_margin: 0.01 + input: + employment_income: 60_000 + employee_pension_contributions_reported: 60_000 + employer_pension_contributions: 40_000 + output: + # Net pay: relief 60_000 comes off employment income, so reduced net + # income is 60_000 - 60_000 floored at 0 (the personal allowance is + # unused). Chargeable amount 100_000 - 60_000 = 40_000: 37_700 at 20% and + # 2_300 at 40%. + pension_contributions_relief: 60_000 + pension_annual_allowance_chargeable_amount: 40_000 + personal_pension_contributions_tax: 37_700 * 0.2 + 2_300 * 0.4 + +- name: Relief at source raises rate limits with ordinary higher-rate income (ss. 192(4), 227(4C)) + period: 2024 + absolute_error_margin: 0.01 + input: + employment_income: 60_000 + personal_pension_contributions: 60_000 + employer_pension_contributions: 40_000 + output: + # Relief at source leaves reduced net income at 60_000 - 12_570 = 47_430 + # before s.192 relief, above the basic limit. Section 192(4) therefore + # raises the basic rate limit by 60_000 to 97_700, so all 40_000 + # of the chargeable amount falls at 20%. + personal_pension_contributions_tax: 40_000 * 0.2 + +# FA 2004 s.192(4)/(4A) tests ordinary income before s.192 relief. The +# annual allowance excess is not income for that test (s.227(5)). These +# reproduce the review's cases where only the excess enters higher bands. +- name: Basic-rate ordinary income does not qualify for RAS band extension + period: 2024 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 40_000 + personal_pension_contributions: 20_000 + employer_pension_contributions: 60_000 + region: LONDON + output: + pension_contributions_relief: 20_000 + pension_annual_allowance_chargeable_amount: 20_000 + # RNI £27,430; £10,270 of excess at 20%, £9,730 at 40%. + personal_pension_contributions_tax: 5_946 + +- name: Scottish basic-rate ordinary income does not qualify for RAS band extension + period: 2026 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 25_000 + personal_pension_contributions: 20_000 + employer_pension_contributions: 60_000 + region: SCOTLAND + output: + pension_contributions_relief: 20_000 + pension_annual_allowance_chargeable_amount: 20_000 + # RNI £12,430; £4,526 at 20%, £14,136 at 21%, £1,338 at 42%. + personal_pension_contributions_tax: 4_435.72 + +- name: RAS eligibility starts strictly above the ordinary UK basic-rate limit + period: 2024 + absolute_error_margin: 0.01 + input: + age: [45, 45] + employment_income: [50_270, 50_271] + personal_pension_contributions: [20_000, 20_000] + employer_pension_contributions: [60_000, 60_000] + region: [LONDON, LONDON] + output: + # RNI exactly £37,700 has no ordinary higher-rate income; the £20,000 + # charge is all at 40%. At RNI £37,701, the £20,000 RAS extension applies: + # £19,999 of excess at 20% plus £1 at 40%. + personal_pension_contributions_tax: [8_000, 4_000.20] + +- name: Separate savings and dividend rates do not qualify for RAS extension + period: 2024 + absolute_error_margin: 0.01 + input: + age: [45, 45] + employment_income: [40_000, 40_000] + savings_interest_income: [20_000, 0] + dividend_income: [0, 20_000] + personal_pension_contributions: [20_000, 20_000] + employer_pension_contributions: [60_000, 60_000] + region: [LONDON, LONDON] + output: + # RNI £47,430 in both cases. Savings higher and dividend upper rates + # are separate rates, outside the literal s.192(4) condition. + personal_pension_contributions_tax: [8_000, 8_000] + +- name: Savings higher rate alone does not satisfy the literal s192 condition + period: 2024 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 40_000 + savings_interest_income: 15_000 + personal_pension_contributions: 20_000 + employer_pension_contributions: 60_000 + region: LONDON + output: + # FA 2016 s.6 introduced separate savings higher/additional rates from + # 2017-18 without expanding FA 2004 s.192(4). Ordinary non-savings + # £27,430 remains below basic; RNI £42,430 plus £20,000 excess is 40%. + personal_pension_contributions_tax: 8_000 + +- name: Separate property higher rate does not satisfy the literal s192 condition + period: 2027 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 20_000 + property_income: 32_000 + personal_pension_contributions: 20_000 + employer_pension_contributions: 60_000 + region: LONDON + output: + # FA 2026 s.6 introduces separate property rates from 2027-28 without + # expanding s.192(4). Other non-savings income is below basic; the + # excess is taxed at the s.227 UK rates on top of RNI £39,430. + personal_pension_contributions_tax: 8_000 + +- name: Savings taxed at the ordinary higher rate qualify before separate savings rates + period: 2016 + absolute_error_margin: 0.01 + input: + age: 45 + # Supply the statutory 2016-17 allowance to isolate the RAS condition + # from the inherited historical PA parameter (which retains £10,600). + # https://www.legislation.gov.uk/ukpga/2015/11/section/5 + personal_allowance: 11_000 + employment_income: 40_000 + savings_interest_income: 15_000 + personal_pension_contributions: 20_000 + employer_pension_contributions: 40_000 + region: LONDON + output: + # RNI £44,000 includes ordinary higher-rate savings before 2017-18. + # RAS extends the £32,000 basic limit to £52,000: £8,000 at 20%, + # then £12,000 at 40% of the £20,000 annual allowance excess. + personal_pension_contributions_tax: 6_400 + +- name: Property taxed at the ordinary higher rate qualifies before separate property rates + period: 2026 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 20_000 + property_income: 32_000 + personal_pension_contributions: 20_000 + employer_pension_contributions: 60_000 + region: LONDON + output: + # RNI £39,430 includes ordinary higher-rate property before 2027-28. + # The RAS extension puts £18,270 at 20% and £1,730 at 40%. + personal_pension_contributions_tax: 4_346 + +- name: Wholly nil-rate savings do not qualify for RAS band extension + period: 2024 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 50_200 + savings_interest_income: 100 + personal_pension_contributions: 20_000 + employer_pension_contributions: 60_000 + region: LONDON + output: + # Before RAS, non-savings £37,630 is below basic. The £100 savings + # takes RNI to £37,730 but is wholly covered by the PSA. No ordinary + # higher-rate tax is chargeable, so the £20,000 excess is all at 40%. + personal_pension_contributions_tax: 8_000 + +- name: Gift Aid can remove ordinary higher-rate liability and the RAS extension + period: 2024 + absolute_error_margin: 0.01 + input: + age: [45, 45] + employment_income: [60_000, 60_000] + personal_pension_contributions: [20_000, 20_000] + employer_pension_contributions: [60_000, 60_000] + gift_aid: [0, 8_000] + region: [LONDON, LONDON] + output: + # RNI £47,430. Without a gift, ordinary income is above £37,700 and + # RAS raises that limit to £57,700. With £10,000 gross Gift Aid, the + # ordinary limit is £47,700: no s.192 claim, and only the gift extends + # the charge's limit. The £20,000 excess then has £270 at 20% and + # £19,730 at 40%. Tax need not be monotone when RAS eligibility changes. + personal_pension_contributions_tax: [5_946, 7_946] + +- name: UK higher-rate savings do not meet the Scottish RAS extension condition + period: 2026 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 25_000 + savings_interest_income: 30_000 + personal_pension_contributions: 20_000 + employer_pension_contributions: 60_000 + region: SCOTLAND + output: + # Non-savings RNI £12,430 is below Scottish intermediate rate. Higher + # UK rates on savings do not meet s.192(4A)'s Scottish-rate condition. + # RNI £42,430 plus £20,000 excess remains in the Scottish 42% band. + personal_pension_contributions_tax: 8_400 + +- name: RAS condition uses the Scottish basic limit before the starter band existed + period: 2017 + absolute_error_margin: 0.01 + input: + age: [45, 45] + employment_income: [43_000, 43_001] + personal_pension_contributions: [20_000, 20_000] + employer_pension_contributions: [40_000, 40_000] + region: [SCOTLAND, SCOTLAND] + output: + # PA £11,500, Scottish basic limit £31,500, AA £40,000. RNI exactly + # at the basic limit does not meet s.192(4A); £1 above does, raising + # the limit by RAS. The £20,000 excess is 40%, or £19,999 at 20% + £1 at 40%. + pension_annual_allowance_chargeable_amount: [20_000, 20_000] + personal_pension_contributions_tax: [8_000, 4_000.20] + +- name: Gift Aid raises the rate limits by its grossed-up amount (s. 227(4C)) + period: 2025 + absolute_error_margin: 0.01 + input: + employment_income: 60_000 + personal_pension_contributions: 10_000 + employer_pension_contributions: 60_000 + gift_aid: 1_000 + output: + # Reduced net income 60_000 - 12_570 = 47_430. Basic rate limit + # 37_700 + 10_000 + 1_250 (Gift Aid grossed up) = 48_950. Chargeable + # amount 70_000 - 60_000 = 10_000: 1_520 at 20%, 8_480 at 40%. + personal_pension_contributions_tax: 1_520 * 0.2 + 8_480 * 0.4 + +- name: Gift Aid with relief at source above relevant earnings crosses the basic band + period: 2024 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 40_000 + personal_pension_contributions: 70_000 + employer_pension_contributions: 50_000 + gift_aid: 1_000 + region: LONDON + output: + # FA 2004 ss.188-190: only £40,000 of the £70,000 personal contribution + # attracts relief. The unrelieved £30,000 remains part of the pension + # input amount under s.233(1)(a), assuming it has not been refunded. + # https://www.gov.uk/hmrc-internal-manuals/pensions-tax-manual/ptm053200 + pension_contributions_relief: 40_000 + pension_contributions_for_annual_allowance: 120_000 + pension_annual_allowance: 60_000 + pension_annual_allowance_chargeable_amount: 60_000 + gift_aid_grossed_up: 1_250 + # ITA 2007 s.58 deducts the gross gift for adjusted net income only; + # it does not deduct the gift from net income or reduced net income. + # https://www.legislation.gov.uk/ukpga/2007/3/section/58 + net_income: 40_000 + # s.227(4B): RNI = £40,000 - £12,570 PA = £27,430, with no Gift Aid + # deduction. Ordinary income is below higher rate, so s.192(4) does + # not increase the limit for RAS. Section 227(5) excludes the excess + # from that income condition. Only £1,250 gross Gift Aid extends the + # basic limit to £38,950: £11,520 at 20% and £48,480 at 40%. The gift + # reduces the no-gift charge of £21,946 by £250. + personal_pension_contributions_tax: 11_520 * 0.2 + 48_480 * 0.4 + +- name: Relief at source above relevant earnings without Gift Aid + period: 2024 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 40_000 + personal_pension_contributions: 70_000 + employer_pension_contributions: 50_000 + region: LONDON + output: + # The same £27,430 RNI and £60,000 chargeable amount. Ordinary income + # is below higher rate, so s.192(4) leaves the basic limit at £37,700. + pension_contributions_relief: 40_000 + pension_annual_allowance_chargeable_amount: 60_000 + personal_pension_contributions_tax: 10_270 * 0.2 + 49_730 * 0.4 + +- name: Fully tapered annual allowance still allows relief up to relevant earnings + period: 2024 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 400_000 + personal_pension_contributions: 100_000 + region: LONDON + output: + # FA 2004 s.228ZA: threshold income £300,000 > £200,000 and adjusted + # income £400,000 > £260,000. £60,000 - (£400,000 - £260,000) / 2 + # reaches the £10,000 floor. The model's simplified taper gives the + # same floor here; this case does not validate both statutory tests. + # https://www.legislation.gov.uk/ukpga/2004/12/section/228ZA/2024-04-06 + pension_contributions_relief: 100_000 + pension_annual_allowance: 10_000 + pension_annual_allowance_chargeable_amount: 90_000 + # s.227(4A)-(4C): RNI £400,000 and the additional-rate limit raised + # by £100,000 to £225,140 leave the entire excess at 45%. + personal_pension_contributions_tax: 90_000 * 0.45 + +- name: Scottish taxpayer pays Scottish rates (model PA taper limitation) + period: 2026 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 150_000 + personal_pension_contributions: 80_000 + region: SCOTLAND + output: + # Model reduced net income £150,000 and the limits extended by £80,000 + # put the entire charge in the 45% advanced band. Known s.58 limitation: + # the model omits RAS from ANI, so PA is zero instead of £12,570. With + # that PA restored, the statutory charge would be £5,000 at 42% plus + # £15,000 at 45% = £8,850. The net-pay case below checks statutory rates + # without depending on that existing PA-taper deviation. + personal_pension_contributions_tax: 20_000 * 0.45 + +- name: Scottish starter band is charged at the Scottish basic rate (s. 227(4AA)) + period: 2026 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 100_000 + employee_pension_contributions_reported: 100_000 + region: SCOTLAND + output: + # Net pay: reduced net income 100_000 - 100_000 floored at 0. Chargeable + # amount 40_000: 20% up to the 16_956 basic rate limit (the starter band + # included), 21% to 31_092, then 42%. + # 2026-27 limits: https://www.gov.scot/publications/scottish-income-tax-technical-factsheet/ + pension_contributions_relief: 100_000 + pension_annual_allowance: 60_000 + pension_annual_allowance_chargeable_amount: 40_000 + personal_pension_contributions_tax: 16_956 * 0.2 + (31_092 - 16_956) * 0.21 + (40_000 - 31_092) * 0.42 + +# A model deviation, documented: the model gives relief at source as a +# deduction, so a Scottish starter-rate slice is relieved at 19%, while relief +# at source pays 20% and the charge on that slice is at the Scottish basic rate +# (s. 227(4AA)). Contributing beyond the allowance therefore costs this taxpayer +# 1% of the 3_967 starter band (£39.67) more income tax. +- name: Scottish relief at source at the annual allowance (model deviation, see comment) + period: 2026 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 80_000 + personal_pension_contributions: 60_000 + region: SCOTLAND + output: + # Taxable income 80_000 - 12_570 - 60_000 = 7_430: 3_967 at 19%, 3_463 at 20%. + income_tax: 3_967 * 0.19 + 3_463 * 0.2 + +- name: Scottish relief at source beyond the annual allowance (model deviation, see comment) + period: 2026 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 80_000 + personal_pension_contributions: 67_430 + region: SCOTLAND + output: + # No taxable income after relief; the 7_430 chargeable amount sits within + # the raised Scottish basic rate limit, at 20%. + personal_pension_contributions_tax: 7_430 * 0.2 + income_tax: 7_430 * 0.2 + +- name: Unused annual allowance brought forward covers the excess (s. 228A) + period: 2024 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 150_000 + personal_pension_contributions: 80_000 + unused_pension_annual_allowance: 20_000 + region: LONDON + output: + # Assume registered-scheme membership in the prior year and an unused + # £20,000 still available from the previous three tax years. s.228A + # increases this year's £60,000 allowance to £80,000, covering all + # £80,000 pension input. Carry-forward does not increase s.190 relief. + # https://www.legislation.gov.uk/ukpga/2004/12/section/228A/2024-04-06 + pension_contributions_relief: 80_000 + pension_contributions_for_annual_allowance: 80_000 + pension_annual_allowance: 60_000 + pension_annual_allowance_chargeable_amount: 0 + personal_pension_contributions_tax: 0 + # Existing model limitation: s.58 omits the RAS adjustment when tapering + # PA, leaving PA zero here. This income-tax expectation preserves that + # behavior; the zero annual allowance charge is the statutory check. + income_tax: 28_460 - 8_000 + +- name: Carry-forward covers excess without a personal allowance taper + period: 2024 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 100_000 + personal_pension_contributions: 80_000 + unused_pension_annual_allowance: 20_000 + region: LONDON + output: + # FA 2004 s.228A: assume £20,000 of eligible unused allowance from the + # prior three years. Available allowance £60,000 + £20,000 covers the + # full £80,000 input. s.190 independently allows relief on all £80,000. + # PA is the full £12,570 with or without s.58's pension adjustment. + pension_contributions_relief: 80_000 + pension_contributions_for_annual_allowance: 80_000 + pension_annual_allowance: 60_000 + pension_annual_allowance_chargeable_amount: 0 + personal_pension_contributions_tax: 0 + +- name: Unused annual allowance brought forward covers part of the excess + period: 2024 + absolute_error_margin: 0.01 + input: + age: 45 + employment_income: 150_000 + personal_pension_contributions: 80_000 + unused_pension_annual_allowance: 5_000 + region: LONDON + output: + pension_annual_allowance_chargeable_amount: 15_000 + personal_pension_contributions_tax: 15_000 * 0.4 diff --git a/policyengine_uk/tests/test_pension_annual_allowance_properties.py b/policyengine_uk/tests/test_pension_annual_allowance_properties.py new file mode 100644 index 0000000000..9aedff95c4 --- /dev/null +++ b/policyengine_uk/tests/test_pension_annual_allowance_properties.py @@ -0,0 +1,679 @@ +"""Property-based tests for pension contributions relief and the annual +allowance charge (issue #2237). + +Relief runs to the annual limit in FA 2004 s. 190 (relevant UK earnings, +raised to the basic amount where lower, the increase only through relief at +source, s. 191(7)), not to the annual allowance. The model takes personal +pension contributions as relief at source and employee contributions as a net +pay arrangement. The annual allowance charge (s. 227) then taxes the pension +input amount above the allowance, plus any unused allowance brought forward +(s. 228A), as the top slice of reduced net income at the non-savings rates +(s. 227(4A)), with the rate limits raised by qualifying relief-at-source contributions +(ss. 192(4)/(4A), 227(4C)) and grossed-up Gift Aid, or at the Scottish rates with the +starter band at the Scottish basic rate (s. 227(4AA)). + +Invariants, for any generated population of single adults with contributions +split between relief at source and net pay: + +1. Relief bounds: relief is the lesser of the contributions and the s. 190 + limit (the basic-amount increase capped at relief-at-source contributions) + for anyone under 75, and nil at 75 or over. +2. The excess is taxed once: raising contributions, up to relevant earnings, + never raises income tax by more than it raises the charge. So income tax + before the charge never rises with contributions. +3. With non-savings income only and stable eligibility for any RAS band + extension, contributions above the allowance up to relevant earnings never + cost more income tax than contributing up to the allowance. +4. Charge bounds: nil exactly when the chargeable amount is nil, and between + the lowest and highest rate charged times the chargeable amount. +5. Differential: the charge equals an independent band-by-band sum of the + chargeable amount stacked on reduced net income. +6. Carry-forward: unused allowance reduces the chargeable amount one for one + until it is nil, and never raises the charge. +7. With stable RAS extension eligibility, Gift Aid never raises income tax, + including when contributions exceed relevant earnings or the allowance. + Its s. 58 adjusted-net-income deduction does not reduce reduced net income. + +Invariant 3 requires the s.192 condition to hold at both contribution levels +when there are RAS contributions. The excess can enter higher bands while +ordinary income remains below higher rate, and s.227(5) excludes that excess +from the condition. Total tax can then rise without double taxation. Gift Aid +can also remove ordinary higher-rate liability and thus RAS band extension, +so invariant 7 compares only cases with the same eligibility at each gift. + +Invariant 3 is also restricted to non-savings income. With dividends on top, the +relief comes off non-savings income and lets dividends fall to lower dividend +rates, while s. 227(4A) charges the excess at the non-savings rates, so income +tax can rise (intended: that is what the statute does). It also stops where +contributions use up income after allowances: relief beyond that is worth +nothing, while the charge still falls on the whole input amount (also +intended). And it is restricted to taxpayers outside Scotland. The model gives +relief at source as a deduction, which relieves a Scottish starter-rate slice +at 19%, while the charge on that slice is at the Scottish basic rate +(s. 227(4AA)), so income tax can rise by up to 1% of the starter band +(a model deviation: relief at source pays 20%; see the YAML example). +""" + +import numpy as np +import pytest +from hypothesis import HealthCheck, example, given, settings +from hypothesis import strategies as st + +from policyengine_uk import Simulation + +PROPERTY_SETTINGS = settings( + max_examples=10, + deadline=None, + derandomize=True, + suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large], +) +# 2020: £40,000 allowance, £4,000 tapered minimum. 2024: £60,000 allowance. +# 2026: Scottish starter band present; 2027: property income rates. +YEARS = [2020, 2024, 2026, 2027] +REGIONS = ["LONDON", "NORTH_EAST", "WALES", "SCOTLAND"] +TOLERANCE = 0.01 +# Simulated values are float32: allow a relative error on large amounts. +RELATIVE_TOLERANCE = 1e-6 + + +def _close(actual, expected): + return abs(actual - expected) <= max(TOLERANCE, RELATIVE_TOLERANCE * abs(expected)) + + +person_strategy = st.fixed_dictionaries( + { + "age": st.integers(18, 80), + "employment_income": st.integers(0, 400_000), + "self_employment_income": st.integers(-20_000, 200_000), + "employer_pension_contributions": st.integers(0, 80_000), + "contribution_share": st.floats(0, 1.2), + # Share of contributions paid through a net pay arrangement. + "net_pay_share": st.sampled_from([0.0, 0.5, 1.0]), + "gift_aid": st.integers(0, 5_000), + "savings_interest_income": st.integers(0, 30_000), + "dividend_income": st.integers(0, 80_000), + "unused_pension_annual_allowance": st.integers(0, 120_000), + "region": st.sampled_from(REGIONS), + } +) +population_strategy = st.lists(person_strategy, min_size=4, max_size=12) + + +@st.composite +def reference_population_strategy(draw): + people = [ + {**person, "property_income": draw(st.integers(0, 80_000))} + for person in draw(population_strategy) + ] + # Unrestricted draws rarely combine a positive RAS charge with ordinary + # income below higher rate. Include generated people on either side of + # that condition in every population, with enough excess to cross a limit + # whose extension changes the charge. + for income in [ + draw(st.integers(38_000, 45_000)), + draw(st.integers(60_000, 70_000)), + ]: + people.append( + { + "age": draw(st.integers(18, 74)), + "employment_income": income, + "self_employment_income": 0, + "employer_pension_contributions": draw(st.integers(60_000, 80_000)), + "contribution_share": draw(st.floats(0.5, 0.75)), + "net_pay_share": 0.0, + "gift_aid": draw(st.integers(0, 2_000)), + "savings_interest_income": 0, + "dividend_income": 0, + "property_income": 0, + "unused_pension_annual_allowance": 0, + "region": "LONDON", + } + ) + return people + + +def _situation(people, year, overrides=None): + overrides = overrides or {} + situation = {"people": {}, "benunits": {}, "households": {}} + for i, person in enumerate(people): + name = f"p{i}" + values = {**person, **overrides.get(i, {})} + situation["people"][name] = { + key: {year: values[key]} + for key in [ + "age", + "employment_income", + "self_employment_income", + "employer_pension_contributions", + "personal_pension_contributions", + "employee_pension_contributions_reported", + "gift_aid", + "savings_interest_income", + "dividend_income", + "unused_pension_annual_allowance", + ] + } + situation["people"][name]["property_income"] = { + year: values.get("property_income", 0) + } + situation["benunits"][f"b{i}"] = {"members": [name]} + situation["households"][f"h{i}"] = { + "members": [name], + "region": {year: values["region"]}, + } + return situation + + +def _relevant_earnings(person): + return person["employment_income"] + max(0, person["self_employment_income"]) + + +def _with_contributions(people, contributions): + return [ + { + **person, + "personal_pension_contributions": float(c) * (1 - person["net_pay_share"]), + "employee_pension_contributions_reported": float(c) + * person["net_pay_share"], + } + for person, c in zip(people, contributions) + ] + + +def _calc(people, year, variables): + sim = Simulation(situation=_situation(people, year)) + return {v: np.array(sim.calculate(v, year), dtype=float) for v in variables} + + +def _base_contributions(people): + return [p["contribution_share"] * max(_relevant_earnings(p), 3_600) for p in people] + + +@PROPERTY_SETTINGS +@given(population_strategy, st.sampled_from(YEARS)) +def test_relief_is_the_section_190_limit(people, year): + people = _with_contributions(people, _base_contributions(people)) + out = _calc(people, year, ["pension_contributions_relief"]) + basic_amount = 3_600 + for i, person in enumerate(people): + earnings = _relevant_earnings(person) + relief_at_source = person["personal_pension_contributions"] + total = relief_at_source + person["employee_pension_contributions_reported"] + limit = earnings + min(max(0, basic_amount - earnings), relief_at_source) + expected = min(total, limit) if person["age"] < 75 else 0 + relief = out["pension_contributions_relief"][i] + assert _close(relief, expected) + assert relief <= max(earnings, basic_amount) + max( + TOLERANCE, RELATIVE_TOLERANCE * max(earnings, basic_amount) + ) + + +@PROPERTY_SETTINGS +@given(population_strategy, st.sampled_from(YEARS), st.floats(0, 1)) +def test_extra_contributions_never_raise_tax_by_more_than_the_charge( + people, year, step +): + # Two contribution levels, both within relevant earnings. + earnings = np.array([max(_relevant_earnings(p), 3_600) for p in people]) + low = np.array([min(p["contribution_share"], 1) for p in people]) * earnings + high = low + step * (earnings - low) + variables = ["income_tax", "personal_pension_contributions_tax"] + before = _calc(_with_contributions(people, low), year, variables) + after = _calc(_with_contributions(people, high), year, variables) + tax_rise = after["income_tax"] - before["income_tax"] + charge_rise = ( + after["personal_pension_contributions_tax"] + - before["personal_pension_contributions_tax"] + ) + slack = TOLERANCE + RELATIVE_TOLERANCE * np.maximum( + abs(before["income_tax"]), abs(after["income_tax"]) + ) + assert np.all(tax_rise <= charge_rise + slack) + + +@PROPERTY_SETTINGS +@example( + people=[ + { + "age": 54, + "employment_income": 362_880, + "self_employment_income": 5_249, + "employer_pension_contributions": 60_817, + "contribution_share": 1.0294618785360077, + "net_pay_share": 1.0, + "gift_aid": 2_629, + "savings_interest_income": 64, + "dividend_income": 8_818, + "unused_pension_annual_allowance": 96_126, + "region": "LONDON", + } + ], + year=2020, + step=0.5420285667238235, +) +@given(population_strategy, st.sampled_from(YEARS), st.floats(0, 1)) +def test_contributions_above_the_allowance_are_not_taxed_twice(people, year, step): + # Non-savings income only, under 75, no carry-forward: contributions of + # exactly the allowance (net of employer contributions) against any + # amount from there up to relevant earnings. + people = [ + { + **p, + "age": min(p["age"], 74), + "savings_interest_income": 0, + "dividend_income": 0, + "property_income": 0, + "unused_pension_annual_allowance": 0, + "region": "NORTH_EAST" if p["region"] == "SCOTLAND" else p["region"], + } + for p in people + ] + zero_sim = Simulation( + situation=_situation(_with_contributions(people, [0] * len(people)), year) + ) + allowance = np.array( + zero_sim.calculate("pension_annual_allowance", year), dtype=float + ) + # Income after allowances with no contributions. Relief beyond it is worth + # nothing, but the charge still falls on the input amount, so the + # comparison stops there as well as at relevant earnings. + taxable_income = np.maximum( + 0, + np.array(zero_sim.calculate("net_income", year), dtype=float) + - np.array(zero_sim.calculate("allowances", year), dtype=float), + ) + earnings = np.array([_relevant_earnings(p) for p in people], dtype=float) + upper = np.minimum(earnings, taxable_income) + employer = np.array([p["employer_pension_contributions"] for p in people]) + at_allowance = np.clip(allowance - employer, 0, earnings) + above = at_allowance + step * np.maximum(0, upper - at_allowance) + variables = [ + "income_tax", + "net_income", + "allowances", + "personal_pension_contributions", + "pension_contributions_relief", + "gift_aid_grossed_up", + ] + tax_at = _calc(_with_contributions(people, at_allowance), year, variables) + tax_above = _calc(_with_contributions(people, above), year, variables) + basic_limit = float( + zero_sim.tax_benefit_system.parameters( + year + ).gov.hmrc.income_tax.rates.uk.thresholds[1] + ) + + def qualifies_for_ras_extension(out): + ras = np.minimum( + out["personal_pension_contributions"], out["pension_contributions_relief"] + ) + ordinary_income = np.maximum( + 0, out["net_income"] - np.maximum(0, out["allowances"] - ras) + ) + return ordinary_income > basic_limit + out["gift_aid_grossed_up"] + + net_pay_only = np.array([p["net_pay_share"] == 1 for p in people]) + applicable = net_pay_only | ( + qualifies_for_ras_extension(tax_at) & qualifies_for_ras_extension(tax_above) + ) + slack = TOLERANCE + RELATIVE_TOLERANCE * np.maximum( + abs(tax_at["income_tax"]), abs(tax_above["income_tax"]) + ) + assert np.all( + tax_above["income_tax"][applicable] + <= (tax_at["income_tax"] + slack)[applicable] + ) + + +def _reference_charge(chargeable, reduced_net_income, thresholds, rates, extension): + """Band-by-band sum with rate limits raised by the eligible extension.""" + bottom = reduced_net_income + top = reduced_net_income + chargeable + lowers = [thresholds[0]] + [t + extension for t in thresholds[1:]] + uppers = lowers[1:] + [np.inf] + charge = 0.0 + for lower, upper_limit, rate in zip(lowers, uppers, rates): + charge += rate * max(0.0, min(top, upper_limit) - max(bottom, lower)) + return charge + + +def _reference_ras_extension_eligibility( + reduced_net_income, + savings, + dividends, + gross_gift, + scottish, + income_tax, + year, + property_income=0, +): + """Find an ordinary income slice taxed above basic, apart from s.192. + + Section 192(4) names the higher and additional rates, excluding dividend + rates, savings rates from 2017 and rUK property rates from 2027. Scottish + property still bears Scottish rates and can meet s.192(4A). The annual + allowance excess never enters these ordinary income slices (s.227(5)). + """ + non_savings = max(0, reduced_net_income - savings - dividends) + savings_top = max(0, reduced_net_income - dividends) + if scottish: + scale = income_tax.rates.scotland.rates + # These generated years all have the starter band before basic. + basic_rate = float(scale.rates[1] if year >= 2018 else scale.rates[0]) + slices = [(0, non_savings)] + else: + scale = income_tax.rates.uk + basic_rate = float(scale.rates[0]) + ordinary_rates_top = max( + 0, non_savings - (property_income if year >= 2027 else 0) + ) + slices = [(0, ordinary_rates_top)] + if year < 2017: + psa = income_tax.allowances.personal_savings_allowance + if reduced_net_income > scale.thresholds[2] + gross_gift: + savings_allowance = float(psa.additional) + elif reduced_net_income > scale.thresholds[1] + gross_gift: + savings_allowance = float(psa.higher) + else: + savings_allowance = float(psa.basic) + starting_rate_savings = max( + 0, income_tax.rates.savings_starter_rate.allowance - non_savings + ) + nil_savings = min( + savings_top - non_savings, starting_rate_savings + savings_allowance + ) + slices.append((non_savings + nil_savings, savings_top)) + for index, (threshold, rate) in enumerate(zip(scale.thresholds, scale.rates)): + if rate <= basic_rate: + continue + lower = threshold + gross_gift + upper = ( + scale.thresholds[index + 1] + gross_gift + if index + 1 < len(scale.thresholds) + else np.inf + ) + for bottom, top in slices: + if min(top, upper) > max(bottom, lower): + return True + return False + + +@PROPERTY_SETTINGS +@given(reference_population_strategy(), st.sampled_from(YEARS)) +def test_charge_matches_band_by_band_reference(people, year): + people = _with_contributions(people, _base_contributions(people)) + sim = Simulation(situation=_situation(people, year)) + chargeable = np.array( + sim.calculate("pension_annual_allowance_chargeable_amount", year), dtype=float + ) + charge = np.array( + sim.calculate("personal_pension_contributions_tax", year), dtype=float + ) + get = lambda v: np.array(sim.calculate(v, year), dtype=float) # noqa: E731 + # FA 2004 s. 227(4B)-(4C), ITA 2007 ss. 23 and 58: reduced net income + # starts before the gross Gift Aid adjustment to adjusted net income. + # RAS stays in this base; s.192 conditions its rate-limit extension + # on ordinary higher-rate liability apart from s.192 itself. + relief_at_source = np.minimum( + get("personal_pension_contributions"), get("pension_contributions_relief") + ) + gross_gift = get("gift_aid_grossed_up") + reduced_net_income = np.maximum( + 0, + get("net_income") - np.maximum(0, get("allowances") - relief_at_source), + ) + scottish = np.array(sim.calculate("pays_scottish_income_tax", year)) + rates = sim.tax_benefit_system.parameters(year).gov.hmrc.income_tax.rates + uk_thresholds, uk_rates = list(rates.uk.thresholds), list(rates.uk.rates) + sco_thresholds = list(rates.scotland.rates.thresholds) + sco_rates = list(rates.scotland.rates.rates) + if year >= 2018: + # s. 227(4AA): the starter band is charged at the Scottish basic rate. + sco_rates[0] = sco_rates[1] + gate_coverage = {False: False, True: False} + for i in range(len(people)): + thresholds, band_rates = ( + (sco_thresholds, sco_rates) if scottish[i] else (uk_thresholds, uk_rates) + ) + qualifies = _reference_ras_extension_eligibility( + reduced_net_income[i], + get("taxable_savings_interest_income")[i], + get("taxable_dividend_income")[i], + gross_gift[i], + bool(scottish[i]), + sim.tax_benefit_system.parameters(year).gov.hmrc.income_tax, + year, + get("taxable_property_income")[i], + ) + extension = gross_gift[i] + (relief_at_source[i] if qualifies else 0) + expected = _reference_charge( + chargeable[i], reduced_net_income[i], thresholds, band_rates, extension + ) + assert _close(charge[i], expected) + alternative_extension = gross_gift[i] + ( + 0 if qualifies else relief_at_source[i] + ) + alternative_charge = _reference_charge( + chargeable[i], + reduced_net_income[i], + thresholds, + band_rates, + alternative_extension, + ) + gate_coverage[qualifies] |= not _close(expected, alternative_charge) + # Bounds: nil exactly when nothing is chargeable, and between the + # lowest and highest rate charged. + assert (charge[i] == 0) == (chargeable[i] == 0) + slack = max(TOLERANCE, RELATIVE_TOLERANCE * max(band_rates) * chargeable[i]) + assert charge[i] >= min(band_rates) * chargeable[i] - slack + assert charge[i] <= max(band_rates) * chargeable[i] + slack + + # Both eligibility outcomes must actually affect a generated charge; + # positive contributions alone would leave this property vacuous. + assert all(gate_coverage.values()) + + # FA 2004 ss. 227ZA and 228A: no charge within the available allowance, + # including unused allowance from the previous three years. + available = get("pension_annual_allowance") + np.maximum( + 0, get("unused_pension_annual_allowance") + ) + within_allowance = get("pension_contributions_for_annual_allowance") <= available + assert np.all(charge >= 0) + assert np.all(charge[within_allowance] == 0) + + +@PROPERTY_SETTINGS +@given(population_strategy, st.sampled_from(YEARS)) +def test_gift_aid_never_increases_tax_with_stable_ras_eligibility(people, year): + people = _with_contributions(people, _base_contributions(people)) + # Compare the same pension/input amounts with zero, drawn, and larger + # gifts, across UK and Scottish rates and mixed income sources. + zero_gift = [{**p, "gift_aid": 0} for p in people] + larger_gift = [{**p, "gift_aid": p["gift_aid"] + 4_000} for p in people] + combined = zero_gift + people + larger_gift + sim = Simulation(situation=_situation(combined, year)) + get = lambda v: np.array(sim.calculate(v, year), dtype=float) # noqa: E731 + ras = np.minimum( + get("personal_pension_contributions"), get("pension_contributions_relief") + ) + reduced_net_income = np.maximum( + 0, get("net_income") - np.maximum(0, get("allowances") - ras) + ) + p = sim.tax_benefit_system.parameters(year).gov.hmrc.income_tax + qualifies = np.array( + [ + _reference_ras_extension_eligibility( + rni, savings, dividends, gift, scottish, p, year + ) + for rni, savings, dividends, gift, scottish in zip( + reduced_net_income, + get("taxable_savings_interest_income"), + get("taxable_dividend_income"), + get("gift_aid_grossed_up"), + sim.calculate("pays_scottish_income_tax", year), + ) + ] + ) + no_gift_gate, gift_gate, more_gift_gate = np.split(qualifies, 3) + stable_gate = (no_gift_gate == gift_gate) & (gift_gate == more_gift_gate) + before, with_gift, with_more = np.split(get("income_tax"), 3) + slack = TOLERANCE + RELATIVE_TOLERANCE * np.maximum(abs(before), abs(with_gift)) + assert np.all(with_gift[stable_gate] <= (before + slack)[stable_gate]) + assert np.all(with_more[stable_gate] <= (with_gift + slack)[stable_gate]) + + +@PROPERTY_SETTINGS +@given(population_strategy, st.sampled_from(YEARS), st.integers(0, 150_000)) +def test_unused_allowance_reduces_chargeable_amount_one_for_one(people, year, extra): + people = _with_contributions(people, _base_contributions(people)) + variables = [ + "pension_annual_allowance_chargeable_amount", + "personal_pension_contributions_tax", + ] + before = _calc(people, year, variables) + more_unused = [ + { + **p, + "unused_pension_annual_allowance": p["unused_pension_annual_allowance"] + + extra, + } + for p in people + ] + after = _calc(more_unused, year, variables) + chargeable_before = before["pension_annual_allowance_chargeable_amount"] + expected = np.maximum(0, chargeable_before - extra) + assert np.allclose( + after["pension_annual_allowance_chargeable_amount"], + expected, + atol=TOLERANCE, + rtol=RELATIVE_TOLERANCE, + ) + slack = TOLERANCE + RELATIVE_TOLERANCE * np.maximum( + abs(before["personal_pension_contributions_tax"]), + abs(after["personal_pension_contributions_tax"]), + ) + assert np.all( + after["personal_pension_contributions_tax"] + <= before["personal_pension_contributions_tax"] + slack + ) + + +def test_scottish_basic_band_is_not_lifted_when_the_starter_band_is_removed(): + """A reform that removes the Scottish starter band (null threshold, basic + band from zero) leaves the lowest band at the basic rate: the charge is + not lifted to the intermediate rate.""" + from policyengine_uk.utils.scenario import Scenario + + def remove_starter_band(simulation): + system = simulation.tax_benefit_system + system.reset_parameters() + brackets = system.parameters.gov.hmrc.income_tax.rates.scotland.rates.brackets + brackets[0].threshold.update(period="year:2026-01-01:1", value=None) + brackets[1].threshold.update(period="year:2026-01-01:1", value=0) + system.process_parameters() + + situation = { + "people": { + "p": { + "age": {2026: 45}, + "employment_income": {2026: 12_570}, + "employer_pension_contributions": {2026: 70_000}, + } + }, + "benunits": {"b": {"members": ["p"]}}, + "households": {"h": {"members": ["p"], "region": {2026: "SCOTLAND"}}}, + } + sim = Simulation( + situation=situation, + scenario=Scenario( + simulation_modifier=remove_starter_band, applied_before_data_load=True + ), + ) + rates = sim.tax_benefit_system.parameters(2026).gov.hmrc.income_tax.rates + assert float(rates.scotland.rates.rates[0]) == 0.2 + # Reduced net income 0; chargeable amount 10_000, all in the basic band. + charge = float(sim.calculate("personal_pension_contributions_tax", 2026)[0]) + assert abs(charge - 10_000 * 0.2) < TOLERANCE + + +def _charge_situation(year, region, **inputs): + return { + "people": { + "p": { + "age": {year: 45}, + **{key: {year: value} for key, value in inputs.items()}, + } + }, + "benunits": {"b": {"members": ["p"]}}, + "households": {"h": {"members": ["p"], "region": {year: region}}}, + } + + +def test_mixed_methods_below_higher_rate_have_unextended_charge_lower_bound(): + """Either relief allocation leaves ordinary income below higher rate. + + With £50,000 earnings, at least £30,000 of £40,000 net pay must receive + relief if all £20,000 RAS does. RNI is therefore at most £7,430. A net-pay + allocation of £40,000 instead leaves RNI nil. Neither can meet s.192(4). + The £70,000 excess therefore costs at least £37,700 × 20% + £32,300 × 40%. + This does not presume a statutory ordering of net-pay and RAS relief. + """ + sim = Simulation( + situation=_charge_situation( + 2024, + "LONDON", + employment_income=50_000, + employee_pension_contributions_reported=40_000, + personal_pension_contributions=20_000, + employer_pension_contributions=70_000, + ) + ) + assert float(sim.calculate("pension_contributions_relief", 2024)[0]) == 50_000 + assert ( + float(sim.calculate("pension_annual_allowance_chargeable_amount", 2024)[0]) + == 70_000 + ) + charge = float(sim.calculate("personal_pension_contributions_tax", 2024)[0]) + assert charge >= 20_460 - TOLERANCE + + +@pytest.fixture +def scottish_advanced_rate_charge_simulation(): + return Simulation( + situation=_charge_situation( + 2026, + "SCOTLAND", + employment_income=112_000, + employer_pension_contributions=70_000, + ) + ) + + +def test_scottish_charge_uses_top_limit_parameter( + scottish_advanced_rate_charge_simulation, +): + """The charge follows the configured top-rate parameter.""" + sim = scottish_advanced_rate_charge_simulation + scale = sim.tax_benefit_system.parameters( + 2026 + ).gov.hmrc.income_tax.rates.scotland.rates + top_limit = float(scale.thresholds[-1]) + advanced_rate, top_rate = map(float, scale.rates[-2:]) + # PA £6,570; RNI £105,430; chargeable amount £10,000. + advanced_amount = min(10_000, max(0, top_limit - 105_430)) + expected = advanced_amount * advanced_rate + (10_000 - advanced_amount) * top_rate + charge = float(sim.calculate("personal_pension_contributions_tax", 2026)[0]) + assert charge == pytest.approx(expected, abs=TOLERANCE) + + +def test_scottish_charge_below_statutory_top_limit_is_all_advanced_rate( + scottish_advanced_rate_charge_simulation, +): + """S6M-20844: £105,430 RNI plus £10,000 excess remains below £125,140. + + https://www.parliament.scot/chamber-and-committees/votes-and-motions/S6M-20844 + """ + sim = scottish_advanced_rate_charge_simulation + assert float(sim.calculate("personal_allowance", 2026)[0]) == 6_570 + charge = float(sim.calculate("personal_pension_contributions_tax", 2026)[0]) + assert charge == pytest.approx(4_500, abs=TOLERANCE) diff --git a/policyengine_uk/variables/gov/hmrc/pensions/pension_annual_allowance_chargeable_amount.py b/policyengine_uk/variables/gov/hmrc/pensions/pension_annual_allowance_chargeable_amount.py new file mode 100644 index 0000000000..c9c4e300c4 --- /dev/null +++ b/policyengine_uk/variables/gov/hmrc/pensions/pension_annual_allowance_chargeable_amount.py @@ -0,0 +1,34 @@ +from policyengine_uk.model_api import * + + +class pension_annual_allowance_chargeable_amount(Variable): + value_type = float + entity = Person + label = "Chargeable amount for the pension annual allowance charge" + documentation = ( + "The default chargeable amount (FA 2004 s. 227ZA(3)): the total pension " + "input amount less the annual allowance, which unused annual allowance " + "brought forward increases (s. 228A(2)). Nil if the input amount is " + "within that allowance." + ) + definition_period = YEAR + reference = [ + dict( + title="Finance Act 2004 s. 227ZA", + href="https://www.legislation.gov.uk/ukpga/2004/12/section/227ZA", + ), + dict( + title="Finance Act 2004 s. 228A", + href="https://www.legislation.gov.uk/ukpga/2004/12/section/228A", + ), + ] + unit = GBP + + def formula(person, period, parameters): + pension_input_amount = person( + "pension_contributions_for_annual_allowance", period + ) + annual_allowance = person("pension_annual_allowance", period) + max_( + 0, person("unused_pension_annual_allowance", period) + ) + return max_(0, pension_input_amount - annual_allowance) diff --git a/policyengine_uk/variables/gov/hmrc/pensions/pension_contributions_relief.py b/policyengine_uk/variables/gov/hmrc/pensions/pension_contributions_relief.py index a506e58726..ed04e338df 100644 --- a/policyengine_uk/variables/gov/hmrc/pensions/pension_contributions_relief.py +++ b/policyengine_uk/variables/gov/hmrc/pensions/pension_contributions_relief.py @@ -5,25 +5,62 @@ class pension_contributions_relief(Variable): value_type = float entity = Person label = "Reduction in taxable income from pension contributions" - definition_period = YEAR - reference = dict( - title="Finance Act 2004 s. 188-194", - href="https://www.legislation.gov.uk/ukpga/2004/12/section/188", + documentation = ( + "Relief for the contributions an individual pays to registered pension " + "schemes (FA 2004 s. 188), up to the annual limit for relief: the " + "individual's relevant UK earnings, raised to the basic amount where " + "earnings are lower (s. 190). Only relief at source can give the part " + "above earnings (s. 191(7)); the model takes personal pension " + "contributions as relief at source and employee contributions as a " + "net pay arrangement. The annual allowance does not limit relief. " + "Contributions above it can be relieved here and separately attract " + "the annual allowance charge (personal_pension_contributions_tax) " + "under s. 227. The charge need not equal their tax relief." ) + definition_period = YEAR + reference = [ + dict( + title="Finance Act 2004 s. 188", + href="https://www.legislation.gov.uk/ukpga/2004/12/section/188", + ), + dict( + title="Finance Act 2004 s. 189", + href="https://www.legislation.gov.uk/ukpga/2004/12/section/189", + ), + dict( + title="Finance Act 2004 s. 190", + href="https://www.legislation.gov.uk/ukpga/2004/12/section/190", + ), + dict( + title="Finance Act 2004 s. 191", + href="https://www.legislation.gov.uk/ukpga/2004/12/section/191", + ), + ] unit = GBP def formula(person, period, parameters): + hmrc = parameters(period).gov.hmrc contributions = person("pension_contributions", period) - pension_allowance = person("pension_annual_allowance", period) - age_limit = parameters( - period - ).gov.hmrc.pensions.pension_contributions_relief_age_limit - income = add(person, period, ["employment_income", "self_employment_income"]) - under_age_limit = person("age", period) < age_limit - basic_amount = parameters( - period - ).gov.hmrc.income_tax.reliefs.pension_contribution.basic_amount - tax_relief = min_(income, contributions) * under_age_limit - max_pension_relief = max_(basic_amount, pension_allowance) - - return min_(tax_relief, max_pension_relief) + # Relevant UK earnings (s. 189(2)) are employment income and trading + # income. A trading loss gives no relevant earnings; it does not + # reduce employment income. + relevant_uk_earnings = person("employment_income", period) + max_( + 0, person("self_employment_income", period) + ) + # s. 190(1)-(2): relief up to relevant UK earnings, raised to the basic + # amount where earnings are lower. s. 191(7): only relief at source + # (personal pension contributions here) can give that increase. + basic_amount_increase = min_( + max_( + 0, + hmrc.income_tax.reliefs.pension_contribution.basic_amount + - relevant_uk_earnings, + ), + person("personal_pension_contributions", period), + ) + annual_limit = relevant_uk_earnings + basic_amount_increase + # Contributions paid after age 75 are not relievable (s. 188(3)(a)). + under_age_limit = ( + person("age", period) < hmrc.pensions.pension_contributions_relief_age_limit + ) + return min_(contributions, annual_limit) * under_age_limit diff --git a/policyengine_uk/variables/gov/hmrc/pensions/private_pension_contributions_tax.py b/policyengine_uk/variables/gov/hmrc/pensions/private_pension_contributions_tax.py index 4fad564e10..fb0aae07ae 100644 --- a/policyengine_uk/variables/gov/hmrc/pensions/private_pension_contributions_tax.py +++ b/policyengine_uk/variables/gov/hmrc/pensions/private_pension_contributions_tax.py @@ -1,16 +1,53 @@ from policyengine_uk.model_api import * +def _top_slice_charge(bottom, top, thresholds, rates, extension): + """Tax on the slice from ``bottom`` to ``top`` of income, at ``rates`` + between ``thresholds``, every limit above the first raised by + ``extension``.""" + charge = 0 + for i, rate in enumerate(rates): + lower = thresholds[i] + (extension if i > 0 else 0) + upper = thresholds[i + 1] + extension if i + 1 < len(thresholds) else np.inf + charge = charge + rate * max_(0, min_(top, upper) - max_(bottom, lower)) + return charge + + class personal_pension_contributions_tax(Variable): value_type = float entity = Person - label = "Reduction in taxable income from pension contributions to pensions other than the State Pension" + label = "Pension annual allowance charge" + documentation = ( + "The annual allowance charge (FA 2004 s. 227) on the chargeable amount, " + "the pension input amount above the annual allowance. It is charged at " + "the basic, higher and additional rates on the slices of the chargeable " + "amount that fall in each band when it is added to the top of the " + "individual's reduced net income, their income after allowances " + "(s. 227(4A)-(4B)), with gross Gift Aid extending rate limits. " + "Relieved relief-at-source contributions extend limits only where " + "ordinary income, before that relief, meets s. 192(4)/(4A)'s " + "above-basic-rate condition (s. 227(4C)/(5)). Separate savings rates " + "from 2017 and UK property rates from 2027 do not satisfy s. 192(4). A Scottish " + "taxpayer pays the Scottish rates, with the Scottish basic rate on any " + "slice within the Scottish basic rate limit (s. 227(4AA)). " + "Personal contribution relief has a separate earnings limit " + "(pension_contributions_relief); the annual allowance does not " + "also deny that relief." + ) definition_period = YEAR reference = [ + dict( + title="Finance Act 2004 s. 192", + href="https://www.legislation.gov.uk/ukpga/2004/12/section/192", + ), dict( title="Finance Act 2004 s. 227", href="https://www.legislation.gov.uk/ukpga/2004/12/section/227", ), + dict( + title="Income Tax Act 2007 s. 58", + href="https://www.legislation.gov.uk/ukpga/2007/3/section/58", + ), dict( title="Finance Act 2004 s. 233", href="https://www.legislation.gov.uk/ukpga/2004/12/section/233", @@ -19,16 +56,115 @@ class personal_pension_contributions_tax(Variable): unit = GBP def formula(person, period, parameters): - p = parameters(period).gov.hmrc.income_tax.rates.uk - taxed_income = person("taxed_income", period) + income_tax = parameters(period).gov.hmrc.income_tax + rates = income_tax.rates + chargeable_amount = person("pension_annual_allowance_chargeable_amount", period) + # FA 2004 s. 227(4B)-(4C): relief at source remains in reduced net + # income. It raises rate limits only if s. 192's condition is met. + # The model includes + # that relief in allowances, so restore it at Step 3. Net pay + # contributions stay deducted. Gift Aid is already excluded from + # allowances; only its gross amount extends the limits (ITA 2007 + # s. 414(2)), without another deduction from the taxable base. + relief_at_source = min_( + person("personal_pension_contributions", period), + person("pension_contributions_relief", period), + ) + gross_gift = person("gift_aid_grossed_up", period) + allowances_at_step_3 = max_( + 0, + person("allowances", period) - relief_at_source, + ) + # Reduced net income is income after ITA 2007 s. 23 Step 3, not + # adjusted net income after the s. 58 gross Gift Aid deduction. + reduced_net_income = max_( + 0, person("net_income", period) - allowances_at_step_3 + ) + top_of_charge = reduced_net_income + chargeable_amount + + # s. 192(4): test ordinary liability apart from RAS relief, with + # Gift Aid's limits still extended. s. 227(5) excludes the pension + # excess itself. Separate dividend rates, savings rates from 2017 + # (FA 2016 s. 6) and UK property rates from 2027 (FA 2026 s. 6) do not + # satisfy its named higher/additional-rate condition. Retain the + # model's fixed allowance allocation, apart from RAS relief. + savings = person("taxable_savings_interest_income", period) + dividends = person("taxable_dividend_income", period) + non_savings = max_(0, reduced_net_income - savings - dividends) + uk_basic_limit = rates.uk.thresholds[1] + gross_gift + # Property is stacked above other non-savings income. Its part of + # this pre-RAS base must use allowances with RAS restored too. + property_at_separate_rates = min_( + person("taxable_property_income", period), non_savings + ) * (period.start.year >= 2027) + uk_ras_condition = non_savings - property_at_separate_rates > uk_basic_limit + if period.start.year < 2017: + # Before separate savings rates, a non-nil higher/additional + # savings slice was charged at the rates named in s. 192(4). + savings_top = max_(0, reduced_net_income - dividends) + savings_after_allowances = savings_top - non_savings + savings_amounts = income_tax.allowances.personal_savings_allowance + savings_allowance_without_ras = select( + [ + reduced_net_income > rates.uk.thresholds[2] + gross_gift, + reduced_net_income > uk_basic_limit, + ], + [savings_amounts.additional, savings_amounts.higher], + default=savings_amounts.basic, + ) + nil_rate_savings = min_( + savings_after_allowances, + savings_allowance_without_ras + + max_(0, rates.savings_starter_rate.allowance - non_savings), + ) + uk_ras_condition = uk_ras_condition | ( + savings_top > max_(uk_basic_limit, non_savings + nil_rate_savings) + ) - personal_pension_contributions = person( - "pension_contributions_for_annual_allowance", period + uk_charge = _top_slice_charge( + reduced_net_income, + top_of_charge, + list(rates.uk.thresholds), + list(rates.uk.rates), + gross_gift + relief_at_source * uk_ras_condition, ) - pension_annual_allowance = person("pension_annual_allowance", period) - taxable_contributions = ( - personal_pension_contributions - pension_annual_allowance + + # s. 227(4AA)(b)(i): no slice is charged at the starter rate. The + # Scottish basic rate applies to every slice up to the Scottish basic + # rate limit, so charge the starter band at the basic rate. The + # starter bracket (the first) is null before 2018-19, when the lowest + # Scottish rate was the basic rate; it is present only with both a + # rate and a threshold. + scottish_rates = rates.scotland.rates + scottish_band_rates = list(scottish_rates.rates) + starter_bracket = person.simulation.tax_benefit_system.parameters.gov.hmrc.income_tax.rates.scotland.rates.brackets[ + 0 + ] + has_starter_band = ( + starter_bracket.rate(period.start) is not None + and starter_bracket.threshold(period.start) is not None + and len(scottish_band_rates) > 1 + ) + if has_starter_band: + scottish_band_rates[0] = scottish_band_rates[1] + # s. 192(4A): only non-savings income is charged at Scottish rates. + # The first rate above basic is intermediate from 2018, higher before. + scottish_ras_condition = False + for threshold, rate in zip(scottish_rates.thresholds, scottish_band_rates): + if rate > scottish_band_rates[0]: + scottish_ras_condition = scottish_ras_condition | ( + non_savings > threshold + gross_gift + ) + scottish_charge = _top_slice_charge( + reduced_net_income, + top_of_charge, + list(scottish_rates.thresholds), + scottish_band_rates, + gross_gift + relief_at_source * scottish_ras_condition, ) - tax_rate = p.marginal_rates(taxed_income) - return max_(0, taxable_contributions * tax_rate) + return where( + person("pays_scottish_income_tax", period), + scottish_charge, + uk_charge, + ) diff --git a/policyengine_uk/variables/input/unused_pension_annual_allowance.py b/policyengine_uk/variables/input/unused_pension_annual_allowance.py new file mode 100644 index 0000000000..59b2549769 --- /dev/null +++ b/policyengine_uk/variables/input/unused_pension_annual_allowance.py @@ -0,0 +1,23 @@ +from policyengine_uk.model_api import * + + +class unused_pension_annual_allowance(Variable): + label = "unused pension annual allowance brought forward" + documentation = ( + "Unused annual allowance from the three previous tax years that is " + "available for this tax year (FA 2004 s. 228A(5)): the amount by which " + "each of those years' annual allowance exceeded the total pension " + "input amount, for years in which the individual was a member of a " + "registered pension scheme, less any part already used up in an " + "intervening year (earliest year first). It increases this year's " + "annual allowance (s. 228A(2)). Survey data does not record past " + "pension input amounts, so this defaults to nil." + ) + entity = Person + definition_period = YEAR + value_type = float + unit = GBP + reference = dict( + title="Finance Act 2004 s. 228A", + href="https://www.legislation.gov.uk/ukpga/2004/12/section/228A", + )