diff --git a/changelog.d/2255.fixed.md b/changelog.d/2255.fixed.md new file mode 100644 index 0000000000..2e58071506 --- /dev/null +++ b/changelog.d/2255.fixed.md @@ -0,0 +1 @@ +- Stopped a negative income source, such as a property loss or a self-employment loss, from reducing a claimant's other Pension Credit income. diff --git a/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_earnings.yaml b/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_earnings.yaml index 6570a74d76..35c1ea27de 100644 --- a/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_earnings.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_earnings.yaml @@ -64,4 +64,49 @@ benunit: members: [person] output: - pension_credit_earnings: 0 \ No newline at end of file + pension_credit_earnings: 0 + +# Issue #2255. Computation of Earnings Regulations 1996 reg. 13(12), applied to +# Pension Credit by SPC Regulations 2002 reg. 17B(5)(b): "any loss incurred in +# any one of his employments shall not be offset against his earnings in any +# other of his employments" +# (https://www.legislation.gov.uk/uksi/1996/2745/regulation/13). +- name: A self-employment loss is not set against wages + period: 2023 + input: + people: + person: + employment_income: 10_000 + self_employment_income: -8_000 + benunits: + benunit: + members: [person] + output: + pension_credit_earnings: 10_000 + +- name: A self-employment loss alone gives nil earnings + period: 2023 + input: + people: + person: + employment_income: 0 + self_employment_income: -8_000 + benunits: + benunit: + members: [person] + output: + pension_credit_earnings: 0 + +- name: A partner's self-employment loss is not set against the claimant's wages + period: 2023 + input: + people: + person: + employment_income: 10_000 + partner: + self_employment_income: -8_000 + benunits: + benunit: + members: [person, partner] + output: + pension_credit_earnings: 10_000 diff --git a/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_income.yaml b/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_income.yaml index b6cf5c9493..a69dfec245 100644 --- a/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_income.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/dwp/pension_credit/pension_credit_income.yaml @@ -123,3 +123,98 @@ private_pension_wealth: 200_000 output: pension_credit_assessable_capital: 12_000 + +# Issue #2255. State Pension Credit Act 2002 s. 15(1) and SPC Regulations 2002 +# reg. 15 list receipts; nothing lets a loss on one be set against another +# (https://www.legislation.gov.uk/uksi/2002/1792/regulation/15). A property +# loss used to wipe out the pension here and pay the full guarantee credit. +- name: A property loss does not reduce other Pension Credit income. + period: 2026 + absolute_error_margin: 1 + input: + people: + person: + age: 75 + private_pension_income: 20_000 + property_income: -30_000 + benunits: + benunit: + members: person + households: + household: + members: person + region: WALES + tenure_type: OWNED_OUTRIGHT + output: + property_income_after_finance_costs: -30_000 + pension_credit_income: 18_514 + pension_credit: 0 + +- name: The same person without the property loss has the same Pension Credit income. + period: 2026 + absolute_error_margin: 1 + input: + people: + person: + age: 75 + private_pension_income: 20_000 + benunits: + benunit: + members: person + households: + household: + members: person + region: WALES + tenure_type: OWNED_OUTRIGHT + output: + pension_credit_income: 18_514 + pension_credit: 0 + +- name: Positive property income still counts in Pension Credit income. + period: 2026 + absolute_error_margin: 1 + input: + people: + person: + age: 75 + private_pension_income: 20_000 + property_income: 3_000 + benunits: + benunit: + members: person + households: + household: + members: person + region: WALES + tenure_type: OWNED_OUTRIGHT + output: + # 20,000 + 3,000, less income tax of 20% of (23,000 - 12,570) = 2,086. + pension_credit_income: 20_914 + pension_credit: 0 + +# Issue #2255, earnings. A self-employment loss is not set against wages +# (Computation of Earnings Regulations 1996 reg. 13(12), applied by SPC +# Regulations 2002 reg. 17B(5)(b)). The loss used to cut Pension Credit income +# from 10,000 to 2,000 and raise the award from 2,376 to 10,376. +- name: A self-employment loss does not reduce Pension Credit income from wages. + period: 2026 + absolute_error_margin: 1 + input: + people: + person: + age: 70 + employment_income: 10_000 + self_employment_income: -8_000 + benunits: + benunit: + members: person + households: + household: + members: person + region: WALES + tenure_type: OWNED_OUTRIGHT + output: + pension_credit_earnings: 10_000 + pension_credit_income: 10_000 + # 238 x 52 = 12,376, less income of 10,000. + pension_credit: 2_376 diff --git a/policyengine_uk/tests/test_pension_credit_income_losses.py b/policyengine_uk/tests/test_pension_credit_income_losses.py new file mode 100644 index 0000000000..94e4b5e535 --- /dev/null +++ b/policyengine_uk/tests/test_pension_credit_income_losses.py @@ -0,0 +1,136 @@ +"""A loss on one income source does not reduce Pension Credit income (#2255). + +State Pension Credit Act 2002 ss. 15 to 16 and the State Pension Credit +Regulations 2002 regs. 15 to 18 say what counts as income. Nothing in them +lets a negative amount on one source be set against another, and for earnings +the Computation of Earnings Regulations 1996 reg. 13(12), applied by SPC +Regulations reg. 17B(5)(b), says so: "any loss incurred in any one of his +employments shall not be offset against his earnings in any other of his +employments". +""" + +import pytest +from hypothesis import given, settings +from hypothesis import strategies as st + +from policyengine_uk import Simulation + +YEAR = 2026 +INPUTS = ( + "private_pension_income", + "property_income", + "employment_income", + "self_employment_income", +) + + +def _pension_credit(cases: list[dict]) -> list[tuple[float, float]]: + """Pension Credit income and award for single pensioners, one per case. + + Each case gives annual amounts for any of INPUTS; the rest are nil. All + the cases go into one simulation, which costs about the same as one. + """ + people, benunits, households = {}, {}, {} + for i, case in enumerate(cases): + people[f"person_{i}"] = { + "age": {YEAR: 75}, + **{name: {YEAR: case.get(name, 0)} for name in INPUTS}, + } + benunits[f"benunit_{i}"] = {"members": [f"person_{i}"]} + households[f"household_{i}"] = { + "members": [f"person_{i}"], + "region": {YEAR: "WALES"}, + "tenure_type": {YEAR: "OWNED_OUTRIGHT"}, + } + sim = Simulation( + situation={ + "people": people, + "benunits": benunits, + "households": households, + } + ) + income = sim.calculate("pension_credit_income", YEAR) + credit = sim.calculate("pension_credit", YEAR) + return [(float(a), float(b)) for a, b in zip(income, credit)] + + +amounts = st.integers(min_value=0, max_value=40_000) +losses = st.integers(min_value=-100_000, max_value=0) +property_incomes = st.integers(min_value=-100_000, max_value=20_000) + + +def batches(*strategies): + return st.lists(st.tuples(*strategies), min_size=1, max_size=8) + + +def _paired(cases: list[dict], baselines: list[dict]): + """Results for each case beside its baseline, from one simulation.""" + results = _pension_credit(cases + baselines) + return zip(results[: len(cases)], results[len(cases) :]) + + +@settings(max_examples=5, deadline=None) +@given(batch=batches(amounts, losses)) +def test_a_property_loss_counts_as_nil(batch): + pairs = _paired( + [ + {"private_pension_income": pension, "property_income": loss} + for pension, loss in batch + ], + [{"private_pension_income": pension} for pension, _ in batch], + ) + for with_loss, without in pairs: + assert with_loss == pytest.approx(without, abs=0.01) + + +@settings(max_examples=5, deadline=None) +@given(batch=batches(amounts, property_incomes)) +def test_pension_credit_is_never_higher_than_with_no_property_income(batch): + # Not monotonicity in general: the model's property allowance makes + # Pension Credit step up between two positive property incomes. + pairs = _paired( + [ + {"private_pension_income": pension, "property_income": amount} + for pension, amount in batch + ], + [{"private_pension_income": pension} for pension, _ in batch], + ) + for (_, credit), (_, credit_without) in pairs: + assert credit <= credit_without + 0.01 + + +@settings(max_examples=5, deadline=None) +@given(batch=batches(amounts, amounts, losses)) +def test_a_self_employment_loss_counts_as_nil(batch): + pairs = _paired( + [ + { + "private_pension_income": pension, + "employment_income": wages, + "self_employment_income": loss, + } + for pension, wages, loss in batch + ], + [ + {"private_pension_income": pension, "employment_income": wages} + for pension, wages, _ in batch + ], + ) + for with_loss, without in pairs: + assert with_loss == pytest.approx(without, abs=0.01) + + +def test_issue_2255_reproducers(): + (property_loss, trading_loss) = _pension_credit( + [ + {"private_pension_income": 20_000, "property_income": -30_000}, + {"employment_income": 10_000, "self_employment_income": -8_000}, + ] + ) + # 20,000 less income tax of 20% of (20,000 - 12,570). + assert property_loss == (pytest.approx(18_514, abs=1), 0) + # 238 x 52 = 12,376, less wages of 10,000. + assert trading_loss == ( + pytest.approx(10_000, abs=1), + pytest.approx(2_376, abs=1), + ) diff --git a/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_earnings.py b/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_earnings.py index c4a6137b6a..75d452b78e 100644 --- a/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_earnings.py +++ b/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_earnings.py @@ -15,6 +15,8 @@ class pension_credit_earnings(Variable): reference = ( "https://www.legislation.gov.uk/ukpga/2002/16/section/5", "https://www.legislation.gov.uk/uksi/2002/1792/regulation/17A", + "https://www.legislation.gov.uk/uksi/2002/1792/regulation/17B", + "https://www.legislation.gov.uk/uksi/1996/2745/regulation/13", ) def formula(benunit, period, parameters): @@ -22,5 +24,8 @@ def formula(benunit, period, parameters): period ).gov.dwp.pension_credit.guarantee_credit.earnings_sources person = benunit.members - earnings = add(person, period, sources) + # A loss in one employment is not set against earnings in another + # (Computation of Earnings Regs 1996 reg. 13(12), applied by SPC + # Regs 2002 reg. 17B(5)(b)), so a negative source counts as nil. + earnings = sum(max_(0, person(source, period)) for source in sources) return benunit.sum(earnings * person("is_claimant_or_partner", period)) diff --git a/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_income.py b/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_income.py index 1160800f3a..944419416e 100644 --- a/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_income.py +++ b/policyengine_uk/variables/gov/dwp/pension_credit/pension_credit_income.py @@ -25,7 +25,13 @@ def formula(benunit, period, parameters): total = 0 for source in sources: if person.entity.get_variable(source).entity.is_person: - total += benunit.sum(person(source, period) * is_claimant_or_partner) + # Nothing in the State Pension Credit Act 2002 ss. 15 to 16 + # or SPC Regs 2002 regs. 15 to 18 lets a loss on one source + # be set against another, so a negative source, such as a + # property loss, counts as nil. + total += benunit.sum( + max_(0, person(source, period)) * is_claimant_or_partner + ) else: total += add(benunit, period, [source])