diff --git a/changelog.d/2410.fixed.md b/changelog.d/2410.fixed.md new file mode 100644 index 0000000000..d5592bbb05 --- /dev/null +++ b/changelog.d/2410.fixed.md @@ -0,0 +1 @@ +- Keep Universal Credit advance repayment cash demand fixed through standard allowance reforms while preserving supplied deduction rates, existing caps, abolition switches and protected-floor allocation. diff --git a/changelog.d/fix-2574-advance-missingness.fixed.md b/changelog.d/fix-2574-advance-missingness.fixed.md new file mode 100644 index 0000000000..fba866c16f --- /dev/null +++ b/changelog.d/fix-2574-advance-missingness.fixed.md @@ -0,0 +1 @@ +- Preserved each benefit unit's Universal Credit advance repayment fallback when other units supply cash, while retaining explicit zero repayments. diff --git a/docs/book/validation/uc-deductions.md b/docs/book/validation/uc-deductions.md index 69d0e258fc..d5b9e7e52d 100644 --- a/docs/book/validation/uc-deductions.md +++ b/docs/book/validation/uc-deductions.md @@ -8,6 +8,42 @@ PolicyEngine UK models the money DWP takes off Universal Credit awards to repay The implementation separates **latent demand** from the **statutory cap**. `uc_latent_deduction_rate` assigns deduction demand from the distribution DWP observed in March to May 2025 — the last full months under the 25% cap — and `gov.dwp.universal_credit.deductions.cap` applies the operational cap (40% to October 2019, 30%, 25%, then 15% under the Fair Repayment Rate from 30 April 2025) at runtime. Assigning observed post-cap rates directly would bake the cap into the data and make cap-raising reforms inexpressible. +## Advance repayments under allowance reforms + +`uc_advance_repayment_amount` accepts annual cash instalments before the cap, +abolition switch and available-award limits. Set the actual amount when known; +zero explicitly removes the advance estimate. Negative values, including the +default -1, mean no amount was supplied. Each omitted benefit unit uses the +fallback even when other units supply cash. A change to the standard allowance +does not increase this demand. Actual recovery can increase if a higher +allowance releases a binding deduction cap. + +For existing latent-rate and type-combination inputs, the fallback keeps the +existing marginal-mean split and converts its advance share using the **same +year's unreformed standard allowance** for the claimant category. The reference +reads the projected baseline parameter tree at 30 April, consistently with +fiscal-year sampling. For example, the 2025 single 25+ allowance of £400.14/month +converts a 10% advance share to £40.014/month. Reforming the allowance to £440 +keeps that cash demand unchanged, subject to the current 15% cap and penny floor. +[SI 2013/383 regulation 10](https://www.legislation.gov.uk/uksi/2013/383/regulation/10) +provides for recovery by offset/deduction; it does not set an allowance-indexed +instalment. + +The final award and protected-floor allocation continue to consume +`uc_deduction_rate` times the standard allowance. An explicitly supplied rate +retains its existing effect and overrides the rate formula, including its cash +advance calculation. The usual advance, third-party and government abolition +switches retain their existing behavior. + +This change isolates allowance reforms within each annual cross-section. The +legacy inputs do not identify the cash-origin year, repayment duration or cohort +schedule. They cannot establish unchanged instalments across projected years or +family-status changes. Supply cash for the relevant years to describe a known +advance schedule. Government/third-party percentage proxies and the aggregate +above-cap excess are unchanged; their legal classification, maintenance priority +and annual projection remain separate work under #2410. No maintenance or last +resort cash interface or new category incidence is introduced. + ## Validation against DWP deductions statistics Enhanced FRS 2023/24 v1.40.3, against [DWP's Universal Credit deductions statistics](https://www.gov.uk/government/statistics/universal-credit-quarterly-statistics-29-april-2013-to-12-february-2026/universal-credit-deductions-statistics-march-2025-to-february-2026). diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/uc_fixed_deductions.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/uc_fixed_deductions.yaml new file mode 100644 index 0000000000..4446602377 --- /dev/null +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/uc_fixed_deductions.yaml @@ -0,0 +1,225 @@ +# SI 2013/383 reg 10: advances are cash instalments, not a percentage. +# SI 2013/380 Sch 6 paras 3-4: penny floor, ceiling and exceptions. +- name: An allowance increase leaves an affordable fixed advance unchanged + period: 2025 + absolute_error_margin: 0.01 + input: + age: 30 + would_claim_uc: true + universal_credit_pre_benefit_cap: 6_000 + uc_advance_repayment_amount: 360 + gov.dwp.universal_credit.standard_allowance.amount.SINGLE_OLD: 440 + output: + uc_deductions: 360 + universal_credit: 5_640 + +- name: A binding administrative cap can limit a fixed advance + period: 2025 + absolute_error_margin: 0.01 + input: + age: 30 + would_claim_uc: true + universal_credit_pre_benefit_cap: 6_000 + uc_advance_repayment_amount: 1_200 + gov.dwp.universal_credit.standard_allowance.amount.SINGLE_OLD: 440 + output: + # Cash demand is £100/month, capped at 15% x £440 = £66/month. + uc_deductions: 792 + +- name: A five percent deduction scales with the allowance + period: 2025 + absolute_error_margin: 0.01 + input: + age: 30 + would_claim_uc: true + universal_credit_pre_benefit_cap: 6_000 + uc_latent_deduction_rate: 0.05 + uc_deduction_combination: THIRD_PARTY_ONLY + gov.dwp.universal_credit.standard_allowance.amount.SINGLE_OLD: 440 + output: + uc_deductions: 264 + +- name: Mixed fixed and percentage demands share the administrative cap + period: 2025 + absolute_error_margin: 0.01 + input: + age: 30 + would_claim_uc: true + universal_credit_pre_benefit_cap: 6_000 + uc_advance_repayment_amount: 600 + uc_latent_deduction_rate: 0.05 + uc_deduction_combination: THIRD_PARTY_ONLY + gov.dwp.universal_credit.standard_allowance.amount.SINGLE_OLD: 440 + output: + # £50 cash + 5% x £440 = £72; administrative cap £66/month. + uc_deductions: 792 + +- name: Fixed deductions still leave a penny per assessment period + period: 2025 + absolute_error_margin: 0.01 + input: + age: 30 + would_claim_uc: true + universal_credit_pre_benefit_cap: 120 + uc_advance_repayment_amount: 360 + output: + uc_deductions: 119.88 + universal_credit: 0.12 + +- name: Abolishing advances removes an explicitly supplied cash instalment + period: 2025 + absolute_error_margin: 0.01 + input: + age: 30 + would_claim_uc: true + universal_credit_pre_benefit_cap: 6_000 + uc_advance_repayment_amount: 360 + gov.dwp.universal_credit.deductions.abolish.advance: true + output: + uc_deductions: 0 + +- name: A legacy advance rate uses the same year's unreformed allowance + period: 2025 + absolute_error_margin: 0.01 + input: + age: 30 + would_claim_uc: true + universal_credit_pre_benefit_cap: 6_000 + uc_latent_deduction_rate: 0.1 + uc_deduction_combination: ADVANCE_ONLY + gov.dwp.universal_credit.standard_allowance.amount.SINGLE_OLD: 440 + output: + # The legacy 10% represented £40.014/month at the unreformed £400.14. + # It does not become £44 when only the allowance is reformed. + uc_advance_repayment_amount: 480.168 + uc_deductions: 480.168 + universal_credit: 5_519.832 + +- name: An explicit zero replaces the legacy advance estimate + period: 2025 + absolute_error_margin: 0.01 + input: + age: 30 + would_claim_uc: true + universal_credit_pre_benefit_cap: 6_000 + uc_latent_deduction_rate: 0.1 + uc_deduction_combination: ADVANCE_ONLY + uc_advance_repayment_amount: 0 + output: + uc_deductions: 0 + +- name: An explicit zero leaves another benefit unit's advance estimate intact + period: 2025 + absolute_error_margin: 0.01 + input: + people: + zero_claimant: + age: 30 + missing_claimant: + age: 30 + benunits: + zero: + members: [zero_claimant] + would_claim_uc: true + universal_credit_pre_benefit_cap: 6_000 + uc_benefit_cap_reduction: 0 + uc_latent_deduction_rate: 0.1 + uc_deduction_combination: ADVANCE_ONLY + uc_advance_repayment_amount: 0 + missing: + members: [missing_claimant] + would_claim_uc: true + universal_credit_pre_benefit_cap: 6_000 + uc_benefit_cap_reduction: 0 + uc_latent_deduction_rate: 0.1 + uc_deduction_combination: ADVANCE_ONLY + households: + zero_household: + members: [zero_claimant] + missing_household: + members: [missing_claimant] + output: + # Only the supplied zero removes the £40.014/month legacy advance. + uc_deductions: [0, 480.168] + universal_credit: [6_000, 5_519.832] + +- name: A capped family's fixed advance stays cash at the current allowance + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent1: + age: 35 + is_claimant_or_partner: true + child_tax_credit_reported: 3_000 + parent2: + age: 33 + is_claimant_or_partner: true + child1: + age: 13 + child2: + age: 11 + child3: + age: 9 + child4: + age: 7 + benunits: + family: + members: [parent1, parent2, child1, child2, child3, child4] + would_claim_uc: false + would_claim_uc_at_legacy_closure: true + uc_advance_repayment_amount: 600 + households: + household: + members: [parent1, parent2, child1, child2, child3, child4] + rent: 30_000 + tenure_type: RENT_FROM_COUNCIL + region: LONDON + output: + # SI 2013/376 reg 81: the extra allowance is offset by the benefit cap. + # Actual family inputs produce £21,277.40 before £600 fixed recovery. + claims_universal_credit: true + uc_advance_repayment_amount: 600 + uc_deductions: 600 + universal_credit: 20_677.4 + +- name: A capped family's fixed advance stays cash after an allowance uplift + period: 2025 + absolute_error_margin: 0.01 + input: + gov.dwp.universal_credit.standard_allowance.amount.COUPLE_OLD: 690.91 + people: + parent1: + age: 35 + is_claimant_or_partner: true + child_tax_credit_reported: 3_000 + parent2: + age: 33 + is_claimant_or_partner: true + child1: + age: 13 + child2: + age: 11 + child3: + age: 9 + child4: + age: 7 + benunits: + family: + members: [parent1, parent2, child1, child2, child3, child4] + would_claim_uc: false + would_claim_uc_at_legacy_closure: true + uc_advance_repayment_amount: 600 + households: + household: + members: [parent1, parent2, child1, child2, child3, child4] + rent: 30_000 + tenure_type: RENT_FROM_COUNCIL + region: LONDON + output: + # SI 2013/376 reg 81: the extra allowance is offset by the benefit cap. + # Actual family inputs produce £21,277.40 before £600 fixed recovery. + claims_universal_credit: true + uc_advance_repayment_amount: 600 + uc_deductions: 600 + universal_credit: 20_677.4 diff --git a/policyengine_uk/tests/test_uc_advance_repayment_properties.py b/policyengine_uk/tests/test_uc_advance_repayment_properties.py new file mode 100644 index 0000000000..f5445df4f6 --- /dev/null +++ b/policyengine_uk/tests/test_uc_advance_repayment_properties.py @@ -0,0 +1,156 @@ +"""A unit's advance repayment input must retain its own missingness. + +Core creates an input array for the whole population when any benefit unit +supplies a value. Omitted units must still use their legacy cash estimate, +while an explicitly supplied zero must suppress advance repayments. +""" + +import numpy as np +import pytest +from hypothesis import example, given, settings +from hypothesis import strategies as st + +from policyengine_uk import Simulation + +pytestmark = pytest.mark.usefixtures("cloned_uk_tax_benefit_system") + +YEAR = 2025 +FALLBACK = 0.1 * 400.14 * 12 +COMBINATIONS = [ + "NONE", + "ADVANCE_ONLY", + "THIRD_PARTY_ONLY", + "GOVERNMENT_ONLY", + "ADVANCE_AND_GOVERNMENT", + "ADVANCE_AND_THIRD_PARTY", + "THIRD_PARTY_AND_GOVERNMENT", + "ALL_THREE", +] + + +def situation(amounts, year=YEAR, age=30, latent=0.1, combination="ADVANCE_ONLY"): + people, benunits, households = {}, {}, {} + for i, amount in enumerate(amounts): + person = f"person_{i}" + people[person] = {"age": {year: age}} + unit = { + "members": [person], + "would_claim_uc": {year: True}, + "universal_credit_pre_benefit_cap": {year: 6_000}, + "uc_benefit_cap_reduction": {year: 0}, + "uc_latent_deduction_rate": {year: latent}, + "uc_deduction_combination": {year: combination}, + } + if amount is not None: + unit["uc_advance_repayment_amount"] = {year: amount} + benunits[f"benunit_{i}"] = unit + households[f"household_{i}"] = {"members": [person]} + return {"people": people, "benunits": benunits, "households": households} + + +@pytest.mark.parametrize( + "amounts, expected", + [ + ([0, None], [0, FALLBACK]), + ([None, 0], [FALLBACK, 0]), + ([None, None], [FALLBACK, FALLBACK]), + ([0, 0], [0, 0]), + ([120, 240], [120, 240]), + ([-1, 0], [FALLBACK, 0]), + ([-1, -1], [FALLBACK, FALLBACK]), + ], + ids=[ + "zero-then-missing", + "missing-then-zero", + "fully-unsupplied", + "fully-supplied-zero", + "fully-supplied-positive", + "sentinel-and-zero", + "fully-supplied-sentinels", + ], +) +def test_each_unit_resolves_its_own_advance_amount(amounts, expected): + simulation = Simulation(situation=situation(amounts)) + np.testing.assert_allclose( + simulation.calculate("uc_deductions", YEAR), expected, rtol=1e-6, atol=1e-3 + ) + + +cash = st.integers(1, 300_000).map(lambda pennies: pennies / 100) +optional_cash = st.one_of(st.sampled_from([None, -1.0, 0.0]), cash) + + +@settings(max_examples=12, deadline=None, derandomize=True) +@given( + target=optional_cash, + peers=st.lists(optional_cash, min_size=1, max_size=4), + position=st.integers(0, 4), + age=st.integers(18, 60), + latent=st.floats(0, 0.4, allow_nan=False, allow_infinity=False), + combination=st.sampled_from(COMBINATIONS), + year=st.sampled_from([2025, 2026]), +) +@example( + target=None, + peers=[0], + position=1, + age=30, + latent=0.1, + combination="ADVANCE_ONLY", + year=2025, +) +@example( + target=None, + peers=[None, 120], + position=0, + age=24, + latent=0.2, + combination="ALL_THREE", + year=2026, +) +@example( + target=0, + peers=[0, 120], + position=1, + age=30, + latent=0.1, + combination="ADVANCE_ONLY", + year=2025, +) +@example( + target=120, + peers=[0, 240], + position=2, + age=30, + latent=0.1, + combination="ADVANCE_AND_GOVERNMENT", + year=2025, +) +@example( + target=-1, + peers=[0], + position=0, + age=30, + latent=0.1, + combination="ADVANCE_ONLY", + year=2025, +) +def test_advance_deduction_is_independent_of_peers_supplied_cash( + target, peers, position, age, latent, combination, year +): + """Change only other units' supplied cash; retain the target's deduction.""" + target_index = position % (len(peers) + 1) + missing_peers = [None] * len(peers) + supplied_peers = peers.copy() + missing_peers.insert(target_index, target) + supplied_peers.insert(target_index, target) + + def deduction(amounts): + simulation = Simulation( + situation=situation(amounts, year, age, latent, combination) + ) + return simulation.calculate("uc_deductions", year)[target_index] + + assert deduction(supplied_peers) == pytest.approx( + deduction(missing_peers), rel=1e-6, abs=1e-3 + ) diff --git a/policyengine_uk/tests/test_uc_deductions.py b/policyengine_uk/tests/test_uc_deductions.py index 7ec582d90c..216dd1c00e 100644 --- a/policyengine_uk/tests/test_uc_deductions.py +++ b/policyengine_uk/tests/test_uc_deductions.py @@ -415,3 +415,38 @@ def test_abolishing_all_types_removes_deductions(self): }, ) assert reform.calculate("uc_deductions", YEAR)[0] == 0 + + +def test_allowance_scenario_preserves_the_legacy_advance_cash_reference(): + """The actual UK dated-reform route must retain the unreformed cash anchor. + + SI 2013/383 reg 10 does not index an advance instalment to the allowance. + The existing latent 10% is £40.014/month at the published 2025-26 + single 25+ allowance, £400.14; both demands are below the 15% cap. + """ + situation = make_situation( + uc_latent_deduction_rate={YEAR: 0.1}, + uc_deduction_combination={YEAR: "ADVANCE_ONLY"}, + ) + baseline = Simulation(situation=situation) + reformed = Simulation( + situation=situation, + reform={ + "gov.dwp.universal_credit.standard_allowance.amount.SINGLE_OLD": { + "2025-01-01.2025-12-31": 440 + } + }, + ) + assert baseline.calculate("uc_standard_allowance", YEAR)[0] == pytest.approx( + 400.14 * 12 + ) + assert reformed.calculate("uc_standard_allowance", YEAR)[0] == pytest.approx( + 440 * 12 + ) + for simulation in (baseline, reformed): + assert simulation.calculate("uc_advance_repayment_amount", YEAR)[ + 0 + ] == pytest.approx(0.1 * 400.14 * 12) + assert simulation.calculate("uc_deductions", YEAR)[0] == pytest.approx( + 0.1 * 400.14 * 12 + ) diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/deductions/_deduction_amounts.py b/policyengine_uk/variables/gov/dwp/universal_credit/deductions/_deduction_amounts.py new file mode 100644 index 0000000000..71016bd19a --- /dev/null +++ b/policyengine_uk/variables/gov/dwp/universal_credit/deductions/_deduction_amounts.py @@ -0,0 +1,74 @@ +"""Calibration helpers; cash estimates are not statutory instalment rules.""" + +from policyengine_uk.model_api import * + + +def deduction_type_shares(benunit, period, parameters): + """Split the legacy total by its existing marginal-mean approximation.""" + m = parameters(period).gov.simulation.uc_deductions.mean_monthly_amount_by_type + combination = benunit("uc_deduction_combination", period) + advance = ( + np.isin( + combination.decode_to_str(), + [ + "ADVANCE_ONLY", + "ADVANCE_AND_GOVERNMENT", + "ADVANCE_AND_THIRD_PARTY", + "ALL_THREE", + ], + ) + * m.ADVANCE + ) + third_party = ( + np.isin( + combination.decode_to_str(), + [ + "THIRD_PARTY_ONLY", + "ADVANCE_AND_THIRD_PARTY", + "THIRD_PARTY_AND_GOVERNMENT", + "ALL_THREE", + ], + ) + * m.THIRD_PARTY + ) + government = ( + np.isin( + combination.decode_to_str(), + [ + "GOVERNMENT_ONLY", + "ADVANCE_AND_GOVERNMENT", + "THIRD_PARTY_AND_GOVERNMENT", + "ALL_THREE", + ], + ) + * m.GOVERNMENT + ) + total = advance + third_party + government + return tuple( + np.divide(part, total, out=np.zeros_like(part, dtype=float), where=total > 0) + for part in (advance, third_party, government) + ) + + +def reference_standard_allowance(benunit, period, parameters): + """Same-year current-law allowance, sampled as UK fiscal parameters are. + + The baseline tree is projected but not fiscal-year annualised. A legacy + rate has no cash-origin year, so this preserves its annual cross-section; + it does not establish a debt instalment's path across projection years. + """ + p = parameters(f"{period.start.year}-04-30").baseline.gov.dwp.universal_credit + claimant_type = benunit("uc_standard_allowance_claimant_type", period) + return p.standard_allowance.amount[claimant_type] * MONTHS_IN_YEAR + + +def estimated_advance_repayment_amount(benunit, period, parameters): + """Convert the legacy advance share to same-year unreformed cash.""" + p = parameters(period).gov.simulation.uc_deductions + advance_share, _, _ = deduction_type_shares(benunit, period, parameters) + latent = max_(benunit("uc_latent_deduction_rate", period), 0) + return ( + min_(latent, p.calibration_cap) + * advance_share + * reference_standard_allowance(benunit, period, parameters) + ) diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/deductions/uc_advance_repayment_amount.py b/policyengine_uk/variables/gov/dwp/universal_credit/deductions/uc_advance_repayment_amount.py new file mode 100644 index 0000000000..4499a675bc --- /dev/null +++ b/policyengine_uk/variables/gov/dwp/universal_credit/deductions/uc_advance_repayment_amount.py @@ -0,0 +1,26 @@ +from policyengine_uk.model_api import * +from policyengine_uk.variables.gov.dwp.universal_credit.deductions._deduction_amounts import ( + estimated_advance_repayment_amount, +) + + +class uc_advance_repayment_amount(Variable): + label = "UC advance repayment cash demand" + documentation = ( + "Annual cash instalments before the deductions cap, abolition and penny floor. " + "An explicit nonnegative amount, including zero, overrides the legacy " + "estimate. Negative values, including the default -1, mean no amount " + "was supplied; the deduction rate then uses the fallback for that unit. The " + "fallback splits the supplied annual latent rate by the published type means " + "and converts its advance share using that year's unreformed allowance. " + "It is an annual cross-sectional estimate, not a longitudinal debt schedule." + ) + entity = BenUnit + definition_period = YEAR + value_type = float + default_value = -1 + unit = GBP + reference = "https://www.legislation.gov.uk/uksi/2013/383/regulation/10" + + def formula(benunit, period, parameters): + return estimated_advance_repayment_amount(benunit, period, parameters) diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/deductions/uc_deduction_rate.py b/policyengine_uk/variables/gov/dwp/universal_credit/deductions/uc_deduction_rate.py index 8271d6053f..d1b5539560 100644 --- a/policyengine_uk/variables/gov/dwp/universal_credit/deductions/uc_deduction_rate.py +++ b/policyengine_uk/variables/gov/dwp/universal_credit/deductions/uc_deduction_rate.py @@ -1,80 +1,55 @@ from policyengine_uk.model_api import * -from policyengine_uk.variables.gov.dwp.universal_credit.deductions.uc_deduction_combination import ( - UCDeductionCombination, +from policyengine_uk.variables.gov.dwp.universal_credit.deductions._deduction_amounts import ( + deduction_type_shares, + estimated_advance_repayment_amount, ) class uc_deduction_rate(Variable): label = "UC deduction rate" documentation = ( - "Deductions taken from this benefit unit's Universal Credit award as " - "a fraction of the standard allowance, after removing any abolished " - "deduction types and applying the deductions cap. The above-cap " - "excess (latent demand above 25% of the standard allowance, covering " - "last resort and child maintenance deductions) sits on top of the " - "cap." + "Deductions as a fraction of the current Universal Credit standard allowance, " + "after removing abolished ordinary debt types and applying the cap. " + "Advance demand is held in cash through an allowance reform; the rate " + "therefore adjusts when the allowance changes. An explicitly supplied " + "rate retains its existing precedence in the final award. The legacy " + "above-cap excess is unchanged." ) entity = BenUnit definition_period = YEAR value_type = float def formula(benunit, period, parameters): - # Law: the cap and abolition switches. Estimation: the mean amounts - # by type (gov.simulation), used only to split a household's total - # rate across its deduction types. law = parameters(period).gov.dwp.universal_credit.deductions - m = parameters(period).gov.simulation.uc_deductions.mean_monthly_amount_by_type - latent = benunit("uc_latent_deduction_rate", period) - combination = benunit("uc_deduction_combination", period) - - advance_weight = 0.0 if law.abolish.advance else m.ADVANCE - third_party_weight = 0.0 if law.abolish.third_party else m.THIRD_PARTY - government_weight = 0.0 if law.abolish.government else m.GOVERNMENT - - def retained(kept, total): - return kept / max(total, 1e-9) - - retained_share = select( - [ - combination == UCDeductionCombination.ADVANCE_ONLY, - combination == UCDeductionCombination.THIRD_PARTY_ONLY, - combination == UCDeductionCombination.GOVERNMENT_ONLY, - combination == UCDeductionCombination.ADVANCE_AND_GOVERNMENT, - combination == UCDeductionCombination.ADVANCE_AND_THIRD_PARTY, - combination == UCDeductionCombination.THIRD_PARTY_AND_GOVERNMENT, - combination == UCDeductionCombination.ALL_THREE, - ], - [ - retained(advance_weight, m.ADVANCE), - retained(third_party_weight, m.THIRD_PARTY), - retained(government_weight, m.GOVERNMENT), - retained( - advance_weight + government_weight, - m.ADVANCE + m.GOVERNMENT, - ), - retained( - advance_weight + third_party_weight, - m.ADVANCE + m.THIRD_PARTY, - ), - retained( - third_party_weight + government_weight, - m.THIRD_PARTY + m.GOVERNMENT, - ), - retained( - advance_weight + third_party_weight + government_weight, - m.ADVANCE + m.THIRD_PARTY + m.GOVERNMENT, - ), - ], - default=0.0, - ) - # The cappable portion covers the three modeled deduction types - # (advances, third party, government debt) and responds to the cap - # and abolition switches. Latent demand above the calibration-window - # cap belongs to categories permitted to exceed the cap (last resort - # and child maintenance deductions), exempt from both. calibration_cap = parameters( period ).gov.simulation.uc_deductions.calibration_cap - cappable = min_(latent, calibration_cap) * retained_share + _, third_share, government_share = deduction_type_shares( + benunit, period, parameters + ) + remaining_share = third_share * ( + not law.abolish.third_party + ) + government_share * (not law.abolish.government) + allowance = benunit("uc_standard_allowance", period) + latent = benunit("uc_latent_deduction_rate", period) + other_rate = min_(latent, calibration_cap) * remaining_share + advance = benunit("uc_advance_repayment_amount", period) + # A partially supplied input array contains -1 for omitted units. + # Resolve those units independently, retaining explicitly supplied zero. + advance = where( + advance >= 0, + advance, + estimated_advance_repayment_amount(benunit, period, parameters), + ) + if law.abolish.advance: + advance = 0 + advance_rate = np.divide( + max_(advance, 0), + allowance, + out=np.zeros_like(allowance), + where=allowance > 0, + ) + # Preserve the original unclassified above-cap proxy. Its legal + # categories and time path need separate data/policy work (#2410). above_cap_excess = max_(latent - calibration_cap, 0) - return min_(cappable, law.cap) + above_cap_excess + return min_(advance_rate + other_rate, law.cap) + above_cap_excess