diff --git a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml index 2df3304f3..8461f366c 100644 --- a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml +++ b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml @@ -1,6 +1,6 @@ description: New Brunswick provides the following Spouse or Common-law partner base amount. values: - 2022-01-01: x + 2022-01-01: 10_105 2023-01-01: 10_741 2024-01-01: 11_246 metadata: diff --git a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/nb_spouse_and_common_law_partner_amount_credit.py b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/nb_spouse_and_common_law_partner_amount_credit.py deleted file mode 100644 index 8c1d85f40..000000000 --- a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/nb_spouse_and_common_law_partner_amount_credit.py +++ /dev/null @@ -1,31 +0,0 @@ -from policyengine_canada.model_api import * - -class nb_spouse_and_common_law_partner_amount_credit(Variable): - value_type = float - entity = Household - label = "New Brunswick spouse and common-law partner amount credit" - definition_period = YEAR - defined_for = ProvinceCode.NB - - p = parameters(period).gov.provinces.nb.tax.income.credits.spouse_or_common_law_partner_amount - base_amount = p.base_amount - max_credit = p.max_credit - - def formula(household, period, parameters): - year = period.start.year - if year == 2022: - base_amount = 10_105 - max_credit = 9_186 - elif year == 2023: - base_amount = 10_741 - max_credit = 9_764 - elif year == 2024: - base_amount = 11_246 - max_credit = 10_223 - else: - raise ValueError(f"Year {year} not supported.") - - spouse_income = add(household, period, ["spouse_income"]) - result = base_amount - spouse_income - return min(max_credit, max(0, result)) - diff --git a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/test.yaml b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/test.yaml index d09e85c47..c975e316e 100644 --- a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/test.yaml +++ b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/test.yaml @@ -1,6 +1,34 @@ - name: One person eligible and one not period: 2022 + input: + people: + head: + is_spouse: false + individual_net_income: 10_000 + spouse: + is_spouse: true + individual_net_income: 1_000 + household: + members: [head, spouse] + province_code: NB + output: + nb_spouse_and_common_law_partner_amount_credit: 9_105 + period: 2023 + input: + people: + head: + is_spouse: false + individual_net_income: 10_000 + spouse: + is_spouse: true + individual_net_income: 1_000 + household: + members: [head, spouse] + province_code: NB + output: + nb_spouse_and_common_law_partner_amount_credit: 9_741 + period: 2024 input: people: @@ -14,26 +42,54 @@ members: [head, spouse] province_code: NB output: - spouse_income: [0, 1_000] + nb_spouse_and_common_law_partner_amount_credit: 10_223 - name: Eligible spouse period: 2022 + input: + province_code: NB + is_spouse: true + individual_net_income: 10_000 + output: + nb_spouse_and_common_law_partner_amount_credit: 105 + period: 2023 + input: + province_code: NB + is_spouse: true + individual_net_income: 10_000 + output: + nb_spouse_and_common_law_partner_amount_credit: 741 + period: 2024 input: province_code: NB is_spouse: true individual_net_income: 10_000 output: - spouse_income: 10_000 + nb_spouse_and_common_law_partner_amount_credit: 1_246 - name: Ineligible spouse period: 2022 + input: + province_code: NB + is_spouse: false + individual_net_income: 10_000 + output: + nb_spouse_and_common_law_partner_amount_credit: 0 + period: 2023 - period: 2024 input: province_code: NB is_spouse: false individual_net_income: 10_000 output: - spouse_income: 0 \ No newline at end of file + nb_spouse_and_common_law_partner_amount_credit: 0 + + period: 2024 + input: + province_code: NB + is_spouse: false + individual_net_income: 10_000 + output: + nb_spouse_and_common_law_partner_amount_credit: 0 diff --git a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/nb_spouse_and_common_law_partner_amount_credit.yaml b/policyengine_canada/tests/gov/provinces/nb/tax/income/credits/nb_spouse_and_common_law_partner_amount_credit.yaml similarity index 78% rename from policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/nb_spouse_and_common_law_partner_amount_credit.yaml rename to policyengine_canada/tests/gov/provinces/nb/tax/income/credits/nb_spouse_and_common_law_partner_amount_credit.yaml index 6f3bb6b40..fe33d6bbe 100644 --- a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/nb_spouse_and_common_law_partner_amount_credit.yaml +++ b/policyengine_canada/tests/gov/provinces/nb/tax/income/credits/nb_spouse_and_common_law_partner_amount_credit.yaml @@ -75,4 +75,20 @@ output: nb_spouse_and_common_law_partner_amount_credit: 0 +parameters: + gov: + provinces: + nb: + tax: + income: + credits: + spouse_or_common_law_partner_amount: + base_amount: + 2022-01-01: 10_105 + 2023-01-01: 10_741 + 2024-01-01: 11_246 + max_credit: + 2022-01-01: 9_186 + 2023-01-01: 9_764 + 2024-01-01: 10_223 diff --git a/policyengine_canada/variables/gov/provinces/nb/tax/income/nb_spouse_and_common_law_partner_amount_credit.py b/policyengine_canada/variables/gov/provinces/nb/tax/income/nb_spouse_and_common_law_partner_amount_credit.py new file mode 100644 index 000000000..bc8e8da9e --- /dev/null +++ b/policyengine_canada/variables/gov/provinces/nb/tax/income/nb_spouse_and_common_law_partner_amount_credit.py @@ -0,0 +1,18 @@ +from policyengine_canada.model_api import * + +class nb_spouse_and_common_law_partner_amount_credit(Variable): + value_type = float + entity = Household + label = "New Brunswick spouse and common-law partner amount credit" + definition_period = YEAR + defined_for = ProvinceCode.NB + + + def formula(household, period, parameters): + p = parameters(period).gov.provinces.nb.tax.income.credits.spouse_or_common_law_partner_amount + base_amount = p.base_amount + max_credit = p.max_credit + + spouse_income = add(household, period, ["spouse_income"]) + reduced_amount = max_(base_amount - spouse_income, 0) +