Skip to content

Parameterise VAT rate and ETB year in VAT imputation#354

Merged
MaxGhenis merged 2 commits intomainfrom
fix/vat-parameterize
Apr 17, 2026
Merged

Parameterise VAT rate and ETB year in VAT imputation#354
MaxGhenis merged 2 commits intomainfrom
fix/vat-parameterize

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

datasets/imputations/vat.py hardcoded three values that will drift:

  • CONSUMPTION_PCT_REDUCED_RATE = 0.03 ("from OBR's VAT page" with no URL or year).
  • CURRENT_VAT_RATE = 0.2 — "current" will not stay current.
  • etb.year == 2020 inline, with no way to rebuild on 2021 data that's already in the ETB file.

This PR:

  • Adds _get_vat_parameters(year) which reads the standard rate and reduced-rate share from policyengine_uk.parameters.gov.hmrc.vat keyed on year. Falls back to a VAT_RATE_BY_YEAR module dict and ultimately the statutory 2020 values so offline test environments still work.
  • Adds a year argument (and DEFAULT_ETB_YEAR = 2020 constant) on generate_etb_table and save_imputation_models.
  • Keeps the default behaviour identical — the checked-in vat.pkl stays fingerprint-compatible unless retrained.

Adds test_vat_parameters.py covering the parameter lookup, the module fallback, the year-filtering kwarg, and the rate sensitivity of the computed full_rate_vat_expenditure_rate.

Test plan

  • uv run pytest policyengine_uk_data/tests/test_vat_parameters.py -q passes.

Finding U7 from the bug hunt.

@MaxGhenis
Copy link
Copy Markdown
Contributor Author

Self-review: APPROVE. See /tmp/bug-hunt/reviews/uk-data-reviews.md for detail. (GitHub blocks self-approve, so leaving as comment.)

@MaxGhenis MaxGhenis merged commit 7a437f1 into main Apr 17, 2026
3 checks passed
@MaxGhenis MaxGhenis deleted the fix/vat-parameterize branch April 17, 2026 16:05
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.

1 participant