diff --git a/changelog.d/fixed/fix-climate-action-category.md b/changelog.d/fixed/fix-climate-action-category.md new file mode 100644 index 000000000..2790eebf0 --- /dev/null +++ b/changelog.d/fixed/fix-climate-action-category.md @@ -0,0 +1 @@ +Fixed climate_action_incentive_category enum crash that broke household_net_income and marginal_tax_rate for all household types. diff --git a/policyengine_canada/tests/gov/cra/tax/income/credits/climate_action/climate_action_incentive_category.yaml b/policyengine_canada/tests/gov/cra/tax/income/credits/climate_action/climate_action_incentive_category.yaml new file mode 100644 index 000000000..9e9a88029 --- /dev/null +++ b/policyengine_canada/tests/gov/cra/tax/income/credits/climate_action/climate_action_incentive_category.yaml @@ -0,0 +1,74 @@ +- name: Two-parent household with child — category defaults without crash + period: 2026 + input: + people: + parent1: + age: 35 + is_head: true + is_spouse: false + employment_income: 50_000 + parent2: + age: 33 + is_head: false + is_spouse: true + child: + age: 5 + is_head: false + is_spouse: false + households: + household: + members: [parent1, parent2, child] + province_code: ONT + is_married: true + output: + climate_action_incentive_category: + - HEAD + - SPOUSE + - OTHER_CHILD + +- name: Single parent household — eldest child gets special category + period: 2026 + input: + people: + parent: + age: 35 + is_head: true + is_spouse: false + employment_income: 45_000 + child1: + age: 10 + is_head: false + is_spouse: false + is_dependant: true + child2: + age: 7 + is_head: false + is_spouse: false + is_dependant: true + households: + household: + members: [parent, child1, child2] + province_code: ONT + is_married: false + output: + climate_action_incentive_category: + - HEAD + - ELDEST_CHILD_IN_SINGLE_PARENT_HOUSEHOLD + - OTHER_CHILD + +- name: Single person — head only + period: 2026 + input: + people: + person: + age: 40 + is_head: true + is_spouse: false + employment_income: 90_000 + households: + household: + members: [person] + province_code: ONT + output: + climate_action_incentive_category: + - HEAD diff --git a/policyengine_canada/tests/gov/cra/tax/income/credits/climate_action/integration_two_parent.yaml b/policyengine_canada/tests/gov/cra/tax/income/credits/climate_action/integration_two_parent.yaml new file mode 100644 index 000000000..bc5efc3f6 --- /dev/null +++ b/policyengine_canada/tests/gov/cra/tax/income/credits/climate_action/integration_two_parent.yaml @@ -0,0 +1,53 @@ +- name: Two-parent household with child — household_net_income does not crash + period: 2026 + absolute_error_margin: 1 + input: + people: + parent1: + age: 35 + is_head: true + is_spouse: false + employment_income: 50_000 + parent2: + age: 33 + is_head: false + is_spouse: true + employment_income: 30_000 + child: + age: 5 + is_head: false + is_spouse: false + households: + household: + members: [parent1, parent2, child] + province_code: ONT + is_married: true + output: + climate_action_incentive_category: + - HEAD + - SPOUSE + - OTHER_CHILD + +- name: Married couple no children — climate action does not crash + period: 2026 + absolute_error_margin: 1 + input: + people: + head: + age: 40 + is_head: true + is_spouse: false + employment_income: 90_000 + spouse: + age: 38 + is_head: false + is_spouse: true + households: + household: + members: [head, spouse] + province_code: ONT + is_married: true + output: + climate_action_incentive_category: + - HEAD + - SPOUSE diff --git a/policyengine_canada/variables/gov/cra/tax/income/credits/climate_action/climate_action_incentive_category.py b/policyengine_canada/variables/gov/cra/tax/income/credits/climate_action/climate_action_incentive_category.py index fae5243d2..dc590c854 100644 --- a/policyengine_canada/variables/gov/cra/tax/income/credits/climate_action/climate_action_incentive_category.py +++ b/policyengine_canada/variables/gov/cra/tax/income/credits/climate_action/climate_action_incentive_category.py @@ -41,4 +41,5 @@ def formula(person, period, parameters): ClimateActionIncentiveCategory.ELDEST_CHILD_IN_SINGLE_PARENT_HOUSEHOLD, ClimateActionIncentiveCategory.OTHER_CHILD, ], + default=ClimateActionIncentiveCategory.OTHER_CHILD, )