Skip to content

Remove pass-through allowance variables (#414)#1640

Merged
MaxGhenis merged 4 commits intomainfrom
fix/remove-pass-through-allowance-variables-414
May 2, 2026
Merged

Remove pass-through allowance variables (#414)#1640
MaxGhenis merged 4 commits intomainfrom
fix/remove-pass-through-allowance-variables-414

Conversation

@vahid-ahmadi
Copy link
Copy Markdown
Collaborator

Summary

  • Removes trading_allowance, property_allowance, and dividend_allowance — three Variables whose formulas only returned the same-named parameter value. Callers (trading_allowance_deduction, property_allowance_deduction, taxable_property_income, taxed_dividend_income) now read those parameters directly.
  • Fixes the taxable_self_employment_income_deductions parameter list to reference trading_allowance_deduction (the amount capped at self_employment_income) rather than the raw trading_allowance. Pre-existing max_(0, ...) meant outputs were already equivalent; this makes the intent explicit.
  • Moves tests that injected these variables as inputs to override the corresponding parameter path instead. Drops the now-meaningless test that asserted the default dividend_allowance value.

Closes #414.

Test plan

  • policyengine-core test policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax -c policyengine_uk — 9 failed / 145 passed, identical 9 preexisting failures on main (gift-aid/PA taper, pension annual allowance, marriage allowance); one fewer pass corresponds to the deleted dividend_allowance output assertion.
  • Full CI run (make test) on this branch

🤖 Generated with Claude Code

`trading_allowance`, `property_allowance`, and `dividend_allowance`
variables each just returned their same-named parameter. Callers
(`trading_allowance_deduction`, `property_allowance_deduction`,
`taxable_property_income`, `taxed_dividend_income`) now read the
parameter directly.

The `taxable_self_employment_income` deductions list now references
`trading_allowance_deduction` (the capped amount actually deductible
against self-employment income) instead of the raw allowance. This
gives identical taxable-income outputs since the pre-existing
`max_(0, ...)` clamp already absorbed any over-deduction.

Tests that previously injected these variables as inputs now override
the corresponding parameter path. The obsolete test that asserted the
default `dividend_allowance` value is dropped since the variable no
longer exists.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vahid-ahmadi vahid-ahmadi requested a review from MaxGhenis April 21, 2026 11:14
@vahid-ahmadi vahid-ahmadi self-assigned this Apr 21, 2026
Copy link
Copy Markdown
Collaborator

@MaxGhenis MaxGhenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holding this one because a first-party data pipeline still emits two of the variables being removed. policyengine-uk-data currently sets \ and \ in ; after this PR those names no longer exist in PE-UK. I do not think we should merge the model removal until the companion uk-data cleanup lands and verifies the generated SPI/enhanced datasets still load against the new variable set. The formula changes themselves look reasonable; the blocker is the cross-repo dataset contract.

@MaxGhenis
Copy link
Copy Markdown
Collaborator

Clarifying the review body above: the first-party policyengine-uk-data pipeline still writes these removed PE-UK variable names in policyengine_uk_data/datasets/spi.py:

  • trading_allowance
  • property_allowance

So the blocker is not the formula simplification itself; it is merging the PE-UK variable removal before the companion uk-data cleanup verifies SPI/enhanced datasets no longer emit or rely on those columns.

@MaxGhenis
Copy link
Copy Markdown
Collaborator

Fixed the blocker two ways:

  1. Pushed f41d3b7 here so taxable_property_income now uses the concrete property_allowance_deduction variable, matching taxable_self_employment_income's use of trading_allowance_deduction. That keeps pre-net datasets able to override the actual deduction without reintroducing policy-parameter pass-through inputs.
  2. Opened companion uk-data PR Use SPI allowance deduction overrides policyengine-uk-data#385, which moves SPI overrides from trading_allowance / property_allowance to trading_allowance_deduction / property_allowance_deduction and adds a regression test.

Local checks here:

  • uv run policyengine-core test policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/bases/taxable_property_income.yaml policyengine_uk/tests/policy/baseline/gov/hmrc/income_tax/bases/taxable_self_employment_income.yaml -c policyengine_uk -> 23 passed
  • uv run ruff check policyengine_uk/variables/gov/hmrc/income_tax/bases/taxable_property_income.py -> passed

Copy link
Copy Markdown
Collaborator

@MaxGhenis MaxGhenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed after the companion uk-data fix. This now removes the pass-through allowance variables while keeping the concrete deduction variables as the data override point; taxable_property_income uses property_allowance_deduction, matching the self-employment path. Local targeted YAML tests passed (23 cases), ruff passed, and GitHub CI is green.

@MaxGhenis MaxGhenis merged commit f44b543 into main May 2, 2026
9 checks passed
@MaxGhenis MaxGhenis deleted the fix/remove-pass-through-allowance-variables-414 branch May 2, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove allowance variables that are only parameters

2 participants