From b1a660045033bafd67a6f45ef8a5d7e17e798bbb Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sun, 4 Oct 2026 06:57:09 -0400 Subject: [PATCH 01/14] Exempt unit trusts and stocks and shares ISAs from the sale-expense deduction corporate_wealth is now itemised in the capital sources lists (#1974), so the sale-expense lists name directly_held_shares, which DWP values less 10% for costs of sale (ADM H1665; DMG 29671/52671/84763; HBGM W1.513), and unitemised_corporate_wealth, which keeps the previous flat treatment on datasets that do not itemise. Unit trusts have no costs of sale even when sold through a broker (ADM H1673-H1674; DMG 29680-29681, 52680-52681, 84771-84772; HBGM W1.530-W1.531), and an ISA is valued at what the holder would get by withdrawing it, with no paragraph applying the 10% (ADM H1656-H1658; DMG 29662-29664, 52662, 84748-84750). The survey bucket of unit and investment trusts is treated as having no costs of sale; investment trusts were 8.2% and 6.9% of the pooled funds in stocks and shares ISAs at 5 April 2022 and 2025 (HMRC ISA Table 9.6). The property tests keep their own legal asset set and assert each programme's list against it, and gain the split invariants: the residual, backward compatibility with every component nil, conservation at a zero rate, split effect = rate x (trusts + ISA), and no double counting. #1974's itemising-invariance test no longer holds by design and is replaced by them. Co-Authored-By: Claude Opus 5.5 --- changelog.d/sale-expense-share-split.fixed.md | 1 + .../income/capital/sale_expenses/sources.yaml | 37 ++- .../income/capital/sale_expenses/sources.yaml | 36 ++- .../capital/sale_expenses/sources.yaml | 36 ++- .../capital/sale_expenses/sources.yaml | 36 ++- .../income/capital/sale_expenses/sources.yaml | 38 ++- .../capital/sale_expenses/sources.yaml | 34 ++- .../dwp/capital_valuation_share_split.yaml | 260 ++++++++++++++++ .../tests/test_capital_share_components.py | 34 +-- .../test_capital_valuation_properties.py | 287 +++++++++++++++--- .../tests/test_stock_capital_periods.py | 36 +++ 11 files changed, 710 insertions(+), 125 deletions(-) create mode 100644 changelog.d/sale-expense-share-split.fixed.md create mode 100644 policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml diff --git a/changelog.d/sale-expense-share-split.fixed.md b/changelog.d/sale-expense-share-split.fixed.md new file mode 100644 index 0000000000..1060d7977b --- /dev/null +++ b/changelog.d/sale-expense-share-split.fixed.md @@ -0,0 +1 @@ +- Apply the 10% sale-expense deduction to directly held shares only, so unit and investment trusts (ADM H1673-H1674) and stocks and shares ISAs (ADM H1656) count at full value in every means test; datasets that do not itemise `corporate_wealth` keep its previous treatment. diff --git a/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sale_expenses/sources.yaml index 40f6f3fb9a..0f05cea7e0 100644 --- a/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sale_expenses/sources.yaml @@ -6,14 +6,28 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (DMG 52620-52623 and 52685). `corporate_wealth` is listed because + sale (DMG 52620-52623 and 52685). `directly_held_shares` is listed because shares are valued less 10% for the costs of selling them (DMG 52671). - It is a mixed variable, though: it also holds unit trusts, which have no - costs of sale (DMG 52681), stocks and shares ISAs and employee share - options, and datasets built before private pension wealth was split out also - fold non-defined-benefit pension wealth into it, which is not capital at - all. The deduction reaches all of these until the data separate them. - Sources not counted as income-related ESA capital are ignored. + `unit_and_investment_trusts` is deliberately not listed: a unit trust is + valued at its bid price and has no costs of sale, because the person + withdraws from the manager, even if they use a stockbroker (DMG + 52680-52681). Investment trusts are not named in the guidance and, as listed + company shares, arguably take the 10%, but the Wealth and Assets Survey asks + about unit and investment trusts in one question, so the whole bucket is + treated as having no costs of sale. That approximation counts investment + trusts at full value; HMRC ISA statistics (table 9.6) put investment trusts + at about 7% to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April + 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed + either: an ISA is valued at what the person would get by withdrawing it, and + no ISA paragraph applies the 10% (DMG 52662-52664). + `unitemised_corporate_wealth` is listed so that datasets which do not + itemise `corporate_wealth` keep its previous flat treatment: there it equals + `corporate_wealth`, which mixes shares with unit trusts, stocks and shares + ISAs and employee share options, and, on datasets built before private + pension wealth was split out, non-defined-benefit pension wealth, which is + not capital at all. The deduction reaches all of these until the data + separate them. Sources not counted as income-related ESA capital are + ignored. metadata: label: Income-related ESA capital sources with sale expenses period: year @@ -27,13 +41,16 @@ metadata: href: https://assets.publishing.service.gov.uk/media/69d8f30ad3e08b8871b665ac/dmg-Ch-52.pdf#page=115 - title: Decision Makers' Guide chapter 52, para. 52623 href: https://assets.publishing.service.gov.uk/media/69d8f30ad3e08b8871b665ac/dmg-Ch-52.pdf#page=116 + - title: Decision Makers' Guide chapter 52, paras. 52662-52664 + href: https://assets.publishing.service.gov.uk/media/69d8f30ad3e08b8871b665ac/dmg-Ch-52.pdf#page=124 - title: Decision Makers' Guide chapter 52, para. 52671 href: https://assets.publishing.service.gov.uk/media/69d8f30ad3e08b8871b665ac/dmg-Ch-52.pdf#page=126 - - title: Decision Makers' Guide chapter 52, paras. 52681 and 52685 - href: https://assets.publishing.service.gov.uk/media/69d8f30ad3e08b8871b665ac/dmg-Ch-52.pdf#page=128 + - title: Decision Makers' Guide chapter 52, paras. 52680-52681 and 52685 + href: https://assets.publishing.service.gov.uk/media/69d8f30ad3e08b8871b665ac/dmg-Ch-52.pdf#page=127 values: 2008-10-27: - owned_land - other_residential_property_value - non_residential_property_value - - corporate_wealth + - directly_held_shares + - unitemised_corporate_wealth diff --git a/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sale_expenses/sources.yaml index 538833841b..db4d9e0322 100644 --- a/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sale_expenses/sources.yaml @@ -6,14 +6,27 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (DMG 29620-29623 and 29685). `corporate_wealth` is listed because - shares are valued less 10% for the costs of selling them (DMG 29671). It is - a mixed variable, though: it also holds unit trusts, which have no costs of - sale (DMG 29681), stocks and shares ISAs and employee share options, and - datasets built before private pension wealth was split out also fold non- - defined-benefit pension wealth into it, which is not capital at all. The - deduction reaches all of these until the data separate them. Sources not - counted as income-based JSA capital are ignored. + sale (DMG 29620-29623 and 29685). `directly_held_shares` is listed because + shares are valued less 10% for the costs of selling them (DMG 29671). + `unit_and_investment_trusts` is deliberately not listed: a unit trust is + valued at its bid price and has no costs of sale, because the person + withdraws from the manager, even if they use a stockbroker (DMG + 29680-29681). Investment trusts are not named in the guidance and, as listed + company shares, arguably take the 10%, but the Wealth and Assets Survey asks + about unit and investment trusts in one question, so the whole bucket is + treated as having no costs of sale. That approximation counts investment + trusts at full value; HMRC ISA statistics (table 9.6) put investment trusts + at about 7% to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April + 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed + either: an ISA is valued at what the person would get by withdrawing it, and + no ISA paragraph applies the 10% (DMG 29662-29664). + `unitemised_corporate_wealth` is listed so that datasets which do not + itemise `corporate_wealth` keep its previous flat treatment: there it equals + `corporate_wealth`, which mixes shares with unit trusts, stocks and shares + ISAs and employee share options, and, on datasets built before private + pension wealth was split out, non-defined-benefit pension wealth, which is + not capital at all. The deduction reaches all of these until the data + separate them. Sources not counted as income-based JSA capital are ignored. metadata: label: Income-based JSA capital sources with sale expenses period: year @@ -25,13 +38,16 @@ metadata: href: https://www.legislation.gov.uk/nisr/2007/396/regulation/7 - title: Decision Makers' Guide chapter 29, paras. 29620-29623 href: https://assets.publishing.service.gov.uk/media/69d8f3a496c86b751317022c/dmg-Ch-29.pdf#page=124 + - title: Decision Makers' Guide chapter 29, paras. 29662-29664 + href: https://assets.publishing.service.gov.uk/media/69d8f3a496c86b751317022c/dmg-Ch-29.pdf#page=135 - title: Decision Makers' Guide chapter 29, para. 29671 href: https://assets.publishing.service.gov.uk/media/69d8f3a496c86b751317022c/dmg-Ch-29.pdf#page=137 - - title: Decision Makers' Guide chapter 29, paras. 29681 and 29685 + - title: Decision Makers' Guide chapter 29, paras. 29680-29681 and 29685 href: https://assets.publishing.service.gov.uk/media/69d8f3a496c86b751317022c/dmg-Ch-29.pdf#page=139 values: 1996-10-07: - owned_land - other_residential_property_value - non_residential_property_value - - corporate_wealth + - directly_held_shares + - unitemised_corporate_wealth diff --git a/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sale_expenses/sources.yaml index f57c9f5bd7..84284223d9 100644 --- a/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sale_expenses/sources.yaml @@ -7,14 +7,29 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (HBGM BW1 Annex F and BP1 F2.03). `corporate_wealth` is listed because - shares are valued less 10% for the costs of selling them (HBGM W1.513). It - is a mixed variable, though: it also holds unit trusts, which have no costs - of sale (HBGM W1.530-W1.531), stocks and shares ISAs and employee share - options, and datasets built before private pension wealth was split out also - fold non-defined-benefit pension wealth into it, which is not capital at - all. The deduction reaches all of these until the data separate them. - Sources not counted as Housing Benefit capital are ignored. + sale (HBGM BW1 Annex F and BP1 F2.03). `directly_held_shares` is listed + because shares are valued less 10% for selling costs (HBGM W1.513 and + P1.513). `unit_and_investment_trusts` is deliberately not listed: unit trust + holdings are valued at the bid price, which already takes account of the + selling expenses, and the 10% is not deducted even if they could be sold + through a bank or stockbroker (HBGM W1.530-W1.531 and P1.530-P1.531). + Investment trusts are not named in the guidance and, as listed company + shares, arguably take the 10%, but the Wealth and Assets Survey asks about + unit and investment trusts in one question, so the whole bucket is treated + as having no costs of sale. That approximation counts investment trusts at + full value; HMRC ISA statistics (table 9.6) put investment trusts at about 7% + to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April + 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed either: the HB + guidance manual has no ISA paragraph, and the DWP guidance on the parallel + Income Support and JSA rule values an ISA at what the person would get by + withdrawing it, with no ISA paragraph applying the 10% (DMG 29662-29664). + `unitemised_corporate_wealth` is listed so that datasets which do not + itemise `corporate_wealth` keep its previous flat treatment: there it equals + `corporate_wealth`, which mixes shares with unit trusts, stocks and shares + ISAs and employee share options, and, on datasets built before private + pension wealth was split out, non-defined-benefit pension wealth, which is + not capital at all. The deduction reaches all of these until the data + separate them. Sources not counted as Housing Benefit capital are ignored. metadata: label: Housing Benefit capital sources with sale expenses period: year @@ -40,6 +55,8 @@ metadata: href: https://assets.publishing.service.gov.uk/media/5a749328ed915d0e8e3994c0/hbgm-bw1-assessment-of-capital.pdf#page=43 - title: Housing Benefit Guidance Manual BP1, paras. P1.513 and P1.530-P1.531 href: https://assets.publishing.service.gov.uk/media/5a7ec5d840f0b6230268b71f/hbgm-bp1-assessment-of-capital.pdf#page=38 + - title: Decision Makers' Guide chapter 29, paras. 29662-29664 (ISAs, parallel IS and JSA guidance) + href: https://assets.publishing.service.gov.uk/media/69d8f3a496c86b751317022c/dmg-Ch-29.pdf#page=135 - title: Housing Benefit Guidance Manual BW1, Annex F href: https://assets.publishing.service.gov.uk/media/5a749328ed915d0e8e3994c0/hbgm-bw1-assessment-of-capital.pdf#page=93 - title: Housing Benefit Guidance Manual BP1, paras. F2.00-F2.03 @@ -49,4 +66,5 @@ values: - owned_land - other_residential_property_value - non_residential_property_value - - corporate_wealth + - directly_held_shares + - unitemised_corporate_wealth diff --git a/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sale_expenses/sources.yaml index baa3504bda..06188a12fd 100644 --- a/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sale_expenses/sources.yaml @@ -6,14 +6,27 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (DMG 29620-29623 and 29685). `corporate_wealth` is listed because - shares are valued less 10% for the costs of selling them (DMG 29671). It is - a mixed variable, though: it also holds unit trusts, which have no costs of - sale (DMG 29681), stocks and shares ISAs and employee share options, and - datasets built before private pension wealth was split out also fold non- - defined-benefit pension wealth into it, which is not capital at all. The - deduction reaches all of these until the data separate them. Sources not - counted as Income Support capital are ignored. + sale (DMG 29620-29623 and 29685). `directly_held_shares` is listed because + shares are valued less 10% for the costs of selling them (DMG 29671). + `unit_and_investment_trusts` is deliberately not listed: a unit trust is + valued at its bid price and has no costs of sale, because the person + withdraws from the manager, even if they use a stockbroker (DMG + 29680-29681). Investment trusts are not named in the guidance and, as listed + company shares, arguably take the 10%, but the Wealth and Assets Survey asks + about unit and investment trusts in one question, so the whole bucket is + treated as having no costs of sale. That approximation counts investment + trusts at full value; HMRC ISA statistics (table 9.6) put investment trusts + at about 7% to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April + 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed + either: an ISA is valued at what the person would get by withdrawing it, and + no ISA paragraph applies the 10% (DMG 29662-29664). + `unitemised_corporate_wealth` is listed so that datasets which do not + itemise `corporate_wealth` keep its previous flat treatment: there it equals + `corporate_wealth`, which mixes shares with unit trusts, stocks and shares + ISAs and employee share options, and, on datasets built before private + pension wealth was split out, non-defined-benefit pension wealth, which is + not capital at all. The deduction reaches all of these until the data + separate them. Sources not counted as Income Support capital are ignored. metadata: label: Income Support capital sources with sale expenses period: year @@ -25,13 +38,16 @@ metadata: href: https://www.legislation.gov.uk/nisr/2007/396/regulation/4 - title: Decision Makers' Guide chapter 29, paras. 29620-29623 href: https://assets.publishing.service.gov.uk/media/69d8f3a496c86b751317022c/dmg-Ch-29.pdf#page=124 + - title: Decision Makers' Guide chapter 29, paras. 29662-29664 + href: https://assets.publishing.service.gov.uk/media/69d8f3a496c86b751317022c/dmg-Ch-29.pdf#page=135 - title: Decision Makers' Guide chapter 29, para. 29671 href: https://assets.publishing.service.gov.uk/media/69d8f3a496c86b751317022c/dmg-Ch-29.pdf#page=137 - - title: Decision Makers' Guide chapter 29, paras. 29681 and 29685 + - title: Decision Makers' Guide chapter 29, paras. 29680-29681 and 29685 href: https://assets.publishing.service.gov.uk/media/69d8f3a496c86b751317022c/dmg-Ch-29.pdf#page=139 values: 2010-01-01: - owned_land - other_residential_property_value - non_residential_property_value - - corporate_wealth + - directly_held_shares + - unitemised_corporate_wealth diff --git a/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sale_expenses/sources.yaml index 1dbbd6816f..dae92445b4 100644 --- a/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sale_expenses/sources.yaml @@ -6,14 +6,27 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (DMG 84712-84715 and 84731). `corporate_wealth` is listed because - shares are valued less 10% for the costs of selling them (DMG 84763). It is - a mixed variable, though: it also holds unit trusts, which have no costs of - sale (DMG 84772), stocks and shares ISAs and employee share options, and - datasets built before private pension wealth was split out also fold non- - defined-benefit pension wealth into it, which is not capital at all. The - deduction reaches all of these until the data separate them. Sources not - counted as Pension Credit capital are ignored. + sale (DMG 84712-84715 and 84731). `directly_held_shares` is listed because + shares are valued less 10% for the costs of selling them (DMG 84763). + `unit_and_investment_trusts` is deliberately not listed: a unit trust is + valued at its bid price and has no costs of sale, because the person + withdraws from the manager, even if they use a stockbroker (DMG + 84771-84772). Investment trusts are not named in the guidance and, as listed + company shares, arguably take the 10%, but the Wealth and Assets Survey asks + about unit and investment trusts in one question, so the whole bucket is + treated as having no costs of sale. That approximation counts investment + trusts at full value; HMRC ISA statistics (table 9.6) put investment trusts + at about 7% to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April + 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed + either: an ISA is valued at what the person would get by withdrawing it, and + no ISA paragraph applies the 10% (DMG 84748-84750). + `unitemised_corporate_wealth` is listed so that datasets which do not + itemise `corporate_wealth` keep its previous flat treatment: there it equals + `corporate_wealth`, which mixes shares with unit trusts, stocks and shares + ISAs and employee share options, and, on datasets built before private + pension wealth was split out, non-defined-benefit pension wealth, which is + not capital at all. The deduction reaches all of these until the data + separate them. Sources not counted as Pension Credit capital are ignored. metadata: label: Pension Credit capital sources with sale expenses period: year @@ -27,13 +40,16 @@ metadata: href: https://assets.publishing.service.gov.uk/media/6a5e38bb8b7e4fa537e693d5/dmg-ch84.pdf#page=99 - title: Decision Makers' Guide chapter 84, para. 84731 href: https://assets.publishing.service.gov.uk/media/6a5e38bb8b7e4fa537e693d5/dmg-ch84.pdf#page=102 + - title: Decision Makers' Guide chapter 84, paras. 84748-84750 + href: https://assets.publishing.service.gov.uk/media/6a5e38bb8b7e4fa537e693d5/dmg-ch84.pdf#page=105 - title: Decision Makers' Guide chapter 84, para. 84763 href: https://assets.publishing.service.gov.uk/media/6a5e38bb8b7e4fa537e693d5/dmg-ch84.pdf#page=107 - - title: Decision Makers' Guide chapter 84, para. 84772 - href: https://assets.publishing.service.gov.uk/media/6a5e38bb8b7e4fa537e693d5/dmg-ch84.pdf#page=109 + - title: Decision Makers' Guide chapter 84, paras. 84771-84772 + href: https://assets.publishing.service.gov.uk/media/6a5e38bb8b7e4fa537e693d5/dmg-ch84.pdf#page=108 values: 2003-10-06: - owned_land - other_residential_property_value - non_residential_property_value - - corporate_wealth + - directly_held_shares + - unitemised_corporate_wealth diff --git a/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sale_expenses/sources.yaml index fe25cbe7d8..f7a760beb9 100644 --- a/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sale_expenses/sources.yaml @@ -6,14 +6,27 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (ADM H1604-H1607 and H1675). `corporate_wealth` is listed because - shares are valued less 10% for the costs of selling them (ADM H1665). It is - a mixed variable, though: it also holds unit trusts, which have no costs of - sale (ADM H1674), stocks and shares ISAs and employee share options, and - datasets built before private pension wealth was split out also fold non- - defined-benefit pension wealth into it, which is not capital at all. The - deduction reaches all of these until the data separate them. Sources not - counted as Universal Credit capital are ignored. + sale (ADM H1604-H1607 and H1675). `directly_held_shares` is listed because + shares are valued less 10% for the costs of selling them (ADM H1665). + `unit_and_investment_trusts` is deliberately not listed: a unit trust is + valued at its bid price and has no costs of sale, because the person + withdraws from the manager, even if they use a stockbroker (ADM + H1673-H1674). Investment trusts are not named in the guidance and, as listed + company shares, arguably take the 10%, but the Wealth and Assets Survey asks + about unit and investment trusts in one question, so the whole bucket is + treated as having no costs of sale. That approximation counts investment + trusts at full value; HMRC ISA statistics (table 9.6) put investment trusts + at about 7% to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April + 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed + either: an ISA is valued at what the person would get by withdrawing it, and + no ISA paragraph applies the 10% (ADM H1656-H1658). + `unitemised_corporate_wealth` is listed so that datasets which do not + itemise `corporate_wealth` keep its previous flat treatment: there it equals + `corporate_wealth`, which mixes shares with unit trusts, stocks and shares + ISAs and employee share options, and, on datasets built before private + pension wealth was split out, non-defined-benefit pension wealth, which is + not capital at all. The deduction reaches all of these until the data + separate them. Sources not counted as Universal Credit capital are ignored. metadata: label: Universal Credit capital sources with sale expenses period: year @@ -25,7 +38,7 @@ metadata: href: https://www.legislation.gov.uk/nisr/2016/216/regulation/49 - title: Advice for Decision Making chapter H1, paras. H1604-H1607 href: https://assets.publishing.service.gov.uk/media/6a5e0ac7a2662d4563fe39e0/adm-ch-h1.pdf#page=44 - - title: Advice for Decision Making chapter H1, para. H1656 + - title: Advice for Decision Making chapter H1, paras. H1656-H1658 href: https://assets.publishing.service.gov.uk/media/6a5e0ac7a2662d4563fe39e0/adm-ch-h1.pdf#page=55 - title: Advice for Decision Making chapter H1, para. H1665 href: https://assets.publishing.service.gov.uk/media/6a5e0ac7a2662d4563fe39e0/adm-ch-h1.pdf#page=57 @@ -36,4 +49,5 @@ values: - owned_land - other_residential_property_value - non_residential_property_value - - corporate_wealth + - directly_held_shares + - unitemised_corporate_wealth diff --git a/policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml b/policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml new file mode 100644 index 0000000000..d1c1a17514 --- /dev/null +++ b/policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml @@ -0,0 +1,260 @@ +# corporate_wealth itemised into directly_held_shares, unit_and_investment_trusts +# and stocks_and_shares_isa, with unitemised_corporate_wealth carrying whatever +# is not itemised (max(0, corporate_wealth - the three components)). +# Capital is valued at market value less 10% where a sale would incur expenses +# (UC Regs 2013 reg. 49(1); HB Regs 2006 reg. 47; IS Regs 1987 reg. 49; JSA +# Regs 1996 reg. 111; ESA Regs 2008 reg. 113; SPC Regs 2002 reg. 19). Shares +# take the 10% (ADM H1665; DMG 29671, 52671, 84763; HBGM W1.513). Unit trusts +# have no costs of sale (ADM H1673-H1674; DMG 29680-29681, 52680-52681, +# 84771-84772; HBGM W1.530-W1.531), and the survey bucket of unit and +# investment trusts is treated the same. An ISA is valued at what the person +# would get by withdrawing it, with no 10% (ADM H1656; DMG 29662, 52662, +# 84748). Expected values are worked by hand from those rules. + +- name: UC unsplit corporate_wealth keeps the flat 10% treatment + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 30 + benunits: + benunit: + members: person + households: + household: + members: person + # No components, so the residual is all 12,000 of corporate_wealth: + # 5,000 + 90% of 12,000 = 15,800, the same as before the split. + savings: 5_000 + corporate_wealth: 12_000 + output: + unitemised_corporate_wealth: 12_000 + uc_assessable_capital: 15_800 + is_uc_eligible: true + # 9,800 above 6,000 is 40 steps of 250 (rounded up): 40 * 4.35 * 12. + uc_tariff_income: 2_088 + +- name: UC split of the same total exempts trusts and ISAs and crosses the limit + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 30 + benunits: + benunit: + members: person + households: + household: + members: person + # Residual max(0, 12,000 - (4,000 + 3,000 + 5,000)) = 0. Capital is + # 5,000 + 90% of 4,000 + 3,000 + 5,000 = 16,600, above the 16,000 + # limit; unsplit, the same household held 15,800 and qualified. + savings: 5_000 + corporate_wealth: 12_000 + directly_held_shares: 4_000 + unit_and_investment_trusts: 3_000 + stocks_and_shares_isa: 5_000 + output: + unitemised_corporate_wealth: 0 + uc_assessable_capital: 16_600 + is_uc_eligible: false + +- name: UC counts the components when corporate_wealth is not given + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 30 + benunits: + benunit: + members: person + households: + household: + members: person + # Residual max(0, 0 - 15,600) = 0. Capital is + # 1,000 + 90% of 10,000 + 2,600 + 3,000 = 15,600. + savings: 1_000 + directly_held_shares: 10_000 + unit_and_investment_trusts: 2_600 + stocks_and_shares_isa: 3_000 + output: + unitemised_corporate_wealth: 0 + uc_assessable_capital: 15_600 + is_uc_eligible: true + # 9,600 above 6,000 is 39 steps of 250 (38.4 rounded up): 39 * 4.35 * 12. + uc_tariff_income: 2_035.8 + +- name: UC partial split values the unitemised residual less 10% + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 30 + benunits: + benunit: + members: person + households: + household: + members: person + # Only the ISA is itemised: residual 12,000 - 5,000 = 7,000. Share-like + # capital is 90% of 7,000 + 5,000 = 11,300; with savings 15,300 + # (unsplit it would be 4,000 + 10,800 = 14,800). + savings: 4_000 + corporate_wealth: 12_000 + stocks_and_shares_isa: 5_000 + output: + unitemised_corporate_wealth: 7_000 + uc_assessable_capital: 15_300 + # 9,300 above 6,000 is 38 steps of 250 (37.2 rounded up): 38 * 4.35 * 12. + uc_tariff_income: 1_983.6 + +- name: UC components exceeding corporate_wealth leave a nil residual + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 30 + benunits: + benunit: + members: person + households: + household: + members: person + # The components (7,000) exceed corporate_wealth (5,000), so the + # residual is max(0, -2,000) = 0, not a negative offset. Capital is + # 1,000 + 90% of 4,000 + 3,000 = 7,600. + savings: 1_000 + corporate_wealth: 5_000 + directly_held_shares: 4_000 + unit_and_investment_trusts: 3_000 + output: + unitemised_corporate_wealth: 0 + uc_assessable_capital: 7_600 + # 1,600 above 6,000 is 7 steps of 250 (6.4 rounded up): 7 * 4.35 * 12. + uc_tariff_income: 365.4 + +- name: Housing Benefit split exempts trusts and ISAs + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 30 + in_social_housing: true + housing_benefit_reported: 1 + benunits: + benunit: + members: person + would_claim_uc: false + households: + household: + members: person + # Residual 0. 1,100 + 90% of 5,000 + 4,000 + 6,000 = 15,600 (HBGM + # W1.513, W1.530); unsplit it would be 1,100 + 13,500 = 14,600. + savings: 1_100 + corporate_wealth: 15_000 + directly_held_shares: 5_000 + unit_and_investment_trusts: 4_000 + stocks_and_shares_isa: 6_000 + output: + unitemised_corporate_wealth: 0 + housing_benefit_assessable_capital: 15_600 + # 9,600 above 6,000 is 39 steps of 250 (38.4 rounded up) at 1 a week. + housing_benefit_tariff_income: 2_028 + housing_benefit_eligible: true + +- name: Income Support split exempts unit trusts + period: 2021 + absolute_error_margin: 0.01 + input: + people: + person: + age: 30 + benunits: + benunit: + members: person + households: + household: + members: person + # Residual 0. 90% of 6,000 + 4,000 = 9,400 (DMG 29671, 29681); + # unsplit it would be 9,000. + corporate_wealth: 10_000 + directly_held_shares: 6_000 + unit_and_investment_trusts: 4_000 + output: + income_support_assessable_capital: 9_400 + +- name: Income-based JSA split exempts stocks and shares ISAs + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 30 + benunits: + benunit: + members: person + households: + household: + members: person + # Residual 0. 2,000 + 90% of 3,000 + 6,000 = 10,700 (DMG 29662, + # 29671); unsplit it would be 2,000 + 8,100 = 10,100. + savings: 2_000 + corporate_wealth: 9_000 + directly_held_shares: 3_000 + stocks_and_shares_isa: 6_000 + output: + jsa_income_assessable_capital: 10_700 + +- name: Income-related ESA split exempts trusts and ISAs + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 40 + benunits: + benunit: + members: person + households: + household: + members: person + # Residual 0. 3,000 + 90% of 2,000 + 3,000 + 5,000 = 12,800 (DMG + # 52662, 52671, 52681); unsplit it would be 3,000 + 9,000 = 12,000. + savings: 3_000 + corporate_wealth: 10_000 + directly_held_shares: 2_000 + unit_and_investment_trusts: 3_000 + stocks_and_shares_isa: 5_000 + output: + esa_income_assessable_capital: 12_800 + +- name: Pension Credit split exempts trusts and ISAs + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 70 + benunits: + benunit: + members: person + households: + household: + members: person + # Residual 0. 2,100 + 90% of 10,000 + 8,000 + 12,000 = 31,100 (DMG + # 84748, 84763, 84772); unsplit it would be 2,100 + 27,000 = 29,100. + savings: 2_100 + corporate_wealth: 30_000 + directly_held_shares: 10_000 + unit_and_investment_trusts: 8_000 + stocks_and_shares_isa: 12_000 + output: + pension_credit_assessable_capital: 31_100 + # 21,100 above 10,000 is 43 steps of 500 (42.2 rounded up) at 1 a week. + pension_credit_deemed_income: 2_236 diff --git a/policyengine_uk/tests/test_capital_share_components.py b/policyengine_uk/tests/test_capital_share_components.py index 8d4a5201ce..885d66333f 100644 --- a/policyengine_uk/tests/test_capital_share_components.py +++ b/policyengine_uk/tests/test_capital_share_components.py @@ -1,10 +1,10 @@ -"""Itemising corporate_wealth never changes a household's capital total. +"""The means-test capital sources itemise corporate_wealth. -The means-test capital sources list corporate_wealth's components and -unitemised_corporate_wealth (the part a dataset does not itemise) instead of -corporate_wealth. With no valuation rule that tells the components apart, every -programme's assessable capital must equal what it is when the same holdings are -entered as one unitemised corporate_wealth. +The lists name corporate_wealth's components and unitemised_corporate_wealth +(the part a dataset does not itemise) instead of corporate_wealth. Since the +sale-expense lists tell the components apart, itemising changes capital by +exactly rate x (trusts + ISA): that, conservation at a zero rate and the other +valuation invariants are in test_capital_valuation_properties.py. """ import pytest @@ -86,25 +86,3 @@ def test_unitemised_corporate_wealth_is_the_floored_remainder( "unitemised_corporate_wealth", YEAR )[0] assert residual == max(0, corporate_wealth - sum(components)) - - -@pytest.mark.parametrize("variable", SOURCE_LISTS) -@settings(max_examples=15, deadline=None) -@given( - savings=amount, - corporate_wealth=amount, - components=st.tuples(amount, amount, amount), -) -def test_itemising_never_changes_capital( - variable, savings, corporate_wealth, components -): - """Split holdings count exactly as max(corporate_wealth, their sum) does.""" - itemised = {"savings": savings, "corporate_wealth": corporate_wealth} - itemised.update(dict(zip(COMPONENTS, components))) - unitemised = { - "savings": savings, - "corporate_wealth": max(corporate_wealth, sum(components)), - } - assert _capital(variable, itemised) == pytest.approx( - _capital(variable, unitemised), abs=1e-2 - ) diff --git a/policyengine_uk/tests/test_capital_valuation_properties.py b/policyengine_uk/tests/test_capital_valuation_properties.py index 3ccf6d7eb3..4e77f884b9 100644 --- a/policyengine_uk/tests/test_capital_valuation_properties.py +++ b/policyengine_uk/tests/test_capital_valuation_properties.py @@ -7,9 +7,19 @@ Regs 1987 reg. 49; JSA Regs 1996 reg. 111; ESA Regs 2008 reg. 113; SPC Regs 2002 reg. 19). A bank or building society account is valued at its balance (ADM H1675); land and property always have costs of sale (H1606) and shares -are valued less 10% (H1665). +are valued less 10% (H1665). Unit trusts have no costs of sale (H1673-H1674) +and an ISA is valued at what the person would get by withdrawing it (H1656). -Invariants, for any generated population of single-adult households: +corporate_wealth may be itemised into directly_held_shares, +unit_and_investment_trusts and stocks_and_shares_isa; unitemised_corporate_wealth +carries whatever is not itemised, so it is all of corporate_wealth on datasets +without the components and about nil on datasets that build corporate_wealth as +their exact sum. The survey bucket of unit and investment trusts is treated as +having no costs of sale, an approximation for its investment-trust part. + +Invariants, for any generated population of single-adult households, whose +share-like holdings are unsplit, split consistently (corporate_wealth equal to +the components' sum), partly split, given as components only, or drawn freely: 1. Non-increasing: every programme's assessable capital is at most the same household's capital with the deduction switched off (rate 0, no debt). @@ -17,14 +27,27 @@ deduction on or off. 3. Differential: capital equals a direct implementation of the regulation, savings + sum over sources of max(0, 90% of value - secured debt), where - the test itself fixes which assets take the 10% (land, property and - shares, not cash), so a wrong parameter list fails it. + the test itself fixes which assets count and which take the 10% (land, + property, directly held shares and unitemised corporate wealth; not cash, + trusts or ISAs), so a wrong parameter list fails it. 4. Monotone: a higher sale-expense rate, or more secured debt, never raises capital. 5. Isolation: debt secured on one source never takes capital below the value of the household's unencumbered sources, and capital is never negative. (Isolation between two encumbered sources is pinned by the differential and by a YAML case.) +6. Residual: unitemised_corporate_wealth is never negative and equals + max(0, corporate_wealth - sum of components). +7. Backward compatibility: with every component nil, every programme's capital + is bit-for-bit the capital under a reform restoring the source lists used + before the split. +8. Conservation: at rate 0, a consistent split leaves capital unchanged. +9. Split effect: a consistent split less the unsplit household is rate x + (trusts + ISA), which lies in [0, rate x corporate_wealth]. +10. No double counting: capital is at most the other assets plus + max(corporate_wealth, sum of components). +11. Aggregates: total_wealth, net_wealth and corporate_sector_wealth do not + change with the component inputs. """ from functools import reduce @@ -33,7 +56,7 @@ from hypothesis import HealthCheck, given, settings from hypothesis import strategies as st -from policyengine_uk import Simulation +from policyengine_uk import CountryTaxBenefitSystem, Simulation YEAR = 2026 PROPERTY_SETTINGS = settings( @@ -56,45 +79,105 @@ "pension_credit_assessable_capital": "gov.dwp.pension_credit.income.capital", } PENSION_AGE_ONLY = {"pension_credit_assessable_capital"} +COMPONENTS = ( + "directly_held_shares", + "unit_and_investment_trusts", + "stocks_and_shares_isa", +) +RESIDUAL = "unitemised_corporate_wealth" +SHARE_LIKE = (*COMPONENTS, RESIDUAL) +PROPERTY = ("other_residential_property_value", "non_residential_property_value") +# The assets each programme counts, fixed here rather than read from the +# parameters. Universal Credit's list has never included owned_land; that +# predates the capital-valuation work and is outside these properties. +LEGACY_COUNTED = {"savings", "owned_land", *PROPERTY, *SHARE_LIKE} +COUNTED = { + variable: LEGACY_COUNTED + for variable in PROGRAMMES + if variable != "uc_assessable_capital" +} | {"uc_assessable_capital": {"savings", *PROPERTY, *SHARE_LIKE}} # The assets whose sale incurs expenses, fixed here from the law rather than -# read from the parameters: real property always (ADM H1606), shares (H1665); -# never a bank or building society balance (H1675). +# read from the parameters: real property always (ADM H1606) and shares +# (H1665); never a bank or building society balance (H1675), a unit trust +# (H1673-H1674) or an ISA (H1656). The unitemised residual keeps the flat +# treatment corporate_wealth had before it was itemised. SALE_EXPENSE_ASSETS = { "owned_land", - "other_residential_property_value", - "non_residential_property_value", - "corporate_wealth", + *PROPERTY, + "directly_held_shares", + RESIDUAL, } LEGAL_RATE = 0.1 -ASSETS = [ +# The source lists in force before corporate_wealth was itemised, for the +# backward-compatibility differential. +PRE_SPLIT_LEGACY_SOURCES = [ "savings", "owned_land", "corporate_wealth", - "other_residential_property_value", - "non_residential_property_value", + *PROPERTY, ] +PRE_SPLIT_SOURCES = { + "gov.dwp.universal_credit.means_test.capital": [ + "savings", + *PROPERTY, + "corporate_wealth", + ], + "gov.dwp.housing_benefit.means_test.capital": PRE_SPLIT_LEGACY_SOURCES, + "gov.dwp.income_support.means_test.capital": PRE_SPLIT_LEGACY_SOURCES, + "gov.dwp.JSA.income.capital": PRE_SPLIT_LEGACY_SOURCES, + "gov.dwp.ESA.income.capital": PRE_SPLIT_LEGACY_SOURCES, + "gov.dwp.pension_credit.income.capital": [ + "savings", + "owned_land", + *PROPERTY, + "corporate_wealth", + ], +} +PRE_SPLIT_SALE_EXPENSE_SOURCES = ["owned_land", *PROPERTY, "corporate_wealth"] +BASE_ASSETS = ["savings", "owned_land", "corporate_wealth", *PROPERTY] DEBTS = { "owned_land": "owned_land_secured_debt", "other_residential_property_value": "other_residential_property_secured_debt", "non_residential_property_value": "non_residential_property_secured_debt", } +SPLIT_MODES = ("unsplit", "consistent", "partial", "components_only", "free") amount = st.one_of(st.just(0.0), st.floats(0, 400_000, allow_nan=False)) @st.composite -def households(draw, cash_only=False): - assets = {asset: draw(amount) for asset in ASSETS} +def households(draw, mode=None, cash_only=False, dividends=False): + mode = mode or draw(st.sampled_from(SPLIT_MODES)) + assets = {asset: draw(amount) for asset in BASE_ASSETS} + components = {component: draw(amount) for component in COMPONENTS} + if mode == "unsplit": + components = {component: 0.0 for component in COMPONENTS} + elif mode == "consistent": + assets["corporate_wealth"] = sum(components.values()) + elif mode == "partial": + components = { + component: value if draw(st.booleans()) else 0.0 + for component, value in components.items() + } + assets["corporate_wealth"] = sum(components.values()) + draw(amount) + elif mode == "components_only": + assets["corporate_wealth"] = 0.0 + assets |= components debts = {debt: draw(amount) for debt in DEBTS.values()} if cash_only: - assets = {asset: 0.0 for asset in ASSETS} | {"savings": assets["savings"]} + assets = {asset: 0.0 for asset in assets} | {"savings": assets["savings"]} debts = {debt: 0.0 for debt in debts} - return dict(age=draw(st.sampled_from([30, 70])), assets=assets, debts=debts) + unit = dict(age=draw(st.sampled_from([30, 70])), assets=assets, debts=debts) + if dividends: + unit["dividend_income"] = draw(st.floats(0, 50_000, allow_nan=False)) + return unit -def situation(units, debt_scale=1.0): +def situation(units, debt_scale=1.0, dividends=True): people, benunits, homes = {}, {}, {} for i, unit in enumerate(units): people[f"p{i}"] = {"age": {YEAR: unit["age"]}} + if dividends and "dividend_income" in unit: + people[f"p{i}"]["dividend_income"] = {YEAR: unit["dividend_income"]} benunits[f"b{i}"] = {"members": [f"p{i}"]} homes[f"h{i}"] = { "members": [f"p{i}"], @@ -110,16 +193,46 @@ def rate_reform(rate): } -def calculate(units, rate=None, debt_scale=1.0): +PRE_SPLIT_REFORM = { + f"{node}.{parameter}": {str(YEAR): value} + for node, sources in PRE_SPLIT_SOURCES.items() + for parameter, value in ( + ("sources", sources), + ("sale_expenses.sources", PRE_SPLIT_SALE_EXPENSE_SOURCES), + ) +} +EXTRA_OUTPUTS = ( + "guarantee_credit", + RESIDUAL, + "uc_tariff_income", + "uc_unearned_income", + "pension_credit_deemed_income", + "total_wealth", + "net_wealth", + "corporate_sector_wealth", +) + + +def calculate(units, rate=None, debt_scale=1.0, reform=None, dividends=True): + if rate is not None: + reform = (reform or {}) | rate_reform(rate) sim = Simulation( - situation=situation(units, debt_scale), - reform=None if rate is None else rate_reform(rate), + situation=situation(units, debt_scale, dividends), + reform=reform, ) - values = {v: np.asarray(sim.calculate(v, YEAR), dtype=float) for v in PROGRAMMES} - values["guarantee_credit"] = np.asarray(sim.calculate("guarantee_credit", YEAR)) + values = { + v: np.asarray(sim.calculate(v, YEAR), dtype=float) + for v in (*PROGRAMMES, *EXTRA_OUTPUTS) + } return sim, values +def without_components(unit): + """The same household with corporate_wealth left unitemised.""" + assets = unit["assets"] | {component: 0.0 for component in COMPONENTS} + return unit | {"assets": assets} + + def parameter_node(sim, path): return reduce(getattr, path.split("."), sim.tax_benefit_system.parameters(YEAR)) @@ -130,21 +243,43 @@ def applies(variable, unit, guarantee_credit=0.0): return (unit["age"] >= 67) == (variable in PENSION_AGE_ONLY) -def expected_capital(unit, node): +def residual(unit): + assets = unit["assets"] + return max(0.0, assets["corporate_wealth"] - sum(assets[c] for c in COMPONENTS)) + + +def share_like_total(unit): + """max(corporate_wealth, sum of components): the share-like holdings once.""" + return sum(unit["assets"][c] for c in COMPONENTS) + residual(unit) + + +def expected_capital(unit, variable, rate=LEGAL_RATE): """Reg. 49(1) applied source by source, independently of the model.""" + values = unit["assets"] | {RESIDUAL: residual(unit)} total = 0.0 - for source in node.sources: - value = unit["assets"][source] + for source in COUNTED[variable]: + value = values[source] if source in SALE_EXPENSE_ASSETS: - value *= 1 - LEGAL_RATE + value *= 1 - rate if source in DEBTS: value = max(0.0, value - unit["debts"][DEBTS[source]]) total += value return total -def close(a, b): - return abs(a - b) <= 1 + 1e-6 * abs(b) +def close(a, b, scale=0.0): + """Equal up to float32 rounding of totals as large as ``b`` or ``scale``.""" + return abs(a - b) <= 1 + 1e-6 * max(abs(b), abs(scale)) + + +def test_source_lists_match_the_legal_asset_sets(): + parameters = CountryTaxBenefitSystem().parameters(YEAR) + for variable, path in PROGRAMMES.items(): + node = reduce(getattr, path.split("."), parameters) + assert set(node.sources) == COUNTED[variable], variable + assert set(node.sale_expenses.sources) == SALE_EXPENSE_ASSETS, variable + assert "corporate_wealth" not in node.sources, variable + assert node.sale_expenses.rate == LEGAL_RATE, variable @PROPERTY_SETTINGS @@ -155,11 +290,7 @@ def test_valuation_matches_the_regulation_and_never_adds_capital(units): for variable, path in PROGRAMMES.items(): node = parameter_node(sim, path) assert node.sale_expenses.rate == LEGAL_RATE - assert "savings" in node.sources - counted = set(node.sources) - assert set(node.sale_expenses.sources) & counted == ( - SALE_EXPENSE_ASSETS & counted - ), variable + assert set(node.sale_expenses.sources) == SALE_EXPENSE_ASSETS, variable for i, unit in enumerate(units): gc = valued["guarantee_credit"][i] assert valued[variable][i] >= 0, (variable, unit) @@ -168,15 +299,97 @@ def test_valuation_matches_the_regulation_and_never_adds_capital(units): if gc > 0: assert valued[variable][i] == 0, unit if applies(variable, unit, gc): - expected = expected_capital(unit, node) + expected = expected_capital(unit, variable) assert close(valued[variable][i], expected), (variable, unit) # Debt secured on property never reaches the other assets. + values = unit["assets"] | {RESIDUAL: residual(unit)} floor = sum( - unit["assets"][s] * (1 - LEGAL_RATE * (s in SALE_EXPENSE_ASSETS)) - for s in node.sources + values[s] * (1 - LEGAL_RATE * (s in SALE_EXPENSE_ASSETS)) + for s in COUNTED[variable] if s not in DEBTS ) assert valued[variable][i] >= floor - 1, (variable, unit) + # Each share-like holding is counted at most once. + other = sum( + unit["assets"][s] for s in COUNTED[variable] if s not in SHARE_LIKE + ) + ceiling = other + share_like_total(unit) + assert valued[variable][i] <= ceiling + 1 + 1e-6 * ceiling, ( + variable, + unit, + ) + + +@PROPERTY_SETTINGS +@given(st.lists(households(), min_size=20, max_size=200)) +def test_residual_is_corporate_wealth_less_its_components_floored_at_nil(units): + _, valued = calculate(units) + for i, unit in enumerate(units): + assert valued[RESIDUAL][i] >= 0, unit + assert close(valued[RESIDUAL][i], residual(unit)), unit + if all(unit["assets"][c] == 0 for c in COMPONENTS): + assert valued[RESIDUAL][i] == np.float32(unit["assets"]["corporate_wealth"]) + + +@PROPERTY_SETTINGS +@given(st.lists(households(mode="unsplit"), min_size=20, max_size=200)) +def test_unsplit_datasets_match_the_pre_split_source_lists_exactly(units): + _, split_lists = calculate(units) + _, pre_split = calculate(units, reform=PRE_SPLIT_REFORM) + for variable in ( + *PROGRAMMES, + "guarantee_credit", + "uc_tariff_income", + "uc_unearned_income", + "pension_credit_deemed_income", + ): + assert np.array_equal(split_lists[variable], pre_split[variable]), variable + + +@PROPERTY_SETTINGS +@given( + st.lists(households(mode="consistent"), min_size=20, max_size=200), + st.one_of(st.just(LEGAL_RATE), st.floats(0, 0.5)), +) +def test_a_consistent_split_moves_capital_only_by_the_exempt_holdings(units, rate): + unsplit_units = [without_components(unit) for unit in units] + _, split0 = calculate(units, rate=0.0) + _, unsplit0 = calculate(unsplit_units, rate=0.0) + _, split = calculate(units, rate=rate) + _, unsplit = calculate(unsplit_units, rate=rate) + for variable in PROGRAMMES: + for i, unit in enumerate(units): + if not ( + applies(variable, unit, split0["guarantee_credit"][i]) + and applies(variable, unit, unsplit0["guarantee_credit"][i]) + ): + continue + # At rate 0 itemising corporate_wealth conserves capital. + assert close(split0[variable][i], unsplit0[variable][i]), (variable, unit) + if not ( + applies(variable, unit, split["guarantee_credit"][i]) + and applies(variable, unit, unsplit["guarantee_credit"][i]) + ): + continue + exempt = ( + unit["assets"]["unit_and_investment_trusts"] + + unit["assets"]["stocks_and_shares_isa"] + ) + difference = split[variable][i] - unsplit[variable][i] + scale = max(split[variable][i], unsplit[variable][i]) + assert close(difference, rate * exempt, scale), (variable, unit, rate) + cap = rate * unit["assets"]["corporate_wealth"] + slack = 1 + 1e-6 * scale + assert -slack <= difference <= cap + slack, (variable, unit, rate) + + +@PROPERTY_SETTINGS +@given(st.lists(households(), min_size=20, max_size=200)) +def test_wealth_aggregates_ignore_the_components(units): + _, itemised = calculate(units) + _, unitemised = calculate([without_components(unit) for unit in units]) + for variable in ("total_wealth", "net_wealth", "corporate_sector_wealth"): + assert np.array_equal(itemised[variable], unitemised[variable]), variable @PROPERTY_SETTINGS diff --git a/policyengine_uk/tests/test_stock_capital_periods.py b/policyengine_uk/tests/test_stock_capital_periods.py index eead7689d9..fe6f440ddf 100644 --- a/policyengine_uk/tests/test_stock_capital_periods.py +++ b/policyengine_uk/tests/test_stock_capital_periods.py @@ -57,3 +57,39 @@ def test_pension_credit_capital_stocks_are_not_prorated_monthly(): simulation.calculate("pension_credit_assessable_capital", "2026-01")[0] == 33_600 ) + + +def test_itemised_share_like_stocks_are_not_prorated_monthly(): + stocks = { + "savings": 1_000, + "corporate_wealth": 12_000, + "directly_held_shares": 4_000, + "unit_and_investment_trusts": 3_000, + "stocks_and_shares_isa": 2_000, + } + for age, capital in ( + (30, "uc_assessable_capital"), + (70, "pension_credit_assessable_capital"), + ): + situation = { + "people": {"person": {"age": {"2026": age}}}, + "benunits": {"benunit": {"members": ["person"]}}, + "households": { + "household": { + "members": ["person"], + **{name: {"2026": value} for name, value in stocks.items()}, + } + }, + } + simulation = Simulation(situation=situation) + + for name, value in stocks.items(): + assert simulation.calculate(name, "2026-01")[0] == value, name + # 12,000 less the 9,000 itemised. + assert simulation.calculate("unitemised_corporate_wealth", "2026-01")[0] == ( + 3_000 + ) + # Shares and the unitemised residual less 10% for the expenses of + # sale; unit trusts and the ISA at their withdrawal value: + # 1,000 + 3,600 + 3,000 + 2,000 + 2,700. + assert simulation.calculate(capital, "2026-01")[0] == 12_300, capital From b7e6bc5c54feeb35fe8bcf979943f491be64e627 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 12 Oct 2026 11:32:57 -0400 Subject: [PATCH 02/14] Split share-like capital by expenses of sale on #1974's block design #1974 replaced the components-plus-residual design with one share_like_capital block that keeps the supplied corporate_wealth exactly. This follow-up now splits that block in two: - share_like_capital_with_sale_expenses: share_like_capital less the itemised holdings in gov.dwp.share_like_capital.without_sale_expenses (unit and investment trusts, stocks and shares ISAs), floored at nil; all of it when nothing is itemised. - share_like_capital_without_sale_expenses: the rest, exactly nil when nothing is itemised. The six capital lists name both parts and the six sale-expense lists the first, so datasets that carry only corporate_wealth keep #1969's flat 10% exactly (differential test, annual and monthly, against the lists before itemising, including negative aggregates and a value whose 90% is a fraction of a penny over the limit). The exempt holdings are a parameter list, so the methodology call on investment trusts and ISAs (d1396) is a one-line change. Merged the refreshed #1969 (54ed063b1) and #1974 (7784193a). #1969's property oracle reads the share-like sources from an unitemised household's corporate_wealth; the split invariants (definition of both parts, the unitemised differential, split effect = 10% of trusts plus ISAs on UC capital, components-only valuation) are in test_capital_share_components. Dropping the nothing-itemised branch from the formula fails the differential. Co-Authored-By: Claude Opus 5.5 --- changelog.d/sale-expense-share-split.fixed.md | 2 +- docs/book/assumptions/growthfactors.md | 2 +- policyengine_uk/data/uprating_indices.yaml | 2 + .../income/capital/sale_expenses/sources.yaml | 34 +-- .../gov/dwp/ESA/income/capital/sources.yaml | 5 +- .../income/capital/sale_expenses/sources.yaml | 33 +-- .../gov/dwp/JSA/income/capital/sources.yaml | 5 +- .../capital/sale_expenses/sources.yaml | 36 +--- .../means_test/capital/sources.yaml | 5 +- .../capital/sale_expenses/sources.yaml | 33 +-- .../means_test/capital/sources.yaml | 5 +- .../income/capital/sale_expenses/sources.yaml | 33 +-- .../income/capital/sources.yaml | 3 +- .../without_sale_expenses.yaml | 29 +++ .../capital/sale_expenses/sources.yaml | 33 +-- .../means_test/capital/sources.yaml | 5 +- .../dwp/capital_valuation_share_split.yaml | 19 +- .../tests/test_capital_share_components.py | 197 ++++++++++-------- .../test_capital_valuation_properties.py | 29 ++- .../tests/test_stock_capital_periods.py | 13 +- .../share_like_capital_with_sale_expenses.py | 35 ++++ ...hare_like_capital_without_sale_expenses.py | 20 ++ 22 files changed, 320 insertions(+), 258 deletions(-) create mode 100644 policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml create mode 100644 policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py create mode 100644 policyengine_uk/variables/household/wealth/share_like_capital_without_sale_expenses.py diff --git a/changelog.d/sale-expense-share-split.fixed.md b/changelog.d/sale-expense-share-split.fixed.md index 1060d7977b..014f38dd95 100644 --- a/changelog.d/sale-expense-share-split.fixed.md +++ b/changelog.d/sale-expense-share-split.fixed.md @@ -1 +1 @@ -- Apply the 10% sale-expense deduction to directly held shares only, so unit and investment trusts (ADM H1673-H1674) and stocks and shares ISAs (ADM H1656) count at full value in every means test; datasets that do not itemise `corporate_wealth` keep its previous treatment. +- Value share-like capital by asset type in every means test: directly held shares, and any `corporate_wealth` a dataset does not itemise, take the 10% sale-expense deduction; unit trusts (ADM H1673-H1674) and stocks and shares ISAs (ADM H1656) count at full value, as does the survey's combined unit and investment trust bucket, an approximation for its investment trusts. diff --git a/docs/book/assumptions/growthfactors.md b/docs/book/assumptions/growthfactors.md index f58b658b7d..f75004a01f 100644 --- a/docs/book/assumptions/growthfactors.md +++ b/docs/book/assumptions/growthfactors.md @@ -62,7 +62,7 @@ We derive these rates from OBR GDP growth and ONS population projections. |-------------|------|------|------|------|------|------|------|------| | Growth rate | 9.2% | 5.0% | 3.8% | 2.8% | 2.8% | 3.1% | 3.3% | 3.3% | -We use per capita GDP for these variables: `benunit_reported_capital`, `capital_gains`, `capital_gains_badr`, `capital_gains_before_response`, `capital_gains_carried_interest`, `capital_gains_residential_property`, `cash_isa`, `corporate_wealth`, `dividend_income`, `gross_financial_wealth`, `household_lifetime_isa_balance`, `lifetime_isa_balance`, `lump_sum_income`, `main_residence_value`, `maintenance_income`, `miscellaneous_income`, `mortgage_capital_repayment`, `net_financial_wealth`, `non_residential_property_secured_debt`, `non_residential_property_value`, `other_investment_income`, `other_residential_property_secured_debt`, `other_residential_property_value`, `owned_land`, `owned_land_secured_debt`, `pension_credit_reported_capital`, `pension_income`, `private_pension_wealth`, `private_transfer_income`, `property_income`, `property_rental_income`, `savings`, `savings_interest_income`, `sublet_income`, `uc_reported_capital`, `unit_and_investment_trusts` +We use per capita GDP for these variables: `benunit_reported_capital`, `capital_gains`, `capital_gains_badr`, `capital_gains_before_response`, `capital_gains_carried_interest`, `capital_gains_residential_property`, `cash_isa`, `corporate_wealth`, `directly_held_shares`, `dividend_income`, `gross_financial_wealth`, `household_lifetime_isa_balance`, `lifetime_isa_balance`, `lump_sum_income`, `main_residence_value`, `maintenance_income`, `miscellaneous_income`, `mortgage_capital_repayment`, `net_financial_wealth`, `non_residential_property_secured_debt`, `non_residential_property_value`, `other_investment_income`, `other_residential_property_secured_debt`, `other_residential_property_value`, `owned_land`, `owned_land_secured_debt`, `pension_credit_reported_capital`, `pension_income`, `private_pension_wealth`, `private_transfer_income`, `property_income`, `property_rental_income`, `savings`, `savings_interest_income`, `stocks_and_shares_isa`, `sublet_income`, `uc_reported_capital`, `unit_and_investment_trusts` ## Council tax diff --git a/policyengine_uk/data/uprating_indices.yaml b/policyengine_uk/data/uprating_indices.yaml index c3eb624a68..699e3958f4 100644 --- a/policyengine_uk/data/uprating_indices.yaml +++ b/policyengine_uk/data/uprating_indices.yaml @@ -95,6 +95,7 @@ gov.economic_assumptions.yoy_growth.obr.per_capita.gdp: - benunit_reported_capital - cash_isa - corporate_wealth +- directly_held_shares - dividend_income - gross_financial_wealth - household_lifetime_isa_balance @@ -122,6 +123,7 @@ gov.economic_assumptions.yoy_growth.obr.per_capita.gdp: - property_rental_income - savings - savings_interest_income +- stocks_and_shares_isa - sublet_income # A formula of benunit_reported_capital; listed so a dataset that stores it # directly is uprated like the input. diff --git a/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sale_expenses/sources.yaml index 0f05cea7e0..384cd7d7db 100644 --- a/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sale_expenses/sources.yaml @@ -6,28 +6,15 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (DMG 52620-52623 and 52685). `directly_held_shares` is listed because - shares are valued less 10% for the costs of selling them (DMG 52671). - `unit_and_investment_trusts` is deliberately not listed: a unit trust is - valued at its bid price and has no costs of sale, because the person - withdraws from the manager, even if they use a stockbroker (DMG - 52680-52681). Investment trusts are not named in the guidance and, as listed - company shares, arguably take the 10%, but the Wealth and Assets Survey asks - about unit and investment trusts in one question, so the whole bucket is - treated as having no costs of sale. That approximation counts investment - trusts at full value; HMRC ISA statistics (table 9.6) put investment trusts - at about 7% to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April - 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed - either: an ISA is valued at what the person would get by withdrawing it, and - no ISA paragraph applies the 10% (DMG 52662-52664). - `unitemised_corporate_wealth` is listed so that datasets which do not - itemise `corporate_wealth` keep its previous flat treatment: there it equals - `corporate_wealth`, which mixes shares with unit trusts, stocks and shares - ISAs and employee share options, and, on datasets built before private - pension wealth was split out, non-defined-benefit pension wealth, which is - not capital at all. The deduction reaches all of these until the data - separate them. Sources not counted as income-related ESA capital are - ignored. + sale (DMG 52620-52623 and 52685). `share_like_capital_with_sale_expenses` is + listed: the part of share-like capital whose sale incurs expenses, namely + directly held shares, valued less 10% for selling costs (DMG 52671), and all + of `corporate_wealth` on datasets that do not itemise it. Unit and + investment trusts and stocks and shares ISAs are valued without the + deduction; `gov.dwp.share_like_capital.without_sale_expenses` lists them, + with the guidance and the approximation for investment trusts, which the + survey cannot separate from unit trusts. Sources not counted as + income-related ESA capital are ignored. metadata: label: Income-related ESA capital sources with sale expenses period: year @@ -52,5 +39,4 @@ values: - owned_land - other_residential_property_value - non_residential_property_value - - directly_held_shares - - unitemised_corporate_wealth + - share_like_capital_with_sale_expenses diff --git a/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sources.yaml b/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sources.yaml index a5de71cb3e..6f75bf1b1e 100644 --- a/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/ESA/income/capital/sources.yaml @@ -6,7 +6,7 @@ description: > held directly, the share-like sources, `other_residential_property_value` for residential property other than the home, and `non_residential_property_value` for other land and premises. - `share_like_capital` is `corporate_wealth` as supplied, or the sum of its + `share_like_capital_with_sale_expenses` and `share_like_capital_without_sale_expenses` split `share_like_capital`, which is `corporate_wealth` as supplied, or the sum of its itemised components (`directly_held_shares`, `unit_and_investment_trusts`, `stocks_and_shares_isa`) where that is larger, so a household given only the components has them counted and no holding counts twice. @@ -37,6 +37,7 @@ values: 2008-10-27: - savings - owned_land - - share_like_capital + - share_like_capital_with_sale_expenses + - share_like_capital_without_sale_expenses - other_residential_property_value - non_residential_property_value diff --git a/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sale_expenses/sources.yaml index db4d9e0322..78f4811cb3 100644 --- a/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sale_expenses/sources.yaml @@ -6,27 +6,15 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (DMG 29620-29623 and 29685). `directly_held_shares` is listed because - shares are valued less 10% for the costs of selling them (DMG 29671). - `unit_and_investment_trusts` is deliberately not listed: a unit trust is - valued at its bid price and has no costs of sale, because the person - withdraws from the manager, even if they use a stockbroker (DMG - 29680-29681). Investment trusts are not named in the guidance and, as listed - company shares, arguably take the 10%, but the Wealth and Assets Survey asks - about unit and investment trusts in one question, so the whole bucket is - treated as having no costs of sale. That approximation counts investment - trusts at full value; HMRC ISA statistics (table 9.6) put investment trusts - at about 7% to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April - 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed - either: an ISA is valued at what the person would get by withdrawing it, and - no ISA paragraph applies the 10% (DMG 29662-29664). - `unitemised_corporate_wealth` is listed so that datasets which do not - itemise `corporate_wealth` keep its previous flat treatment: there it equals - `corporate_wealth`, which mixes shares with unit trusts, stocks and shares - ISAs and employee share options, and, on datasets built before private - pension wealth was split out, non-defined-benefit pension wealth, which is - not capital at all. The deduction reaches all of these until the data - separate them. Sources not counted as income-based JSA capital are ignored. + sale (DMG 29620-29623 and 29685). `share_like_capital_with_sale_expenses` is + listed: the part of share-like capital whose sale incurs expenses, namely + directly held shares, valued less 10% for selling costs (DMG 29671), and all + of `corporate_wealth` on datasets that do not itemise it. Unit and + investment trusts and stocks and shares ISAs are valued without the + deduction; `gov.dwp.share_like_capital.without_sale_expenses` lists them, + with the guidance and the approximation for investment trusts, which the + survey cannot separate from unit trusts. Sources not counted as income-based + JSA capital are ignored. metadata: label: Income-based JSA capital sources with sale expenses period: year @@ -49,5 +37,4 @@ values: - owned_land - other_residential_property_value - non_residential_property_value - - directly_held_shares - - unitemised_corporate_wealth + - share_like_capital_with_sale_expenses diff --git a/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sources.yaml b/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sources.yaml index 7c5262e767..0c0504f4b6 100644 --- a/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/JSA/income/capital/sources.yaml @@ -6,7 +6,7 @@ description: > directly, the share-like sources, `other_residential_property_value` for residential property other than the home, and `non_residential_property_value` for other land and premises. - `share_like_capital` is `corporate_wealth` as supplied, or the sum of its + `share_like_capital_with_sale_expenses` and `share_like_capital_without_sale_expenses` split `share_like_capital`, which is `corporate_wealth` as supplied, or the sum of its itemised components (`directly_held_shares`, `unit_and_investment_trusts`, `stocks_and_shares_isa`) where that is larger, so a household given only the components has them counted and no holding counts twice. @@ -38,6 +38,7 @@ values: 1996-10-07: - savings - owned_land - - share_like_capital + - share_like_capital_with_sale_expenses + - share_like_capital_without_sale_expenses - other_residential_property_value - non_residential_property_value diff --git a/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sale_expenses/sources.yaml index 84284223d9..3c48fff910 100644 --- a/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sale_expenses/sources.yaml @@ -7,29 +7,16 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (HBGM BW1 Annex F and BP1 F2.03). `directly_held_shares` is listed - because shares are valued less 10% for selling costs (HBGM W1.513 and - P1.513). `unit_and_investment_trusts` is deliberately not listed: unit trust - holdings are valued at the bid price, which already takes account of the - selling expenses, and the 10% is not deducted even if they could be sold - through a bank or stockbroker (HBGM W1.530-W1.531 and P1.530-P1.531). - Investment trusts are not named in the guidance and, as listed company - shares, arguably take the 10%, but the Wealth and Assets Survey asks about - unit and investment trusts in one question, so the whole bucket is treated - as having no costs of sale. That approximation counts investment trusts at - full value; HMRC ISA statistics (table 9.6) put investment trusts at about 7% - to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April - 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed either: the HB - guidance manual has no ISA paragraph, and the DWP guidance on the parallel - Income Support and JSA rule values an ISA at what the person would get by - withdrawing it, with no ISA paragraph applying the 10% (DMG 29662-29664). - `unitemised_corporate_wealth` is listed so that datasets which do not - itemise `corporate_wealth` keep its previous flat treatment: there it equals - `corporate_wealth`, which mixes shares with unit trusts, stocks and shares - ISAs and employee share options, and, on datasets built before private - pension wealth was split out, non-defined-benefit pension wealth, which is - not capital at all. The deduction reaches all of these until the data - separate them. Sources not counted as Housing Benefit capital are ignored. + sale (HBGM BW1 Annex F and BP1 F2.03). + `share_like_capital_with_sale_expenses` is listed: the part of share-like + capital whose sale incurs expenses, namely directly held shares, valued less + 10% for selling costs (HBGM W1.513 and P1.513), and all of + `corporate_wealth` on datasets that do not itemise it. Unit and investment + trusts and stocks and shares ISAs are valued without the deduction; + `gov.dwp.share_like_capital.without_sale_expenses` lists them, with the + guidance and the approximation for investment trusts, which the survey + cannot separate from unit trusts. Sources not counted as Housing Benefit + capital are ignored. metadata: label: Housing Benefit capital sources with sale expenses period: year @@ -66,5 +53,4 @@ values: - owned_land - other_residential_property_value - non_residential_property_value - - directly_held_shares - - unitemised_corporate_wealth + - share_like_capital_with_sale_expenses diff --git a/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sources.yaml b/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sources.yaml index dbf6a86c0b..b7178bf360 100644 --- a/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/housing_benefit/means_test/capital/sources.yaml @@ -5,7 +5,7 @@ description: > are `savings` for liquid capital, `owned_land` for land held directly, the share-like sources, `other_residential_property_value` for residential property other than the home, and `non_residential_property_value` for other - land and premises. `share_like_capital` is `corporate_wealth` as supplied, + land and premises. `share_like_capital_with_sale_expenses` and `share_like_capital_without_sale_expenses` split `share_like_capital`, which is `corporate_wealth` as supplied, or the sum of its itemised components (`directly_held_shares`, `unit_and_investment_trusts`, `stocks_and_shares_isa`) where that is larger, so a household given only the components has them counted and no holding @@ -45,6 +45,7 @@ values: 2006-04-10: - savings - owned_land - - share_like_capital + - share_like_capital_with_sale_expenses + - share_like_capital_without_sale_expenses - other_residential_property_value - non_residential_property_value diff --git a/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sale_expenses/sources.yaml index 06188a12fd..ef18e218f9 100644 --- a/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sale_expenses/sources.yaml @@ -6,27 +6,15 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (DMG 29620-29623 and 29685). `directly_held_shares` is listed because - shares are valued less 10% for the costs of selling them (DMG 29671). - `unit_and_investment_trusts` is deliberately not listed: a unit trust is - valued at its bid price and has no costs of sale, because the person - withdraws from the manager, even if they use a stockbroker (DMG - 29680-29681). Investment trusts are not named in the guidance and, as listed - company shares, arguably take the 10%, but the Wealth and Assets Survey asks - about unit and investment trusts in one question, so the whole bucket is - treated as having no costs of sale. That approximation counts investment - trusts at full value; HMRC ISA statistics (table 9.6) put investment trusts - at about 7% to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April - 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed - either: an ISA is valued at what the person would get by withdrawing it, and - no ISA paragraph applies the 10% (DMG 29662-29664). - `unitemised_corporate_wealth` is listed so that datasets which do not - itemise `corporate_wealth` keep its previous flat treatment: there it equals - `corporate_wealth`, which mixes shares with unit trusts, stocks and shares - ISAs and employee share options, and, on datasets built before private - pension wealth was split out, non-defined-benefit pension wealth, which is - not capital at all. The deduction reaches all of these until the data - separate them. Sources not counted as Income Support capital are ignored. + sale (DMG 29620-29623 and 29685). `share_like_capital_with_sale_expenses` is + listed: the part of share-like capital whose sale incurs expenses, namely + directly held shares, valued less 10% for selling costs (DMG 29671), and all + of `corporate_wealth` on datasets that do not itemise it. Unit and + investment trusts and stocks and shares ISAs are valued without the + deduction; `gov.dwp.share_like_capital.without_sale_expenses` lists them, + with the guidance and the approximation for investment trusts, which the + survey cannot separate from unit trusts. Sources not counted as Income + Support capital are ignored. metadata: label: Income Support capital sources with sale expenses period: year @@ -49,5 +37,4 @@ values: - owned_land - other_residential_property_value - non_residential_property_value - - directly_held_shares - - unitemised_corporate_wealth + - share_like_capital_with_sale_expenses diff --git a/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sources.yaml b/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sources.yaml index 971341aa06..e5e83161db 100644 --- a/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/income_support/means_test/capital/sources.yaml @@ -3,7 +3,7 @@ description: > `private_pension_wealth` is excluded because Schedule 10 paragraphs 23 and 23A disregard the value of the right to receive an occupational or personal pension and the value of funds held under a personal pension scheme. - `share_like_capital` is `corporate_wealth` as supplied, or the sum of its + `share_like_capital_with_sale_expenses` and `share_like_capital_without_sale_expenses` split `share_like_capital`, which is `corporate_wealth` as supplied, or the sum of its itemised components (`directly_held_shares`, `unit_and_investment_trusts`, `stocks_and_shares_isa`) where that is larger, so a household given only the components has them counted and no holding counts twice. @@ -26,6 +26,7 @@ values: 2010-01-01: - savings - owned_land - - share_like_capital + - share_like_capital_with_sale_expenses + - share_like_capital_without_sale_expenses - other_residential_property_value - non_residential_property_value diff --git a/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sale_expenses/sources.yaml index dae92445b4..dd312c18b8 100644 --- a/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sale_expenses/sources.yaml @@ -6,27 +6,15 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (DMG 84712-84715 and 84731). `directly_held_shares` is listed because - shares are valued less 10% for the costs of selling them (DMG 84763). - `unit_and_investment_trusts` is deliberately not listed: a unit trust is - valued at its bid price and has no costs of sale, because the person - withdraws from the manager, even if they use a stockbroker (DMG - 84771-84772). Investment trusts are not named in the guidance and, as listed - company shares, arguably take the 10%, but the Wealth and Assets Survey asks - about unit and investment trusts in one question, so the whole bucket is - treated as having no costs of sale. That approximation counts investment - trusts at full value; HMRC ISA statistics (table 9.6) put investment trusts - at about 7% to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April - 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed - either: an ISA is valued at what the person would get by withdrawing it, and - no ISA paragraph applies the 10% (DMG 84748-84750). - `unitemised_corporate_wealth` is listed so that datasets which do not - itemise `corporate_wealth` keep its previous flat treatment: there it equals - `corporate_wealth`, which mixes shares with unit trusts, stocks and shares - ISAs and employee share options, and, on datasets built before private - pension wealth was split out, non-defined-benefit pension wealth, which is - not capital at all. The deduction reaches all of these until the data - separate them. Sources not counted as Pension Credit capital are ignored. + sale (DMG 84712-84715 and 84731). `share_like_capital_with_sale_expenses` is + listed: the part of share-like capital whose sale incurs expenses, namely + directly held shares, valued less 10% for selling costs (DMG 84763), and all + of `corporate_wealth` on datasets that do not itemise it. Unit and + investment trusts and stocks and shares ISAs are valued without the + deduction; `gov.dwp.share_like_capital.without_sale_expenses` lists them, + with the guidance and the approximation for investment trusts, which the + survey cannot separate from unit trusts. Sources not counted as Pension + Credit capital are ignored. metadata: label: Pension Credit capital sources with sale expenses period: year @@ -51,5 +39,4 @@ values: - owned_land - other_residential_property_value - non_residential_property_value - - directly_held_shares - - unitemised_corporate_wealth + - share_like_capital_with_sale_expenses diff --git a/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sources.yaml b/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sources.yaml index b567570949..9e80b09f52 100644 --- a/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/pension_credit/income/capital/sources.yaml @@ -29,4 +29,5 @@ values: - owned_land - other_residential_property_value - non_residential_property_value - - share_like_capital + - share_like_capital_with_sale_expenses + - share_like_capital_without_sale_expenses diff --git a/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml b/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml new file mode 100644 index 0000000000..086d7d849c --- /dev/null +++ b/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml @@ -0,0 +1,29 @@ +description: > + Itemised share-like holdings valued for every means test without the + deduction for expenses of sale. Unit trusts are valued at the bid price, + which the manager pays on withdrawal, with no costs of sale even when sold + through a broker (ADM H1673-H1674; DMG 29680-29681, 52680-52681, + 84771-84772; HBGM W1.530-W1.531). The Wealth and Assets Survey asks about + unit and investment trusts in one question, so the whole bucket is listed; + investment trusts are quoted shares, which take the deduction (ADM H1665), + and were 8.2% of the pooled funds held in stocks and shares ISAs at 5 April + 2022 and 6.9% at 5 April 2025 (HMRC ISA Table 9.6). An ISA is valued at + what the holder would get by withdrawing it, and no ISA paragraph applies + the deduction (ADM H1656-H1658; DMG 29662-29664, 52662, 84748-84750). + Everything else in share_like_capital takes the deduction: directly held + shares, and on datasets that do not itemise it, all of corporate_wealth. +metadata: + label: Share-like holdings without expenses of sale + period: year + unit: list + reference: + - title: Advice for Decision Making chapter H1, paras. H1656-H1658 + href: https://assets.publishing.service.gov.uk/media/6a5e0ac7a2662d4563fe39e0/adm-ch-h1.pdf#page=55 + - title: Advice for Decision Making chapter H1, paras. H1673-H1674 + href: https://assets.publishing.service.gov.uk/media/6a5e0ac7a2662d4563fe39e0/adm-ch-h1.pdf#page=59 + - title: HMRC Annual savings statistics 2026, ISA Table 9.6 + href: https://www.gov.uk/government/statistics/annual-savings-statistics-2026 +values: + 2013-04-29: + - unit_and_investment_trusts + - stocks_and_shares_isa diff --git a/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sale_expenses/sources.yaml b/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sale_expenses/sources.yaml index f7a760beb9..0194852eb6 100644 --- a/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sale_expenses/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sale_expenses/sources.yaml @@ -6,27 +6,15 @@ description: > `other_residential_property_value` and `non_residential_property_value` are listed. `savings` is not listed: a bank or building society account is valued at its balance, and the costs of withdrawing money are not costs of - sale (ADM H1604-H1607 and H1675). `directly_held_shares` is listed because - shares are valued less 10% for the costs of selling them (ADM H1665). - `unit_and_investment_trusts` is deliberately not listed: a unit trust is - valued at its bid price and has no costs of sale, because the person - withdraws from the manager, even if they use a stockbroker (ADM - H1673-H1674). Investment trusts are not named in the guidance and, as listed - company shares, arguably take the 10%, but the Wealth and Assets Survey asks - about unit and investment trusts in one question, so the whole bucket is - treated as having no costs of sale. That approximation counts investment - trusts at full value; HMRC ISA statistics (table 9.6) put investment trusts - at about 7% to 8% of the pooled funds held in stocks and shares ISAs (8.2% at 5 April - 2022, 6.9% at 5 April 2025). `stocks_and_shares_isa` is deliberately not listed - either: an ISA is valued at what the person would get by withdrawing it, and - no ISA paragraph applies the 10% (ADM H1656-H1658). - `unitemised_corporate_wealth` is listed so that datasets which do not - itemise `corporate_wealth` keep its previous flat treatment: there it equals - `corporate_wealth`, which mixes shares with unit trusts, stocks and shares - ISAs and employee share options, and, on datasets built before private - pension wealth was split out, non-defined-benefit pension wealth, which is - not capital at all. The deduction reaches all of these until the data - separate them. Sources not counted as Universal Credit capital are ignored. + sale (ADM H1604-H1607 and H1675). `share_like_capital_with_sale_expenses` is + listed: the part of share-like capital whose sale incurs expenses, namely + directly held shares, valued less 10% for selling costs (ADM H1665), and all + of `corporate_wealth` on datasets that do not itemise it. Unit and + investment trusts and stocks and shares ISAs are valued without the + deduction; `gov.dwp.share_like_capital.without_sale_expenses` lists them, + with the guidance and the approximation for investment trusts, which the + survey cannot separate from unit trusts. Sources not counted as Universal + Credit capital are ignored. metadata: label: Universal Credit capital sources with sale expenses period: year @@ -49,5 +37,4 @@ values: - owned_land - other_residential_property_value - non_residential_property_value - - directly_held_shares - - unitemised_corporate_wealth + - share_like_capital_with_sale_expenses diff --git a/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sources.yaml b/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sources.yaml index c4615ccf9c..d982144dba 100644 --- a/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sources.yaml +++ b/policyengine_uk/parameters/gov/dwp/universal_credit/means_test/capital/sources.yaml @@ -5,7 +5,7 @@ description: > current mappings are `savings` for liquid capital, `other_residential_property_value` for residential property other than the home, `non_residential_property_value` for other land and premises, and the - share-like sources. `share_like_capital` is `corporate_wealth` as supplied, + share-like sources. `share_like_capital_with_sale_expenses` and `share_like_capital_without_sale_expenses` split `share_like_capital`, which is `corporate_wealth` as supplied, or the sum of its itemised components (`directly_held_shares`, `unit_and_investment_trusts`, `stocks_and_shares_isa`) where that is larger, so a household given only the components has them counted and no holding @@ -52,4 +52,5 @@ values: - savings - other_residential_property_value - non_residential_property_value - - share_like_capital + - share_like_capital_with_sale_expenses + - share_like_capital_without_sale_expenses diff --git a/policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml b/policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml index d1c1a17514..1563961bed 100644 --- a/policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml @@ -1,6 +1,7 @@ # corporate_wealth itemised into directly_held_shares, unit_and_investment_trusts -# and stocks_and_shares_isa, with unitemised_corporate_wealth carrying whatever -# is not itemised (max(0, corporate_wealth - the three components)). +# and stocks_and_shares_isa. share_like_capital_with_sale_expenses is the part +# valued less 10%: directly held shares plus anything not itemised (all of +# corporate_wealth when nothing is itemised). # Capital is valued at market value less 10% where a sale would incur expenses # (UC Regs 2013 reg. 49(1); HB Regs 2006 reg. 47; IS Regs 1987 reg. 49; JSA # Regs 1996 reg. 111; ESA Regs 2008 reg. 113; SPC Regs 2002 reg. 19). Shares @@ -29,7 +30,7 @@ savings: 5_000 corporate_wealth: 12_000 output: - unitemised_corporate_wealth: 12_000 + share_like_capital_with_sale_expenses: 12_000 uc_assessable_capital: 15_800 is_uc_eligible: true # 9,800 above 6,000 is 40 steps of 250 (rounded up): 40 * 4.35 * 12. @@ -57,7 +58,7 @@ unit_and_investment_trusts: 3_000 stocks_and_shares_isa: 5_000 output: - unitemised_corporate_wealth: 0 + share_like_capital_with_sale_expenses: 4_000 uc_assessable_capital: 16_600 is_uc_eligible: false @@ -81,13 +82,13 @@ unit_and_investment_trusts: 2_600 stocks_and_shares_isa: 3_000 output: - unitemised_corporate_wealth: 0 + share_like_capital_with_sale_expenses: 10_000 uc_assessable_capital: 15_600 is_uc_eligible: true # 9,600 above 6,000 is 39 steps of 250 (38.4 rounded up): 39 * 4.35 * 12. uc_tariff_income: 2_035.8 -- name: UC partial split values the unitemised residual less 10% +- name: UC partial split values the part not itemised less 10% period: 2026 absolute_error_margin: 0.01 input: @@ -107,7 +108,7 @@ corporate_wealth: 12_000 stocks_and_shares_isa: 5_000 output: - unitemised_corporate_wealth: 7_000 + share_like_capital_with_sale_expenses: 7_000 uc_assessable_capital: 15_300 # 9,300 above 6,000 is 38 steps of 250 (37.2 rounded up): 38 * 4.35 * 12. uc_tariff_income: 1_983.6 @@ -133,7 +134,7 @@ directly_held_shares: 4_000 unit_and_investment_trusts: 3_000 output: - unitemised_corporate_wealth: 0 + share_like_capital_with_sale_expenses: 4_000 uc_assessable_capital: 7_600 # 1,600 above 6,000 is 7 steps of 250 (6.4 rounded up): 7 * 4.35 * 12. uc_tariff_income: 365.4 @@ -162,7 +163,7 @@ unit_and_investment_trusts: 4_000 stocks_and_shares_isa: 6_000 output: - unitemised_corporate_wealth: 0 + share_like_capital_with_sale_expenses: 5_000 housing_benefit_assessable_capital: 15_600 # 9,600 above 6,000 is 39 steps of 250 (38.4 rounded up) at 1 a week. housing_benefit_tariff_income: 2_028 diff --git a/policyengine_uk/tests/test_capital_share_components.py b/policyengine_uk/tests/test_capital_share_components.py index 3194e95198..c66ba2dba1 100644 --- a/policyengine_uk/tests/test_capital_share_components.py +++ b/policyengine_uk/tests/test_capital_share_components.py @@ -1,14 +1,24 @@ -"""share_like_capital replaces corporate_wealth in the means-test capital lists. +"""Share-like capital in the means tests, itemised and valued by asset type. + +The capital lists name share_like_capital's two parts: +share_like_capital_with_sale_expenses (directly held shares, and all of an +unitemised corporate_wealth), which the sale-expense lists value less 10%, and +share_like_capital_without_sale_expenses (unit and investment trusts, stocks +and shares ISAs), valued in full. Invariants: 1. share_like_capital is corporate_wealth as supplied (any sign, any fraction) - unless the itemised components add up to more than it by more than the - rounding tolerance, in which case it is their sum. -2. Differential: for identical inputs that carry no components, or components - consistent with corporate_wealth, every programme's assessable capital and - eligibility equal those under the original lists (corporate_wealth), - exactly, annually and monthly. -3. A household given only the components has them counted. + unless the itemised components exceed it beyond the rounding tolerance, in + which case it is their sum. +2. With no itemised holdings, the part with sale expenses is all of + share_like_capital and the other part is exactly nil; otherwise the part + with sale expenses is share_like_capital less trusts and ISAs, floored at + nil, and the two parts add up to share_like_capital. +3. Differential: for identical unitemised inputs, every programme's assessable + capital and UC eligibility equal those under the lists before itemising + (corporate_wealth valued less 10%), exactly, annually and monthly. +4. Split effect: a consistent split raises a working-age single adult's UC + capital by 10% of trusts plus ISAs, against the unitemised lists. """ import numpy as np @@ -27,13 +37,18 @@ "unit_and_investment_trusts", "stocks_and_shares_isa", ) -SOURCE_LISTS = { - "uc_assessable_capital": "gov.dwp.universal_credit.means_test.capital.sources", - "housing_benefit_assessable_capital": "gov.dwp.housing_benefit.means_test.capital.sources", - "income_support_assessable_capital": "gov.dwp.income_support.means_test.capital.sources", - "jsa_income_assessable_capital": "gov.dwp.JSA.income.capital.sources", - "esa_income_assessable_capital": "gov.dwp.ESA.income.capital.sources", - "pension_credit_assessable_capital": "gov.dwp.pension_credit.income.capital.sources", +WITH, WITHOUT = ( + "share_like_capital_with_sale_expenses", + "share_like_capital_without_sale_expenses", +) +LEGAL_RATE = 0.1 +NODES = { + "uc_assessable_capital": "gov.dwp.universal_credit.means_test.capital", + "housing_benefit_assessable_capital": "gov.dwp.housing_benefit.means_test.capital", + "income_support_assessable_capital": "gov.dwp.income_support.means_test.capital", + "jsa_income_assessable_capital": "gov.dwp.JSA.income.capital", + "esa_income_assessable_capital": "gov.dwp.ESA.income.capital", + "pension_credit_assessable_capital": "gov.dwp.pension_credit.income.capital", } YEAR = 2026 SETTINGS = settings( @@ -52,26 +67,30 @@ def _parameter(path): return node(f"{YEAR}-01-01") -ORIGINAL_LISTS = { - path: [ - "corporate_wealth" if source == "share_like_capital" else source - for source in _parameter(path) - ] - for path in SOURCE_LISTS.values() -} -ORIGINAL_REFORM = { - path: {str(YEAR): sources} for path, sources in ORIGINAL_LISTS.items() +def _unitemised(sources): + """The list before itemising: corporate_wealth where the share parts are.""" + out = [] + for source in sources: + if source == WITHOUT: + continue + out.append("corporate_wealth" if source == WITH else source) + return out + + +UNITEMISED_REFORM = { + f"{node}.{name}": {str(YEAR): _unitemised(_parameter(f"{node}.{name}"))} + for node in NODES.values() + for name in ("sources", "sale_expenses.sources") } money = st.floats(min_value=0, max_value=200_000, allow_nan=False, width=32) signed_money = st.floats(min_value=-5_000, max_value=200_000, allow_nan=False, width=32) -def _situation(households): - """One single-adult household per entry; ages alternate 30 and 70.""" +def _situation(households, age=None): people, benunits, hhs = {}, {}, {} for i, assets in enumerate(households): - people[f"p{i}"] = {"age": {YEAR: 70 if i % 2 else 30}} + people[f"p{i}"] = {"age": {YEAR: age or (70 if i % 2 else 30)}} benunits[f"b{i}"] = {"members": [f"p{i}"], "would_claim_uc": {YEAR: True}} hhs[f"h{i}"] = { "members": [f"p{i}"], @@ -80,28 +99,25 @@ def _situation(households): return {"people": people, "benunits": benunits, "households": hhs} -def _results(households, reform=None, period=YEAR): - sim = Simulation(situation=_situation(households), reform=reform) - out = {v: sim.calculate(v, period) for v in SOURCE_LISTS} +def _results(households, reform=None, period=YEAR, age=None): + sim = Simulation(situation=_situation(households, age), reform=reform) + out = {v: sim.calculate(v, period) for v in NODES} out["is_uc_eligible"] = sim.calculate("is_uc_eligible", period) - out["share_like_capital"] = sim.calculate("share_like_capital", YEAR) + for v in ("share_like_capital", WITH, WITHOUT): + out[v] = sim.calculate(v, YEAR) return out -def _assert_same_as_original(households): - for period in (YEAR, f"{YEAR}-01"): - new = _results(households, period=period) - old = _results(households, reform=ORIGINAL_REFORM, period=period) - for variable in (*SOURCE_LISTS, "is_uc_eligible"): - assert np.array_equal(new[variable], old[variable]), (variable, period) - - -@pytest.mark.parametrize("variable", SOURCE_LISTS) -def test_lists_name_share_like_capital_only(variable): - sources = list(_parameter(SOURCE_LISTS[variable])) - assert "share_like_capital" in sources - assert "corporate_wealth" not in sources - assert not set(COMPONENTS) & set(sources) +@pytest.mark.parametrize("variable", NODES) +def test_lists_name_the_two_parts(variable): + sources = list(_parameter(f"{NODES[variable]}.sources")) + sale = list(_parameter(f"{NODES[variable]}.sale_expenses.sources")) + assert WITH in sources and WITHOUT in sources + assert not {"corporate_wealth", "share_like_capital", *COMPONENTS} & set(sources) + assert WITH in sale and WITHOUT not in sale + assert not {"corporate_wealth", *COMPONENTS} & set(sale) + without = set(_parameter("gov.dwp.share_like_capital.without_sale_expenses")) + assert without == {"unit_and_investment_trusts", "stocks_and_shares_isa"} @SETTINGS @@ -112,62 +128,75 @@ def test_lists_name_share_like_capital_only(variable): max_size=40, ) ) -def test_share_like_capital_keeps_the_supplied_aggregate(rows): +def test_share_like_capital_and_its_parts(rows): households = [] for corporate_wealth, components, itemise in rows: assets = {"corporate_wealth": corporate_wealth} if itemise: assets |= dict(zip(COMPONENTS, components)) households.append(assets) - got = _results(households)["share_like_capital"] - for value, assets in zip(got, households): + got = _results(households) + for i, assets in enumerate(households): cw = np.float32(assets["corporate_wealth"]) - itemised = np.float32(sum(np.float32(assets.get(c, 0)) for c in COMPONENTS)) + values = [np.float32(assets.get(c, 0)) for c in COMPONENTS] + itemised = np.float32(sum(values)) tolerance = RELATIVE_TOLERANCE * abs(cw) + ABSOLUTE_TOLERANCE - expected = itemised if itemised > 0 and itemised > cw + tolerance else cw - assert value == pytest.approx(expected, rel=1e-6, abs=1e-3) - if not (itemised > 0 and itemised > cw + tolerance): - assert value == cw # exactly the supplied aggregate + exceeds = itemised > 0 and itemised > cw + tolerance + share_like = got["share_like_capital"][i] + if exceeds: + assert share_like == pytest.approx(itemised, rel=1e-6, abs=1e-3) + else: + assert share_like == cw + if itemised == 0: + assert got[WITH][i] == share_like and got[WITHOUT][i] == 0 + else: + expected = max(0.0, share_like - values[1] - values[2]) + assert got[WITH][i] == pytest.approx(expected, rel=1e-6, abs=1e-2) + assert got[WITH][i] + got[WITHOUT][i] == pytest.approx( + share_like, rel=1e-6, abs=1e-2 + ) @SETTINGS @given( - st.lists( - st.tuples(money, signed_money, st.tuples(money, money, money), st.booleans()), - min_size=1, - max_size=30, - ) + st.lists(st.tuples(money, signed_money), min_size=1, max_size=30), ) -def test_capital_matches_the_original_lists(rows): - """Unsplit, or split consistently: identical to listing corporate_wealth.""" - households = [] - for savings, corporate_wealth, components, split in rows: - assets = {"savings": savings, "corporate_wealth": corporate_wealth} - if split: - assets |= dict(zip(COMPONENTS, components)) - assets["corporate_wealth"] = float(sum(components)) - households.append(assets) - _assert_same_as_original(households) +def test_unitemised_inputs_match_the_lists_before_itemising(rows): + households = [{"savings": s, "corporate_wealth": cw} for s, cw in rows] + households += [ + {"savings": 6_001, "corporate_wealth": -2}, + {"savings": 0, "corporate_wealth": 17_777.78}, # 90% is £16,000.002 + ] + for period in (YEAR, f"{YEAR}-01"): + new = _results(households, period=period) + old = _results(households, reform=UNITEMISED_REFORM, period=period) + for variable in (*NODES, "is_uc_eligible"): + assert np.array_equal(new[variable], old[variable]), (variable, period) -def test_float32_rounding_at_the_limit_keeps_eligibility(): - """Components whose float32 sum overshoots £16,000 by a fraction of a penny.""" +@SETTINGS +@given( + st.lists(st.tuples(money, st.tuples(money, money, money)), min_size=1, max_size=30) +) +def test_a_consistent_split_exempts_trusts_and_isas(rows): households = [ { - "savings": 0, - "corporate_wealth": 16_000, - "directly_held_shares": 6_744.81, - "unit_and_investment_trusts": 6_581.24, - "stocks_and_shares_isa": 2_673.95, - }, - {"savings": 6_001, "corporate_wealth": -2}, - {"savings": 15_999.99, "corporate_wealth": 0.01}, + "savings": savings, + "corporate_wealth": float(sum(components)), + **dict(zip(COMPONENTS, components)), + } + for savings, components in rows ] - _assert_same_as_original(households) - assert _results(households)["share_like_capital"][0] == 16_000 + new = _results(households, age=30) + old = _results(households, reform=UNITEMISED_REFORM, age=30) + for i, (_, (_, trusts, isa)) in enumerate(rows): + exempt = np.float32(trusts) + np.float32(isa) + assert new["uc_assessable_capital"][i] - old["uc_assessable_capital"][ + i + ] == pytest.approx(LEGAL_RATE * exempt, rel=1e-5, abs=0.05) -def test_components_alone_are_counted(): +def test_components_alone_are_valued_by_type(): households = [ { "savings": 1_000, @@ -176,6 +205,8 @@ def test_components_alone_are_counted(): "stocks_and_shares_isa": 5_000, } ] - got = _results(households) + got = _results(households, age=30) assert got["share_like_capital"][0] == 12_000 - assert got["uc_assessable_capital"][0] == 13_000 + assert got[WITH][0] == 4_000 and got[WITHOUT][0] == 8_000 + # £1,000 + 90% of £4,000 + £3,000 + £5,000. + assert got["uc_assessable_capital"][0] == pytest.approx(12_600) diff --git a/policyengine_uk/tests/test_capital_valuation_properties.py b/policyengine_uk/tests/test_capital_valuation_properties.py index 4bafb0c51d..0517d3181d 100644 --- a/policyengine_uk/tests/test_capital_valuation_properties.py +++ b/policyengine_uk/tests/test_capital_valuation_properties.py @@ -7,7 +7,9 @@ Regs 1987 reg. 49; JSA Regs 1996 reg. 111; ESA Regs 2008 reg. 113; SPC Regs 2002 reg. 19). A bank or building society account is valued at its balance (ADM H1675); land and property always have costs of sale (H1606) and shares -are valued less 10% (H1665). +are valued less 10% (H1665). The households here hold share-like wealth only +as unitemised corporate_wealth, which all takes the 10%; itemised holdings +(unit trusts and ISAs without it) are tested in test_capital_share_components. Invariants, for any generated population of single-adult households: @@ -57,14 +59,29 @@ } PENSION_AGE_ONLY = {"pension_credit_assessable_capital"} # The assets whose sale incurs expenses, fixed here from the law rather than -# read from the parameters: real property always (ADM H1606), shares (H1665); -# never a bank or building society balance (H1675). +# read from the parameters: real property always (ADM H1606), shares (H1665), +# and unitemised corporate wealth with them; never a bank or building society +# balance (H1675). SALE_EXPENSE_ASSETS = { "owned_land", "other_residential_property_value", "non_residential_property_value", - "corporate_wealth", + "share_like_capital_with_sale_expenses", +} +# How each capital source reads an unitemised household's inputs: all of its +# corporate_wealth has expenses of sale, none is without. +SHARE_LIKE_SOURCES = { + "share_like_capital_with_sale_expenses": lambda assets: assets["corporate_wealth"], + "share_like_capital_without_sale_expenses": lambda assets: 0.0, } + + +def asset_value(unit, source): + if source in SHARE_LIKE_SOURCES: + return SHARE_LIKE_SOURCES[source](unit["assets"]) + return unit["assets"][source] + + LEGAL_RATE = 0.1 ASSETS = [ "savings", @@ -141,7 +158,7 @@ def expected_capital(unit, node): """Reg. 49(1) applied source by source, independently of the model.""" total = 0.0 for source in node.sources: - value = unit["assets"][source] + value = asset_value(unit, source) if source in SALE_EXPENSE_ASSETS: value *= 1 - LEGAL_RATE if source in DEBTS: @@ -179,7 +196,7 @@ def test_valuation_matches_the_regulation_and_never_adds_capital(units): assert close(valued[variable][i], expected), (variable, unit) # Debt secured on property never reaches the other assets. floor = sum( - unit["assets"][s] * (1 - LEGAL_RATE * (s in SALE_EXPENSE_ASSETS)) + asset_value(unit, s) * (1 - LEGAL_RATE * (s in SALE_EXPENSE_ASSETS)) for s in node.sources if s not in DEBTS ) diff --git a/policyengine_uk/tests/test_stock_capital_periods.py b/policyengine_uk/tests/test_stock_capital_periods.py index fe6f440ddf..92d4d82100 100644 --- a/policyengine_uk/tests/test_stock_capital_periods.py +++ b/policyengine_uk/tests/test_stock_capital_periods.py @@ -85,11 +85,12 @@ def test_itemised_share_like_stocks_are_not_prorated_monthly(): for name, value in stocks.items(): assert simulation.calculate(name, "2026-01")[0] == value, name - # 12,000 less the 9,000 itemised. - assert simulation.calculate("unitemised_corporate_wealth", "2026-01")[0] == ( - 3_000 - ) - # Shares and the unitemised residual less 10% for the expenses of + # 12,000 less the unit trusts and ISA (5,000): the 4,000 of shares + # and the 3,000 not itemised. + assert simulation.calculate("share_like_capital_with_sale_expenses", "2026-01")[ + 0 + ] == (7_000) + # Shares and the part not itemised less 10% for the expenses of # sale; unit trusts and the ISA at their withdrawal value: - # 1,000 + 3,600 + 3,000 + 2,000 + 2,700. + # 1,000 + 90% of 7,000 + 3,000 + 2,000 = 1,000 + 6,300 + 5,000. assert simulation.calculate(capital, "2026-01")[0] == 12_300, capital diff --git a/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py b/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py new file mode 100644 index 0000000000..596008d993 --- /dev/null +++ b/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py @@ -0,0 +1,35 @@ +from policyengine_uk.model_api import * + +COMPONENTS = [ + "directly_held_shares", + "unit_and_investment_trusts", + "stocks_and_shares_isa", +] + + +class share_like_capital_with_sale_expenses(Variable): + label = "share-like capital with expenses of sale" + documentation = ( + "The part of share_like_capital whose sale would incur expenses, so " + "that the means tests value it less 10%: share_like_capital less the " + "itemised holdings listed in gov.dwp.share_like_capital." + "without_sale_expenses (unit and investment trusts, stocks and shares " + "ISAs), floored at nil. A household with no itemised holdings has all " + "of its share-like capital here, so datasets that carry only " + "corporate_wealth keep the flat 10% on it." + ) + entity = Household + definition_period = YEAR + value_type = float + unit = GBP + quantity_type = STOCK + + def formula(household, period, parameters): + share_like = household("share_like_capital", period) + itemised = add(household, period, COMPONENTS) + without = add( + household, + period, + parameters(period).gov.dwp.share_like_capital.without_sale_expenses, + ) + return where(itemised > 0, max_(0, share_like - without), share_like) diff --git a/policyengine_uk/variables/household/wealth/share_like_capital_without_sale_expenses.py b/policyengine_uk/variables/household/wealth/share_like_capital_without_sale_expenses.py new file mode 100644 index 0000000000..ad777f2f0b --- /dev/null +++ b/policyengine_uk/variables/household/wealth/share_like_capital_without_sale_expenses.py @@ -0,0 +1,20 @@ +from policyengine_uk.model_api import * + + +class share_like_capital_without_sale_expenses(Variable): + label = "share-like capital without expenses of sale" + documentation = ( + "The part of share_like_capital the means tests value at full value: " + "share_like_capital less share_like_capital_with_sale_expenses. Nil " + "for a household with no itemised holdings." + ) + entity = Household + definition_period = YEAR + value_type = float + unit = GBP + quantity_type = STOCK + + def formula(household, period, parameters): + return household("share_like_capital", period) - household( + "share_like_capital_with_sale_expenses", period + ) From 10c54a5962176f3fb5befa757793d121ce459077 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Tue, 13 Oct 2026 08:50:32 -0400 Subject: [PATCH 03/14] Start the exempt list in 1996, sum it from zero, and test float32 grouping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review of b7e6bc5c5: - gov.dwp.share_like_capital.without_sale_expenses started in 2013, after the legacy capital lists (JSA from 1996-10-07), so a 2012 simulation with unitemised corporate_wealth raised ParameterNotFoundError; it now starts at 1996-10-07, and Income Support and JSA capital in 2012 are tested (both fail with the 2013 start). - An empty exempt list made add() return None; the exempt holdings are now summed from a numeric zero, and an empty-list reform (every share-like holding less 10%) is tested. - The property oracle now follows the engine's float32 grouping (components left to right, exempt holdings summed before subtraction) and compares exactly; the reviewer's example (trusts £200,000, ISA £199,999.984375) is pinned. Co-Authored-By: Claude Opus 5.5 --- .../without_sale_expenses.yaml | 2 +- .../tests/test_capital_share_components.py | 67 ++++++++++++++++--- .../share_like_capital_with_sale_expenses.py | 12 ++-- 3 files changed, 64 insertions(+), 17 deletions(-) diff --git a/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml b/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml index 086d7d849c..fa06ccc205 100644 --- a/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml +++ b/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml @@ -24,6 +24,6 @@ metadata: - title: HMRC Annual savings statistics 2026, ISA Table 9.6 href: https://www.gov.uk/government/statistics/annual-savings-statistics-2026 values: - 2013-04-29: + 1996-10-07: - unit_and_investment_trusts - stocks_and_shares_isa diff --git a/policyengine_uk/tests/test_capital_share_components.py b/policyengine_uk/tests/test_capital_share_components.py index c66ba2dba1..c848efc0a8 100644 --- a/policyengine_uk/tests/test_capital_share_components.py +++ b/policyengine_uk/tests/test_capital_share_components.py @@ -28,7 +28,6 @@ from policyengine_uk import CountryTaxBenefitSystem, Simulation from policyengine_uk.variables.household.wealth.share_like_capital import ( - ABSOLUTE_TOLERANCE, RELATIVE_TOLERANCE, ) @@ -139,22 +138,68 @@ def test_share_like_capital_and_its_parts(rows): for i, assets in enumerate(households): cw = np.float32(assets["corporate_wealth"]) values = [np.float32(assets.get(c, 0)) for c in COMPONENTS] - itemised = np.float32(sum(values)) - tolerance = RELATIVE_TOLERANCE * abs(cw) + ABSOLUTE_TOLERANCE - exceeds = itemised > 0 and itemised > cw + tolerance + # The engine's float32 grouping: components added left to right, the + # exempt holdings summed before they are subtracted. + itemised = np.float32(np.float32(values[0] + values[1]) + values[2]) + exempt = np.float32(values[1] + values[2]) + tolerance = RELATIVE_TOLERANCE * max(abs(cw), itemised) share_like = got["share_like_capital"][i] - if exceeds: - assert share_like == pytest.approx(itemised, rel=1e-6, abs=1e-3) + if itemised > 0 and itemised > cw + tolerance: + assert share_like == itemised else: assert share_like == cw if itemised == 0: assert got[WITH][i] == share_like and got[WITHOUT][i] == 0 else: - expected = max(0.0, share_like - values[1] - values[2]) - assert got[WITH][i] == pytest.approx(expected, rel=1e-6, abs=1e-2) - assert got[WITH][i] + got[WITHOUT][i] == pytest.approx( - share_like, rel=1e-6, abs=1e-2 - ) + assert got[WITH][i] == max(np.float32(0), np.float32(share_like - exempt)) + assert got[WITHOUT][i] == np.float32(share_like - got[WITH][i]) + + +def test_float32_grouping_of_the_exempt_holdings(): + """Trusts and ISA summed first: £400,000 less £399,999.98 rounds to nil.""" + households = [ + { + "corporate_wealth": 399_999.984375, + "unit_and_investment_trusts": 200_000, + "stocks_and_shares_isa": 199_999.984375, + } + ] + got = _results(households) + assert got[WITH][0] == 0 + + +def test_an_empty_exempt_list_values_everything_less_10_percent(): + """A ruling that every share-like holding takes the 10% is a parameter edit.""" + reform = {"gov.dwp.share_like_capital.without_sale_expenses": {str(YEAR): []}} + households = [ + {"savings": 1_000, "corporate_wealth": 12_000}, + { + "savings": 1_000, + "directly_held_shares": 4_000, + "unit_and_investment_trusts": 3_000, + "stocks_and_shares_isa": 5_000, + }, + ] + got = _results(households, reform=reform, age=30) + assert list(got[WITH]) == [12_000, 12_000] + assert list(got[WITHOUT]) == [0, 0] + # £1,000 + 90% of £12,000 either way. + assert got["uc_assessable_capital"] == pytest.approx([11_800, 11_800]) + + +@pytest.mark.parametrize( + "variable", ["income_support_assessable_capital", "jsa_income_assessable_capital"] +) +def test_legacy_capital_before_universal_credit(variable): + """2012: the legacy lists apply, and so does the exempt list (from 1996).""" + situation = _situation([{"savings": 1_000, "corporate_wealth": 12_000}], age=30) + for entity in situation.values(): + for name, values in entity.items(): + for key, by_year in list(values.items()): + if isinstance(by_year, dict) and YEAR in by_year: + values[key] = {2012: by_year[YEAR]} + capital = Simulation(situation=situation).calculate(variable, 2012)[0] + assert capital == pytest.approx(11_800) @SETTINGS diff --git a/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py b/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py index 596008d993..d5136dd2b3 100644 --- a/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py +++ b/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py @@ -27,9 +27,11 @@ class share_like_capital_with_sale_expenses(Variable): def formula(household, period, parameters): share_like = household("share_like_capital", period) itemised = add(household, period, COMPONENTS) - without = add( - household, - period, - parameters(period).gov.dwp.share_like_capital.without_sale_expenses, - ) + # Summed from a numeric zero so that an empty list (every holding + # taking the deduction) still works. + without = 0 * share_like + for variable in parameters( + period + ).gov.dwp.share_like_capital.without_sale_expenses: + without = without + household(variable, period) return where(itemised > 0, max_(0, share_like - without), share_like) From 90e52b48ae98a74f3ac2c0e22e758ae6eb129af7 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 31 Oct 2026 12:04:51 -0400 Subject: [PATCH 04/14] Count an itemised stocks-and-shares ISA in full in every means test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1969's fc066bd31 made main's test_isa_balances.py expect UC's 10% on a stored stocks-and-shares ISA total, because the ISA then reached capital through share_like_capital, which #1969 values less 10%. With the split, an itemised ISA sits in share_like_capital_without_sale_expenses and counts at its withdrawal value (ADM H1656), so UC capital is (1,000 + 3,000 + 2,000) x growth: 6,000 x 1.07224 = 6,433.44 in 2027. A new parametrised test pins the person-balance route in all six means tests: a £1,000 saver with a £3,000 cash ISA and a £2,000 stocks-and-shares ISA has £6,000 of capital, the ISA wholly in the part without sale expenses. The changelog fragment loses its leading list marker, which towncrier would render as a double bullet. Co-Authored-By: Claude Opus 5.5 --- changelog.d/sale-expense-share-split.fixed.md | 2 +- policyengine_uk/tests/test_isa_balances.py | 78 ++++++++++++++++--- 2 files changed, 70 insertions(+), 10 deletions(-) diff --git a/changelog.d/sale-expense-share-split.fixed.md b/changelog.d/sale-expense-share-split.fixed.md index 014f38dd95..70a719b327 100644 --- a/changelog.d/sale-expense-share-split.fixed.md +++ b/changelog.d/sale-expense-share-split.fixed.md @@ -1 +1 @@ -- Value share-like capital by asset type in every means test: directly held shares, and any `corporate_wealth` a dataset does not itemise, take the 10% sale-expense deduction; unit trusts (ADM H1673-H1674) and stocks and shares ISAs (ADM H1656) count at full value, as does the survey's combined unit and investment trust bucket, an approximation for its investment trusts. +Value share-like capital by asset type in every means test: directly held shares, and any `corporate_wealth` a dataset does not itemise, take the 10% sale-expense deduction; unit trusts (ADM H1673-H1674) and stocks and shares ISAs (ADM H1656) count at full value, as does the survey's combined unit and investment trust bucket, an approximation for its investment trusts. diff --git a/policyengine_uk/tests/test_isa_balances.py b/policyengine_uk/tests/test_isa_balances.py index e5a28362aa..588d221b6c 100644 --- a/policyengine_uk/tests/test_isa_balances.py +++ b/policyengine_uk/tests/test_isa_balances.py @@ -3,12 +3,14 @@ Datasets built before the per-person balances existed store only the household totals. Those totals must keep their stored values, projected with savings, rather than fall to the sum of balances the dataset does not have. +Every means test counts both kinds of ISA at their withdrawal value, without +the 10% for expenses of sale. """ import pandas as pd import pytest -from policyengine_uk import Microsimulation +from policyengine_uk import Microsimulation, Simulation from policyengine_uk.data.dataset_schema import UKSingleYearDataset @@ -59,15 +61,17 @@ def test_stored_household_totals_without_person_balances_project_with_savings(): shares = simulation.calculate("stocks_and_shares_isa", 2027).values[0] assert cash == pytest.approx(3_000.0 * growth) assert shares == pytest.approx(2_000.0 * growth) - # Savings and the cash ISA reach the capital pool at their value. The - # stocks-and-shares ISA reaches it through share_like_capital, which - # Universal Credit values less its sale-expense rate until the data - # separate ISAs from shares. - rate = simulation.tax_benefit_system.parameters( - "2027-04-06" - ).gov.dwp.universal_credit.means_test.capital.sale_expenses.rate + # Savings, the cash ISA and the stocks-and-shares ISA all reach the + # capital pool at their value: an ISA is valued at what its holder would + # get by withdrawing it, with no deduction for expenses of sale (ADM + # H1656), so the itemised ISA sits in the part of share_like_capital + # without them. + without = simulation.calculate("share_like_capital_without_sale_expenses", 2027) + with_expenses = simulation.calculate("share_like_capital_with_sale_expenses", 2027) + assert without.values[0] == pytest.approx(2_000.0 * growth) + assert with_expenses.values[0] == 0 capital = simulation.calculate("uc_assessable_capital", 2027).values[0] - expected = (1_000.0 + 3_000.0 + 2_000.0 * (1 - rate)) * growth + expected = (1_000.0 + 3_000.0 + 2_000.0) * growth assert capital == pytest.approx(expected, rel=1e-5) @@ -91,3 +95,59 @@ def test_household_totals_sum_the_person_balances_in_every_year(): household_shares = simulation.calculate("stocks_and_shares_isa", year) assert household_cash == pytest.approx(cash.sum()) assert household_shares.values[0] == pytest.approx(shares.sum()) + + +def _isa_situation(age, period, **person): + """One adult with £1,000 of savings and the given person-level balances.""" + return { + "people": { + "person": { + "age": {period: age}, + **{name: {period: value} for name, value in person.items()}, + } + }, + "benunits": { + "benunit": {"members": ["person"], "would_claim_uc": {period: False}} + }, + "households": { + "household": {"members": ["person"], "savings": {period: 1_000.0}} + }, + } + + +@pytest.mark.parametrize( + "variable, age, period", + [ + ("uc_assessable_capital", 30, 2026), + ("housing_benefit_assessable_capital", 30, 2026), + # Income Support's capital list applies to a working-age claimant + # before Universal Credit replaced it. + ("income_support_assessable_capital", 30, 2021), + ("jsa_income_assessable_capital", 30, 2026), + ("esa_income_assessable_capital", 40, 2026), + ("pension_credit_assessable_capital", 70, 2026), + ], +) +def test_person_isa_balances_count_in_full_in_every_means_test(variable, age, period): + """Neither a cash ISA nor a stocks-and-shares ISA takes the 10% for + expenses of sale: each is valued at its withdrawal value (ADM H1656; DMG + 29662, 52662, 84748). £1,000 + £3,000 + £2,000 = £6,000, where the 10% + on the stocks-and-shares ISA would give £5,800.""" + simulation = Simulation( + situation=_isa_situation( + age, + period, + cash_isa_balance=3_000.0, + stocks_and_shares_isa_balance=2_000.0, + ) + ) + assert simulation.calculate("stocks_and_shares_isa", period)[0] == 2_000 + assert simulation.calculate("share_like_capital_without_sale_expenses", period)[ + 0 + ] == pytest.approx(2_000) + assert simulation.calculate("share_like_capital_with_sale_expenses", period)[0] == 0 + if variable == "housing_benefit_assessable_capital": + assert not simulation.calculate( + "housing_benefit_on_passporting_benefit", period + )[0] + assert simulation.calculate(variable, period)[0] == pytest.approx(6_000, abs=0.01) From ce360946a084d90579535d29b02bd260edcfa8c2 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 31 Oct 2026 12:21:04 -0400 Subject: [PATCH 05/14] Test that every means test values itemised holdings by type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A Hypothesis property gives single adults only itemised holdings, with the ISAs as their own person-level balances, and checks all six means tests against the law: savings, cash ISAs, unit trusts and stocks and shares ISAs in full, directly held shares less 10%, each rounded by the programme's rule, to within a penny of float32 noise. A pinned example gives £15,600. The list test also asserts that each capital list names cash_isa and that no sale-expense list names savings or cash_isa. Co-Authored-By: Claude Opus 5.5 --- .../tests/test_capital_share_components.py | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/policyengine_uk/tests/test_capital_share_components.py b/policyengine_uk/tests/test_capital_share_components.py index 35b018ccb3..80f68c4853 100644 --- a/policyengine_uk/tests/test_capital_share_components.py +++ b/policyengine_uk/tests/test_capital_share_components.py @@ -23,6 +23,10 @@ from the part with sale expenses, whether it was entered within corporate_wealth or as directly held shares. 6. The exempt list exists from the first date any capital list does. +7. Valuation by type: given only itemised holdings, with the ISAs held as the + person's own balances, all six means tests count savings, cash ISAs, unit + trusts and stocks and shares ISAs in full and directly held shares less + 10%, rounded by each programme's rule, to within a penny. """ import numpy as np @@ -127,6 +131,8 @@ def test_lists_name_the_two_parts(variable): assert not {"corporate_wealth", "share_like_capital", *COMPONENTS} & set(sources) assert WITH in sale and WITHOUT not in sale assert not {"corporate_wealth", *COMPONENTS} & set(sale) + # Deposit balances have no costs of sale (ADM H1607, H1675). + assert "cash_isa" in sources and not {"savings", "cash_isa"} & set(sale) without = set(_parameter("gov.dwp.share_like_capital.without_sale_expenses")) assert without == {"unit_and_investment_trusts", "stocks_and_shares_isa"} @@ -403,3 +409,81 @@ def test_a_disregarded_company_holding_leaves_the_part_with_sale_expenses(): # The pool counts the shares at 90%, and the holding leaves it at that. assert sim.calculate("household_uc_pool_company_holdings", YEAR)[0] == 27_000 assert list(sim.calculate("uc_assessable_capital", YEAR)) == [5_000, 5_000] + + +ROUNDS_DOWN = { + "uc_assessable_capital": False, + "housing_benefit_assessable_capital": False, + "income_support_assessable_capital": True, + "jsa_income_assessable_capital": True, + "esa_income_assessable_capital": True, + "pension_credit_assessable_capital": True, +} +pennies = st.integers(min_value=0, max_value=2_000_000) + + +@settings( + max_examples=10, + deadline=None, + derandomize=True, + suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large], +) +@given( + st.lists( + st.tuples( + pennies, + pennies, + pennies, + pennies, + pennies, + st.sampled_from([30, 70]), + st.booleans(), + ), + min_size=1, + max_size=20, + ) +) +# £1,000 of savings, £3,000 in a cash ISA, £3,000 of unit trusts and a £5,000 +# stocks-and-shares ISA in full, and 90% of £4,000 of shares: £15,600. +@example([(100_000, 300_000, 400_000, 300_000, 500_000, 30, False)]) +def test_itemised_holdings_are_valued_by_type_in_every_means_test(rows): + """Given only itemised holdings, with the ISAs held as the person's own + balances, every means test counts savings, a cash ISA, unit trusts and a + stocks-and-shares ISA in full and directly held shares less 10%, rounded + by the programme's rule. The engine adds the holdings in float32, which + can move the shares' value by a fraction of a penny before valuation, so + each total is checked to within a penny.""" + people, benunits, homes = {}, {}, {} + for i, (savings, cash_isa, shares, trusts, isa, age, claims_uc) in enumerate(rows): + people[f"p{i}"] = { + "age": {YEAR: age}, + "cash_isa_balance": {YEAR: cash_isa / 100}, + "stocks_and_shares_isa_balance": {YEAR: isa / 100}, + } + benunits[f"b{i}"] = { + "members": [f"p{i}"], + "would_claim_uc": {YEAR: claims_uc}, + } + homes[f"h{i}"] = { + "members": [f"p{i}"], + "savings": {YEAR: savings / 100}, + "directly_held_shares": {YEAR: shares / 100}, + "unit_and_investment_trusts": {YEAR: trusts / 100}, + } + sim = Simulation( + situation={"people": people, "benunits": benunits, "households": homes} + ) + passported = sim.calculate("housing_benefit_on_passporting_benefit", YEAR) + for variable, round_down in ROUNDS_DOWN.items(): + values = sim.calculate(variable, YEAR) + for i, (savings, cash_isa, shares, trusts, isa, age, _) in enumerate(rows): + if variable == "pension_credit_assessable_capital": + if age < 67: + continue + elif age >= 67 or ( + variable == "housing_benefit_assessable_capital" and passported[i] + ): + continue + share_pence = (9 * shares + (0 if round_down else 5)) // 10 + expected = (savings + cash_isa + trusts + isa + share_pence) / 100 + assert abs(values[i] - expected) <= 0.011, (variable, rows[i], values[i]) From 2f1051e9fd6340bcfd2a6eb81fdfc616f283bb38 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 31 Oct 2026 12:36:47 -0400 Subject: [PATCH 06/14] Rename the shard-duration lines for the share-components tests this PR renamed test_ci_test_shards.py fails on any shard_durations.toml entry that names a missing test. Main's table lists three tests that this PR replaced with its split versions: - test_capital_matches_the_original_lists became test_unitemised_inputs_match_the_lists_before_itemising, the same four-period differential on the unitemised households; - test_share_like_capital_keeps_the_supplied_aggregate became test_share_like_capital_and_its_parts; - test_float32_rounding_at_the_limit_keeps_eligibility became test_float32_rounding_at_the_limit_keeps_the_aggregate. Each line keeps its measured duration, as the table's header asks of a renaming pull request, until the table is regenerated. Every one of the 566 entries now names a test that exists. Co-Authored-By: Claude Opus 5.5 --- policyengine_uk/tests/shard_durations.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/policyengine_uk/tests/shard_durations.toml b/policyengine_uk/tests/shard_durations.toml index 2c52eb6701..907d405416 100644 --- a/policyengine_uk/tests/shard_durations.toml +++ b/policyengine_uk/tests/shard_durations.toml @@ -13,7 +13,7 @@ # rename or delete its line here. Regenerate when a shard drifts well above # the others. [seconds] -"policyengine_uk/tests/test_capital_share_components.py::test_capital_matches_the_original_lists" = 1299 +"policyengine_uk/tests/test_capital_share_components.py::test_unitemised_inputs_match_the_lists_before_itemising" = 1299 "policyengine_uk/tests/test_statutory_pension_edges.py::test_nics_cap_preserves_aa_inputs_and_charge_with_fixed_ordinary_tax[2029]" = 761 "policyengine_uk/tests/test_statutory_pension_edges.py::test_nics_cap_preserves_aa_inputs_and_charge_with_fixed_ordinary_tax[2030]" = 753 "policyengine_uk/tests/test_mixed_age_couple_properties.py::test_mixed_age_couple_invariants" = 498 @@ -129,7 +129,7 @@ "policyengine_uk/tests/test_disable_simulated_benefits_benefit_cap.py::test_the_benefit_cap_matches_the_replaced_readers_with_the_reform_off" = 108 "policyengine_uk/tests/test_income_support_gate_reads_claimant_or_partner_awards.py::test_the_switched_gate_matches_the_replaced_code" = 107 "policyengine_uk/tests/test_dataframe_dataset.py::test_a_frame_over_several_years_exports_the_same_frame_again" = 107 -"policyengine_uk/tests/test_capital_share_components.py::test_share_like_capital_keeps_the_supplied_aggregate" = 107 +"policyengine_uk/tests/test_capital_share_components.py::test_share_like_capital_and_its_parts" = 107 "policyengine_uk/tests/test_uc_unearned_benefits_properties.py::test_carer_support_payment_counts_like_capped_private_pension" = 107 "policyengine_uk/tests/test_uc_single_claim_properties.py::test_maximum_amount_is_the_solo_claimants" = 107 "policyengine_uk/tests/test_uc_earnings_deductions_properties.py::test_unearned_income_never_changes_earned_income" = 107 @@ -329,7 +329,7 @@ "policyengine_uk/tests/test_uc_earned_income_before_work_allowance_properties.py::test_award_earned_income_is_before_work_allowance_less_the_allowance" = 55 "policyengine_uk/tests/test_capital_share_components.py::test_one_unit_of_float32_rounding_above_a_power_of_two_keeps_the_aggregate" = 55 "policyengine_uk/tests/test_housing_benefit_savings_credit_only_properties.py::test_net_income_does_not_fall_where_savings_credit_ends" = 54 -"policyengine_uk/tests/test_capital_share_components.py::test_float32_rounding_at_the_limit_keeps_eligibility" = 54 +"policyengine_uk/tests/test_capital_share_components.py::test_float32_rounding_at_the_limit_keeps_the_aggregate" = 54 "policyengine_uk/tests/test_housing_benefit_specified_accommodation_disregard_properties.py::test_differential_against_the_statutory_reference" = 54 "policyengine_uk/tests/test_hbai_negative_income_properties.py::test_reset_income_and_its_measures" = 54 "policyengine_uk/tests/test_benunit_reported_capital_properties.py::test_programme_variable_set_directly_wins_for_that_programme" = 53 From 6a0d26d618e018d673e23adaaf777cbd2a498d35 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 31 Oct 2026 17:53:49 -0400 Subject: [PATCH 07/14] Test that the part with sale expenses stops at nil MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When trusts and an ISA exceed corporate_wealth only by float32 rounding, share_like_capital keeps corporate_wealth and subtracting the exempt holdings goes below nil. £16,000 of corporate_wealth with £8,000.01 of trusts and an £8,000 ISA leaves -£0.009765625 without the floor. No fixed case reached the floor before: the grouping case lands at exactly nil either way. A fixed test and a matching @example on the property pin it. Co-Authored-By: Claude Opus 5.5 --- .../tests/test_capital_share_components.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/policyengine_uk/tests/test_capital_share_components.py b/policyengine_uk/tests/test_capital_share_components.py index 80f68c4853..e91475b2c9 100644 --- a/policyengine_uk/tests/test_capital_share_components.py +++ b/policyengine_uk/tests/test_capital_share_components.py @@ -147,6 +147,8 @@ def test_lists_name_the_two_parts(variable): ) # Subtracting trusts and ISA one at a time leaves £0.015625 here; grouped, nil. @example([(399_999.984375, (0.0, 200_000.0, 199_999.984375), True)]) +# Trusts and ISA exceed corporate_wealth by float32 rounding: floored at nil. +@example([(16_000.0, (0.0, 8_000.01, 8_000.0), True)]) def test_share_like_capital_and_its_parts(rows): households = [] for corporate_wealth, components, itemise in rows: @@ -191,6 +193,24 @@ def test_float32_grouping_of_the_exempt_holdings(): assert got[WITH][0] == 0 +def test_exempt_holdings_above_the_aggregate_by_rounding_leave_nil_with_expenses(): + """£8,000.01 of trusts and an £8,000 ISA add up in float32 to + £16,000.009765625, above £16,000 of corporate_wealth by less than a + millionth, so share_like_capital keeps the £16,000. Subtracting the exempt + holdings would leave -£0.009765625; the part with sale expenses stops at + nil, and the part without holds all £16,000.""" + households = [ + { + "corporate_wealth": 16_000, + "unit_and_investment_trusts": 8_000.01, + "stocks_and_shares_isa": 8_000, + } + ] + got = _results(households) + assert got["share_like_capital"][0] == 16_000 + assert got[WITH][0] == 0 and got[WITHOUT][0] == 16_000 + + def test_an_empty_exempt_list_values_everything_less_10_percent(): """A ruling that every share-like holding takes the 10% is a parameter edit.""" reform = {"gov.dwp.share_like_capital.without_sale_expenses": {str(YEAR): []}} From ce91e92ea9d2d7c7025d932ba613438bf4a70a8d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 3 Nov 2026 07:43:08 +0000 Subject: [PATCH 08/14] Expect the stocks-and-shares ISA at face value in the stored-totals test Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LwQq6JPpGLuS9js3RjsmWH --- .../tests/test_stored_household_totals.py | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/policyengine_uk/tests/test_stored_household_totals.py b/policyengine_uk/tests/test_stored_household_totals.py index 52c1ea99e6..5d92adb523 100644 --- a/policyengine_uk/tests/test_stored_household_totals.py +++ b/policyengine_uk/tests/test_stored_household_totals.py @@ -216,25 +216,20 @@ def test_stored_household_totals_grow_past_the_projection_horizon(): assert totals[year][0] == pytest.approx( totals[PROJECTION_END_YEAR][0] * growth, rel=1e-6 ) - # Savings, the cash ISA and the stocks-and-shares ISA make up the capital. - # Savings and the cash ISA count at their value. The stocks-and-shares ISA - # reaches the capital through share_like_capital, which Universal Credit - # values less its sale-expense rate (Universal Credit Regulations 2013 - # reg. 49(1)(a)). The parts grow alike, so capital keeps the same ratio to - # savings in every year: 5.8 for this household. + # Savings, the cash ISA and the stocks-and-shares ISA make up the capital, + # each at its value. A decision maker values an ISA at what its holder + # would get by withdrawing it, with no deduction for expenses of sale (ADM + # H1656), so the stored stocks-and-shares ISA reaches the capital through + # share_like_capital_without_sale_expenses. The parts grow alike, so + # capital keeps the same ratio to savings in every year: 6 for this + # household. cash_isa = _values(simulation, "cash_isa") shares_isa = _values(simulation, "stocks_and_shares_isa") ratio = capital[DATA_YEAR][0] / savings[DATA_YEAR][0] for year in YEARS: - rate = simulation.tax_benefit_system.parameters( - period(year).start - ).gov.dwp.universal_credit.means_test.capital.sale_expenses.rate - expected = ( - savings[year][0] + cash_isa[year][0] + shares_isa[year][0] * (1 - rate) - ) - assert capital[year][0] == pytest.approx(expected, rel=1e-5), year face_value = savings[year][0] + cash_isa[year][0] + shares_isa[year][0] - assert capital[year][0] < face_value - 0.01, year + assert capital[year][0] == pytest.approx(face_value, rel=1e-5), year + assert capital[year][0] == pytest.approx(6 * savings[year][0], rel=1e-5), year assert capital[year][0] == pytest.approx(ratio * savings[year][0], rel=1e-5) From 65cebd3f6e58be6fa097fdf5e6b7625e6a9679a6 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 12 Nov 2026 09:27:57 -0500 Subject: [PATCH 09/14] Count person stocks and shares ISAs at face value in main's ISA tests This branch values stocks and shares ISAs without the deduction for expenses of sale (ADM H1656-H1658), and the ISA person source now comes out of share_like_capital_without_sale_expenses. Main's person ISA cases expected 90%, so each counted ISA rises by a tenth. Cases 13 to 15 test a boundary, so their inputs move to keep it: a 30,600 ISA in Case 13, and household totals of 16,000 and 6,000 in Cases 14 and 15. Co-Authored-By: Claude Opus 5.5 --- .../baseline/gov/dwp/person_isa_capital.yaml | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/policyengine_uk/tests/policy/baseline/gov/dwp/person_isa_capital.yaml b/policyengine_uk/tests/policy/baseline/gov/dwp/person_isa_capital.yaml index a282d3c84d..86162714b5 100644 --- a/policyengine_uk/tests/policy/baseline/gov/dwp/person_isa_capital.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/dwp/person_isa_capital.yaml @@ -9,11 +9,14 @@ # from the household's capital, then allocates the remainder by claimant and # partner counts, between pension-age adults for Pension Credit, or wholly to # a unit on the IS, JSA or ESA claim path. Each programme values the pool's -# share_like_capital, and each stocks and shares ISA balance the formula moves -# out of it, at market value less 10% for the expenses of sale (UC Regs 2013 -# reg 49(1)(a); HB Regs 2006 reg 47; IS Regs 1987 reg 49; JSA Regs 1996 reg -# 111; ESA Regs 2008 reg 113; SPC Regs 2002 reg 19), and counts savings and -# cash ISAs at face value. +# share-like holdings with expenses of sale (directly held shares, and all of +# an unitemised corporate_wealth) at market value less 10% (UC Regs 2013 reg +# 49(1)(a); HB Regs 2006 reg 47; IS Regs 1987 reg 49; JSA Regs 1996 reg 111; +# ESA Regs 2008 reg 113; SPC Regs 2002 reg 19). It counts savings, cash ISAs +# and each stocks and shares ISA balance the formula moves out of +# share_like_capital at face value: an ISA is valued at what the holder would +# get by withdrawing it, with no deduction for expenses of sale (ADM +# H1656-H1658; DMG 29662-29664, 52662, 84748-84750). - name: Case 1, a lodger's cash ISA stays out of the main benefit unit's capital. period: 2025 @@ -75,9 +78,9 @@ # The formula subtracts the child's 6,000 from savings 9,000 plus # share_like_capital 6,000 and allocates the remaining 9,000 by claimant # counts: 6,000 to the parents and 3,000 to the child's unit, which adds - # the 6,000 ISA less 10%, 5,400. - uc_assessable_capital: [6_000, 8_400] - housing_benefit_assessable_capital: [6_000, 8_400] + # the 6,000 ISA at face value. + uc_assessable_capital: [6_000, 9_000] + housing_benefit_assessable_capital: [6_000, 9_000] - name: Case 3, an adult child's ISA inside corporate wealth stays out of the parents' capital. period: 2025 @@ -107,10 +110,10 @@ share_like_capital: 9_000 # The formula subtracts the child's 6,000 ISA from corporate wealth # 9,000, values the remaining 3,000 less 10% at 2,700 and allocates it: - # 1,800 to the parents and 900 to the child's unit, which adds the ISA - # less 10%, 5,400. - uc_assessable_capital: [1_800, 6_300] - housing_benefit_assessable_capital: [1_800, 6_300] + # 1,800 to the parents and 900 to the child's unit, which adds the 6,000 + # ISA at face value. + uc_assessable_capital: [1_800, 6_900] + housing_benefit_assessable_capital: [1_800, 6_900] - name: Case 4, a parent's Income Support claim does not count an adult child's cash ISA. period: 2025 @@ -187,8 +190,8 @@ savings: 2_000 output: # The parent's claiming unit takes the 2,000 of savings; the child's unit - # counts the ISA less 10%, 4,500. - esa_income_assessable_capital: [2_000, 4_500] + # counts the 5,000 ISA at face value. + esa_income_assessable_capital: [2_000, 5_000] - name: Case 7, a pensioner couple's Pension Credit counts their own ISAs and not a lodger's. period: 2025 @@ -217,8 +220,8 @@ # The formula subtracts all three balances from savings 4,000, cash_isa # 9,000 and share_like_capital 2,000, and allocates the remaining 4,000 # between the two pension-age adults. The couple's unit adds their own - # 3,000 cash ISA and the 2,000 stocks and shares ISA less 10%, 1,800. - pension_credit_assessable_capital: [8_800, 0] + # 3,000 cash ISA and 2,000 stocks and shares ISA at face value. + pension_credit_assessable_capital: [9_000, 0] - name: Case 8, a dependent child's junior ISA counts in no benefit unit. period: 2025 @@ -277,9 +280,9 @@ # Joint claimants' combined capital (WRA 2012 s 5(2)(a)): the formula # allocates savings of 6,000 by claimant counts, 4,000 to the couple and # 2,000 to the lodger, and the couple's unit adds their 4,000 cash ISA - # and the 3,000 stocks and shares ISA less 10%, 2,700. - uc_assessable_capital: [10_700, 2_000] - housing_benefit_assessable_capital: [10_700, 2_000] + # and the 3,000 stocks and shares ISA at face value. + uc_assessable_capital: [11_000, 2_000] + housing_benefit_assessable_capital: [11_000, 2_000] - name: Case 10, a household total above the balances keeps the rest in the pool. period: 2025 @@ -377,7 +380,7 @@ age: 30 lodger: age: 30 - stocks_and_shares_isa_balance: 34_000 + stocks_and_shares_isa_balance: 30_600 benunits: tenant_unit: members: tenant @@ -387,16 +390,15 @@ household: members: [tenant, lodger] output: - # The ISA less 10%, 30,600, exceeds reg 18's 16,000 limit. Pooling it - # would give each claimant 15,300, within the limit. The formula - # attributes it to its holder. + # The ISA of 30,600 exceeds reg 18's 16,000 limit. Pooling it would give + # each claimant 15,300, within the limit. The formula attributes it to + # its holder. uc_assessable_capital: [0, 30_600] # Cases 14 to 17: where balances exceed a household total, the model counts # exactly the total, so a holder at a capital limit or a tariff threshold -# stays on its boundary. In Cases 14 and 15 the stocks and shares total, less -# 10% and rounded to the nearest penny (UC Regs 2013 reg 6(1)), comes to the -# boundary: 90% of 17,777.78 is 16,000.002 and 90% of 6,666.67 is 6,000.003. +# stays on its boundary. In Cases 14 and 15 the stocks and shares total is the +# boundary itself, since a stocks and shares ISA counts at face value. # The model stores amounts in float32 (spacing 0.0009765625 at 16,000), and # absolute_error_margin 0 fails on one unit in the last place. @@ -426,10 +428,10 @@ cash_isa: 16_000 stocks_home: members: stocks_holder - stocks_and_shares_isa: 17_777.78 + stocks_and_shares_isa: 16_000 output: cash_isa_countable_capital: [16_000, 0] - stocks_and_shares_isa_countable_capital: [0, 17_777.78] + stocks_and_shares_isa_countable_capital: [0, 16_000] # WRA 2012 s 5(1)(a) requires capital not greater than the amount reg # 18(1)(a) prescribes, 16,000, so capital of exactly 16,000 keeps # entitlement. Reg 72(1) deems 4.35 a month for each 250 above 6,000: @@ -464,10 +466,10 @@ cash_isa: 6_000 stocks_home: members: stocks_holder - stocks_and_shares_isa: 6_666.67 + stocks_and_shares_isa: 6_000 output: cash_isa_countable_capital: [6_000, 0] - stocks_and_shares_isa_countable_capital: [0, 6_666.67] + stocks_and_shares_isa_countable_capital: [0, 6_000] # Reg 72(1) deems no income from capital of 6,000 or less. uc_assessable_capital: [6_000, 6_000] uc_tariff_income: [0, 0] @@ -578,8 +580,8 @@ share_like_capital: 100 output: stocks_and_shares_isa_countable_capital: 100 - # UC counts the 100 less 10%. - uc_assessable_capital: 90 + # UC counts the 100 at face value. + uc_assessable_capital: 100 - name: Case 19, a child's ISA counts in no unit when the parent reports the family's capital. period: 2025 From df8c1ea79ca095126723fee8b1ba7e62e62a92fa Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 12 Nov 2026 09:31:38 -0500 Subject: [PATCH 10/14] Value the share-like parts separately in main's ISA property tests Main's tests valued all of share_like_capital, and each stocks and shares ISA, at 90%. On this branch only share_like_capital_with_sale_expenses takes the deduction, and the ISA person source comes out of share_like_capital_without_sale_expenses at face value. The helpers now value each part by whether the programme's sale_expenses.sources lists it, and the hand-worked cases follow: the producer-shape households give UC capital of 10,900, 8,950, 14,000 and 11,000, and the list-reform test drops share_like_capital_without_sale_expenses, the source that holds the ISA. Co-Authored-By: Claude Opus 5.5 --- .../tests/test_person_isa_capital.py | 134 ++++++++++-------- 1 file changed, 73 insertions(+), 61 deletions(-) diff --git a/policyengine_uk/tests/test_person_isa_capital.py b/policyengine_uk/tests/test_person_isa_capital.py index 5ab33ba7e3..669c441b9a 100644 --- a/policyengine_uk/tests/test_person_isa_capital.py +++ b/policyengine_uk/tests/test_person_isa_capital.py @@ -18,10 +18,14 @@ Credit holders outside a pension-age unit), equals savings, cash_isa and share_like_capital together, up to float32 rounding of the remainder's shares and each programme's penny rounding. Each programme values - share_like_capital, and each stocks and shares ISA it moves out of it, at - its sale-expense share (90%), and savings and cash ISAs at face value. Where balances exceed a total, the holdings sum to it exactly, so - that source leaves nothing in the remainder: an adult with no ISA counts - exactly the capital they count without the other members' ISAs. + share_like_capital_with_sale_expenses (directly held shares, and all of + an unitemised corporate_wealth) at its sale-expense share (90%), and + share_like_capital_without_sale_expenses (unit and investment trusts and + stocks and shares ISAs), each stocks and shares ISA it moves out of that + part, savings and cash ISAs at face value. Where balances exceed a total, + the holdings sum to it exactly, so that source leaves nothing in the + remainder: an adult with no ISA counts exactly the capital they count + without the other members' ISAs. 2. Where the balances' stored sum exceeds the total, the holdings sum to the total exactly, each in proportion to its balance within the step invariant 7 gives; otherwise each member counts their balance exactly. @@ -83,6 +87,10 @@ } MEANS_TEST_CAPITAL = (*CAPITAL, "council_tax_reduction_assessable_capital") ISA_SOURCES = tuple(HOUSEHOLD_SOURCE_OF) +SHARE_LIKE_PARTS = ( + "share_like_capital_with_sale_expenses", + "share_like_capital_without_sale_expenses", +) BALANCE = { "cash_isa_countable_capital": "cash_isa_balance", "stocks_and_shares_isa_countable_capital": "stocks_and_shares_isa_balance", @@ -394,12 +402,12 @@ def test_household_only_data_keep_todays_capital(): assert np.array_equal( simulation.calculate(name, year), before.calculate(name, year) ), (name, year) - # The first household's pool: savings 3,000, cash_isa 4,000 and - # corporate_wealth 5,000 (which holds the 2,000 ISA) less 10%, 4,500, - # shared by three claimants, two of them the couple. UC rounds each to - # the nearest penny. + # The first household's pool: savings 3,000, cash_isa 4,000, and + # corporate_wealth 5,000, which holds the 2,000 ISA at face value and + # 3,000 of other shares less 10%, 2,700: 11,700 shared by three + # claimants, two of them the couple. uc = simulation.calculate("uc_assessable_capital", YEAR) - assert list(uc[:2]) == pytest.approx([7_666.67, 3_833.33], abs=0.001) + assert list(uc[:2]) == pytest.approx([7_800, 3_900], abs=0.001) def test_both_forms_in_one_dataset_add_up_to_the_stored_total(): @@ -492,11 +500,20 @@ def test_both_forms_in_one_dataset_add_up_to_the_stored_total(): ] -def _household_capital(simulation, year, share=1): +def _household_capital(simulation, year, variable=None): + """Savings, cash ISAs and share-like capital, as ``variable`` values them. + + With no ``variable``, at market value. + """ + share_like = sum( + (_share_counted(variable, part) if variable else 1) + * simulation.calculate(part, year) + for part in SHARE_LIKE_PARTS + ) return ( simulation.calculate("savings", year) + simulation.calculate("cash_isa", year) - + share * simulation.calculate("share_like_capital", year) + + share_like ) @@ -522,23 +539,20 @@ def test_person_balances_without_household_totals_count_with_their_holders(): simulation.calculate("share_like_capital", year), simulation.calculate("corporate_wealth", year), ) - holdings = _household_capital( - simulation, year, _share_counted("uc_assessable_capital") - ) + holdings = _household_capital(simulation, year, "uc_assessable_capital") uc = simulation.calculate("uc_assessable_capital", year) assert np.bincount(benunit_household, weights=uc) == pytest.approx( holdings, rel=1e-6 ) - # Savings 7,000 and 2,000 of non-ISA shares less 10%, 1,800, make the - # first pool, 2,933.33 for each claimant. The couple adds a 3,000 cash ISA - # and a 2,000 stocks and shares ISA less 10% (1,800), and the other unit a - # 5,000 cash ISA and a 1,000 one less 10% (900). The second pool, savings - # 12,000 and 3,000 of trusts less 10% (2,700), gives the parents 9,800 - # and their son 4,900 in UC, to which they add 4,000 and 5,400 of ISAs; - # the pension-age parents count all 14,700 and their 4,000 in Pension - # Credit. UC rounds to the nearest penny, and the legacy programmes - # round down. - expected_uc = [10_666.67, 8_833.33, 13_800, 10_300] + # Savings 7,000, 1,500 of directly held shares less 10%, 1,350, and 500 + # of trusts at face value make the first pool, 2,950 for each claimant. + # The couple adds a 3,000 cash ISA and a 2,000 stocks and shares ISA, and + # the other unit a 5,000 cash ISA and a 1,000 stocks and shares ISA, all + # at face value. The second pool, savings 12,000 and 3,000 of trusts, + # gives the parents 10,000 and their son 5,000 in UC, to which they add + # 4,000 and 6,000 of ISAs; the pension-age parents count all 15,000 and + # their 4,000 in Pension Credit. + expected_uc = [10_900, 8_950, 14_000, 11_000] assert list(simulation.calculate("uc_assessable_capital", YEAR)) == pytest.approx( expected_uc, abs=0.001 ) @@ -548,7 +562,7 @@ def test_person_balances_without_household_totals_count_with_their_holders(): assert list(capital[:2]) == pytest.approx(expected_uc[:2], abs=0.011), name assert list( simulation.calculate("pension_credit_assessable_capital", YEAR) - ) == pytest.approx([0, 0, 18_700, 0], abs=0.001) + ) == pytest.approx([0, 0, 19_000, 0], abs=0.001) # One benefit unit each, with a child: the adults' cash and stocks and shares @@ -726,35 +740,31 @@ def _check_counted_isas(simulation): return counted -def _share_counted(variable): - """The share of share_like_capital's market value ``variable`` counts. +def _share_counted(variable, source): + """The share of household ``source``'s market value ``variable`` counts. - The programme counts share_like_capital, and each stocks and shares ISA - balance it moves out of it, less its sale-expense rate where its - ``sale_expenses.sources`` lists share_like_capital. + The programme counts ``source``, and each person ISA it moves out of it, + less its sale-expense rate where its ``sale_expenses.sources`` lists + ``source``. """ capital = _node(CAPITAL[variable]) date = f"{YEAR}-01-01" - if "share_like_capital" in capital.sale_expenses.sources(date): + if source in capital.sale_expenses.sources(date): return 1 - capital.sale_expenses.rate(date) return 1 -# The share of each ISA person source's value a programme counts, given the -# share it counts of share_like_capital. -def _isa_shares(share): +# The share of each ISA person source's value a programme counts: the share +# it counts of the household source that holds it. +def _isa_shares(variable): return { - "cash_isa_countable_capital": 1, - "stocks_and_shares_isa_countable_capital": share, + source: _share_counted(variable, HOUSEHOLD_SOURCE_OF[source]) + for source in ISA_SOURCES } -def _holdings(simulation, share=1): - return ( - simulation.calculate("savings", YEAR) - + simulation.calculate("cash_isa", YEAR) - + share * simulation.calculate("share_like_capital", YEAR) - ) +def _holdings(simulation, variable=None): + return _household_capital(simulation, YEAR, variable) @SITUATION_SETTINGS @@ -775,8 +785,7 @@ def test_a_pound_counts_once_in_working_age_means_tests(units, holdings): "jsa_income_assessable_capital", "esa_income_assessable_capital", ): - share = _share_counted(name) - weights = _isa_shares(share) + weights = _isa_shares(name) uncounted = sum( (weights[source] * amount * dependants).sum() for source, amount in counted.items() @@ -785,7 +794,7 @@ def test_a_pound_counts_once_in_working_age_means_tests(units, holdings): # Float32 shares of the remainder, and each valuation's penny # rounding, come to within a few pence. assert capital.sum() + uncounted == pytest.approx( - _holdings(simulation, share)[0], rel=1e-5, abs=0.05 + _holdings(simulation, name)[0], rel=1e-5, abs=0.05 ), name # Each unit counts at least its own claimant's and partner's ISAs. own = sum( @@ -901,8 +910,7 @@ def test_a_pound_counts_once_in_pension_credit(households): > 0 ) counts = simulation.calculate("is_claimant_or_partner", YEAR) & in_pension_unit - share = _share_counted("pension_credit_assessable_capital") - weights = _isa_shares(share) + weights = _isa_shares("pension_credit_assessable_capital") uncounted = sum( _by_household(simulation, "person", weights[source] * amount * ~counts) for source, amount in counted.items() @@ -911,7 +919,9 @@ def test_a_pound_counts_once_in_pension_credit(households): # Float32 shares of the remainder, and each valuation's penny rounding, # come to within a few pence. assert _by_household(simulation, "benunit", capital) + uncounted == pytest.approx( - _holdings(simulation, share), rel=1e-5, abs=0.05 + _holdings(simulation, "pension_credit_assessable_capital"), + rel=1e-5, + abs=0.05, ) if households is STORED_TOTALS: # The last household's ISA holdings sum exactly to its totals, so its @@ -1075,28 +1085,30 @@ def test_reforms_to_either_list_keep_each_isa_with_its_household_source(): def capital(name): return list(simulation.calculate(name, YEAR)) - # The lodger's unit counts the 10,000 cash ISA and the 4,000 stocks and - # shares ISA less 10% (3,600), and half the 2,000 of savings. - assert capital("uc_assessable_capital") == [1_000, 14_600] - assert capital("housing_benefit_assessable_capital") == [1_000, 14_600] + # The lodger's unit counts the 10,000 cash ISA, the 4,000 stocks and + # shares ISA at face value, and half the 2,000 of savings. + assert capital("uc_assessable_capital") == [1_000, 15_000] + assert capital("housing_benefit_assessable_capital") == [1_000, 15_000] sources = list(_node(uc_path + ".sources")(f"{YEAR}-01-01")) # Dropping cash_isa from UC's sources: savings 2,000 shared, and the - # lodger keeps their stocks and shares ISA less 10%. Dropping - # share_like_capital: the 10,000 cash ISA stays theirs. + # lodger keeps their stocks and shares ISA. Dropping + # share_like_capital_without_sale_expenses, which holds that ISA: the + # 10,000 cash ISA stays theirs. for dropped, expected in ( - ("cash_isa", [1_000, 4_600]), - ("share_like_capital", [1_000, 11_000]), + ("cash_isa", [1_000, 5_000]), + ("share_like_capital_without_sale_expenses", [1_000, 11_000]), ): + assert dropped in sources, dropped kept = [name for name in sources if name != dropped] with _law(simulation, uc_path + ".sources", kept): assert capital("uc_assessable_capital") == expected, dropped # Emptying UC's person_sources returns both ISAs to the pool: savings - # 2,000, the cash ISA and the stocks and shares ISA less 10%, 15,600 in - # all, shared by two claimants. Housing Benefit keeps its own lists. + # 2,000 and the two ISAs, 16,000 in all, shared by two claimants. + # Housing Benefit keeps its own lists. with _law(simulation, uc_path + ".person_sources", []): - assert capital("uc_assessable_capital") == [7_800, 7_800] - assert capital("housing_benefit_assessable_capital") == [1_000, 14_600] - assert capital("uc_assessable_capital") == [1_000, 14_600] + assert capital("uc_assessable_capital") == [8_000, 8_000] + assert capital("housing_benefit_assessable_capital") == [1_000, 15_000] + assert capital("uc_assessable_capital") == [1_000, 15_000] @pytest.mark.parametrize("variable", CAPITAL) From 3fe76ee3e62480972a5b9d57a1bd6773e8d1e1a3 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Fri, 13 Nov 2026 07:02:58 -0500 Subject: [PATCH 11/14] Allow float32's step in the itemised-holdings means-test property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test checked each total to within £0.011, and CI at df8c1ea79 failed it. The engine holds totals in float32. Its float32 sum can round a penny under the exact total, which the test's docstring allows, and it then stores that figure to float32's step, which the £0.011 bound didn't allow for above about £16,000. CI drew a household the test expects at £16,834.13: the engine gives £16,834.12, held as 16,834.119, which is £0.0109 under, and the test's own float32 subtraction read £0.0117. The check now subtracts in float64 and allows a penny plus one float32 step at the expected value. Two households are pinned: CI's, and one expected at £37,747.34 that the engine holds as 37,747.328, which is £0.0119 under and fails the old bound in float64 too. Co-Authored-By: Claude Fable 5.2 --- .../tests/test_capital_share_components.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/policyengine_uk/tests/test_capital_share_components.py b/policyengine_uk/tests/test_capital_share_components.py index e91475b2c9..a6e7e57944 100644 --- a/policyengine_uk/tests/test_capital_share_components.py +++ b/policyengine_uk/tests/test_capital_share_components.py @@ -466,13 +466,22 @@ def test_a_disregarded_company_holding_leaves_the_part_with_sale_expenses(): # £1,000 of savings, £3,000 in a cash ISA, £3,000 of unit trusts and a £5,000 # stocks-and-shares ISA in full, and 90% of £4,000 of shares: £15,600. @example([(100_000, 300_000, 400_000, 300_000, 500_000, 30, False)]) +# Income Support counts £16,834.13 here. The engine gives £16,834.12, held +# in float32 as 16,834.119: £0.0109 under, or £0.0117 when the comparison +# itself runs in float32. +@example([(510_510, 1_046_019, 2_051, 437, 124_602, 30, True)]) +# Income Support counts £37,747.34 here, and the engine holds £37,747.33 as +# 37,747.328: £0.0119 under, a penny plus half of float32's step at that +# size (£0.0039). +@example([(1_813_184, 40_164, 988_571, 7_260, 1_024_413, 30, False)]) def test_itemised_holdings_are_valued_by_type_in_every_means_test(rows): """Given only itemised holdings, with the ISAs held as the person's own balances, every means test counts savings, a cash ISA, unit trusts and a stocks-and-shares ISA in full and directly held shares less 10%, rounded by the programme's rule. The engine adds the holdings in float32, which can move the shares' value by a fraction of a penny before valuation, so - each total is checked to within a penny.""" + each total is checked to within a penny plus float32's step at that + size.""" people, benunits, homes = {}, {}, {} for i, (savings, cash_isa, shares, trusts, isa, age, claims_uc) in enumerate(rows): people[f"p{i}"] = { @@ -506,4 +515,9 @@ def test_itemised_holdings_are_valued_by_type_in_every_means_test(rows): continue share_pence = (9 * shares + (0 if round_down else 5)) // 10 expected = (savings + cash_isa + trusts + isa + share_pence) / 100 - assert abs(values[i] - expected) <= 0.011, (variable, rows[i], values[i]) + tolerance = 0.01 + float(np.spacing(np.float32(expected))) + assert abs(float(values[i]) - expected) <= tolerance, ( + variable, + rows[i], + values[i], + ) From 690a562228006161e1f50c5121053b7398c52149 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 16 Nov 2026 05:31:03 -0500 Subject: [PATCH 12/14] Say the full ISA value rests on ADM H1656's silence on costs of sale The without_sale_expenses description and the changelog fragment now say the model counts a stocks and shares ISA at its full withdrawal value because H1656 says nothing about costs of sale, not that a paragraph exempts it. The description also notes that employee share options, which the survey asks about with employee shares, take the deduction as an approximation. A comment on COMPONENTS says every name on the exempt list must be one of them, since the formula reads only COMPONENTS to decide whether a household itemises. Co-Authored-By: Claude Opus 5.5 --- changelog.d/sale-expense-share-split.fixed.md | 2 +- .../gov/dwp/share_like_capital/without_sale_expenses.yaml | 8 ++++++-- .../wealth/share_like_capital_with_sale_expenses.py | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/changelog.d/sale-expense-share-split.fixed.md b/changelog.d/sale-expense-share-split.fixed.md index 70a719b327..7863885269 100644 --- a/changelog.d/sale-expense-share-split.fixed.md +++ b/changelog.d/sale-expense-share-split.fixed.md @@ -1 +1 @@ -Value share-like capital by asset type in every means test: directly held shares, and any `corporate_wealth` a dataset does not itemise, take the 10% sale-expense deduction; unit trusts (ADM H1673-H1674) and stocks and shares ISAs (ADM H1656) count at full value, as does the survey's combined unit and investment trust bucket, an approximation for its investment trusts. +Value share-like capital by asset type in every means test. Directly held shares, and any `corporate_wealth` a dataset does not itemise, take the 10% sale-expense deduction. Unit trusts count at full value (ADM H1673-H1674), as does the survey's combined unit and investment trust bucket, an approximation for its investment trusts. Stocks and shares ISAs count at their full withdrawal value, because ADM H1656 says nothing about costs of sale. diff --git a/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml b/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml index fa06ccc205..76b7c40c94 100644 --- a/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml +++ b/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml @@ -8,10 +8,14 @@ description: > investment trusts are quoted shares, which take the deduction (ADM H1665), and were 8.2% of the pooled funds held in stocks and shares ISAs at 5 April 2022 and 6.9% at 5 April 2025 (HMRC ISA Table 9.6). An ISA is valued at - what the holder would get by withdrawing it, and no ISA paragraph applies - the deduction (ADM H1656-H1658; DMG 29662-29664, 52662, 84748-84750). + what the holder would get by withdrawing it (ADM H1656-H1658; DMG + 29662-29664, 52662, 84748-84750). The model counts that value in full, a + reading that rests on ADM H1656 saying nothing about costs of sale. Everything else in share_like_capital takes the deduction: directly held shares, and on datasets that do not itemise it, all of corporate_wealth. + Directly held shares include employee shares and share options, which the + Wealth and Assets Survey asks about together, so share options also take + the deduction, an approximation. metadata: label: Share-like holdings without expenses of sale period: year diff --git a/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py b/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py index d5136dd2b3..bbd8b72f33 100644 --- a/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py +++ b/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py @@ -1,5 +1,10 @@ from policyengine_uk.model_api import * +# The share-like holdings a dataset can itemise. The formula treats a +# household as itemising only when one of these is positive, so every name in +# gov.dwp.share_like_capital.without_sale_expenses must be in this list. A +# reform that adds a holding outside it would leave a household that itemises +# only that holding with all of its share-like capital under the deduction. COMPONENTS = [ "directly_held_shares", "unit_and_investment_trusts", From d6cf32529fdc7a6d6802f9bd7f55ea98a46b388c Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 16 Nov 2026 05:31:03 -0500 Subject: [PATCH 13/14] Check that every sale-expense name is a counted capital source valued_capital reads only each programme's capital.sources, so a name on capital.sale_expenses.sources outside them is never valued. The property now asserts the sale list is a subset of the counted sources for all six programmes, which the intersection check alone could not see. Co-Authored-By: Claude Opus 5.5 --- policyengine_uk/tests/test_capital_valuation_properties.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/policyengine_uk/tests/test_capital_valuation_properties.py b/policyengine_uk/tests/test_capital_valuation_properties.py index 8c7a6fbaa0..3298677890 100644 --- a/policyengine_uk/tests/test_capital_valuation_properties.py +++ b/policyengine_uk/tests/test_capital_valuation_properties.py @@ -228,6 +228,13 @@ def check_valuation(units): assert node.sale_expenses.rate == LEGAL_RATE assert "savings" in node.sources counted = set(node.sources) + # Every name on the sale-expense list must be a counted source: + # valued_capital reads only node.sources, so a listed name outside + # them is never valued, and the intersection check below can't see it. + assert set(node.sale_expenses.sources) <= counted, ( + variable, + sorted(set(node.sale_expenses.sources) - counted), + ) assert set(node.sale_expenses.sources) & counted == ( SALE_EXPENSE_ASSETS & counted ), variable From 8f755b98176a7b1fe622457e98de593d2cd828ec Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 16 Nov 2026 06:48:29 -0500 Subject: [PATCH 14/14] Describe the share split in #1969's fragment, the ISA docs and test comments #1969's changelog fragment said the 10% reached all of share_like_capital, unit trusts included, "until the data separate them". It now names what takes the deduction after the split: land, property, directly held shares and any corporate_wealth a dataset does not itemise. The ISA docs named share_like_capital as the source the stocks and shares ISA balances leave. They now name share_like_capital_without_sale_expenses, and say every means test counts that part at withdrawal value. The test comments and the parameter description say the model reads ADM H1656's silence on costs of sale as no deduction, rather than saying H1656 rules one out. The COMPONENTS comment notes that share_like_capital sums the same names, and invariant 7 allows float32's step as well as a penny. Co-Authored-By: Claude Opus 5.5 --- changelog.d/sale-expense-share-split.fixed.md | 2 +- changelog.d/uc-capital-sale-expenses.fixed.md | 2 +- .../isa-inputs-and-capital-flows.md | 40 ++++++++++--------- .../without_sale_expenses.yaml | 2 +- .../dwp/capital_valuation_share_split.yaml | 5 ++- .../baseline/gov/dwp/person_isa_capital.yaml | 5 ++- .../tests/test_capital_share_components.py | 3 +- .../test_capital_valuation_properties.py | 5 ++- policyengine_uk/tests/test_isa_balances.py | 4 +- .../tests/test_stored_household_totals.py | 4 +- .../share_like_capital_with_sale_expenses.py | 2 + 11 files changed, 41 insertions(+), 33 deletions(-) diff --git a/changelog.d/sale-expense-share-split.fixed.md b/changelog.d/sale-expense-share-split.fixed.md index 7863885269..b1b35caba9 100644 --- a/changelog.d/sale-expense-share-split.fixed.md +++ b/changelog.d/sale-expense-share-split.fixed.md @@ -1 +1 @@ -Value share-like capital by asset type in every means test. Directly held shares, and any `corporate_wealth` a dataset does not itemise, take the 10% sale-expense deduction. Unit trusts count at full value (ADM H1673-H1674), as does the survey's combined unit and investment trust bucket, an approximation for its investment trusts. Stocks and shares ISAs count at their full withdrawal value, because ADM H1656 says nothing about costs of sale. +Value share-like capital by asset type in every means test. Directly held shares, and any `corporate_wealth` a dataset does not itemise, take the 10% sale-expense deduction. Unit trusts count at full value (ADM H1673-H1674), as does the survey's combined unit and investment trust bucket, an approximation for its investment trusts. Stocks and shares ISAs count at their full withdrawal value, a reading that rests on ADM H1656 saying nothing about costs of sale. diff --git a/changelog.d/uc-capital-sale-expenses.fixed.md b/changelog.d/uc-capital-sale-expenses.fixed.md index 02d0588143..102b57f784 100644 --- a/changelog.d/uc-capital-sale-expenses.fixed.md +++ b/changelog.d/uc-capital-sale-expenses.fixed.md @@ -1 +1 @@ -Value Universal Credit, Housing Benefit, Income Support, income-based JSA, income-related ESA and Pension Credit capital at market value less 10% where a sale would incur expenses and less any debt secured on the asset, as UC Regs 2013 reg. 49(1) and its legacy equivalents require. The 10% applies to land, property and share-like capital (share_like_capital), not to cash savings; share-like capital also holds unit trusts, which have no costs of sale, and in datasets built before the private pension split it holds pension wealth, so the deduction reaches those too until the data separate them. Adds secured-debt inputs for other residential property, non-residential property and land, and the council tax reduction formula deducts the debt secured on land from the land on its own household route. Each programme rounds a fraction of a penny in its capital calculations as its regulations require: to the nearest penny for Universal Credit (UC Regs 2013 reg. 6(1)) and Housing Benefit, and down for the legacy benefits and Pension Credit. The model works out a Lifetime ISA's surrender value from its balance and rounds it under the same rule, and keeps explicit Lifetime ISA capital inputs and reformed valuation formulas. +Value Universal Credit, Housing Benefit, Income Support, income-based JSA, income-related ESA and Pension Credit capital at market value less 10% where a sale would incur expenses and less any debt secured on the asset, as UC Regs 2013 reg. 49(1) and its legacy equivalents require. The 10% applies to land, property, directly held shares and all of a `corporate_wealth` that the dataset does not itemise, not to cash savings. Unitemised `corporate_wealth` can still fold in unit trusts, ISAs and, on datasets built before private pension wealth was split out, non-defined-benefit pension wealth. Adds secured-debt inputs for other residential property, non-residential property and land, and the council tax reduction formula deducts the debt secured on land from the land on its own household route. Each programme rounds a fraction of a penny in its capital calculations as its regulations require: to the nearest penny for Universal Credit (UC Regs 2013 reg. 6(1)) and Housing Benefit, and down for the legacy benefits and Pension Credit. The model works out a Lifetime ISA's surrender value from its balance and rounds it under the same rule, and keeps explicit Lifetime ISA capital inputs and reformed valuation formulas. diff --git a/docs/book/assumptions/isa-inputs-and-capital-flows.md b/docs/book/assumptions/isa-inputs-and-capital-flows.md index c6e0836479..c926b8cba1 100644 --- a/docs/book/assumptions/isa-inputs-and-capital-flows.md +++ b/docs/book/assumptions/isa-inputs-and-capital-flows.md @@ -114,21 +114,22 @@ shares ISA balances in their own benefit unit, through `cash_isa_countable_capital` and `stocks_and_shares_isa_countable_capital` in its `person_sources`, and excludes a dependant's balance, a child's junior ISA among them. The formulas subtract a household's counted balances from `cash_isa` -and `share_like_capital` before they allocate the remainder between benefit -units. Where the balances sum to less than the total the model holds for the -year, the remainder stays in the pool. Where their stored sum exceeds the total, -the model scales them to sum to the total exactly: it rounds each proportional -share down to a whole step of the total's float32 spacing and gives the steps -left over, one each, to the members whose shares lost most in rounding. The pool -then keeps nothing of that total; for totals under £268 million, each holding -passes a capital limit only where its proportional share does; and a sole holder -whose balance reaches the total counts exactly the total. For stocks and shares -ISAs the model takes the smaller of `stocks_and_shares_isa` and -`share_like_capital` as the total. Data that store only household totals hold no -balances, so the pool keeps the whole total. The formulas count a balance only -while the programme's `sources` lists the household source that includes it, so -a reform that drops `cash_isa` or `share_like_capital` from `sources` drops the -balances with it. For a Universal Credit unit that reports its capital +and `share_like_capital_without_sale_expenses` before they allocate the +remainder between benefit units. Where the balances sum to less than the total +the model holds for the year, the remainder stays in the pool. Where their +stored sum exceeds the total, the model scales them to sum to the total exactly: +it rounds each proportional share down to a whole step of the total's float32 +spacing and gives the steps left over, one each, to the members whose shares +lost most in rounding. The pool then keeps nothing of that total; for totals +under £268 million, each holding passes a capital limit only where its +proportional share does; and a sole holder whose balance reaches the total +counts exactly the total. For stocks and shares ISAs the model takes the smaller +of `stocks_and_shares_isa` and `share_like_capital` as the total. Data that +store only household totals hold no balances, so the pool keeps the whole total. +The formulas count a balance only while the programme's `sources` lists the +household source that includes it, so a reform that drops `cash_isa` or +`share_like_capital_without_sale_expenses` from `sources` drops the balances +with it. For a Universal Credit unit that reports its capital (`benunit_reported_capital` or `uc_reported_capital`, zero or more), the formula leaves the unit's claimant's and partner's ISAs in the pool and subtracts the report, as it does for their company holdings. A nonnegative @@ -146,10 +147,11 @@ replaces covered components rather than adding them again. For example, £5,000 savings and a £3,000 ordinary cash ISA give £8,000 UC capital. [UC regulation 72](https://www.legislation.gov.uk/uksi/2013/376/regulation/72) then gives eight £4.35 monthly tariff units, or £34.80 a month. Stocks-and-shares -ISA holdings remain within `share_like_capital`. The separate existing -`lifetime_isa_countable_capital` valuation is unchanged. It does not gain -transaction-level first-home or terminal-illness valuation from the new flow -inputs. +ISA holdings remain within `share_like_capital`, in its part without sale +expenses, which every means test counts at withdrawal value. The separate +existing `lifetime_isa_countable_capital` valuation is unchanged. It does not +gain transaction-level first-home or terminal-illness valuation from the new +flow inputs. Population estimates depend on the input balances, reported-capital overrides, benefit take-up and calibrated weights as well as the capital diff --git a/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml b/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml index 76b7c40c94..c124928df2 100644 --- a/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml +++ b/policyengine_uk/parameters/gov/dwp/share_like_capital/without_sale_expenses.yaml @@ -14,7 +14,7 @@ description: > Everything else in share_like_capital takes the deduction: directly held shares, and on datasets that do not itemise it, all of corporate_wealth. Directly held shares include employee shares and share options, which the - Wealth and Assets Survey asks about together, so share options also take + Wealth and Assets Survey records as one total, so share options also take the deduction, an approximation. metadata: label: Share-like holdings without expenses of sale diff --git a/policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml b/policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml index 1563961bed..d99438122f 100644 --- a/policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/dwp/capital_valuation_share_split.yaml @@ -9,8 +9,9 @@ # have no costs of sale (ADM H1673-H1674; DMG 29680-29681, 52680-52681, # 84771-84772; HBGM W1.530-W1.531), and the survey bucket of unit and # investment trusts is treated the same. An ISA is valued at what the person -# would get by withdrawing it, with no 10% (ADM H1656; DMG 29662, 52662, -# 84748). Expected values are worked by hand from those rules. +# would get by withdrawing it (ADM H1656; DMG 29662, 52662, 84748), and the +# model takes no 10% from it because H1656 says nothing about costs of sale. +# Expected values are worked by hand from those rules. - name: UC unsplit corporate_wealth keeps the flat 10% treatment period: 2026 diff --git a/policyengine_uk/tests/policy/baseline/gov/dwp/person_isa_capital.yaml b/policyengine_uk/tests/policy/baseline/gov/dwp/person_isa_capital.yaml index 86162714b5..cf77891e80 100644 --- a/policyengine_uk/tests/policy/baseline/gov/dwp/person_isa_capital.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/dwp/person_isa_capital.yaml @@ -15,8 +15,9 @@ # ESA Regs 2008 reg 113; SPC Regs 2002 reg 19). It counts savings, cash ISAs # and each stocks and shares ISA balance the formula moves out of # share_like_capital at face value: an ISA is valued at what the holder would -# get by withdrawing it, with no deduction for expenses of sale (ADM -# H1656-H1658; DMG 29662-29664, 52662, 84748-84750). +# get by withdrawing it (ADM H1656-H1658; DMG 29662-29664, 52662, +# 84748-84750), and the model reads H1656's silence on costs of sale as no +# deduction. - name: Case 1, a lodger's cash ISA stays out of the main benefit unit's capital. period: 2025 diff --git a/policyengine_uk/tests/test_capital_share_components.py b/policyengine_uk/tests/test_capital_share_components.py index a6e7e57944..00cab177dc 100644 --- a/policyengine_uk/tests/test_capital_share_components.py +++ b/policyengine_uk/tests/test_capital_share_components.py @@ -26,7 +26,8 @@ 7. Valuation by type: given only itemised holdings, with the ISAs held as the person's own balances, all six means tests count savings, cash ISAs, unit trusts and stocks and shares ISAs in full and directly held shares less - 10%, rounded by each programme's rule, to within a penny. + 10%, rounded by each programme's rule, to within a penny plus float32's + step at that size. """ import numpy as np diff --git a/policyengine_uk/tests/test_capital_valuation_properties.py b/policyengine_uk/tests/test_capital_valuation_properties.py index 3298677890..6ea388515d 100644 --- a/policyengine_uk/tests/test_capital_valuation_properties.py +++ b/policyengine_uk/tests/test_capital_valuation_properties.py @@ -229,8 +229,9 @@ def check_valuation(units): assert "savings" in node.sources counted = set(node.sources) # Every name on the sale-expense list must be a counted source: - # valued_capital reads only node.sources, so a listed name outside - # them is never valued, and the intersection check below can't see it. + # valued_capital values only the names in node.sources, so it never + # values a listed name outside them, and the intersection check below + # can't see one. assert set(node.sale_expenses.sources) <= counted, ( variable, sorted(set(node.sale_expenses.sources) - counted), diff --git a/policyengine_uk/tests/test_isa_balances.py b/policyengine_uk/tests/test_isa_balances.py index 588d221b6c..9e98ba3004 100644 --- a/policyengine_uk/tests/test_isa_balances.py +++ b/policyengine_uk/tests/test_isa_balances.py @@ -63,8 +63,8 @@ def test_stored_household_totals_without_person_balances_project_with_savings(): assert shares == pytest.approx(2_000.0 * growth) # Savings, the cash ISA and the stocks-and-shares ISA all reach the # capital pool at their value: an ISA is valued at what its holder would - # get by withdrawing it, with no deduction for expenses of sale (ADM - # H1656), so the itemised ISA sits in the part of share_like_capital + # get by withdrawing it (ADM H1656), which says nothing about costs of + # sale, so the itemised ISA sits in the part of share_like_capital # without them. without = simulation.calculate("share_like_capital_without_sale_expenses", 2027) with_expenses = simulation.calculate("share_like_capital_with_sale_expenses", 2027) diff --git a/policyengine_uk/tests/test_stored_household_totals.py b/policyengine_uk/tests/test_stored_household_totals.py index 8fd7c15b46..265999eaf3 100644 --- a/policyengine_uk/tests/test_stored_household_totals.py +++ b/policyengine_uk/tests/test_stored_household_totals.py @@ -218,8 +218,8 @@ def test_stored_household_totals_grow_past_the_projection_horizon(): ) # Savings, the cash ISA and the stocks-and-shares ISA make up the capital, # each at its value. A decision maker values an ISA at what its holder - # would get by withdrawing it, with no deduction for expenses of sale (ADM - # H1656), so the stored stocks-and-shares ISA reaches the capital through + # would get by withdrawing it (ADM H1656), which says nothing about costs + # of sale, so the stored stocks-and-shares ISA reaches the capital through # share_like_capital_without_sale_expenses. The parts grow alike, so # capital keeps the same ratio to savings in every year: 6 for this # household. diff --git a/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py b/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py index bbd8b72f33..00e7e484f3 100644 --- a/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py +++ b/policyengine_uk/variables/household/wealth/share_like_capital_with_sale_expenses.py @@ -5,6 +5,8 @@ # gov.dwp.share_like_capital.without_sale_expenses must be in this list. A # reform that adds a holding outside it would leave a household that itemises # only that holding with all of its share-like capital under the deduction. +# share_like_capital sums the same three names, so such a reform must add +# the holding there too. COMPONENTS = [ "directly_held_shares", "unit_and_investment_trusts",