diff --git a/changelog.d/qyp-terminal-date-19.fixed.md b/changelog.d/qyp-terminal-date-19.fixed.md new file mode 100644 index 0000000000..f6ffcb4951 --- /dev/null +++ b/changelog.d/qyp-terminal-date-19.fixed.md @@ -0,0 +1 @@ +- Placed the 1 September following a qualifying young person's 19th birthday from their date of birth, for Universal Credit and Pension Credit (UC Regs 2013 reg. 5(1)(b); SPC Regs 2002 reg. 4A(1)(b)). A 19-year-old in education now counts for Universal Credit by default in household calculations, as in the microdata, and Pension Credit applies the date, which it did not model. diff --git a/changelog.d/uc-pc-qyp-sixteen-route.fixed.md b/changelog.d/uc-pc-qyp-sixteen-route.fixed.md new file mode 100644 index 0000000000..7c8723f135 --- /dev/null +++ b/changelog.d/uc-pc-qyp-sixteen-route.fixed.md @@ -0,0 +1 @@ +- Counted a 16-year-old outside education as a Universal Credit and Pension Credit qualifying young person until the 1 September following their 16th birthday (UC Regs 2013 reg. 5(1)(a); SPC Regs 2002 reg. 4A(1)(a)), in any year that starts before that date. diff --git a/policyengine_uk/parameters/gov/dwp/pension_credit/guarantee_credit/child/eligibility/terminal_date_age_limit.yaml b/policyengine_uk/parameters/gov/dwp/pension_credit/guarantee_credit/child/eligibility/terminal_date_age_limit.yaml new file mode 100644 index 0000000000..09616dbd7b --- /dev/null +++ b/policyengine_uk/parameters/gov/dwp/pension_credit/guarantee_credit/child/eligibility/terminal_date_age_limit.yaml @@ -0,0 +1,9 @@ +description: Age from which Pension Credit qualifying young person status is limited to the period before the 1 September following the 19th birthday. +values: + 0001-01-01: 19 +metadata: + unit: year + label: Pension Credit qualifying young person terminal date age limit + reference: + - title: The State Pension Credit Regulations 2002 reg. 4A(1)(b) + href: https://www.legislation.gov.uk/uksi/2002/1792/regulation/4A diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/child_qualifying_young_person.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/child_qualifying_young_person.yaml index aaf0b00010..4b062a0214 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/child_qualifying_young_person.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/child_qualifying_young_person.yaml @@ -92,6 +92,9 @@ age: 19 age_started_or_accepted_current_education_or_training: 18 current_education: POST_SECONDARY + # Set explicitly: a person left unset takes the date fact's value, + # which is true for anyone under 20 on 6 October. + is_before_universal_credit_qualifying_young_person_terminal_date: false under_terminal_date_age_limit: age: 18 current_education: POST_SECONDARY diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/is_uc_work_allowance_eligible.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/is_uc_work_allowance_eligible.yaml index 4710360580..362a550cd7 100644 --- a/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/is_uc_work_allowance_eligible.yaml +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/family/universal_credit/work_allowance/is_uc_work_allowance_eligible.yaml @@ -79,7 +79,7 @@ output: is_uc_work_allowance_eligible: false -- name: Case 6, a nonqualifying 16-year-old does not create a work allowance. +- name: Case 6, a 16-year-old outside education past the reg. 5(1)(a) route does not create a work allowance. period: 2025 input: people: @@ -91,6 +91,7 @@ age: 16 is_in_non_advanced_education: false is_in_approved_training: false + is_before_first_september_following_16th_birthday: false uc_limited_capability_for_WRA: false benunits: benunit: @@ -98,6 +99,25 @@ output: is_uc_work_allowance_eligible: false +- name: Case 6a, a 16-year-old outside education in the reg. 5(1)(a) route creates a work allowance. + period: 2025 + input: + people: + person1: + age: 40 + is_parent: true + uc_limited_capability_for_WRA: false + person2: + age: 16 + is_in_non_advanced_education: false + is_in_approved_training: false + uc_limited_capability_for_WRA: false + benunits: + benunit: + members: [person1, person2] + output: + is_uc_work_allowance_eligible: true + - name: Case 7, a looked-after child does not create a work allowance. period: 2025 input: diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/qualifying_young_person_no_education_route.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/qualifying_young_person_no_education_route.yaml new file mode 100644 index 0000000000..b06ae2d535 --- /dev/null +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/qualifying_young_person_no_education_route.yaml @@ -0,0 +1,335 @@ +# UC Regs 2013 reg. 5(1)(a) and SPC Regs 2002 reg. 4A(1)(a): a person who has +# reached 16 is a qualifying young person "up to, but not including, the 1st +# September following" their 16th birthday, whatever their education. The +# model counts the route for a year that starts (6 April) before that date. +# Ages are ages on 6 October; with no date of birth, a whole age places the +# birthday on 6 April (months_since_last_birthday 6). + +- name: A 16-year-old outside education is a qualifying young person for UC and Pension Credit. + # 16th birthday 6 April 2026; the route runs to 31 August 2026. + period: 2026 + input: + people: + parent: + age: 40 + is_parent: true + young_person: + age: 16 + current_education: NOT_IN_EDUCATION + benunits: + benunit: + members: [parent, young_person] + output: + is_in_non_advanced_education: [false, false] + is_before_first_september_following_16th_birthday: [false, true] + is_qualifying_young_person_for_universal_credit: [false, true] + is_child_or_qualifying_young_person_for_universal_credit: [false, true] + is_qualifying_young_person_for_pension_credit: [false, true] + is_child_or_qualifying_young_person_for_pension_credit: [false, true] + +- name: A 16-year-old apprentice qualifies through reg. 5(1)(a), which has no contract-of-employment exclusion. + # Reg. 5(3) excludes training under a contract of employment from the + # education route (b) only. + period: 2026 + input: + people: + parent: + age: 40 + is_parent: true + young_person: + age: 16 + current_education: POST_SECONDARY + is_apprentice: true + benunits: + benunit: + members: [parent, young_person] + output: + is_in_non_advanced_education: [false, false] + is_qualifying_young_person_for_universal_credit: [false, true] + is_qualifying_young_person_for_pension_credit: [false, true] + +- name: A 16-year-old outside education whose route has ended for the year is not a qualifying young person. + period: 2026 + input: + people: + parent: + age: 40 + is_parent: true + young_person: + age: 16 + current_education: NOT_IN_EDUCATION + is_before_first_september_following_16th_birthday: false + benunits: + benunit: + members: [parent, young_person] + output: + is_qualifying_young_person_for_universal_credit: [false, false] + is_child_or_qualifying_young_person_for_universal_credit: [false, false] + is_qualifying_young_person_for_pension_credit: [false, false] + is_child_or_qualifying_young_person_for_pension_credit: [false, false] + +- name: The education route still applies after the 1 September following the 16th birthday. + period: 2026 + input: + people: + parent: + age: 40 + is_parent: true + young_person: + age: 16 + current_education: UPPER_SECONDARY + is_before_first_september_following_16th_birthday: false + benunits: + benunit: + members: [parent, young_person] + output: + is_qualifying_young_person_for_universal_credit: [false, true] + is_qualifying_young_person_for_pension_credit: [false, true] + +- name: A 17-year-old with a 16th birthday on 15 September 2025 is in the route until 31 August 2026. + # Born 15 September 2009: aged 17 on 6 October 2026. The 1 September + # following the 16th birthday is 1 September 2026, after 6 April 2026. + period: 2026 + input: + people: + parent: + age: 40 + is_parent: true + young_person: + age: 17 + date_of_birth: 20090915 + current_education: NOT_IN_EDUCATION + benunits: + benunit: + members: [parent, young_person] + output: + is_before_first_september_following_16th_birthday: [false, true] + is_qualifying_young_person_for_universal_credit: [false, true] + is_qualifying_young_person_for_pension_credit: [false, true] + +- name: A 16th birthday on 1 September runs the route to the 17th birthday. + # Born 1 September 2009: the 1 September following the 16th birthday (1 + # September 2025) is 1 September 2026, after 6 April 2026. + period: 2026 + input: + people: + parent: + age: 40 + is_parent: true + young_person: + age: 17 + date_of_birth: 20090901 + current_education: NOT_IN_EDUCATION + benunits: + benunit: + members: [parent, young_person] + output: + is_before_first_september_following_16th_birthday: [false, true] + is_qualifying_young_person_for_universal_credit: [false, true] + +- name: A 16th birthday on 31 August ends the route that day. + # Born 31 August 2009: the route ran only on 31 August 2025, before the + # 2026-27 fiscal year starts. + period: 2026 + input: + people: + parent: + age: 40 + is_parent: true + young_person: + age: 17 + date_of_birth: 20090831 + current_education: NOT_IN_EDUCATION + benunits: + benunit: + members: [parent, young_person] + output: + is_before_first_september_following_16th_birthday: [false, false] + is_qualifying_young_person_for_universal_credit: [false, false] + is_qualifying_young_person_for_pension_credit: [false, false] + +- name: A 16-year-old receiving Universal Credit in their own right is not a qualifying young person. + # Reg. 5(5) and reg. 4A(5) apply to both routes. + period: 2026 + input: + people: + parent: + age: 40 + is_parent: true + young_person: + age: 16 + current_education: NOT_IN_EDUCATION + receives_benefits_in_own_right: true + benunits: + benunit: + members: [parent, young_person] + output: + is_qualifying_young_person_for_universal_credit: [false, false] + is_qualifying_young_person_for_pension_credit: [false, false] + +- name: A looked-after 16-year-old is a qualifying young person but not the family's. + period: 2026 + input: + people: + parent: + age: 40 + is_parent: true + young_person: + age: 16 + current_education: NOT_IN_EDUCATION + is_looked_after_by_local_authority: true + benunits: + benunit: + members: [parent, young_person] + output: + is_qualifying_young_person_for_universal_credit: [false, true] + is_child_or_qualifying_young_person_for_universal_credit: [false, false] + is_qualifying_young_person_for_pension_credit: [false, true] + is_child_or_qualifying_young_person_for_pension_credit: [false, false] + +- name: Neither 15- nor 18-year-olds outside education are qualifying young persons. + # A 15-year-old is a child (Welfare Reform Act 2012 s. 40); an 18-year-old's + # 1 September following their 16th birthday has passed. + period: 2026 + input: + people: + parent: + age: 45 + is_parent: true + child: + age: 15 + current_education: NOT_IN_EDUCATION + adult_child: + age: 18 + current_education: NOT_IN_EDUCATION + benunits: + benunit: + members: [parent, child, adult_child] + output: + is_before_first_september_following_16th_birthday: [false, true, false] + is_qualifying_young_person_for_universal_credit: [false, false, false] + is_child_or_qualifying_young_person_for_universal_credit: [false, true, false] + is_qualifying_young_person_for_pension_credit: [false, false, false] + +- name: A lone parent with a 16-year-old outside education gets the child element and a work allowance. + # 2026-27: born 6 April 2010, before 6 April 2017, so the higher first-child + # amount: GBP 351.88 a month x 12 = GBP 4,222.56. Responsibility for a + # qualifying young person gives the work allowance (reg. 22(1)(b)): no + # housing element, so GBP 710 a month x 12 = GBP 8,520. Maximum amount: the + # single 25-or-over standard allowance GBP 424.90 x 12 = GBP 5,098.80, plus + # the child element, = GBP 9,321.36. + period: 2026 + input: + people: + parent: + age: 40 + is_parent: true + young_person: + age: 16 + current_education: NOT_IN_EDUCATION + benunits: + benunit: + members: [parent, young_person] + households: + household: + members: [parent, young_person] + output: + uc_individual_child_element: [0, 4_222.56] + uc_child_element: 4_222.56 + is_responsible_for_child_or_qualifying_young_person_for_universal_credit: true + is_uc_work_allowance_eligible: true + uc_work_allowance: 8_520 + uc_maximum_amount: 9_321.36 + is_benefit_cap_single_claimant_rate: false + +- name: A pensioner with a 16-year-old outside education gets the Pension Credit child addition. + # 2026-27: born 6 April 2010, before 6 April 2017, so the first child + # addition (Sch. IIA para. 10): GBP 81.07 a week x 52 = GBP 4,215.64. The + # single standard minimum guarantee is GBP 238.00 x 52 = GBP 12,376, so the + # minimum guarantee is GBP 16,591.64. + period: 2026 + input: + people: + pensioner: + age: 70 + is_SP_age: true + young_person: + age: 16 + current_education: NOT_IN_EDUCATION + benunits: + benunit: + members: [pensioner, young_person] + households: + household: + members: [pensioner, young_person] + output: + child_minimum_guarantee_addition: 4_215.64 + standard_minimum_guarantee: 12_376 + minimum_guarantee: 16_591.64 + +- name: In 2025-26 the 16-year-old counts first under the two-child limit, and the youngest child loses the element. + # 2025-26: the 16-year-old (born 6 April 2009) is a qualifying young person + # through reg. 5(1)(a), so the eldest of three. The higher first-child + # amount: GBP 339 a month x 12 = GBP 4,068. The 7-year-old (born 6 April + # 2018): GBP 292.81 x 12 = GBP 3,513.72. The 5-year-old (born 6 April 2020, + # after 6 April 2017) is the third child, so no element (reg. 24A). Total + # GBP 7,581.72. + period: 2025 + input: + people: + parent: + age: 40 + is_parent: true + young_person: + age: 16 + current_education: NOT_IN_EDUCATION + child_7: + age: 7 + child_5: + age: 5 + benunits: + benunit: + members: [parent, young_person, child_7, child_5] + households: + household: + members: [parent, young_person, child_7, child_5] + output: + uc_child_index: [-1, 1, 2, 3] + uc_individual_child_element: [0, 4_068, 3_513.72, 0] + uc_is_child_limit_affected: [false, false, false, true] + uc_child_element: 7_581.72 + +- name: A date of birth given for one person leaves another's age-placed date unchanged. + # The 17-year-old's date of birth (15 September 2009) puts them in the + # route; the 16-year-old elsewhere has none, so age places their birthday + # on 6 April 2010 and they are in it too. + period: 2026 + input: + people: + parent_1: + age: 34 + is_parent: true + young_person_17: + age: 17 + date_of_birth: 20090915 + current_education: NOT_IN_EDUCATION + parent_2: + age: 40 + is_parent: true + young_person_16: + age: 16 + current_education: NOT_IN_EDUCATION + benunits: + benunit_1: + members: [parent_1, young_person_17] + benunit_2: + members: [parent_2, young_person_16] + households: + household_1: + members: [parent_1, young_person_17] + household_2: + members: [parent_2, young_person_16] + output: + is_before_first_september_following_16th_birthday: [false, true, false, true] + is_qualifying_young_person_for_universal_credit: [false, true, false, true] + is_qualifying_young_person_for_pension_credit: [false, true, false, true] diff --git a/policyengine_uk/tests/policy/baseline/finance/benefit/qualifying_young_person_terminal_date.yaml b/policyengine_uk/tests/policy/baseline/finance/benefit/qualifying_young_person_terminal_date.yaml new file mode 100644 index 0000000000..3a3e2493f8 --- /dev/null +++ b/policyengine_uk/tests/policy/baseline/finance/benefit/qualifying_young_person_terminal_date.yaml @@ -0,0 +1,296 @@ +# A young person in non-advanced education or approved training is a +# qualifying young person "up to, but not including, the 1st September +# following their 19th birthday" (UC Regs 2013 reg. 5(1)(b); SPC Regs 2002 +# reg. 4A(1)(b)). The model places that date from the date of birth and +# counts a year that starts (6 April) before it, so every 19-year-old counts +# unless an input says the date has passed. +# +# 2026-27 amounts: Universal Credit child element for a first child born +# before 6 April 2017, £351.88 a month +# (gov/dwp/universal_credit/elements/child/first/higher_amount.yaml); +# Pension Credit first-child addition, £81.07 a week +# (gov/dwp/pension_credit/guarantee_credit/child/first/addition.yaml). + +- name: Case 1, a 19-year-old at school is a Universal Credit and Pension Credit qualifying young person by default. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_parent: true + is_claimant_or_partner: true + student: + age: 19 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 17 + is_claimant_or_partner: false + benunits: + benunit: + members: [parent, student] + output: + is_before_first_september_following_19th_birthday: [false, true] + is_before_universal_credit_qualifying_young_person_terminal_date: [false, true] + is_qualifying_young_person_for_universal_credit: [false, true] + is_qualifying_young_person_for_pension_credit: [false, true] + # 351.88 * 12. + uc_individual_child_element: [0, 4_222.56] + is_uc_work_allowance_eligible: true + +- name: Case 2, the Universal Credit input ends Universal Credit status only. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_parent: true + is_claimant_or_partner: true + student: + age: 19 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 17 + is_before_universal_credit_qualifying_young_person_terminal_date: false + is_claimant_or_partner: false + benunits: + benunit: + members: [parent, student] + output: + is_qualifying_young_person_for_universal_credit: [false, false] + is_qualifying_young_person_for_pension_credit: [false, true] + uc_individual_child_element: [0, 0] + is_uc_work_allowance_eligible: false + +- name: Case 3, the date fact set false ends both. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_parent: true + is_claimant_or_partner: true + student: + age: 19 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 17 + is_before_first_september_following_19th_birthday: false + is_claimant_or_partner: false + benunits: + benunit: + members: [parent, student] + output: + # The parent, not set, takes the default, true: harmless, since every + # reader is behind the qualifying young person age limit. + is_before_universal_credit_qualifying_young_person_terminal_date: [true, false] + is_qualifying_young_person_for_universal_credit: [false, false] + is_qualifying_young_person_for_pension_credit: [false, false] + uc_individual_child_element: [0, 0] + +- name: Case 4, a pensioner gets the Pension Credit child addition for a 19-year-old at school. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + pensioner: + age: 70 + is_claimant_or_partner: true + student: + age: 19 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 17 + is_claimant_or_partner: false + benunits: + benunit: + members: [pensioner, student] + output: + is_qualifying_young_person_for_pension_credit: [false, true] + # 81.07 * 52. + child_minimum_guarantee_addition: 4_215.64 + +- name: Case 5, no Pension Credit child addition once the 1 September after the 19th birthday has passed. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + pensioner: + age: 70 + is_claimant_or_partner: true + student: + age: 19 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 17 + is_before_first_september_following_19th_birthday: false + is_claimant_or_partner: false + benunits: + benunit: + members: [pensioner, student] + output: + is_qualifying_young_person_for_pension_credit: [false, false] + child_minimum_guarantee_addition: 0 + +- name: Case 6, born 31 August 2007, the period ends on the 19th birthday, in the year. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_parent: true + is_claimant_or_partner: true + student: + age: 19 + date_of_birth: 20070831 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 17 + is_claimant_or_partner: false + benunits: + benunit: + members: [parent, student] + output: + is_before_first_september_following_19th_birthday: [false, true] + is_qualifying_young_person_for_universal_credit: [false, true] + is_qualifying_young_person_for_pension_credit: [false, true] + +- name: Case 7, born 15 September 2006, before the date until 31 August 2026 but aged 20 on 6 October. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_parent: true + is_claimant_or_partner: true + student: + age: 20 + date_of_birth: 20060915 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 17 + is_claimant_or_partner: false + benunits: + benunit: + members: [parent, student] + output: + is_before_first_september_following_19th_birthday: [false, true] + # The age limit, read on 6 October, excludes them. + is_qualifying_young_person_for_universal_credit: [false, false] + is_qualifying_young_person_for_pension_credit: [false, false] + +- name: Case 8, born 31 August 2006, the 1 September after the 19th birthday was in 2025. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_parent: true + is_claimant_or_partner: true + student: + age: 20 + date_of_birth: 20060831 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 17 + is_claimant_or_partner: false + benunits: + benunit: + members: [parent, student] + output: + is_before_first_september_following_19th_birthday: [false, false] + is_qualifying_young_person_for_universal_credit: [false, false] + +- name: Case 9, a course begun at 19 does not qualify, whatever the date (reg. 5(2); reg. 4A(2)). + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_parent: true + is_claimant_or_partner: true + student: + age: 19 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 19 + is_claimant_or_partner: false + benunits: + benunit: + members: [parent, student] + output: + is_qualifying_young_person_for_universal_credit: [false, false] + is_qualifying_young_person_for_pension_credit: [false, false] + +- name: Case 10, a 19-year-old outside education is not a qualifying young person, whatever the date. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_parent: true + is_claimant_or_partner: true + young_adult: + age: 19 + current_education: NOT_IN_EDUCATION + is_claimant_or_partner: false + benunits: + benunit: + members: [parent, young_adult] + output: + is_before_first_september_following_19th_birthday: [false, true] + is_qualifying_young_person_for_universal_credit: [false, false] + is_qualifying_young_person_for_pension_credit: [false, false] + +- name: Case 11, born 1 September 2006, the 1 September following the 19th birthday is in 2026, not the birthday itself. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_parent: true + is_claimant_or_partner: true + student: + age: 20 + date_of_birth: 20060901 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 17 + is_claimant_or_partner: false + benunits: + benunit: + members: [parent, student] + output: + # The 19th birthday is 1 September 2025; the 1 September that follows it + # is in 2026, inside the year. + is_before_first_september_following_19th_birthday: [false, true] + # The age limit, read on 6 October, excludes them. + is_qualifying_young_person_for_universal_credit: [false, false] + is_qualifying_young_person_for_pension_credit: [false, false] + +- name: Case 12, setting the date fact for one 19-year-old leaves another's status as the formula gives it. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + pensioner: + age: 70 + is_claimant_or_partner: true + first: + age: 19 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 17 + is_before_first_september_following_19th_birthday: false + is_claimant_or_partner: false + second: + age: 19 + current_education: UPPER_SECONDARY + age_started_or_accepted_current_education_or_training: 17 + is_claimant_or_partner: false + benunits: + benunit: + members: [pensioner, first, second] + output: + # The second takes the default, true, which is the formula's value for + # anyone under 20 on 6 October. + is_before_first_september_following_19th_birthday: [true, false, true] + is_qualifying_young_person_for_universal_credit: [false, false, true] + is_qualifying_young_person_for_pension_credit: [false, false, true] diff --git a/policyengine_uk/tests/policy/baseline/gov/dwp/means_test_income_members.yaml b/policyengine_uk/tests/policy/baseline/gov/dwp/means_test_income_members.yaml index a9d6e1605e..ce709391d1 100644 --- a/policyengine_uk/tests/policy/baseline/gov/dwp/means_test_income_members.yaml +++ b/policyengine_uk/tests/policy/baseline/gov/dwp/means_test_income_members.yaml @@ -47,7 +47,7 @@ output: universal_credit: 9_321.36 -- name: A 17-year-old outside education is not a UC young person, so their pay does not count +- name: A 17-year-old outside education and past the 1 September after their 16th birthday is not a UC young person, so their pay does not count period: 2026 absolute_error_margin: 1 input: diff --git a/policyengine_uk/tests/test_child_and_adult_definitions_properties.py b/policyengine_uk/tests/test_child_and_adult_definitions_properties.py index e67b1f7183..fcf9c8f9f4 100644 --- a/policyengine_uk/tests/test_child_and_adult_definitions_properties.py +++ b/policyengine_uk/tests/test_child_and_adult_definitions_properties.py @@ -38,12 +38,21 @@ 12-year-old explains the flag and makes them a couple. Before/after families share one Simulation to avoid repeated model construction, but occupy distinct households and benefit units. +5. UC reg 5(1)(a) and SPC reg 4A(1)(a): the year counts in the route when it + starts (6 April) before the 1 September following the 16th birthday, for + every date of birth checked against calendar arithmetic. Within ages 16 to + 19 and without own-right benefits, that route alone makes a UC or PC + qualifying young person whatever the education inputs; without it the + education route is unchanged. Own-right benefits exclude both routes. UC + and PC agree below 19, where only UC's terminal date differs. Scope: these are tests of the ENCODED statutory limbs, not full entitlement. Education status proxies full-time non-advanced study: hours, employment contracts, approved providers and interruptions are unobserved. CB/CTC leaver -extensions are omitted, as is UC/PC's unconditional age-16-to-next-September -route. UC's terminal date is an input; PC's September terminal date is absent. +extensions are omitted. UC/PC's route to the 1 September after the 16th +birthday, which has no education condition, counts for a year that starts +before that date (invariant 5). UC's terminal date is an input; PC's September +terminal date is absent. Own-benefit receipt collapses different programme-specific benefit lists. UC/CTC/PC blanket looked-after exclusions omit statutory exceptions. HBAI's fallback assumes dependence at 16--17 regardless of study, requires an @@ -57,11 +66,12 @@ the independent scalar references below. No network or survey data is used. """ +from datetime import date, timedelta from itertools import product from unittest.mock import patch import numpy as np -from hypothesis import HealthCheck, given, settings +from hypothesis import HealthCheck, assume, given, settings from hypothesis import strategies as st from policyengine_uk import Simulation @@ -177,8 +187,17 @@ def statutory_child(age): return age < 16 +def in_route_to_first_september_after_16th_birthday(p): + # UC reg 5(1)(a) and SPC reg 4A(1)(a) have no education condition. With no + # date of birth, a whole age on 6 October places the birthday on 6 April, + # so the year (from 6 April) starts before the 1 September following the + # 16th birthday exactly when that age is under 17. + return p.get("is_before_first_september_following_16th_birthday", p["age"] < 17) + + def qualifying_young_person(p, programme): - # Education/training routes only (see omissions in module docstring): + # CB and CTC: education/training routes only (see omissions in module + # docstring). UC and PC: also the route with no education condition. # CB: https://www.legislation.gov.uk/uksi/2006/223/regulation/3 # CB own-benefit restriction: https://www.legislation.gov.uk/uksi/2006/223/regulation/8 # UC: https://www.legislation.gov.uk/uksi/2013/376/regulation/5 @@ -186,6 +205,11 @@ def qualifying_young_person(p, programme): # PC: https://www.legislation.gov.uk/uksi/2002/1792/regulation/4A if not 16 <= p["age"] < 20 or p["receives_benefits_in_own_right"]: return False + if programme in { + "universal_credit", + "pension_credit", + } and in_route_to_first_september_after_16th_birthday(p): + return True if not (non_advanced_education(p) or p["is_in_approved_training"]): return False if ( @@ -903,3 +927,108 @@ def test_frs_shaped_units_keep_the_under_20_presumption(families): ] assert_values(sim, "is_claimant_or_partner", expected) assert expected == [c for f in families for c in claimants_or_partners(f)] + + +ROUTE = "is_before_first_september_following_16th_birthday" + + +def first_september_following_16th_birthday(born): + # Calendar arithmetic, independent of the model's month grid: a 16th + # birthday before 1 September is followed by 1 September of the same year, + # and one on or after it by the next year's. A 29 February birthday is + # before 1 September whichever day it is kept on in other years. + # https://www.legislation.gov.uk/uksi/2013/376/regulation/5 + # https://www.legislation.gov.uk/uksi/2002/1792/regulation/4A + return date(born.year + 16 + ((born.month, born.day) >= (9, 1)), 9, 1) + + +def age_on_6_october(born, year): + return year - born.year - ((10, 6) < (born.month, born.day)) + + +def assert_route_matches_calendar(births, year): + families = [ + [person(age_on_6_october(born, year), date_of_birth=int(f"{born:%Y%m%d}"))] + for born in births + ] + # The fiscal year starts on 6 April. + expected = [ + date(year, 4, 6) < first_september_following_16th_birthday(born) + for born in births + ] + assert_values(simulate(families, year), ROUTE, expected, year) + + +def test_route_year_starts_before_first_september_for_every_birthday(): + # Every date of birth from 2008 to 2011: ages 14 to 18 on 6 October 2026, + # including the 31 August / 1 September and 6 April / 6 October edges. + start, end = date(2008, 1, 1), date(2012, 1, 1) + births = [start + timedelta(days=d) for d in range((end - start).days)] + assert_route_matches_calendar(births, YEAR) + + +@PROPERTY_SETTINGS +@given( + st.lists(st.dates(date(1990, 1, 1), date(2031, 12, 31)), min_size=1, max_size=30), + st.integers(2013, 2031), +) +def test_route_matches_calendar_arithmetic_in_any_year(births, year): + births = [born for born in births if age_on_6_october(born, year) >= 0] + assume(births) + assert_route_matches_calendar(births, year) + + +def test_route_alone_qualifies_and_leaves_the_education_route_unchanged(): + # Ages 14 to 21, every education value, own-right benefits, approved + # training, apprenticeship and looked-after status, with the route input + # off then on (innermost, so each subject's two rows are adjacent). + rows = list( + product( + range(14, 22), + EDUCATIONS, + product((False, True), repeat=4), + (False, True), + ) + ) + families = [ + [ + person(40, is_parent=True, is_benunit_head=True, **{ROUTE: False}), + person( + age, + current_education=education, + receives_benefits_in_own_right=own_benefits, + is_in_approved_training=training, + is_apprentice=apprentice, + is_looked_after_by_local_authority=looked_after, + **{ROUTE: route}, + ), + ] + for age, education, flags, route in rows + for own_benefits, training, apprentice, looked_after in [flags] + ] + # The oracle: the route, else the education route as before. + assert_definitions(families) + sim = simulate(families) + age = np.array([row[0] for row in rows[::2]]) + own_benefits = np.array([row[2][0] for row in rows[::2]]) + qyp = { + programme: sim.calculate(f"is_qualifying_young_person_for_{programme}", YEAR)[ + 1::2 + ].reshape(-1, 2) + for programme in ("universal_credit", "pension_credit") + } + for programme, status in qyp.items(): + # Switching the route on never removes the status. + assert (status[:, 1] >= status[:, 0]).all(), programme + # With the route on, ages 16 to 19 without own-right benefits qualify, + # whatever the education inputs, and nobody else does. + np.testing.assert_array_equal( + status[:, 1], (16 <= age) & (age < 20) & ~own_benefits, err_msg=programme + ) + # Own-right benefits exclude both routes. + assert not status[own_benefits].any(), programme + # Below 19 the two programmes' definitions are the same. + below_19 = age < 19 + np.testing.assert_array_equal( + qyp["universal_credit"][below_19], qyp["pension_credit"][below_19] + ) diff --git a/policyengine_uk/tests/test_legacy_award_readers_properties.py b/policyengine_uk/tests/test_legacy_award_readers_properties.py index 5cba93171c..8775832915 100644 --- a/policyengine_uk/tests/test_legacy_award_readers_properties.py +++ b/policyengine_uk/tests/test_legacy_award_readers_properties.py @@ -183,13 +183,15 @@ def families(draw): def other_members(draw): """An adult who is neither claimant, partner nor a dependant. - They are under state pension age and not in education, so a 16 to 19 year - old is not a qualifying young person. They have no income other than the - awards they report. + They are under state pension age, not in education and past the 1 + September following their 16th birthday (UC Regs 2013 reg. 5(1)(a)), so a + 16 to 19 year old is not a qualifying young person. They have no income + other than the awards they report. """ return { "age": draw(st.integers(16, 60)), "current_education": "NOT_IN_EDUCATION", + "is_before_first_september_following_16th_birthday": False, **draw(award_reports()), } diff --git a/policyengine_uk/tests/test_means_test_income_properties.py b/policyengine_uk/tests/test_means_test_income_properties.py index 49a9088ef2..04dfad9e74 100644 --- a/policyengine_uk/tests/test_means_test_income_properties.py +++ b/policyengine_uk/tests/test_means_test_income_properties.py @@ -3,7 +3,8 @@ Invariant: for any benefit unit, giving income to a member who is neither the claimant, the partner, nor the programme's own child or young person (for example an 18- or 19-year-old presumed the claimant's child but not in -education, or a third adult) never changes a means test's income. The UC, HB, +education, a 16-year-old outside education and past the 1 September following +their 16th birthday, or a third adult) never changes a means test's income. The UC, HB, IS, tax credit, CTR and Pension Credit income totals are covered. Each example builds families twice in one simulation: once with the other @@ -45,9 +46,10 @@ def families(draw): # A head, an optional partner, and one member who by construction is # outside every programme's family: a 16-19-year-old at least 16 years # younger than the head (presumed the head's child) who is not in - # non-advanced education, so no programme's young person; or a third adult - # no older than the partner (the partner, earlier in member order, wins any - # age tie). + # non-advanced education and is past the 1 September following their 16th + # birthday (UC Regs 2013 reg. 5(1)(a)), so no programme's young person; or + # a third adult no older than the partner (the partner, earlier in member + # order, wins any age tie). kind = draw(st.sampled_from(["presumed_child", "third_adult"])) if kind == "presumed_child": other_age = draw(st.integers(16, 19)) @@ -72,6 +74,7 @@ def families(draw): { "age": other_age, "current_education": education, + "is_before_first_september_following_16th_birthday": False, "employment_income": draw(st.floats(1, 50_000)), "private_pension_income": draw(money), "savings_interest_income": draw(money), diff --git a/policyengine_uk/tests/test_qualifying_young_person_terminal_date_properties.py b/policyengine_uk/tests/test_qualifying_young_person_terminal_date_properties.py new file mode 100644 index 0000000000..a91cb639fa --- /dev/null +++ b/policyengine_uk/tests/test_qualifying_young_person_terminal_date_properties.py @@ -0,0 +1,311 @@ +"""The 1 September following the 19th birthday, for Universal Credit and +Pension Credit qualifying young persons. + +A young person enrolled on, or accepted for, non-advanced education or +approved training is a qualifying young person "up to, but not including, +the 1st September following their 19th birthday" (UC Regs 2013 reg. 5(1)(b); +SPC Regs 2002 reg. 4A(1)(b)). + +Invariants: + +1. is_before_first_september_following_19th_birthday is true exactly when + the year starts (6 April) before that 1 September, for every date of + birth, against calendar arithmetic that shares no code with the model. +2. Universal Credit's own terminal-date variable follows that fact unless it + is set, and setting it changes Universal Credit only. +3. Over every combination of age, education, training, apprenticeship, + own-right benefits, entry age and the two date facts: Universal Credit + and Pension Credit agree, and both equal the regulation's conditions. +4. With the 19th-birthday fact on, both statuses are the earlier definition + without a terminal date, so nothing changes below 19 or for a 19-year-old + before the date; switching the fact on never removes the status; and it + matters only for a 19-year-old in education or training. +5. The formula gives true for everyone under 20 on 6 October, whether the + date of birth or only the age is given, and true is each terminal-date + variable's default. So a situation that sets one of them for some people + leaves everyone else's status as it would be with nothing set. +""" + +from datetime import date, timedelta +from itertools import product +from unittest.mock import patch + +import numpy as np +from hypothesis import HealthCheck, assume, given, settings +from hypothesis import strategies as st + +from policyengine_uk import Simulation +from policyengine_uk.tax_benefit_system import system +from policyengine_uk.variables.household.demographic.highest_education import ( + EducationType, +) + +YEAR = 2026 +_PROPERTY_SYSTEM = system.clone() +EDUCATIONS = tuple(item.name for item in EducationType) +SIXTEEN = "is_before_first_september_following_16th_birthday" +NINETEEN = "is_before_first_september_following_19th_birthday" +UC_TERMINAL = "is_before_universal_credit_qualifying_young_person_terminal_date" +UC = "is_qualifying_young_person_for_universal_credit" +PC = "is_qualifying_young_person_for_pension_credit" +SETTINGS = settings( + max_examples=25, + deadline=None, + derandomize=True, + suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large], +) + + +def person(age, **inputs): + return { + "age": age, + "current_education": "NOT_IN_EDUCATION", + "is_in_approved_training": False, + "is_apprentice": False, + "receives_benefits_in_own_right": False, + "age_started_or_accepted_current_education_or_training": 17, + **inputs, + } + + +def simulate(people, year=YEAR): + """Each person alone in a benefit unit: the status tests are personal.""" + situation = {"people": {}, "benunits": {}, "households": {}} + for i in range(len(people)): + situation["people"][f"p{i}"] = {} + situation["benunits"][f"b{i}"] = {"members": [f"p{i}"]} + situation["households"][f"h{i}"] = {"members": [f"p{i}"]} + with patch( + "policyengine_uk.simulation.CountryTaxBenefitSystem", + side_effect=_PROPERTY_SYSTEM.clone, + ): + sim = Simulation(situation=situation) + variables = people[0].keys() + assert all(p.keys() == variables for p in people) + for variable in variables: + sim.set_input(variable, year, [p[variable] for p in people]) + sim.input_variables = list(variables) + sim.reset_calculations() + return sim + + +def first_september_following_19th_birthday(born): + # A 19th birthday before 1 September is followed by 1 September of the + # same year, and one on or after it by the next year's. A 29 February + # birthday is before 1 September whichever day it is kept on. + # https://www.legislation.gov.uk/uksi/2013/376/regulation/5 + # https://www.legislation.gov.uk/uksi/2002/1792/regulation/4A + return date(born.year + 19 + ((born.month, born.day) >= (9, 1)), 9, 1) + + +def age_on_6_october(born, year): + return year - born.year - ((10, 6) < (born.month, born.day)) + + +def assert_fact_matches_calendar(births, year): + people = [ + person(age_on_6_october(born, year), date_of_birth=int(f"{born:%Y%m%d}")) + for born in births + ] + expected = [ + date(year, 4, 6) < first_september_following_19th_birthday(born) + for born in births + ] + sim = simulate(people, year) + # Invariant 1. + np.testing.assert_array_equal(sim.calculate(NINETEEN, year), expected) + # Invariant 2: Universal Credit's variable follows it when not set. + np.testing.assert_array_equal(sim.calculate(UC_TERMINAL, year), expected) + return expected + + +def test_fact_for_every_date_of_birth(): + # Every date of birth from 2004 to 2009: ages 16 to 22 on 6 October 2026. + start, end = date(2004, 1, 1), date(2010, 1, 1) + births = [start + timedelta(days=d) for d in range((end - start).days)] + expected = dict(zip(births, assert_fact_matches_calendar(births, YEAR))) + # 19 on 31 August 2026: the period ends that day, in the year. + assert expected[date(2007, 8, 31)] + # 19 on 31 August 2025: it ended before the year. + assert not expected[date(2006, 8, 31)] + # 19 on 1 September 2025: it runs to 31 August 2026. + assert expected[date(2006, 9, 1)] + # Everyone aged 19 on 6 October 2026 is before the date. + assert all( + before + for born, before in expected.items() + if age_on_6_october(born, YEAR) == 19 + ) + + +@SETTINGS +@given( + st.lists(st.dates(date(1990, 1, 1), date(2031, 12, 31)), min_size=1, max_size=30), + st.integers(2013, 2031), +) +def test_fact_matches_calendar_arithmetic_in_any_year(births, year): + births = [born for born in births if age_on_6_october(born, year) >= 0] + assume(births) + assert_fact_matches_calendar(births, year) + + +def studying(p): + # Education status stands in for a non-advanced course of more than 12 + # hours a week; reg. 5(3) and reg. 4A(3) exclude a contract of employment. + return ( + p["current_education"] not in {"NOT_IN_EDUCATION", "TERTIARY"} + and not p["is_apprentice"] + ) or p["is_in_approved_training"] + + +def qualifying_young_person(p, terminal_date=True): + # Reg. 5(1), (2), (5); reg. 4A(1), (2), (5). + if not 16 <= p["age"] < 20 or p["receives_benefits_in_own_right"]: + return False + if p[SIXTEEN]: + return True + if not studying(p): + return False + if ( + p["age"] >= 19 + and p["age_started_or_accepted_current_education_or_training"] >= 19 + ): + return False + return p["age"] < 19 or p[NINETEEN] or not terminal_date + + +GRID = [ + person( + age, + current_education=education, + is_in_approved_training=training, + is_apprentice=apprentice, + receives_benefits_in_own_right=own_right, + age_started_or_accepted_current_education_or_training=entry_age, + **{SIXTEEN: sixteen, NINETEEN: nineteen}, + ) + for age, education, training, apprentice, own_right, entry_age, sixteen in product( + range(14, 22), + EDUCATIONS, + (False, True), + (False, True), + (False, True), + (17, 19, 1000), + (False, True), + ) + for nineteen in (False, True) +] + + +def test_universal_credit_and_pension_credit_agree_on_every_combination(): + sim = simulate(GRID) + uc, pc = sim.calculate(UC, YEAR), sim.calculate(PC, YEAR) + expected = np.array([qualifying_young_person(p) for p in GRID]) + # Invariant 3. + np.testing.assert_array_equal(uc, expected) + np.testing.assert_array_equal(pc, expected) + # Invariant 4. Rows are adjacent pairs: the 19th-birthday fact off, on. + off, on = expected[0::2], expected[1::2] + assert (on >= off).all() + np.testing.assert_array_equal( + on, [qualifying_young_person(p, terminal_date=False) for p in GRID[1::2]] + ) + changed = on != off + assert changed.any() + assert all( + p["age"] == 19 and studying(p) and not p[SIXTEEN] + for p, c in zip(GRID[1::2], changed) + if c + ) + + +def test_universal_credit_input_overrides_the_fact_for_universal_credit_only(): + # Invariant 2: a 19-year-old at school, with each programme's input set + # against the fact. + rows = list(product((False, True), repeat=2)) + people = [ + person( + 19, + current_education="UPPER_SECONDARY", + **{SIXTEEN: False, NINETEEN: nineteen, UC_TERMINAL: uc_terminal}, + ) + for nineteen, uc_terminal in rows + ] + sim = simulate(people) + np.testing.assert_array_equal(sim.calculate(UC, YEAR), [u for _, u in rows]) + np.testing.assert_array_equal(sim.calculate(PC, YEAR), [n for n, _ in rows]) + + +DEFAULTED = ( + NINETEEN, + UC_TERMINAL, + "meets_qualifying_young_person_terminal_date_condition_for_pension_credit", +) + + +def test_formula_is_true_under_20_and_is_each_default(): + # Invariant 5, from age and months alone: every age to 25 and every + # month since the last birthday, in three years. + rows = list(product(range(26), range(12))) + for year in (2022, 2026, 2030): + situation = {"people": {}, "benunits": {}, "households": {}} + for i, (age, months) in enumerate(rows): + situation["people"][f"p{i}"] = { + "age": {year: age}, + "months_since_last_birthday": {year: months}, + } + situation["benunits"][f"b{i}"] = {"members": [f"p{i}"]} + situation["households"][f"h{i}"] = {"members": [f"p{i}"]} + with patch( + "policyengine_uk.simulation.CountryTaxBenefitSystem", + side_effect=_PROPERTY_SYSTEM.clone, + ): + sim = Simulation(situation=situation) + under_20 = np.array([age < 20 for age, _ in rows]) + for variable in DEFAULTED: + values = sim.calculate(variable, year) + assert values[under_20].all(), (variable, year) + assert sim.tax_benefit_system.variables[variable].default_value is True + # Not vacuous: the fact is false for some people of 20 or more. + assert not sim.calculate(NINETEEN, year)[~under_20].all() + + +def test_setting_one_person_leaves_the_others_status(): + # Invariant 5 in a household: two 19-year-olds at school, course begun + # at 17. Each terminal-date variable is set false for the first only; + # the second stays a qualifying young person for both programmes. + for variable in DEFAULTED: + people = { + "parent": {"age": {YEAR: 70}, "is_claimant_or_partner": {YEAR: True}}, + **{ + name: { + "age": {YEAR: 19}, + "current_education": {YEAR: "UPPER_SECONDARY"}, + "age_started_or_accepted_current_education_or_training": {YEAR: 17}, + "is_claimant_or_partner": {YEAR: False}, + } + for name in ("first", "second") + }, + } + people["first"][variable] = {YEAR: False} + situation = { + "people": people, + "benunits": {"b": {"members": list(people)}}, + "households": {"h": {"members": list(people)}}, + } + with patch( + "policyengine_uk.simulation.CountryTaxBenefitSystem", + side_effect=_PROPERTY_SYSTEM.clone, + ): + sim = Simulation(situation=situation) + uc = sim.calculate(UC, YEAR) + pc = sim.calculate(PC, YEAR) + # The second student is a qualifying young person for both. + assert uc[2] and pc[2], variable + # The first loses the status the variable governs. + if variable == UC_TERMINAL: + assert not uc[1] and pc[1] + elif variable == NINETEEN: + assert not uc[1] and not pc[1] + else: + assert uc[1] and not pc[1] diff --git a/policyengine_uk/variables/gov/dwp/is_responsible_for_child_or_young_person_for_uc_or_housing_benefit.py b/policyengine_uk/variables/gov/dwp/is_responsible_for_child_or_young_person_for_uc_or_housing_benefit.py index 2897b52f3a..4a3eba2ffc 100644 --- a/policyengine_uk/variables/gov/dwp/is_responsible_for_child_or_young_person_for_uc_or_housing_benefit.py +++ b/policyengine_uk/variables/gov/dwp/is_responsible_for_child_or_young_person_for_uc_or_housing_benefit.py @@ -11,11 +11,12 @@ class is_responsible_for_child_or_young_person_for_uc_or_housing_benefit(Variabl The family rates apply if either scheme's test is met, so neither scheme's families are moved onto the single rate by the other's narrower definition. - UC reg 5(1)(a) also makes every 16-year-old a qualifying young person until - the 1 September after their 16th birthday, whatever their education. Annual - ages cannot place that date, so a 16-year-old in the benefit unit who is not - a claimant or partner counts here; the UC child element does not yet model - reg 5(1)(a). + The UC test includes reg 5(1)(a), which makes a 16-year-old a qualifying + young person until the 1 September after their 16th birthday, whatever + their education. Housing Benefit's young person follows Child Benefit, + whose school-leaver rules (Child Benefit (General) Regulations 2006 regs 4, + 5 and 7) are not modelled, so a 16-year-old in the benefit unit who is not + a claimant or partner also counts here for the year. """ value_type = bool diff --git a/policyengine_uk/variables/gov/dwp/pension_credit/guarantee_credit/minimum_guarantee/additional/is_qualifying_young_person_for_pension_credit.py b/policyengine_uk/variables/gov/dwp/pension_credit/guarantee_credit/minimum_guarantee/additional/is_qualifying_young_person_for_pension_credit.py index ee1d028e8d..ff054781b9 100644 --- a/policyengine_uk/variables/gov/dwp/pension_credit/guarantee_credit/minimum_guarantee/additional/is_qualifying_young_person_for_pension_credit.py +++ b/policyengine_uk/variables/gov/dwp/pension_credit/guarantee_credit/minimum_guarantee/additional/is_qualifying_young_person_for_pension_credit.py @@ -5,22 +5,47 @@ class is_qualifying_young_person_for_pension_credit(Variable): value_type = bool entity = Person label = "Qualifying young person for Pension Credit" + documentation = ( + "A person aged 16 to 19 who is either before the 1 September following " + "their 16th birthday, whatever their education (reg. 4A(1)(a)), or in " + "non-advanced education or approved training that meets the entry " + "condition, before the 1 September following their 19th birthday " + "(reg. 4A(1)(b), (2) and (3)), and who is not receiving benefits in " + "their own right (reg. 4A(5)). The own-right benefits input covers " + "Universal Credit, Employment and Support Allowance and Jobseeker's " + "Allowance but not Income Support." + ) definition_period = YEAR reference = "https://www.legislation.gov.uk/uksi/2002/1792/regulation/4A" def formula(person, period, parameters): - return ( + # Reg. 4A(1)(a): no education or training condition. + before_first_september_following_16th_birthday = person( + "is_before_first_september_following_16th_birthday", period + ) + # Reg. 4A(1)(b), (2) and (3). + in_education_or_training = ( person( - "meets_qualifying_young_person_age_condition_for_pension_credit", + "meets_qualifying_young_person_education_or_training_condition_for_pension_credit", period, ) & person( - "meets_qualifying_young_person_education_or_training_condition_for_pension_credit", + "meets_qualifying_young_person_entry_condition_for_pension_credit", period, ) & person( - "meets_qualifying_young_person_entry_condition_for_pension_credit", + "meets_qualifying_young_person_terminal_date_condition_for_pension_credit", period, ) + ) + return ( + person( + "meets_qualifying_young_person_age_condition_for_pension_credit", + period, + ) + & ( + before_first_september_following_16th_birthday + | in_education_or_training + ) & ~person("receives_benefits_in_own_right", period) ) diff --git a/policyengine_uk/variables/gov/dwp/pension_credit/guarantee_credit/minimum_guarantee/additional/meets_qualifying_young_person_terminal_date_condition_for_pension_credit.py b/policyengine_uk/variables/gov/dwp/pension_credit/guarantee_credit/minimum_guarantee/additional/meets_qualifying_young_person_terminal_date_condition_for_pension_credit.py new file mode 100644 index 0000000000..0e616c8a64 --- /dev/null +++ b/policyengine_uk/variables/gov/dwp/pension_credit/guarantee_credit/minimum_guarantee/additional/meets_qualifying_young_person_terminal_date_condition_for_pension_credit.py @@ -0,0 +1,29 @@ +from policyengine_uk.model_api import * + + +class meets_qualifying_young_person_terminal_date_condition_for_pension_credit( + Variable +): + value_type = bool + entity = Person + label = "Meets qualifying young person terminal date condition for Pension Credit" + documentation = ( + "A young person in education or training is a qualifying young person " + "up to, but not including, the 1 September following their 19th " + "birthday (SPC Regs 2002 reg. 4A(1)(b)). Under 19 that date is always " + "ahead; at 19 it is read from " + "is_before_first_september_following_19th_birthday. Its default is " + "true, the value the formula gives everyone under 20 on 6 October, so " + "setting it for some people leaves everyone else under 20 where the " + "formula puts them; older people are excluded by the age limit." + ) + definition_period = YEAR + default_value = True + reference = "https://www.legislation.gov.uk/uksi/2002/1792/regulation/4A" + + def formula(person, period, parameters): + p = parameters(period).gov.dwp.pension_credit.guarantee_credit.child.eligibility + age = person("age", period) + return (age < p.terminal_date_age_limit) | person( + "is_before_first_september_following_19th_birthday", period + ) diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/child_element/is_before_universal_credit_qualifying_young_person_terminal_date.py b/policyengine_uk/variables/gov/dwp/universal_credit/child_element/is_before_universal_credit_qualifying_young_person_terminal_date.py index b9f6e4a784..de58b11b88 100644 --- a/policyengine_uk/variables/gov/dwp/universal_credit/child_element/is_before_universal_credit_qualifying_young_person_terminal_date.py +++ b/policyengine_uk/variables/gov/dwp/universal_credit/child_element/is_before_universal_credit_qualifying_young_person_terminal_date.py @@ -6,11 +6,23 @@ class is_before_universal_credit_qualifying_young_person_terminal_date(Variable) entity = Person label = "Before the Universal Credit qualifying young person terminal date" documentation = ( - "Whether this person is before the Universal Credit terminal date " - "for a 19-year-old qualifying young person. This captures date-of-birth " - "and assessment-period detail that is not otherwise available in the " - "annual model." + "Whether this person is before the Universal Credit terminal date for " + "a 19-year-old qualifying young person: the 1 September following " + "their 19th birthday (UC Regs 2013 reg. 5(1)(b)). It follows the date " + "of birth (is_before_first_september_following_19th_birthday), so a " + "year counts if it starts before that date. Datasets and situations " + "can set it directly: set it to false for a 19-year-old whose 1 " + "September has passed. Its default is true, the value the date fact " + "gives everyone under 20 on 6 October, so setting it for some people " + "leaves everyone else under 20 where the date fact puts them; older " + "people are excluded by the age limit before it is read." ) definition_period = YEAR - default_value = False - reference = "https://www.gov.uk/government/publications/universal-credit-and-families-with-more-than-2-children-information-for-stakeholders/universal-credit-and-families-with-more-than-2-children-information-for-stakeholders" + default_value = True + reference = ( + "https://www.legislation.gov.uk/uksi/2013/376/regulation/5", + "https://www.gov.uk/government/publications/universal-credit-and-families-with-more-than-2-children-information-for-stakeholders/universal-credit-and-families-with-more-than-2-children-information-for-stakeholders", + ) + + def formula(person, period, parameters): + return person("is_before_first_september_following_19th_birthday", period) diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/child_element/is_qualifying_young_person_for_universal_credit.py b/policyengine_uk/variables/gov/dwp/universal_credit/child_element/is_qualifying_young_person_for_universal_credit.py index 2b1608d539..1b1cfd602d 100644 --- a/policyengine_uk/variables/gov/dwp/universal_credit/child_element/is_qualifying_young_person_for_universal_credit.py +++ b/policyengine_uk/variables/gov/dwp/universal_credit/child_element/is_qualifying_young_person_for_universal_credit.py @@ -5,16 +5,25 @@ class is_qualifying_young_person_for_universal_credit(Variable): value_type = bool entity = Person label = "Qualifying young person for Universal Credit" + documentation = ( + "A person aged 16 to 19 who is either before the 1 September following " + "their 16th birthday, whatever their education (reg. 5(1)(a)), or in " + "non-advanced education or approved training that meets the entry and " + "terminal-date conditions (reg. 5(1)(b), (2) and (3)), and who is not " + "receiving Universal Credit, Employment and Support Allowance or " + "Jobseeker's Allowance (reg. 5(5))." + ) definition_period = YEAR reference = "https://www.legislation.gov.uk/uksi/2013/376/regulation/5" def formula(person, period, parameters): - return ( + # Reg. 5(1)(a): no education or training condition. + before_first_september_following_16th_birthday = person( + "is_before_first_september_following_16th_birthday", period + ) + # Reg. 5(1)(b), (2) and (3). + in_education_or_training = ( person( - "meets_qualifying_young_person_age_condition_for_universal_credit", - period, - ) - & person( "meets_qualifying_young_person_education_or_training_condition_for_universal_credit", period, ) @@ -26,5 +35,15 @@ def formula(person, period, parameters): "meets_qualifying_young_person_terminal_date_condition_for_universal_credit", period, ) + ) + return ( + person( + "meets_qualifying_young_person_age_condition_for_universal_credit", + period, + ) + & ( + before_first_september_following_16th_birthday + | in_education_or_training + ) & ~person("receives_benefits_in_own_right", period) ) diff --git a/policyengine_uk/variables/gov/dwp/universal_credit/child_element/meets_qualifying_young_person_terminal_date_condition_for_universal_credit.py b/policyengine_uk/variables/gov/dwp/universal_credit/child_element/meets_qualifying_young_person_terminal_date_condition_for_universal_credit.py index 73837e7b14..9ab4e6a4f5 100644 --- a/policyengine_uk/variables/gov/dwp/universal_credit/child_element/meets_qualifying_young_person_terminal_date_condition_for_universal_credit.py +++ b/policyengine_uk/variables/gov/dwp/universal_credit/child_element/meets_qualifying_young_person_terminal_date_condition_for_universal_credit.py @@ -7,8 +7,19 @@ class meets_qualifying_young_person_terminal_date_condition_for_universal_credit value_type = bool entity = Person label = "Meets qualifying young person terminal date condition for Universal Credit" + documentation = ( + "A young person in education or training is a qualifying young person " + "up to, but not including, the 1 September following their 19th " + "birthday (UC Regs 2013 reg. 5(1)(b)). Under 19 that date is always " + "ahead; at 19 it is read from " + "is_before_universal_credit_qualifying_young_person_terminal_date, " + "which follows the date of birth unless set." + ) definition_period = YEAR - reference = "https://www.gov.uk/government/publications/universal-credit-and-families-with-more-than-2-children-information-for-stakeholders/universal-credit-and-families-with-more-than-2-children-information-for-stakeholders" + reference = ( + "https://www.legislation.gov.uk/uksi/2013/376/regulation/5", + "https://www.gov.uk/government/publications/universal-credit-and-families-with-more-than-2-children-information-for-stakeholders/universal-credit-and-families-with-more-than-2-children-information-for-stakeholders", + ) def formula(person, period, parameters): p = parameters(period).gov.dwp.universal_credit.elements.child.eligibility diff --git a/policyengine_uk/variables/household/demographic/is_before_first_september_following_16th_birthday.py b/policyengine_uk/variables/household/demographic/is_before_first_september_following_16th_birthday.py new file mode 100644 index 0000000000..22dc35fb9d --- /dev/null +++ b/policyengine_uk/variables/household/demographic/is_before_first_september_following_16th_birthday.py @@ -0,0 +1,48 @@ +from policyengine_uk.model_api import * +from policyengine_uk.utils.dates import birth_day + + +class is_before_first_september_following_16th_birthday(Variable): + value_type = bool + entity = Person + label = ( + "Before the 1 September following the 16th birthday at the start of the year" + ) + documentation = ( + "Whether the fiscal year starts (6 April) before the 1 September " + "following the person's 16th birthday, so that some of the year falls " + "in the qualifying young person route that has no education condition " + "(UC Regs 2013 reg. 5(1)(a); SPC Regs 2002 reg. 4A(1)(a)). The date " + "comes from date_of_birth, or from age and months_since_last_birthday. " + "A 16th birthday on 31 August ends the route that day, and one on 1 " + "September runs it to the 17th birthday. The route ends on a fixed 1 " + "September that annual periods cannot split, so a person in it for " + "part of the year counts for the year, as the benefit cap and LHA " + "family rules count a 16-year-old member. This departs from the 6 " + "October reading of annual status that is_SP_age uses. Everyone aged " + "16 on 6 October qualifies, as does a 17-year-old born from 1 " + "September to 6 October. With birthdays spread evenly, a 16-year-old " + "outside education is a child or in the route for 46% of the year on " + "average, and a 17-year-old for 4%. To place the route for one " + "person, set their date_of_birth. Setting this variable for some " + "people gives everyone else in the situation false, so set it for " + "every person or not at all." + ) + definition_period = YEAR + reference = ( + "https://www.legislation.gov.uk/uksi/2013/376/regulation/5", + "https://www.legislation.gov.uk/uksi/2002/1792/regulation/4A", + ) + + def formula(person, period, parameters): + date_of_birth = birth_day(person, period) + # The 16th birthday falls in the birth year plus 16; the 1 September + # following it is in that year if the birthday is before 1 September, + # and otherwise in the next. + born_on_or_after_first_september = date_of_birth % 10_000 >= 901 + year_of_first_september = ( + date_of_birth // 10_000 + 16 + born_on_or_after_first_september + ) + # The year starts on 6 April, before 1 September of the same calendar + # year and after 1 September of the one before. + return year_of_first_september >= period.start.year diff --git a/policyengine_uk/variables/household/demographic/is_before_first_september_following_19th_birthday.py b/policyengine_uk/variables/household/demographic/is_before_first_september_following_19th_birthday.py new file mode 100644 index 0000000000..6d30c8ad83 --- /dev/null +++ b/policyengine_uk/variables/household/demographic/is_before_first_september_following_19th_birthday.py @@ -0,0 +1,52 @@ +from policyengine_uk.model_api import * +from policyengine_uk.utils.dates import birth_day + + +class is_before_first_september_following_19th_birthday(Variable): + value_type = bool + entity = Person + label = ( + "Before the 1 September following the 19th birthday at the start of the year" + ) + documentation = ( + "Whether the fiscal year starts (6 April) before the 1 September " + "following the person's 19th birthday, the date to which a young " + "person in non-advanced education or approved training stays a " + "qualifying young person (UC Regs 2013 reg. 5(1)(b); SPC Regs 2002 " + "reg. 4A(1)(b)). The date comes from date_of_birth, or from age and " + "months_since_last_birthday. A 19th birthday on 31 August ends the " + "period that day, and one on 1 September runs it to the 20th " + "birthday. The period ends on a fixed 1 September that annual " + "periods cannot split, so a person in it for part of the year counts " + "for the year, as is_before_first_september_following_16th_birthday " + "does. Everyone aged 19 on 6 October is before the date. So is a " + "20-year-old born from 1 September to 6 October, whom the qualifying " + "young person age limit, read on 6 October, already excludes. So the " + "formula gives true for everyone under 20 on 6 October, which is " + "everyone that limit lets be a qualifying young person, and the " + "default is true: a situation that sets this for some people gives " + "everyone else true. That is the formula's value for anyone under 20; " + "for someone older it is not, but every reader of this variable is " + "behind the qualifying young person age limit, which excludes them " + "first. Set it to false for a person whose 1 September has passed, or " + "set their date_of_birth." + ) + definition_period = YEAR + default_value = True + reference = ( + "https://www.legislation.gov.uk/uksi/2013/376/regulation/5", + "https://www.legislation.gov.uk/uksi/2002/1792/regulation/4A", + ) + + def formula(person, period, parameters): + date_of_birth = birth_day(person, period) + # The 19th birthday falls in the birth year plus 19; the 1 September + # following it is in that year if the birthday is before 1 September, + # and otherwise in the next. + born_on_or_after_first_september = date_of_birth % 10_000 >= 901 + year_of_first_september = ( + date_of_birth // 10_000 + 19 + born_on_or_after_first_september + ) + # The year starts on 6 April, before 1 September of the same calendar + # year and after 1 September of the one before. + return year_of_first_september >= period.start.year