Fix children receiving negative Marriage Allowance (#1666)#1667
Merged
MaxGhenis merged 1 commit intoMay 9, 2026
Conversation
Children in a married benefit unit are assigned MaritalStatus.MARRIED and have tax_band == NONE, so they passed the Marriage Allowance eligibility checks. The transferable amount calculation then produced a negative value (their full PA minus zero adult-summed unused PA), which flowed into earned_taxable_income and generated phantom basic-rate income tax of 20% × £12,570 per child. Guard marriage_allowance with is_adult, clamp the eligible amount at zero, and fix partners_unused_personal_allowance to subtract the person's own unused PA only when they are an adult (mirrors the inclusion in the benunit sum). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
MaritalStatus.MARRIEDand tax bandNONE, so they cleared every Marriage Allowance gate.partners_unused_personal_allowancethen went negative for them (their own £12,570 PA minus zero adult-summed unused PA),marriage_allowancedid not clamp the negative through, andearned_taxable_incomeended up adding £12,570 of phantom income — taxed at 20% = £2,514 per child.marriage_allowance: gate eligibility onis_adultand clamp the eligible amount at>= 0.partners_unused_personal_allowance: subtract the person's own PA only when they are an adult (mirrors how the benunit sum is built), so non-adults get0rather than-pa.marital_statusandeligible_bandssemantics unchanged so other variables that depend on them are not affected.Test plan
marriage_allowance.yaml: a married benunit with two adults (£55k / £35k) and two children (ages 8, 3) —marriage_allowanceis[0, 0, 0, 0]andincome_taxis[9432, 4486, 0, 0].marriage_allowance.yamlcases still pass (no regression for the basic married-couple scenarios).gov/hmrc/income_tax/allowances/pass — the one failure (meets_marriage_allowance_income_conditions/regression for Add parameter for marriage allowance-eligible tax bands #395) reproduces onmainwithout these changes, so it is not caused by this PR.marriage_allowance = [0, 0, 0, 0],income_tax = [9432, 4486, 0, 0].🤖 Generated with Claude Code