diff --git a/policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds/adult.yaml b/policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds.yaml similarity index 55% rename from policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds/adult.yaml rename to policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds.yaml index 5089229d..343605a0 100644 --- a/policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds/adult.yaml +++ b/policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds.yaml @@ -1,22 +1,23 @@ -description: Income thresholds for tax-free childcare eligibility - adult category +description: Income thresholds for tax-free childcare eligibility metadata: period: year - label: Adult income thresholds for tax-free childcare eligibility + label: Income thresholds for tax-free childcare eligibility reference: - title: Childcare Payments Act href: https://www.legislation.gov.uk/ukdsi/2015/9780111127063 - title: Tax-Free Childcare Guidance href: https://www.gov.uk/tax-free-childcare?step-by-step-nav=d78aeaf6-1747-4d72-9619-f16efb4dd89d -quarterly_income: - values: - 2015-01-01: 2379 - metadata: - unit: currency-GBP - -min_age: - values: - 2015-01-01: 21 - metadata: - unit: year - period: year \ No newline at end of file +brackets: + - threshold: + 2015-01-01: 0 + amount: + 2015-01-01: 0 + - threshold: + 2015-01-01: 18 + amount: + 2015-01-01: 1_788 + - threshold: + 2015-01-01: 21 + amount: + 2015-01-01: 2_379 \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds/young_adult.yaml b/policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds/young_adult.yaml deleted file mode 100644 index 4e82458f..00000000 --- a/policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds/young_adult.yaml +++ /dev/null @@ -1,29 +0,0 @@ -description: Income thresholds for tax-free childcare eligibility - young adult category -metadata: - period: year - label: Young adult income thresholds for tax-free childcare eligibility - reference: - - title: Childcare Payments Act - href: https://www.legislation.gov.uk/ukdsi/2015/9780111127063 - - title: Tax-Free Childcare Guidance - href: https://www.gov.uk/tax-free-childcare?step-by-step-nav=d78aeaf6-1747-4d72-9619-f16efb4dd89d - -quarterly_income: - values: - 2015-01-01: 1788 - metadata: - unit: currency-GBP - -min_age: - values: - 2015-01-01: 18 - metadata: - unit: year - period: year - -max_age: - values: - 2015-01-01: 20 - metadata: - unit: year - period: year \ No newline at end of file diff --git a/policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds/youth.yaml b/policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds/youth.yaml deleted file mode 100644 index 339627ff..00000000 --- a/policyengine_uk/parameters/gov/hmrc/childcare_subsidies/tax_free_childcare/income_thresholds/youth.yaml +++ /dev/null @@ -1,15 +0,0 @@ -description: Income thresholds for tax-free childcare eligibility - youth category -metadata: - period: year - label: Youth income thresholds for tax-free childcare eligibility - reference: - - title: Childcare Payments Act - href: https://www.legislation.gov.uk/ukdsi/2015/9780111127063 - - title: Tax-Free Childcare Guidance - href: https://www.gov.uk/tax-free-childcare?step-by-step-nav=d78aeaf6-1747-4d72-9619-f16efb4dd89d - -quarterly_income: - values: - 2015-01-01: 1331 - metadata: - unit: currency-GBP \ No newline at end of file diff --git a/policyengine_uk/variables/gov/hmrc/tax_free_childcare/conditions/childcare_age_child_condition.py b/policyengine_uk/variables/gov/hmrc/tax_free_childcare/conditions/childcare_age_child_condition.py index 827f14f6..a8d89ba2 100644 --- a/policyengine_uk/variables/gov/hmrc/tax_free_childcare/conditions/childcare_age_child_condition.py +++ b/policyengine_uk/variables/gov/hmrc/tax_free_childcare/conditions/childcare_age_child_condition.py @@ -1,6 +1,5 @@ from policyengine_uk.model_api import * - class child_age_eligible(Variable): value_type = bool entity = Person @@ -22,8 +21,8 @@ def formula(person, period, parameters): age_limits = parameters( period ).gov.hmrc.childcare_subsidies.tax_free_childcare.age - standard_age_limit = age_limits.standard.values - disability_age_limit = age_limits.disability.values + standard_age_limit = age_limits.standard + disability_age_limit = age_limits.disability # Check disability conditions gc = parameters( @@ -42,4 +41,4 @@ def formula(person, period, parameters): age_under_disability_limit = age < disability_age_limit # Combine conditions - return basic_age_condition | (age_under_disability_limit & is_disabled) + return basic_age_condition | (age_under_disability_limit & is_disabled) \ No newline at end of file diff --git a/policyengine_uk/variables/gov/hmrc/tax_free_childcare/conditions/childcare_income_condition.py b/policyengine_uk/variables/gov/hmrc/tax_free_childcare/conditions/childcare_income_condition.py index ac4bfc08..22bec712 100644 --- a/policyengine_uk/variables/gov/hmrc/tax_free_childcare/conditions/childcare_income_condition.py +++ b/policyengine_uk/variables/gov/hmrc/tax_free_childcare/conditions/childcare_income_condition.py @@ -33,36 +33,14 @@ def formula(person, period, parameters): ) yearly_eligible_income = max_(total_income - investment_income, 0) + quarterly_income = yearly_eligible_income / 4 - # Get income thresholds from parameters + # Get required income threshold based on age income_limits = parameters( period ).gov.hmrc.childcare_subsidies.tax_free_childcare.income_thresholds - quarterly_income = yearly_eligible_income / 4 - - # Age >= 21 - meets_adult_condition = (age >= income_limits.adult.min_age.values) & ( - quarterly_income >= income_limits.adult.quarterly_income.values - ) - - # Age 18-20 - meets_young_adult_condition = ( - (age >= income_limits.young_adult.min_age.values) - & (age <= income_limits.young_adult.max_age.values) - & ( - quarterly_income - >= income_limits.young_adult.quarterly_income.values - ) - ) - - # Age < 18 - meets_youth_condition = ( - age < income_limits.young_adult.min_age.values - ) & (quarterly_income >= income_limits.youth.quarterly_income.values) - - # Combine all conditions - return ( - meets_adult_condition - | meets_young_adult_condition - | meets_youth_condition - ) + + required_threshold = income_limits.calc(age) + + # Compare quarterly income to required threshold + return quarterly_income >= required_threshold \ No newline at end of file diff --git a/policyengine_uk/variables/gov/hmrc/tax_free_childcare/tax_free_childcare_benefits.py b/policyengine_uk/variables/gov/hmrc/tax_free_childcare/tax_free_childcare_benefits.py index 91ef3b4e..39438d46 100644 --- a/policyengine_uk/variables/gov/hmrc/tax_free_childcare/tax_free_childcare_benefits.py +++ b/policyengine_uk/variables/gov/hmrc/tax_free_childcare/tax_free_childcare_benefits.py @@ -40,10 +40,14 @@ def formula(benunit, period, parameters): # 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.values - else: - max_amount = p.standard_child.values - - return where(is_eligible, max_amount, 0) + max_amount = where( + is_eligible[child], + where( + child("is_disabled", period), + p.disabled_child.values, + p.standard_child.values + ), + max_amount + ) + + return where(is_eligible, max_amount, 0) \ No newline at end of file