-
Notifications
You must be signed in to change notification settings - Fork 32
Tax free childcare #1004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Tax free childcare #1004
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 ee24d61
Parameterize values
vahid-ahmadi 12d24be
Reformatting to pass the tests
vahid-ahmadi 235fd08
Reformatting with black
vahid-ahmadi b3b1967
Reformatting with black
vahid-ahmadi 55ce6c3
Format code with black
vahid-ahmadi 9952ed9
Format code with black using 79-char line length
vahid-ahmadi d6b22e5
Fix YAML structure
vahid-ahmadi b06a47c
Fix age condition YAML file
vahid-ahmadi 90eb823
Fix age condition YAML file
vahid-ahmadi 0c871a5
Fix other YAML files
vahid-ahmadi b28b5f8
Edit parameterization
vahid-ahmadi ff1f456
Fix formatting
vahid-ahmadi d3ad685
Edit age in YAML files
vahid-ahmadi 5c6d359
Replace if with where
vahid-ahmadi e0221f8
Format with black
vahid-ahmadi fc83a03
Edit for test passing
vahid-ahmadi 4421154
Edit format with black
vahid-ahmadi b4e8d1a
Edit format of benefit py file
vahid-ahmadi cf7f6e6
Edit child as not being boolean
vahid-ahmadi d4ff3b2
Change if to where
vahid-ahmadi 0058402
Change disability definition
vahid-ahmadi 37c7228
Solve .values problem
vahid-ahmadi af96f3a
Edit .values error
vahid-ahmadi e96bc2e
Edit vectorization problem
vahid-ahmadi 153c2f6
Change folder from hmrc to dwp
vahid-ahmadi c9fbd0c
Use is_disabled_for_benefits variable
vahid-ahmadi a2f73d2
Add .astype(bool) to fix error
vahid-ahmadi a061877
Fix bitwise AND operation error
vahid-ahmadi a9ca8a7
Add .astype(bool) to conditions
vahid-ahmadi c7c6762
Add unit tests
vahid-ahmadi 59e1b78
Reformat with black
vahid-ahmadi cebaace
Fix the folders
vahid-ahmadi c1a5cf0
Fix the folders
vahid-ahmadi 49ec556
Merge branch 'tax-free-childcare-new' of https://github.com/policyeng…
vahid-ahmadi 4a5cad5
Implement free childcare program
vahid-ahmadi 4432db2
Format with black
vahid-ahmadi c7c1998
Change tests
vahid-ahmadi 789f676
Edit format based on Pavel's comments
vahid-ahmadi 9fc1b53
Edit tax-free childcare based on Pavel's comments
vahid-ahmadi a15d5a2
Reform with Black
vahid-ahmadi c1bb0e1
Remove redundant files
vahid-ahmadi df9f458
Edit files based on Pavel's comments
vahid-ahmadi d295f33
Format with black
vahid-ahmadi cb6ce03
Edit ‘adjusted_net_income’ and ‘is_blind’ parameters
vahid-ahmadi 6b4656e
Format with black
vahid-ahmadi 7c5f76d
Edit codes based on Max's comments
vahid-ahmadi 060d9f5
Reslove a conflict
vahid-ahmadi e029a0b
Apply Max's comments
vahid-ahmadi 536a410
Apply Max's comments
vahid-ahmadi b4d8890
Edit parameter in py code
vahid-ahmadi 2956ae2
Add the benefit to the list of benefits
vahid-ahmadi 5d45260
Apply Max's comments
vahid-ahmadi 9fe23a3
Edit law part
vahid-ahmadi a707e07
Edit law part
vahid-ahmadi 6899c77
Merge branch 'tax-free-childcare-new' of https://github.com/policyeng…
vahid-ahmadi d227246
Merge branch 'master' into tax-free-childcare-new
vahid-ahmadi a5ff04c
Edit benefit file for now
vahid-ahmadi 9df3baf
Apply Nikhil's comments
vahid-ahmadi bd13fa9
Format with black
vahid-ahmadi d436430
Update policyengine_uk/parameters/gov/hmrc/tax_free_childcare/income/…
nikhilwoodruff f1f5f13
Edit the description of countable income sources
vahid-ahmadi 1fc794a
Merge branch 'tax-free-childcare-new' of https://github.com/policyeng…
vahid-ahmadi cde37ba
Add TFC to gov_spending
vahid-ahmadi 593adcf
Edit name of the variable tax_free_childcare
vahid-ahmadi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...gine_uk/variables/gov/hmrc/tax_free_childcare/conditions/childcare_age_child_condition.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
|
|
||
PavelMakarchuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Combine conditions | ||
| eligible = basic_age_condition | (age_under_17 & is_disabled) | ||
|
|
||
| return benunit.any(eligible) | ||
vahid-ahmadi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
64 changes: 64 additions & 0 deletions
64
...yengine_uk/variables/gov/hmrc/tax_free_childcare/conditions/childcare_income_condition.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
vahid-ahmadi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # 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 | ||
| ) | ||
31 changes: 31 additions & 0 deletions
31
...variables/gov/hmrc/tax_free_childcare/conditions/childcare_incompatibilities_condition.py
vahid-ahmadi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ) |
50 changes: 50 additions & 0 deletions
50
policyengine_uk/variables/gov/hmrc/tax_free_childcare/conditions/childcare_work_condition.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
vahid-ahmadi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 | ||
| ) | ||
33 changes: 33 additions & 0 deletions
33
policyengine_uk/variables/gov/hmrc/tax_free_childcare/tax-free-childcare-benefits.py
vahid-ahmadi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.