Skip to content

Parse NIC Classes 2, 3 and 4 from OBR EFO Table 3.4#355

Merged
MaxGhenis merged 1 commit into
mainfrom
fix/obr-nic-classes
Apr 17, 2026
Merged

Parse NIC Classes 2, 3 and 4 from OBR EFO Table 3.4#355
MaxGhenis merged 1 commit into
mainfrom
fix/obr-nic-classes

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Summary

policyengine_uk_data/targets/sources/obr.py::_parse_nics only covered Class 1 Employee and Class 1 Employer NICs, omitting:

  • Class 2 (flat-rate self-employed)
  • Class 3 (voluntary)
  • Class 4 (self-employed profit-based)

That's ~£2-5B/yr of NIC receipts with no calibration target, which biased the model into pushing self-employment income downward to compensate and distorted reforms touching SE income.

This PR:

  • Adds rows for Classes 2, 3 and 4 in _parse_nics, emitting Targets with the matching policyengine_uk variable names (ni_class_2, ni_class_3, ni_class_4).
  • Switches the per-row lookup to a list of candidate labels so minor OBR wording variation (e.g. "Class 2 NICs" vs "Class 2 Self-Employed NICs") no longer silently skips a row.
  • Partial matches still produce useful targets — missing rows log a warning instead of aborting parsing.

Adds test_obr_nics.py, which drives the parser against an in-memory openpyxl workbook that mirrors OBR's Table 3.4 layout (canonical labels + the common wording variants).

Test plan

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

Finding U8 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 f06bc50 into main Apr 17, 2026
3 checks passed
@MaxGhenis MaxGhenis deleted the fix/obr-nic-classes 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