Skip to content

Commit 719d713

Browse files
Edit childcare programs' interactions and edit is_parent variable (#1106)
* Add fix to is_parent * Add total targets for universal childcare * Add a pytest * Edit pytest * Edit pytest * Edit year * Edit bounds * Hard code takeup rate * Black * Add no TFC condition * Format * Replace <= 0 with ==0 * Edit condition * Edit changes * Add other pytests * Format * Rename variable * Add intractions * Edit test * Add TFC * Edit * Add number of eligible children * Remove test_childcare.py to be excluded from PR * Remove test_childcare.py to be excluded from PR * add changelog * Edit changelog * Add comments * Black * Add would claim variable * Add max_free_entitlement_hours_used * Edit py file * Format * edit definition_period * edit definition_period * Add weeks_per_year * Add hours condition * Format * Add unit tests * Edit unit tests --------- Co-authored-by: Nikhil Woodruff <nikhil.woodruff@outlook.com>
1 parent 0f2cd0f commit 719d713

20 files changed

Lines changed: 333 additions & 37 deletions

changelog_entry.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- bump: patch
2+
changes:
3+
fixed:
4+
- Corrected the is_parent variable to properly identify parents.
5+
- Fixed logic in childcare programs to ensure accurate calculations.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
description: The Department for Education provides targeted, extended, and universal childcare entitlement for these weeks per year.
2+
metadata:
3+
period: year
4+
unit: week
5+
label: childcare entitlement weeks per year
6+
reference:
7+
- title: The Local Authority (Duty to Secure Early Years Provision Free of Charge) Regulations 2014 - regulation 4
8+
href: https://www.legislation.gov.uk/uksi/2014/2147/regulation/4/made
9+
- title: Childcare Choices document - 15 and 30 hours childcare support
10+
href: https://www.childcarechoices.gov.uk/15-and-30-hours-childcare-support/working-families/eligibility
11+
- title: Childcare (Early Years Provision Free of Charge) (Extended Entitlement) Regulations 2016 - Regulation 35(3)
12+
href: https://www.legislation.gov.uk/uksi/2016/1257/part/4/made
13+
values:
14+
2016-01-01: 38

policyengine_uk/tests/policy/baseline/gov/dfe/extended_childcare_entitlement/extended_childcare_entitlement.yaml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,37 @@
103103
members: [child1]
104104
extended_childcare_entitlement_eligible: false
105105
output:
106-
extended_childcare_entitlement: 0 # Not eligible
106+
extended_childcare_entitlement: 0 # Not eligible
107+
108+
- name: Child using fewer hours than maximum entitlement
109+
period: 2025
110+
absolute_error_margin: 1
111+
input:
112+
people:
113+
child1:
114+
age: 3
115+
max_free_entitlement_hours_used: 20
116+
benunits:
117+
benunit1:
118+
members: [child1]
119+
extended_childcare_entitlement_eligible: true
120+
output:
121+
extended_childcare_entitlement: 4611.457 # 20 hours * 38 weeks * £6.07 per hour (2025 rate)
122+
123+
- name: Child using fewer hours than maximum entitlement - multiple children
124+
period: 2025
125+
absolute_error_margin: 100
126+
input:
127+
people:
128+
child1:
129+
age: 2
130+
max_free_entitlement_hours_used: 10
131+
child2:
132+
age: 3
133+
max_free_entitlement_hours_used: 15
134+
benunits:
135+
benunit1:
136+
members: [child1, child2]
137+
extended_childcare_entitlement_eligible: true
138+
output:
139+
extended_childcare_entitlement: 6705.43 # (10 hours * 38 weeks * £8.58 per hour) + (15 hours * 38 weeks * £6.07 per hour) for 2025 rates
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
- name: Child under 2 (ineligible)
2+
period: 2024
3+
input:
4+
people:
5+
child:
6+
age: 1
7+
benunits:
8+
benunit:
9+
members: [child]
10+
targeted_childcare_entitlement_eligible: False
11+
output:
12+
targeted_childcare_entitlement: 0.0
13+
14+
- name: Child aged 2 (eligible)
15+
period: 2024
16+
input:
17+
people:
18+
child:
19+
age: 2
20+
benunits:
21+
benunit:
22+
members: [child]
23+
targeted_childcare_entitlement_eligible: True
24+
output:
25+
targeted_childcare_entitlement: 4_719.60 # 15 hours * 38 weeks * £8.28 per hour
26+
27+
- name: Child aged 3 (not eligible by age, but has targeting)
28+
period: 2024
29+
input:
30+
people:
31+
child:
32+
age: 3
33+
benunits:
34+
benunit:
35+
members: [child]
36+
targeted_childcare_entitlement_eligible: True
37+
output:
38+
targeted_childcare_entitlement: 0.0 # Not eligible by age even if targeting criteria met
39+
40+
- name: Child using fewer hours than maximum entitlement
41+
period: 2024
42+
input:
43+
people:
44+
child:
45+
age: 2
46+
max_free_entitlement_hours_used: 10
47+
benunits:
48+
benunit:
49+
members: [child]
50+
targeted_childcare_entitlement_eligible: True
51+
output:
52+
targeted_childcare_entitlement: 3_146.4 # 10 hours * 38 weeks * £8.28 per hour
53+
54+
- name: Child using exactly maximum entitlement
55+
period: 2024
56+
input:
57+
people:
58+
child:
59+
age: 2
60+
max_free_entitlement_hours_used: 15
61+
benunits:
62+
benunit:
63+
members: [child]
64+
targeted_childcare_entitlement_eligible: True
65+
output:
66+
targeted_childcare_entitlement: 4_719.6 # 15 hours * 38 weeks * £8.28 per hour
67+
68+
- name: Child using more than maximum entitlement (capped)
69+
period: 2024
70+
input:
71+
people:
72+
child:
73+
age: 2
74+
max_free_entitlement_hours_used: 20
75+
benunits:
76+
benunit:
77+
members: [child]
78+
targeted_childcare_entitlement_eligible: True
79+
output:
80+
targeted_childcare_entitlement: 4_719.6 # Capped at 15 hours * 38 weeks * £8.28 per hour
Lines changed: 81 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,123 @@
11
- name: Child under 3 isn't eligible (person-level)
22
period: 2024
33
input:
4-
age: 2
5-
universal_childcare_entitlement_eligible: False
4+
people:
5+
child:
6+
age: 2
7+
universal_childcare_entitlement_eligible: False
68
output:
79
universal_childcare_entitlement: 0.0
810

911
- name: Child aged 3 is eligible (person-level)
1012
period: 2024
1113
input:
12-
age: 3
13-
universal_childcare_entitlement_eligible: True
14+
people:
15+
child:
16+
age: 3
17+
universal_childcare_entitlement_eligible: True
1418
output:
15-
universal_childcare_entitlement: 3351.60
19+
universal_childcare_entitlement: 3_351.60
1620

1721
- name: Child aged 4 is eligible (person-level)
1822
period: 2024
1923
input:
20-
age: 4
21-
universal_childcare_entitlement_eligible: True
24+
people:
25+
child:
26+
age: 4
27+
universal_childcare_entitlement_eligible: True
2228
output:
23-
universal_childcare_entitlement: 3351.60
29+
universal_childcare_entitlement: 3_351.60
2430

2531
- name: Parent (ineligible)
2632
period: 2024
2733
input:
28-
age: 35
29-
universal_childcare_entitlement_eligible: False
34+
people:
35+
parent:
36+
age: 35
37+
universal_childcare_entitlement_eligible: False
3038
output:
3139
universal_childcare_entitlement: 0.0
3240

3341
- name: Child aged 2 (ineligible)
3442
period: 2024
3543
input:
36-
age: 2
37-
universal_childcare_entitlement_eligible: False
44+
people:
45+
child:
46+
age: 2
47+
universal_childcare_entitlement_eligible: False
3848
output:
3949
universal_childcare_entitlement: 0.0
4050

4151
- name: Child aged 3 (eligible)
4252
period: 2024
4353
input:
44-
age: 3
45-
universal_childcare_entitlement_eligible: True
54+
people:
55+
child:
56+
age: 3
57+
universal_childcare_entitlement_eligible: True
4658
output:
47-
universal_childcare_entitlement: 3351.60
59+
universal_childcare_entitlement: 3_351.60
4860

4961
- name: Child aged 4 (eligible)
5062
period: 2024
5163
input:
52-
age: 4
53-
universal_childcare_entitlement_eligible: True
64+
people:
65+
child:
66+
age: 4
67+
universal_childcare_entitlement_eligible: True
5468
output:
55-
universal_childcare_entitlement: 3351.60
69+
universal_childcare_entitlement: 3_351.60
5670

5771
- name: Child aged 5 (ineligible)
5872
period: 2024
5973
input:
60-
age: 5
61-
universal_childcare_entitlement_eligible: False
74+
people:
75+
child:
76+
age: 5
77+
universal_childcare_entitlement_eligible: False
6278
output:
63-
universal_childcare_entitlement: 0.0
79+
universal_childcare_entitlement: 0.0
80+
81+
- name: Child using fewer hours than maximum entitlement
82+
period: 2024
83+
input:
84+
people:
85+
child:
86+
age: 3
87+
universal_childcare_entitlement_eligible: True
88+
max_free_entitlement_hours_used: 10
89+
output:
90+
universal_childcare_entitlement: 2_234.4 # 10 hours * 38 weeks * £5.88 per hour
91+
92+
- name: Child using half of maximum entitlement
93+
period: 2024
94+
input:
95+
people:
96+
child:
97+
age: 3
98+
universal_childcare_entitlement_eligible: True
99+
max_free_entitlement_hours_used: 15
100+
output:
101+
universal_childcare_entitlement: 3_351.6 # 15 hours * 38 weeks * £5.88 per hour
102+
103+
- name: Child using exactly maximum entitlement
104+
period: 2024
105+
input:
106+
people:
107+
child:
108+
age: 4
109+
universal_childcare_entitlement_eligible: True
110+
max_free_entitlement_hours_used: 15
111+
output:
112+
universal_childcare_entitlement: 3_351.6 # 15 hours * 38 weeks * £5.88 per hour
113+
114+
- name: Child using more than maximum entitlement (capped)
115+
period: 2024
116+
input:
117+
people:
118+
child:
119+
age: 3
120+
universal_childcare_entitlement_eligible: True
121+
max_free_entitlement_hours_used: 20
122+
output:
123+
universal_childcare_entitlement: 3_351.6 # Capped at 15 hours * 38 weeks * £5.88 per hour

policyengine_uk/variables/gov/dfe/care_to_learn/care_to_learn_eligible.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class care_to_learn_eligible(Variable):
66
entity = Person
77
label = "eligible for Care to Learn childcare support"
88
definition_period = YEAR
9+
defined_for = "would_claim_care_to_learn"
910

1011
def formula(person, period, parameters):
1112
# Link for instruction: https://www.gov.uk/care-to-learn/eligibility
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from policyengine_uk.model_api import *
2+
3+
4+
class would_claim_care_to_learn(Variable):
5+
value_type = bool
6+
entity = BenUnit
7+
label = "would claim Care to Learn"
8+
documentation = (
9+
"Whether this BenUnit would claim Care to Learn if eligible"
10+
)
11+
definition_period = YEAR
12+
default_value = True

policyengine_uk/variables/gov/dfe/extended_childcare_entitlement/extended_childcare_entitlement.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ def formula(benunit, period, parameters):
1919
age
2020
)
2121

22+
# Get max hours used per child
23+
max_hours_used = benunit.members(
24+
"max_free_entitlement_hours_used", period
25+
)
26+
27+
# Use the appropriate hours based on the condition
28+
weekly_hours_to_use = min_(max_hours_used, weekly_hours_per_child)
29+
2230
# Compute weekly subsidy per child
2331
weekly_subsidy_per_child = (
24-
weekly_hours_per_child * p.childcare_funding_rate.calc(age)
32+
weekly_hours_to_use * p.childcare_funding_rate.calc(age)
2533
)
2634

2735
# Compute total annual expenses
28-
return (
29-
benunit.sum(weekly_subsidy_per_child)
30-
* p.extended_childcare_entitlement.weeks_per_year
31-
)
36+
weeks = p.weeks_per_year
37+
return benunit.sum(weekly_subsidy_per_child) * weeks

policyengine_uk/variables/gov/dfe/extended_childcare_entitlement/extended_childcare_entitlement_eligible.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class extended_childcare_entitlement_eligible(Variable):
66
entity = BenUnit
77
label = "eligibility for extended childcare entitlement"
88
definition_period = YEAR
9+
defined_for = "would_claim_extended_childcare"
910

1011
def formula(benunit, period, parameters):
1112
# Check if household is in England
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from policyengine_uk.model_api import *
2+
3+
4+
class would_claim_extended_childcare(Variable):
5+
value_type = bool
6+
entity = BenUnit
7+
label = "would claim extended childcare entitlement"
8+
documentation = "Whether this family would claim extended childcare entitlement if eligible"
9+
definition_period = YEAR
10+
default_value = True

0 commit comments

Comments
 (0)