Repository navigation
Keep Working Tax Credit age and hours conditions on the same worker - #2472
Merged
Merged
Conversation
vahid-ahmadi
left a comment
Collaborator
There was a problem hiding this comment.
Looks right, fine to approve.
@juaristi22 the new formula matches the second condition of WTC Regulations 2002 reg 4(1) person by person, and the tests catch the pooling bug. One follow-up worth filing and two nits.
- should (follow-up, not this PR):
policyengine_uk/variables/gov/dwp/WTC_worker_element.py:14-15still pools hours withadd(benunit, period, ["weekly_hours"]), which sums every benefit unit member, children included. Reg 10 gives the 30-hour element where the person works 30 hours, or where a couple with a child works 30 hours between them with one working 16. So a childless couple where a disabled partner works 16 hours and the other works 16 hours now passesis_WTC_eligiblecorrectly but would still get the 30-hour element, and a child's hours can count towards it. Same defect class as #2042, so a separate issue would be cleaner than widening this PR. - nit:
policyengine_uk/variables/gov/dwp/is_WTC_eligible.py:55. Because the new formula is keyed to 2012-04-06, annual 2012 still runs the old pooled formula. The docs page says this, which is fine. Just flagging that a 2012 annual run will not show the fix. - nit:
policyengine_uk/variables/gov/dwp/is_WTC_eligible.py:82-84. For the third variation limb (a), the code requires the partner working 16 hours to be at least 16. The regulation puts the age test on "the person" claiming, not on the 16-hour worker. In practice both partners will be adults, so this makes no difference.
What I checked
- Read the full diff, PR body and issue #2042. Read reg 4(1) as at 6 April 2024 on legislation.gov.uk. Each limb of the first, second and third variations maps to one of
disabled_worker,older_worker,ordinary_worker,lone_parentorparents. Only claimant and partner hours count, so a child's hours are excluded. - Hand-computed three YAML expectations at 2024-25 rates with nil income: 60-year-old couple on 16 hours is basic 2,435 + couple 2,500 = 4,935; 25-year-old on 30 hours adds 1,015 for 5,950; disabled worker on 16 hours adds 3,935 for 8,870. All match.
- Ran
policyengine-core test .../tax_credits_working_hours.yaml -c policyengine_uk: 18 passed. Ran pytest ontest_working_tax_credit_eligibility_properties.py: 5 passed. - Reverted
is_WTC_eligible.pyto main: 5 of the 18 YAML cases fail, as expected. ruff checkandruff format --checkclean on the changed Python files.- Process:
2042.fixed.mdfragment, Reproducer and axiom lines present. Hosted CI is green. - Overlaps: #2475 also edits
docs/book/programs/gov/dwp/tax-credits.md, but a trial merge of the two heads is clean. No clash with other open PRs. - Not checked: the pre-2012 formula and the full test suite locally.
🤖 Generated with Claude Code
vahid-ahmadi
approved these changes
Oct 18, 2026
vahid-ahmadi
left a comment
Collaborator
There was a problem hiding this comment.
Approving, per my review above. Nits are optional.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2042.
Working Tax Credit now requires the same claimant or partner to meet the qualifying age or disability condition and work the required hours. This prevents a worker borrowing a nonworking partner’s age or disability, two ordinary 15-hour workers qualifying for the 30-hour route, and a child’s hours completing the parents’ combined-hours requirement. The parental 24-hour route and existing other-disabled-partner exception proxy remain.
The corrected formula starts on 6 April 2012, when the joint-claim variations were inserted into regulation 4. It uses source-referenced age parameters and preserves the earlier formula. Annual 2012 still selects the earlier method under native period selection. The disability and partner-exception flags retain their existing limitations as proxies for regulations 9 and 13; amount, take-up, reported-award and closure rules are unchanged.
Reproducer: policyengine_uk/tests/policy/baseline/finance/benefit/family/tax_credits_working_hours.yaml::A childless worker cannot borrow a nonworking partners age sixty
Validation: 68 checks passed: 18 new natural-input YAML cases, five composition/age-parameter cash controls and 45 existing regressions covering tax credits, closure, Pension Credit passports and childcare. The original code failed five eligibility cases and paid positive final WTC where zero was expected. Three historical probes encountered pre-existing missing parameters; they were excluded from the passing count, with native formula selection and preservation of the earlier method checked separately.
make formatand the focused affected-regression runner passed. The documentation build was not run for the prose-only clarification on the existing page; the full suite remains with hosted CI.Local validation used Python 3.13.14 / Core 3.32.27, versus locked Core 3.33.2. Hosted CI and human review remain pending. No population or RuleSpec parity result is claimed.
axiom: needed