diff --git a/changelog.d/2799.fixed.md b/changelog.d/2799.fixed.md new file mode 100644 index 0000000000..d5a098e7bd --- /dev/null +++ b/changelog.d/2799.fixed.md @@ -0,0 +1 @@ +Use the Universal Credit award before debt deductions when calculating working-age Council Tax Reduction in Merton, Kingston upon Thames, Newham and Westminster. diff --git a/policyengine_uk/tests/policy/baseline/gov/local_authorities/council_tax_reduction/council_tax_reduction_universal_credit_deductions.yaml b/policyengine_uk/tests/policy/baseline/gov/local_authorities/council_tax_reduction/council_tax_reduction_universal_credit_deductions.yaml new file mode 100644 index 0000000000..5328310464 --- /dev/null +++ b/policyengine_uk/tests/policy/baseline/gov/local_authorities/council_tax_reduction/council_tax_reduction_universal_credit_deductions.yaml @@ -0,0 +1,543 @@ +# #2799. Merton and Kingston upon Thames count "the amount of the award of +# universal credit" (their 2026-27 schemes reproduce SI 2012/2886 Sch para +# 37(3)(a) and (4)), Newham counts "the amount of entitlement to universal +# credit", and Westminster compares the maximum amount "to the actual +# universal credit award plus any other income and earnings received". The +# Secretary of State pays the claimant's debts to third parties out of the +# award (SI 2013/380 Sch 6 para 2(1)), so each council counts the same award +# and grants the same reduction after a debt deduction. +# +# Unless a case says otherwise, each case uses a single claimant aged 35 in +# 2026 who earns 8,000 (under the personal allowance and primary threshold), +# rents from the council at 7,800 a year and owes council tax of 2,600. The +# maximum amount comes to 424.90 x 12 + 7,800 = 12,898.80. With no child and +# no limited capability for work, the claimant gets no work allowance (UC +# Regs 2013 reg 22(1)(b)(i)), so the Secretary of State deducts +# 55% x 8,000 = 4,400 and awards 8,498.80. The councils take the maximum +# amount as the applicable amount, and income exceeds it by +# 8,000 + 8,498.80 - 12,898.80 = 3,600. +# Merton, Kingston upon Thames and Westminster award +# 2,600 - 20% x 3,600 = 1,880; Newham awards 70% x 2,600 - 25% x 3,600 = 920. +# Counting the amount payable after a 600 deduction would give 2,000 and +# 1,070. +# +# The model works in annual amounts. It takes a deduction at DWP's 15% cap as +# 15% x 424.90 x 12 = 764.82 a year. The Secretary of State deducts by +# assessment period and rounds 15% x 424.90 = 63.735 to 63.74 (SI 2013/380 Sch +# 6 para 1(2)), or 764.88 over twelve assessment periods. + +- name: Merton counts the Universal Credit award with no deduction + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: MERTON + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + uc_maximum_amount: 12_898.80 + uc_income_reduction: 4_400 + uc_deductions: 0 + universal_credit: 8_498.80 + council_tax_reduction: 1_880 + +- name: Merton counts the Universal Credit award before a 600 debt deduction + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + uc_deductions: 600 + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: MERTON + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + universal_credit: 7_898.80 + council_tax_reduction: 1_880 + +- name: Kingston upon Thames counts the Universal Credit award with no deduction + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: KINGSTON_UPON_THAMES + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + uc_deductions: 0 + universal_credit: 8_498.80 + council_tax_reduction: 1_880 + +- name: Kingston upon Thames counts the Universal Credit award before a 600 debt deduction + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + uc_deductions: 600 + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: KINGSTON_UPON_THAMES + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + universal_credit: 7_898.80 + council_tax_reduction: 1_880 + +- name: Newham counts the Universal Credit award with no deduction + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: NEWHAM + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + uc_deductions: 0 + universal_credit: 8_498.80 + council_tax_reduction: 920 + +- name: Newham counts the Universal Credit award before a 600 debt deduction + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + uc_deductions: 600 + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: NEWHAM + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + universal_credit: 7_898.80 + council_tax_reduction: 920 + +- name: Westminster counts the Universal Credit award with no deduction + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: WESTMINSTER + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + uc_deductions: 0 + universal_credit: 8_498.80 + council_tax_reduction: 1_880 + +- name: Westminster counts the Universal Credit award before a 600 debt deduction + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + uc_deductions: 600 + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: WESTMINSTER + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + universal_credit: 7_898.80 + council_tax_reduction: 1_880 + +- name: Newham counts the Universal Credit award before a deduction at the cap + # A third-party deduction demand of 15% of the standard allowance meets the + # 15% cap, and the model takes it as 764.82 a year. The amount payable + # falls to 8,498.80 - 764.82 = 7,733.98; the award stays at 8,498.80 and + # Newham awards 920. Counting the amount payable would give + # 70% x 2,600 - 25% x (3,600 - 764.82) = 1,111.205. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + uc_has_deduction: true + uc_latent_deduction_rate: 0.15 + uc_deduction_combination: THIRD_PARTY_ONLY + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: NEWHAM + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + uc_deduction_rate: 0.15 + uc_deductions: 764.82 + universal_credit: 7_733.98 + council_tax_reduction: 920 + +- name: Merton counts the Universal Credit award after the benefit cap and before a deduction at the cap + # This case enters a 1,200 benefit cap reduction, and the Secretary of State + # reduces the award by it to 8,498.80 - 1,200 = 7,298.80 (UC Regs 2013 reg + # 81(1)). A deduction at the 15% cap (the model's annual 764.82) leaves + # 6,533.98 payable. + # Income exceeds the maximum amount by 8,000 + 7,298.80 - 12,898.80 = 2,400, + # so Merton awards 2,600 - 20% x 2,400 = 2,120. Counting the amount payable + # would give 2,272.96, and counting the award before the cap 1,880. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + uc_benefit_cap_reduction: 1_200 + uc_has_deduction: true + uc_latent_deduction_rate: 0.15 + uc_deduction_combination: THIRD_PARTY_ONLY + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: MERTON + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + uc_benefit_cap_reduction_after_floor: 1_200 + uc_deductions: 764.82 + universal_credit: 6_533.98 + council_tax_reduction: 2_120 + +- name: Merton counts the Universal Credit award before a 600 debt deduction for a claimant with a private pension + # The Secretary of State counts a 1,000 private pension as unearned income + # (UC Regs 2013 reg 66(1)(a)) and deducts all of it from the award, which + # falls to 12,898.80 - 4,400 - 1,000 = 7,498.80, and the 600 deduction + # leaves 6,898.80 payable. Income exceeds the maximum amount by + # 8,000 + 1,000 + 7,498.80 - 12,898.80 = 3,600, so Merton awards 1,880. + # Counting the amount payable would give 2,000. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + private_pension_income: 1_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + uc_deductions: 600 + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: MERTON + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + uc_unearned_income: 1_000 + universal_credit: 6_898.80 + council_tax_reduction: 1_880 + +- name: Kingston upon Thames counts the Universal Credit award before a 600 debt deduction for a claimant with 8,000 of savings + # The Secretary of State treats 8,000 of capital as yielding 4.35 a month + # for each 250 above 6,000 (UC Regs 2013 reg 72(1)), so 8 x 4.35 x 12 = + # 417.60 a year of unearned income. The award falls to + # 12,898.80 - 4,400 - 417.60 = 8,081.20, and the 600 deduction leaves + # 7,481.20 payable. Income exceeds the maximum amount by + # 8,000 + 417.60 + 8,081.20 - 12,898.80 = 3,600. The savings fall within + # Kingston upon Thames's 16,000 capital limit, so it awards 1,880. Counting + # the amount payable would give 2,000. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + uc_deductions: 600 + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: KINGSTON_UPON_THAMES + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 8_000 + output: + uc_unearned_income: 417.60 + universal_credit: 7_481.20 + council_tax_reduction: 1_880 + +- name: Merton counts the Universal Credit award before a 600 debt deduction in a household with a non-dependant + # The claimant heads the household and shares it with a non-dependant aged + # 40 who has no income and claims nothing. The Secretary of State deducts a + # housing cost contribution of 96.55 a month for the non-dependant (UC Regs + # 2013 Sch 4 paras 13(1) and 14(1)), so the maximum amount falls to + # 12,898.80 - 96.55 x 12 = 11,740.20 and the award to + # 11,740.20 - 4,400 = 7,340.20, and the 600 deduction leaves 6,740.20 + # payable. + # Income exceeds the maximum amount by 8,000 + 7,340.20 - 11,740.20 = 3,600. + # Merton deducts 5.20 a week for a non-dependant out of remunerative work, + # 5.20 x 52 = 270.40 a year, and awards 2,600 - 20% x 3,600 - 270.40 = + # 1,609.60. Counting the amount payable would give 1,729.60. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + is_household_head: true + non_dependant: + age: 40 + is_household_head: false + benunits: + claimant_family: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + uc_deductions: 600 + non_dependant_family: + members: [non_dependant] + would_claim_uc: false + claims_all_entitled_benefits: false + households: + household: + members: [claimant, non_dependant] + country: ENGLAND + region: LONDON + local_authority: MERTON + tenure_type: RENT_FROM_COUNCIL + rent: 7_800 + council_tax: 2_600 + savings: 0 + output: + universal_credit: [6_740.20, 0] + merton_council_tax_reduction_non_dep_deductions: [270.40, 0] + council_tax_reduction: 1_609.60 + +- name: Merton counts the Universal Credit award after the benefit cap the model applies and before a deduction at the cap + # The claimant rents from the council at 17,468.20 a year, so the maximum + # amount comes to 424.90 x 12 + 17,468.20 = 22,567 and the award before + # the cap to 22,567 - 4,400 = 18,167. Earnings of 8,000 fall short of the + # earnings exception, 16 hours a week at the national living wage (UC Regs + # 2013 reg 82(1)(a)), so the cap applies. The award exceeds the 16,967 cap + # for a single person in Greater London by 1,200, and the Secretary of + # State reduces it by that excess to 16,967 (reg 81(1)). + # A deduction at the 15% cap (the model's annual 764.82) leaves 16,202.18 + # payable. Income exceeds the maximum amount by + # 8,000 + 16,967 - 22,567 = 2,400, so Merton awards 2,600 - 20% x 2,400 = + # 2,120. Counting the amount payable would give 2,272.96, and counting the + # award before the cap 1,880. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + uc_has_deduction: true + uc_latent_deduction_rate: 0.15 + uc_deduction_combination: THIRD_PARTY_ONLY + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: MERTON + tenure_type: RENT_FROM_COUNCIL + rent: 17_468.20 + council_tax: 2_600 + savings: 0 + output: + uc_maximum_amount: 22_567 + universal_credit_pre_benefit_cap: 18_167 + is_uc_benefit_cap_exempt: false + uc_benefit_cap: 16_967 + uc_benefit_cap_reduction: 1_200 + uc_benefit_cap_reduction_after_floor: 1_200 + uc_deductions: 764.82 + universal_credit: 16_202.18 + council_tax_reduction: 2_120 + +- name: Under an 85% protected floor, Merton counts the Universal Credit award after the cap reduction the floor leaves + # Under a reform that protects 85% of the standard allowance, the Secretary + # of State may take at most 15% x 424.90 x 12 = 764.82 from the same + # household's award through the cap reduction and deductions together. + # The model meets the deduction first, 764.82, which leaves no + # room for the 1,200 cap reduction. The award stays at 18,167, and the + # deduction leaves 18,167 - 764.82 = 17,402.18 payable. Income exceeds the + # maximum amount by 8,000 + 18,167 - 22,567 = 3,600, so Merton awards + # 1,880. Counting the award after the whole 1,200 cap reduction would give + # 2,120, and counting the amount payable 2,032.96. + period: 2026 + absolute_error_margin: 0.01 + input: + gov.dwp.universal_credit.deductions.protected_floor: 0.85 + people: + claimant: + age: 35 + employment_income: 8_000 + benunits: + benunit: + members: [claimant] + would_claim_uc: true + claims_all_entitled_benefits: true + uc_has_deduction: true + uc_latent_deduction_rate: 0.15 + uc_deduction_combination: THIRD_PARTY_ONLY + households: + household: + members: [claimant] + country: ENGLAND + region: LONDON + local_authority: MERTON + tenure_type: RENT_FROM_COUNCIL + rent: 17_468.20 + council_tax: 2_600 + savings: 0 + output: + uc_benefit_cap_reduction: 1_200 + uc_benefit_cap_reduction_after_floor: 0 + uc_deductions: 764.82 + universal_credit: 17_402.18 + council_tax_reduction: 1_880 diff --git a/policyengine_uk/tests/test_council_tax_reduction_uc_deductions_properties.py b/policyengine_uk/tests/test_council_tax_reduction_uc_deductions_properties.py new file mode 100644 index 0000000000..552e296578 --- /dev/null +++ b/policyengine_uk/tests/test_council_tax_reduction_uc_deductions_properties.py @@ -0,0 +1,309 @@ +"""Four councils count the Universal Credit award before debt deductions (#2799). + +Merton and Kingston upon Thames count "the amount of the award of universal +credit" in their 2026-27 schemes, which reproduce SI 2012/2886 Sch para +37(3)(a) and (4). Newham counts "the amount of entitlement to universal +credit", and Westminster's summary compares the maximum amount "to the actual +universal credit award plus any other income and earnings received". +Parliament sets the award as the maximum amount less the income amounts +(Welfare Reform Act 2012 s 8(1)), and the Secretary of State reduces it for the +benefit cap (UC Regs 2013 reg 81(1)). The Secretary of State then recovers +debts from it: advances and other payments on account (SI 2013/383 reg 10), +overpayments (SI 2013/384 reg 10) and the claimant's liabilities to third +parties (SI 2013/380 Sch 6 para 2(1)). The Secretary of State may not make a +third-party deduction that leaves less than a penny payable (Sch 6 para +3(1)(a)). + +The test checks these conditions in 2026 for working-age single people, +couples and families with children in the four councils. It draws benefit cap +reductions from nil to more than the award, and deduction demands from nil +through the 15% cap to an above-cap excess: + +1. universal_credit + uc_deductions equals the award after the cap, + max(universal_credit_pre_benefit_cap - uc_benefit_cap_reduction, 0), and a + family with deductions keeps at least a penny a month payable. +2. While the award exceeds nil, each council grants the same reduction with + and without the deductions. +3. Where the award exceeds nil, each council's reduction matches a reference + that the test writes from para 37 and each scheme's rates: max(0, liability + x maximum support rate - withdrawal rate x max(0, earned income + unearned + income + award - maximum amount)). + +The module builds one simulation, and each example sets its inputs on it. The +simulation holds a pair of households for each family, one with deductions and +one without. +""" + +import numpy as np +import pytest +from hypothesis import HealthCheck, event, example, given, settings +from hypothesis import strategies as st + +from policyengine_uk import Simulation + +YEAR = 2026 +PENNY_A_MONTH = 0.01 * 12 +# Each 2026-27 scheme's maximum support rate and weekly withdrawal rate. +# Merton and Kingston upon Thames withdraw 2 6/7% of the excess income a day +# (20% a week); Newham supports 70% of the liability and withdraws 3 4/7% a +# day (25% a week); Westminster withdraws 20% a week. +SCHEMES = { + "MERTON": (1.0, 0.20), + "KINGSTON_UPON_THAMES": (1.0, 0.20), + "NEWHAM": (0.70, 0.25), + "WESTMINSTER": (1.0, 0.20), +} +COUNCIL_REDUCTIONS = [ + "merton_council_tax_reduction", + "kingston_upon_thames_council_tax_reduction", + "newham_council_tax_reduction", + "westminster_council_tax_reduction", +] +# Adults and children in each family, so the pairs cover single people, +# couples and families with a work allowance. +STRUCTURES = [(1, 0), (2, 0), (1, 1), (2, 2)] * 2 +COMBINATIONS = [ + "ADVANCE_ONLY", + "THIRD_PARTY_ONLY", + "GOVERNMENT_ONLY", + "ADVANCE_AND_GOVERNMENT", + "ADVANCE_AND_THIRD_PARTY", + "THIRD_PARTY_AND_GOVERNMENT", + "ALL_THREE", +] +BENUNIT_OUTPUTS = [ + "universal_credit", + "uc_deductions", + "uc_deduction_rate", + "universal_credit_pre_benefit_cap", + "uc_benefit_cap_reduction", + "uc_maximum_amount", + "uc_earned_income_before_work_allowance", + "uc_unearned_income", + "simulated_council_tax_reduction_benunit", + *COUNCIL_REDUCTIONS, +] +PROPERTY_SETTINGS = settings( + max_examples=15, + deadline=None, + derandomize=True, + suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large], +) + + +def situation(): + """Build two households per family in STRUCTURES, each its own benefit + unit, with no deductions in slot 2k and the drawn ones in slot 2k + 1.""" + people, benunits, households = {}, {}, {} + for k, (adults, children) in enumerate(STRUCTURES): + for slot in (2 * k, 2 * k + 1): + names = [] + for j in range(adults): + name = f"a{slot}_{j}" + people[name] = { + "age": {YEAR: 35 - 2 * j}, + "is_claimant_or_partner": {YEAR: True}, + "employment_income": {YEAR: 0.0}, + } + names.append(name) + for j in range(children): + name = f"c{slot}_{j}" + people[name] = { + "age": {YEAR: 5 + 3 * j}, + "is_claimant_or_partner": {YEAR: False}, + } + names.append(name) + benunits[f"b{slot}"] = { + "members": names, + "would_claim_uc": {YEAR: True}, + "claims_all_entitled_benefits": {YEAR: True}, + "uc_benefit_cap_reduction": {YEAR: 0.0}, + "uc_has_deduction": {YEAR: False}, + "uc_latent_deduction_rate": {YEAR: 0.0}, + "uc_deduction_combination": {YEAR: "NONE"}, + } + households[f"h{slot}"] = { + "members": names, + "country": {YEAR: "ENGLAND"}, + "region": {YEAR: "LONDON"}, + "local_authority": {YEAR: "MERTON"}, + "tenure_type": {YEAR: "RENT_FROM_COUNCIL"}, + "rent": {YEAR: 0.0}, + "council_tax": {YEAR: 2_000.0}, + "savings": {YEAR: 0.0}, + } + return {"people": people, "benunits": benunits, "households": households} + + +@pytest.fixture(scope="module") +def simulation(cloned_uk_tax_benefit_system): + return Simulation(situation=situation()) + + +def money(high): + return st.floats(0, high, allow_nan=False, allow_infinity=False) + + +@st.composite +def family(draw): + return dict( + council=draw(st.sampled_from(sorted(SCHEMES))), + earnings=[draw(st.one_of(st.just(0.0), money(30_000))) for _ in range(2)], + rent=draw(st.one_of(st.just(0.0), money(15_000))), + council_tax=draw(st.floats(500, 4_000)), + # From nil to more than any award the draws give, so the cap can + # take the whole award. + cap_reduction=draw(st.one_of(st.just(0.0), money(30_000))), + # Latent demand as a share of the standard allowance: from nil + # through the 15% cap, and above the 25% calibration cap, where the + # excess sits on top of the cap. + latent_rate=draw( + st.one_of(st.sampled_from([0.05, 0.15, 0.25, 0.30, 0.40]), money(0.40)) + ), + combination=draw(st.sampled_from(COMBINATIONS)), + ) + + +families = st.lists(family(), min_size=len(STRUCTURES), max_size=len(STRUCTURES)) + +# The issue's example (#2799): a single person earning 8,000, renting from the +# council at 7,800, with council tax of 2,600. +ISSUE = dict( + council="MERTON", + earnings=[8_000.0, 0.0], + rent=7_800.0, + council_tax=2_600.0, + cap_reduction=0.0, + latent_rate=0.15, + combination="THIRD_PARTY_ONLY", +) +EXPLICIT = [ + ISSUE, + # A couple whose award the cap reduces and whose deductions include an + # above-cap excess. + {**ISSUE, "council": "NEWHAM", "cap_reduction": 1_500.0, "latent_rate": 0.30}, + {**ISSUE, "council": "KINGSTON_UPON_THAMES", "combination": "ALL_THREE"}, + # The cap takes the whole award. + {**ISSUE, "council": "WESTMINSTER", "cap_reduction": 30_000.0}, + {**ISSUE, "council": "WESTMINSTER", "earnings": [12_000.0, 0.0]}, + {**ISSUE, "council": "NEWHAM", "latent_rate": 0.40}, + {**ISSUE, "council": "MERTON", "rent": 0.0, "earnings": [0.0, 0.0]}, + {**ISSUE, "council": "KINGSTON_UPON_THAMES", "cap_reduction": 4_000.0}, +] + + +def pairs(values): + """Repeat each family's value for both households.""" + return np.repeat(np.asarray(values), 2) + + +def calculate(simulation, fams): + """Set each family's inputs on its pair of households and calculate.""" + # situation() puts family k // 2 in benefit unit k. + benunit_of = simulation.populations["benunit"].members_entity_id + adult = np.asarray(simulation.calculate("is_claimant_or_partner", YEAR)) + earnings = np.zeros(len(benunit_of)) + adults_seen = np.zeros(2 * len(fams), dtype=int) + for i in np.flatnonzero(adult): + b = benunit_of[i] + earnings[i] = fams[b // 2]["earnings"][adults_seen[b]] + adults_seen[b] += 1 + with_deductions = np.arange(2 * len(fams)) % 2 == 1 + inputs = { + # Simulation moves employment_income here as it builds. + "employment_income_before_lsr": earnings, + "local_authority": pairs([f["council"] for f in fams]), + "rent": pairs([f["rent"] for f in fams]), + "council_tax": pairs([f["council_tax"] for f in fams]), + "uc_benefit_cap_reduction": pairs([f["cap_reduction"] for f in fams]), + "uc_has_deduction": with_deductions, + "uc_latent_deduction_rate": np.where( + with_deductions, pairs([f["latent_rate"] for f in fams]), 0.0 + ), + "uc_deduction_combination": np.where( + with_deductions, pairs([f["combination"] for f in fams]), "NONE" + ), + } + for name, value in inputs.items(): + variable = simulation.tax_benefit_system.variables[name] + possible_values = getattr(variable, "possible_values", None) + if possible_values is not None: + value = possible_values.encode(np.asarray(value)) + simulation.set_input(name, YEAR, value) + values = {v: np.asarray(simulation.calculate(v, YEAR)) for v in BENUNIT_OUTPUTS} + values["liability"] = np.asarray( + simulation.calculate("council_tax_reduction_maximum_eligible_liability", YEAR) + ) + return values + + +def award_after_cap(v): + return np.maximum( + v["universal_credit_pre_benefit_cap"] - v["uc_benefit_cap_reduction"], 0 + ) + + +@PROPERTY_SETTINGS +@given(fams=families) +@example(fams=EXPLICIT) +def test_four_councils_count_the_universal_credit_award_before_deductions( + simulation, fams +): + v = calculate(simulation, fams) + uc, deductions = v["universal_credit"], v["uc_deductions"] + award = award_after_cap(v) + base, plus = slice(0, None, 2), slice(1, None, 2) + + # 1. The award and the amount payable. + assert np.allclose(uc + deductions, award, atol=0.01), [ + (fams[k // 2], uc[k], deductions[k], award[k]) + for k in np.flatnonzero(~np.isclose(uc + deductions, award, atol=0.01))[:3] + ] + assert np.all(deductions[base] == 0) + taken = deductions > 0 + # The model holds amounts in float32, so allow a penny of rounding. + assert np.all(uc[taken] >= PENNY_A_MONTH - 0.01) + + # 2. The reductions do not move with the deductions while the award + # exceeds nil. + council = sum(v[name] for name in COUNCIL_REDUCTIONS) + assert np.allclose(council, v["simulated_council_tax_reduction_benunit"]) + has_award = (award[base] > 0) & (award[plus] > 0) + for k in np.flatnonzero(has_award): + event(f"{fams[k]['council']}: deductions {deductions[2 * k + 1] > 0}") + assert np.allclose(council[plus][has_award], council[base][has_award], atol=0.01), [ + (fams[k], council[2 * k], council[2 * k + 1], deductions[2 * k + 1]) + for k in np.flatnonzero( + has_award & ~np.isclose(council[plus], council[base], atol=0.01) + )[:3] + ] + + # 3. Differential against the scheme's own arithmetic. + rates = np.array([SCHEMES[f["council"]] for f in fams]).repeat(2, axis=0) + excess = np.maximum( + v["uc_earned_income_before_work_allowance"] + + v["uc_unearned_income"] + + award + - v["uc_maximum_amount"], + 0, + ) + reference = np.maximum(v["liability"] * rates[:, 0] - rates[:, 1] * excess, 0) + on_uc = award > 0 + assert np.allclose(council[on_uc], reference[on_uc], atol=0.01), [ + (fams[k // 2], council[k], reference[k]) + for k in np.flatnonzero(on_uc & ~np.isclose(council, reference, atol=0.01))[:3] + ] + + if fams == EXPLICIT: + # In the explicit example the Secretary of State deducts the model's + # annual 764.82 from the issue's award and Merton grants 1,880 with + # and without it. The Newham couple repays at the 15% cap plus a 5% + # excess, the Secretary of State reduces the fourth family's award to + # nil for the cap, and every other family keeps an award and repays + # debt. + assert np.isclose(deductions[1], 764.82, atol=0.01) + assert np.allclose(council[:2], 1_880, atol=0.01) + assert np.isclose(v["uc_deduction_rate"][3], 0.20) + assert np.all(award[6:8] == 0) + assert np.all(deductions[plus][has_award] > 0) + assert has_award.sum() == len(EXPLICIT) - 1 diff --git a/policyengine_uk/variables/gov/local_authorities/council_tax_reduction/_legacy.py b/policyengine_uk/variables/gov/local_authorities/council_tax_reduction/_legacy.py index 4383dba483..6e1a42e74b 100644 --- a/policyengine_uk/variables/gov/local_authorities/council_tax_reduction/_legacy.py +++ b/policyengine_uk/variables/gov/local_authorities/council_tax_reduction/_legacy.py @@ -33,24 +33,36 @@ def legacy_council_tax_reduction( would_claim = benunit("would_claim_council_tax_reduction", period) applicable_amount = benunit("council_tax_reduction_applicable_amount", period) applicable_income = benunit("council_tax_reduction_applicable_income", period) - universal_credit = benunit("universal_credit", period) has_uc_award = applicant_has_universal_credit(benunit, period) uc_applicable_amount = benunit("uc_maximum_amount", period) - # The schemes use "the calculation or estimate of the amount of the + # The councils use "the calculation or estimate of the amount of the # income of the applicant ... made by the Secretary of State for the - # purpose of determining the award of universal credit", plus the award - # (Council Tax Reduction Schemes (Default Scheme) (England) Regulations - # 2012, Sch. para. 37(1) and (3)(a); Kingston upon Thames and Merton - # reproduce it, Newham refers to the same calculation, and Westminster's - # scheme is based on the Default Scheme). That income is - # earned income after tax, National Insurance and pension contributions - # and unearned income. The work allowance and taper are steps in the - # award (UC Regs 2013 reg. 22), not in the income, so the work allowance - # is not deducted here. + # purpose of determining the award of universal credit", plus "the amount + # of the award of universal credit" (Council Tax Reduction Schemes + # (Default Scheme) (England) Regulations 2012, Sch. para. 37(1) and + # (3)(a)). Kingston upon Thames and Merton reproduce para. 37, Newham + # refers to the same calculation and counts "the amount of entitlement to + # universal credit", and Westminster bases its scheme on the Default + # Scheme. The model takes that income as earned income after tax, + # National Insurance and pension contributions, plus unearned income. The + # Secretary of State applies the work allowance and taper to the award + # (UC Regs 2013 reg. 22), not to the income, so the model counts earned + # income before the work allowance. The Secretary of State reduces the + # award for the benefit cap (reg. 81(1)), then recovers debts from it: + # payments on account such as advances (SI 2013/383 reg. 10), + # overpayments (SI 2013/384 reg. 10) and the claimant's liabilities to + # third parties (SI 2013/380 Sch. 6 para. 2(1)). The Secretary of State + # may not make a third-party deduction that leaves less than a penny + # payable (Sch. 6 para. 3(1)(a)), and in para. 11(5) treats the award and + # the amount payable as two figures. The councils count the award after + # the benefit cap and before debt deductions. + # universal_credit gives the amount payable, so the model adds + # uc_deductions to it to recover that award. + uc_award = benunit("universal_credit", period) + benunit("uc_deductions", period) uc_applicable_income = ( benunit("uc_earned_income_before_work_allowance", period) + benunit("uc_unearned_income", period) - + universal_credit + + uc_award ) applicable_amount = where(has_uc_award, uc_applicable_amount, applicable_amount) applicable_income = where(has_uc_award, uc_applicable_income, applicable_income)