Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
adf96a0
Implement tax free childcare
vahid-ahmadi Jan 10, 2025
ee24d61
Parameterize values
vahid-ahmadi Jan 13, 2025
12d24be
Reformatting to pass the tests
vahid-ahmadi Jan 13, 2025
235fd08
Reformatting with black
vahid-ahmadi Jan 13, 2025
b3b1967
Reformatting with black
vahid-ahmadi Jan 13, 2025
55ce6c3
Format code with black
vahid-ahmadi Jan 13, 2025
9952ed9
Format code with black using 79-char line length
vahid-ahmadi Jan 13, 2025
d6b22e5
Fix YAML structure
vahid-ahmadi Jan 13, 2025
b06a47c
Fix age condition YAML file
vahid-ahmadi Jan 13, 2025
90eb823
Fix age condition YAML file
vahid-ahmadi Jan 13, 2025
0c871a5
Fix other YAML files
vahid-ahmadi Jan 13, 2025
b28b5f8
Edit parameterization
vahid-ahmadi Jan 13, 2025
ff1f456
Fix formatting
vahid-ahmadi Jan 13, 2025
d3ad685
Edit age in YAML files
vahid-ahmadi Jan 13, 2025
5c6d359
Replace if with where
vahid-ahmadi Jan 13, 2025
e0221f8
Format with black
vahid-ahmadi Jan 13, 2025
fc83a03
Edit for test passing
vahid-ahmadi Jan 13, 2025
4421154
Edit format with black
vahid-ahmadi Jan 13, 2025
b4e8d1a
Edit format of benefit py file
vahid-ahmadi Jan 13, 2025
cf7f6e6
Edit child as not being boolean
vahid-ahmadi Jan 13, 2025
d4ff3b2
Change if to where
vahid-ahmadi Jan 14, 2025
0058402
Change disability definition
vahid-ahmadi Jan 14, 2025
37c7228
Solve .values problem
vahid-ahmadi Jan 14, 2025
af96f3a
Edit .values error
vahid-ahmadi Jan 14, 2025
e96bc2e
Edit vectorization problem
vahid-ahmadi Jan 14, 2025
153c2f6
Change folder from hmrc to dwp
vahid-ahmadi Jan 14, 2025
c9fbd0c
Use is_disabled_for_benefits variable
vahid-ahmadi Jan 14, 2025
a2f73d2
Add .astype(bool) to fix error
vahid-ahmadi Jan 14, 2025
a061877
Fix bitwise AND operation error
vahid-ahmadi Jan 14, 2025
a9ca8a7
Add .astype(bool) to conditions
vahid-ahmadi Jan 14, 2025
c7c6762
Add unit tests
vahid-ahmadi Jan 14, 2025
59e1b78
Reformat with black
vahid-ahmadi Jan 14, 2025
cebaace
Fix the folders
vahid-ahmadi Jan 15, 2025
c1a5cf0
Fix the folders
vahid-ahmadi Jan 15, 2025
49ec556
Merge branch 'tax-free-childcare-new' of https://github.com/policyeng…
vahid-ahmadi Jan 15, 2025
4a5cad5
Implement free childcare program
vahid-ahmadi Jan 15, 2025
4432db2
Format with black
vahid-ahmadi Jan 15, 2025
c7c1998
Change tests
vahid-ahmadi Jan 15, 2025
789f676
Edit format based on Pavel's comments
vahid-ahmadi Jan 17, 2025
9fc1b53
Edit tax-free childcare based on Pavel's comments
vahid-ahmadi Jan 20, 2025
a15d5a2
Reform with Black
vahid-ahmadi Jan 20, 2025
c1bb0e1
Remove redundant files
vahid-ahmadi Jan 22, 2025
df9f458
Edit files based on Pavel's comments
vahid-ahmadi Jan 23, 2025
d295f33
Format with black
vahid-ahmadi Jan 23, 2025
cb6ce03
Edit ‘adjusted_net_income’ and ‘is_blind’ parameters
vahid-ahmadi Jan 27, 2025
6b4656e
Format with black
vahid-ahmadi Jan 27, 2025
7c5f76d
Edit codes based on Max's comments
vahid-ahmadi Jan 28, 2025
060d9f5
Reslove a conflict
vahid-ahmadi Jan 28, 2025
e029a0b
Apply Max's comments
vahid-ahmadi Jan 28, 2025
536a410
Apply Max's comments
vahid-ahmadi Jan 29, 2025
b4d8890
Edit parameter in py code
vahid-ahmadi Jan 29, 2025
2956ae2
Add the benefit to the list of benefits
vahid-ahmadi Jan 30, 2025
5d45260
Apply Max's comments
vahid-ahmadi Jan 31, 2025
9fe23a3
Edit law part
vahid-ahmadi Jan 31, 2025
a707e07
Edit law part
vahid-ahmadi Feb 3, 2025
6899c77
Merge branch 'tax-free-childcare-new' of https://github.com/policyeng…
vahid-ahmadi Feb 3, 2025
d227246
Merge branch 'master' into tax-free-childcare-new
vahid-ahmadi Feb 4, 2025
a5ff04c
Edit benefit file for now
vahid-ahmadi Feb 4, 2025
9df3baf
Apply Nikhil's comments
vahid-ahmadi Feb 4, 2025
bd13fa9
Format with black
vahid-ahmadi Feb 4, 2025
d436430
Update policyengine_uk/parameters/gov/hmrc/tax_free_childcare/income/…
nikhilwoodruff Feb 4, 2025
f1f5f13
Edit the description of countable income sources
vahid-ahmadi Feb 4, 2025
1fc794a
Merge branch 'tax-free-childcare-new' of https://github.com/policyeng…
vahid-ahmadi Feb 4, 2025
cde37ba
Add TFC to gov_spending
vahid-ahmadi Feb 4, 2025
593adcf
Edit name of the variable tax_free_childcare
vahid-ahmadi Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from policyengine_uk.model_api import *


class child_age_eligible(Variable):
value_type = bool
entity = Person
label = "Child age eligibility requirements"
documentation = "Whether this person meets the age and disability requirements for eligibility"
definition_period = YEAR

def formula(person, period, parameters):
"""
Calculate age eligibility based on age and disability conditions.

Returns:
bool: True if eligible (under 12, or under 17 with disability), False otherwise
"""
# Get the benefit unit the person belongs to
benunit = person.benunit

# Get person's characteristics
age = person("age", period)

# Check disability conditions
gc = parameters(period).gov.dwp.pension_credit.guarantee_credit
standard_disability_benefits = gc.child.disability.eligibility
severe_disability_benefits = gc.child.disability.severe.eligibility

is_disabled = (add(person, period, standard_disability_benefits) |
add(person, period, severe_disability_benefits)) > 0

# Check age conditions
basic_age_condition = (age < 12)
age_under_17 = (age < 17)

# Combine conditions
eligible = basic_age_condition | (age_under_17 & is_disabled)

return benunit.any(eligible)
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from policyengine_uk.model_api import *


class meets_income_requirements(Variable):
value_type = bool
entity = Person
label = "Income requirements and calculations"
documentation = "Whether this person meets the income requirements for tax-free childcare based on age and income thresholds"
definition_period = YEAR

def formula(person, period):
"""
Calculate if a person meets income requirements based on their age and income.

Returns:
bool: True if they meet the income conditions for their age group
"""
# Get person's characteristics
age = person("age", period)

# Calculate eligible income
total_income = person("total_income", period)
# Extract investment incomes to subtract
investment_income = add(
person,
period,
[
"private_pension_income",
"savings_interest_income",
"dividend_income",
"property_income",
]
)

yearly_eligible_income = total_income - investment_income

# Income thresholds by age group
quarterly_income = yearly_eligible_income / 4

# Age >= 21
meets_adult_condition = (
(age >= 21) &
(quarterly_income >= 2379)
)

# Age 18-20
meets_young_adult_condition = (
(age >= 18) &
(age <= 20) &
(quarterly_income >= 1788)
)

# Age < 18
meets_youth_condition = (
(age < 18) &
(quarterly_income >= 1331)
)

# Combine all conditions
return (
meets_adult_condition |
meets_young_adult_condition |
meets_youth_condition
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from policyengine_uk.model_api import *


class incompatibilities_childcare_eligible(Variable):
value_type = bool
entity = Person
label = "Tax-Free Childcare Exclusions"
documentation = "Whether the person's benefit unit meets the incompatibility conditions for tax-free childcare (not receiving WTC, CTC, or UC)"
definition_period = YEAR

def formula(person, period, parameters):
"""
Calculate eligibility based on incompatible benefits.

Returns:
bool: True if eligible (no incompatible benefits received), False if receiving any incompatible benefits
"""
# Get the benefit unit the person belongs to
benunit = person.benunit

# Check if receiving any of the mutually exclusive benefits
has_wtc = benunit("working_tax_credit", period) > 0
has_ctc = benunit("child_tax_credit", period) > 0
has_uc = benunit("universal_credit", period) > 0

# Returns True when person's benefit unit does NOT receive any of these benefits
return ~(
has_wtc |
has_ctc |
has_uc
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from policyengine_uk.model_api import *

class childcare_work_condition(Variable):
value_type = bool
entity = Person
label = "Work conditions for tax-free childcare"
documentation = "Whether the person/couple meets work requirements for tax-free childcare"
definition_period = YEAR
def formula(person, period, parameters):
"""
Calculate if person meets work conditions for:
- Single working adult
- Couple where either both work or one works and other has disability/incapacity
"""
benunit = person.benunit
is_adult = person("is_adult", period)

# Basic work status
in_work = person("in_work", period)

# Get disability/incapacity conditions like we did in childcare age eligibility
gc = parameters(period).gov.dwp.pension_credit.guarantee_credit
standard_disability_benefits = gc.child.disability.eligibility
severe_disability_benefits = gc.child.disability.severe.eligibility

is_disabled = (add(person, period, standard_disability_benefits) |
add(person, period, severe_disability_benefits)) > 0

has_incapacity = person("incapacity_benefit", period) > 0

# Build conditions
# Single adult conditions
is_single = benunit.sum(is_adult) == 1
single_working = is_single & in_work

# Couple conditions
is_couple = benunit.sum(is_adult) == 2
partner_in_work = in_work
partner_has_condition = (is_disabled | has_incapacity)

couple_both_working = is_couple & in_work & partner_in_work
is_partner_working_with_disabled_person = is_couple & partner_in_work & (is_disabled | has_incapacity)
is_person_working_with_disabled_partner = is_couple & in_work & partner_has_condition

return (
single_working |
couple_both_working |
is_person_working_with_disabled_partner |
is_partner_working_with_disabled_person
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from policyengine_uk.model_api import *


def formula(benunit, period, parameters, parents_contribution):
# Define tax-free childcare parameters
p = {
"standard_child": {
"yearly_max": 2000
},
"disabled_child": {
"yearly_max": 4000
},
"government_contribution": 2/8
}

# Check eligibility conditions
meets_age_condition = benunit("child_age_eligible", period)
meets_income_condition = benunit.any(benunit.members("meets_income_requirements", period))
is_eligible = meets_age_condition & meets_income_condition & benunit("incompatibilities_childcare_eligible", period)

# Determine the maximum eligible childcare cost for a single child
max_amount = 0
for child in benunit.members("is_child", period):
if is_eligible[child]:
if child("is_disabled", period):
max_amount = p["disabled_child"]["yearly_max"] # Only consider disabled child's max
else:
max_amount = p["standard_child"]["yearly_max"] # Only consider standard child's max

# Calculate the government contribution
government_contribution = min(parents_contribution * p["government_contribution"], max_amount)

return government_contribution
Loading