From 21806397880a886f4031ce10edec11e91ce694d7 Mon Sep 17 00:00:00 2001 From: karenlilr <167912915+karenlilr@users.noreply.github.com> Date: Fri, 14 Jun 2024 12:53:48 +0000 Subject: [PATCH 01/11] New Brunswick Spouse or Common-law partner amount Fixes #352 --- .../credits/spouse_or_common_law_partner_amount/base_amount.yaml | 0 .../credits/spouse_or_common_law_partner_amount/income_cap.yaml | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml create mode 100644 policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml 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 new file mode 100644 index 000000000..e69de29bb diff --git a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml new file mode 100644 index 000000000..e69de29bb From f548033dd9e529dce872692fee6dcd27d6b90255 Mon Sep 17 00:00:00 2001 From: karenlilr <167912915+karenlilr@users.noreply.github.com> Date: Tue, 18 Jun 2024 06:32:55 +0000 Subject: [PATCH 02/11] Fixes #352 --- .../spouse_or_common_law_partner_amount/base_amount.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) 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 e69de29bb..a1201a07e 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 @@ -0,0 +1,9 @@ +description: New Brunswick Spouse or Common-law partner base amount. +values: + 2023-12-31: 10_741 +metadata: + unit: currency-CAD + label: New Brunswick Spouse or Common-law Partner Base Amount + reference: + - title: Worksheet for the 2023 New Brunswick Personal Tax Credits Return + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf \ No newline at end of file From bfa2e0e801e863c806cda529435d37c3280635d6 Mon Sep 17 00:00:00 2001 From: karenlilr <167912915+karenlilr@users.noreply.github.com> Date: Sat, 22 Jun 2024 12:39:08 +0000 Subject: [PATCH 03/11] base amount Fixes #352 --- .../spouse_or_common_law_partner_amount/income_cap.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml index e69de29bb..d41dba877 100644 --- a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml +++ b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml @@ -0,0 +1,9 @@ +description: New Brunswick Spouse or Common-law partner income cap. +values: + 2023-12-31: 10_741 +metadata: + unit: currency-CAD + label: New Brunswick Spouse or Common-law Partner Income Cap + reference: + - title: Worksheet for the 2023 New Brunswick Personal Tax Credits Return + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf \ No newline at end of file From 5a1d9a9ddd1bfaaf0116dc20ab702913a199cfef Mon Sep 17 00:00:00 2001 From: karenlilr <167912915+karenlilr@users.noreply.github.com> Date: Thu, 27 Jun 2024 04:10:42 +0000 Subject: [PATCH 04/11] base amount format and income cap value Fixes #352 --- .../spouse_or_common_law_partner_amount/base_amount.yaml | 7 ++++--- .../spouse_or_common_law_partner_amount/income_cap.yaml | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) 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 a1201a07e..d25e508f2 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,9 +1,10 @@ -description: New Brunswick Spouse or Common-law partner base amount. +description: New Brunswick provides the following Spouse or Common-law partner base amount. values: - 2023-12-31: 10_741 + 2023-01-01: 10_741 metadata: unit: currency-CAD + period: year label: New Brunswick Spouse or Common-law Partner Base Amount reference: - title: Worksheet for the 2023 New Brunswick Personal Tax Credits Return - href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf \ No newline at end of file + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf#page=1 \ No newline at end of file diff --git a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml index d41dba877..cff8bbc70 100644 --- a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml +++ b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml @@ -1,9 +1,10 @@ -description: New Brunswick Spouse or Common-law partner income cap. +description: New Brunswick reduces Spouse or Common-law partner amount for households with spouse income above this threshold. values: - 2023-12-31: 10_741 + 2023-01-01: 1_023 metadata: unit: currency-CAD + period: year label: New Brunswick Spouse or Common-law Partner Income Cap reference: - - title: Worksheet for the 2023 New Brunswick Personal Tax Credits Return - href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf \ No newline at end of file + - title: 2024 New Brunswick Personal Tax Credits Return + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb/td1nb-24e.pdf#page=1 \ No newline at end of file From 2e953f16d0555dba2d5ad4d94f74eb3804f5f429 Mon Sep 17 00:00:00 2001 From: karenlilr <167912915+karenlilr@users.noreply.github.com> Date: Fri, 5 Jul 2024 10:04:44 +0000 Subject: [PATCH 05/11] 2023 code Fixes #352 --- .../base_amount.yaml | 105 +++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) 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 d25e508f2..a06a21e42 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 @@ -7,4 +7,107 @@ metadata: label: New Brunswick Spouse or Common-law Partner Base Amount reference: - title: Worksheet for the 2023 New Brunswick Personal Tax Credits Return - href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf#page=1 \ No newline at end of file + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf#page=1 + - title: 2023 New Brunswick Personal Tax Credits Return + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf#page=1 + +- name: No spouse income + period: 2023 + input: + people: + head: + spouse_income: 0 + spouse: + spouse_income: 0 + household: + members: [head, spouse] + province_code: NB + output: + ab_spouse_and_common_law_partner_amount_credit: 9_764 + +- name: Spouse income of $1,000 + period: 2023 + input: + province_code: NB + spouse_income: 1_000 + output: + ab_spouse_and_common_law_partner_amount_credit: 9_741 + +- name: Spouse income of $10,000 + period: 2023 + input: + province_code: NB + spouse_income: 10_000 + output: + ab_spouse_and_common_law_partner_amount_credit: 741 + +- name: Capped at 0 + period: 2023 + input: + province_code: AB + spouse_income: 40_000 + output: + ab_spouse_and_common_law_partner_amount_credit: 0 + +SPOUSE_INCOME +- name: One person eligible and one not + 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: + spouse_income: [0, 1_000] + +- name: Eligible spouse + period: 2023 + input: + province_code: NB + is_spouse: true + individual_net_income: 10_000 + output: + spouse_income: 10_000 + +- name: Ineligible spouse + period: 2023 + input: + province_code: NB + is_spouse: false + individual_net_income: 10_000 + output: + spouse_income: 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 + + def formula(household, period, parameters): + spouse_income = add(household, period, ["spouse_income"]) + base_amount = 10_741 + max_credit = 9_764 + result = base_amount - spouse_income + return min(max_credit, max(0, result)) + +class spouse_income(Variable): + value_type = float + entity = Person + label = "Spouse and commonlaw partner income" + definition_period = YEAR + + def formula(person, period, parameters): + spouse = person("is_spouse", period) + income = person("individual_net_income", period) + return spouse * income From bb187bec825c54623338bcae2862ccc87b8a7b2e Mon Sep 17 00:00:00 2001 From: karenlilr <167912915+karenlilr@users.noreply.github.com> Date: Tue, 9 Jul 2024 20:03:10 +0000 Subject: [PATCH 06/11] test file, code in python file, and max credit file added Fixes #352 --- .../base_amount.yaml | 110 ++---------------- .../income_cap.yaml | 10 -- .../max_credit.yaml | 16 +++ ...se_and_common_law_partner_amount_credit.py | 31 +++++ ..._and_common_law_partner_amount_credit.yaml | 78 +++++++++++++ .../test.yaml | 39 +++++++ 6 files changed, 174 insertions(+), 110 deletions(-) delete mode 100644 policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml create mode 100644 policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_credit.yaml create mode 100644 policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/nb_spouse_and_common_law_partner_amount_credit.py create mode 100644 policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/nb_spouse_and_common_law_partner_amount_credit.yaml create mode 100644 policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/test.yaml 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 a06a21e42..2df3304f3 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,113 +1,23 @@ description: New Brunswick provides the following Spouse or Common-law partner base amount. values: + 2022-01-01: x 2023-01-01: 10_741 + 2024-01-01: 11_246 metadata: unit: currency-CAD period: year label: New Brunswick Spouse or Common-law Partner Base Amount reference: + - title: Worksheet for the 2022 New Brunswick Personal Tax Credits Return + href: https://www.cchwebsites.com/content/pdf/tax_forms/ca/en/td1nbws_en.pdf#page=1 + - title: 2022 New Brunswick Personal Tax Credits Return + href: https://www.vitalitenb.ca/sites/default/files/documents/employes/td1nb_nb_personal_tax_credits_return.pdf#page=1 - title: Worksheet for the 2023 New Brunswick Personal Tax Credits Return href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf#page=1 - title: 2023 New Brunswick Personal Tax Credits Return href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf#page=1 + - title: 2024 New Brunswick Personal Tax Credits Return + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb/td1nb-24e.pdf#page=1 + - title: Worksheet for the 2024 New Brunswick Personal Tax Credits Return + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-24e.pdf#page=1 -- name: No spouse income - period: 2023 - input: - people: - head: - spouse_income: 0 - spouse: - spouse_income: 0 - household: - members: [head, spouse] - province_code: NB - output: - ab_spouse_and_common_law_partner_amount_credit: 9_764 - -- name: Spouse income of $1,000 - period: 2023 - input: - province_code: NB - spouse_income: 1_000 - output: - ab_spouse_and_common_law_partner_amount_credit: 9_741 - -- name: Spouse income of $10,000 - period: 2023 - input: - province_code: NB - spouse_income: 10_000 - output: - ab_spouse_and_common_law_partner_amount_credit: 741 - -- name: Capped at 0 - period: 2023 - input: - province_code: AB - spouse_income: 40_000 - output: - ab_spouse_and_common_law_partner_amount_credit: 0 - -SPOUSE_INCOME -- name: One person eligible and one not - 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: - spouse_income: [0, 1_000] - -- name: Eligible spouse - period: 2023 - input: - province_code: NB - is_spouse: true - individual_net_income: 10_000 - output: - spouse_income: 10_000 - -- name: Ineligible spouse - period: 2023 - input: - province_code: NB - is_spouse: false - individual_net_income: 10_000 - output: - spouse_income: 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 - - def formula(household, period, parameters): - spouse_income = add(household, period, ["spouse_income"]) - base_amount = 10_741 - max_credit = 9_764 - result = base_amount - spouse_income - return min(max_credit, max(0, result)) - -class spouse_income(Variable): - value_type = float - entity = Person - label = "Spouse and commonlaw partner income" - definition_period = YEAR - - def formula(person, period, parameters): - spouse = person("is_spouse", period) - income = person("individual_net_income", period) - return spouse * income diff --git a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml deleted file mode 100644 index cff8bbc70..000000000 --- a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/income_cap.yaml +++ /dev/null @@ -1,10 +0,0 @@ -description: New Brunswick reduces Spouse or Common-law partner amount for households with spouse income above this threshold. -values: - 2023-01-01: 1_023 -metadata: - unit: currency-CAD - period: year - label: New Brunswick Spouse or Common-law Partner Income Cap - reference: - - title: 2024 New Brunswick Personal Tax Credits Return - href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb/td1nb-24e.pdf#page=1 \ No newline at end of file diff --git a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_credit.yaml b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_credit.yaml new file mode 100644 index 000000000..07b47f064 --- /dev/null +++ b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_credit.yaml @@ -0,0 +1,16 @@ +description: The New Brunswick spouse or common-law partner amount credit is calculated by taking into account the spouse's net income and comparing it to a base amount. The maximum credit is the highest amount that can be claimed as a credit. +values: + 2022-01-01: 9_186 + 2023-01-01: 9_764 + 2024-01-01: 10_223 +metadata: + unit: currency-CAD + period: year + label: New Brunswick Spouse or Common-law Partner Max Credit + reference: + - title: Worksheet for the 2022 New Brunswick Personal Tax Credits Return + href: https://www.cchwebsites.com/content/pdf/tax_forms/ca/en/td1nbws_en.pdf#page=1 + - title: Worksheet for the 2023 New Brunswick Personal Tax Credits Return + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf#page=1 + - title: Worksheet for the 2024 New Brunswick Personal Tax Credits Return + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-24e.pdf#page=1 \ No newline at end of file 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 new file mode 100644 index 000000000..8c1d85f40 --- /dev/null +++ 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 @@ -0,0 +1,31 @@ +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/nb_spouse_and_common_law_partner_amount_credit.yaml b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/nb_spouse_and_common_law_partner_amount_credit.yaml new file mode 100644 index 000000000..6f3bb6b40 --- /dev/null +++ b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/nb_spouse_and_common_law_partner_amount_credit.yaml @@ -0,0 +1,78 @@ +- name: No spouse income in 2022 + period: 2022 + input: + people: + head: + spouse_income: 0 + spouse: + spouse_income: 0 + household: + members: [head, spouse] + province_code: NB + output: + nb_spouse_and_common_law_partner_amount_credit: 9_186 + +- name: Spouse income of $1,000 in 2022 + period: 2022 + input: + province_code: NB + spouse_income: 1_000 + output: + nb_spouse_and_common_law_partner_amount_credit: 9_105 + +- name: Spouse income of $10,000 in 2022 + period: 2022 + input: + province_code: NB + spouse_income: 10_000 + output: + nb_spouse_and_common_law_partner_amount_credit: 105 + +- name: Capped at 0 in 2022 + period: 2022 + input: + province_code: NB + spouse_income: 40_000 + output: + nb_spouse_and_common_law_partner_amount_credit: 0 + + +- name: No spouse income + period: 2023 + input: + people: + head: + spouse_income: 0 + spouse: + spouse_income: 0 + household: + members: [head, spouse] + province_code: NB + output: + nb_spouse_and_common_law_partner_amount_credit: 9_764 + +- name: Spouse income of $1,000 + period: 2023 + input: + province_code: NB + spouse_income: 1_000 + output: + nb_spouse_and_common_law_partner_amount_credit: 9_741 + +- name: Spouse income of $10,000 + period: 2023 + input: + province_code: NB + spouse_income: 10_000 + output: + nb_spouse_and_common_law_partner_amount_credit: 741 + +- name: Capped at 0 + period: 2023 + input: + province_code: AB + spouse_income: 40_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/test.yaml b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/test.yaml new file mode 100644 index 000000000..d09e85c47 --- /dev/null +++ b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/test.yaml @@ -0,0 +1,39 @@ +- name: One person eligible and one not + period: 2022 + period: 2023 + period: 2024 + 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: + spouse_income: [0, 1_000] + +- name: Eligible spouse + period: 2022 + period: 2023 + period: 2024 + input: + province_code: NB + is_spouse: true + individual_net_income: 10_000 + output: + spouse_income: 10_000 + +- name: Ineligible spouse + period: 2022 + 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 From f9bc39454936b9e541a941dc8e727cb72eabadfe Mon Sep 17 00:00:00 2001 From: karenlilr <167912915+karenlilr@users.noreply.github.com> Date: Wed, 17 Jul 2024 07:21:00 +0000 Subject: [PATCH 07/11] parameters, hard code Fixes #352 --- .../base_amount.yaml | 2 +- ...se_and_common_law_partner_amount_credit.py | 31 --------- .../test.yaml | 64 +++++++++++++++++-- ..._and_common_law_partner_amount_credit.yaml | 16 +++++ ...se_and_common_law_partner_amount_credit.py | 18 ++++++ 5 files changed, 95 insertions(+), 36 deletions(-) delete mode 100644 policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/nb_spouse_and_common_law_partner_amount_credit.py rename policyengine_canada/{parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount => tests/gov/provinces/nb/tax/income/credits}/nb_spouse_and_common_law_partner_amount_credit.yaml (78%) create mode 100644 policyengine_canada/variables/gov/provinces/nb/tax/income/nb_spouse_and_common_law_partner_amount_credit.py 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) + From aadd15675add8decc9d0f8611d6509a87350b606 Mon Sep 17 00:00:00 2001 From: karenlilr <167912915+karenlilr@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:31:13 +0000 Subject: [PATCH 08/11] Fixes #352 --- ...ouse_and_common_law_partner_amount_credit.yaml | 15 --------------- ...spouse_and_common_law_partner_amount_credit.py | 1 + 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/policyengine_canada/tests/gov/provinces/nb/tax/income/credits/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 index fe33d6bbe..8e58e83a7 100644 --- a/policyengine_canada/tests/gov/provinces/nb/tax/income/credits/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 @@ -59,21 +59,6 @@ output: nb_spouse_and_common_law_partner_amount_credit: 9_741 -- name: Spouse income of $10,000 - period: 2023 - input: - province_code: NB - spouse_income: 10_000 - output: - nb_spouse_and_common_law_partner_amount_credit: 741 - -- name: Capped at 0 - period: 2023 - input: - province_code: AB - spouse_income: 40_000 - output: - nb_spouse_and_common_law_partner_amount_credit: 0 parameters: gov: 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 index bc8e8da9e..7bb6ed75d 100644 --- 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 @@ -15,4 +15,5 @@ def formula(household, period, parameters): spouse_income = add(household, period, ["spouse_income"]) reduced_amount = max_(base_amount - spouse_income, 0) + return min(max_credit, reduced_amount) From 1822c7d84fc2bc6e44511b4adf377d9d32219ba0 Mon Sep 17 00:00:00 2001 From: karenlilr <167912915+karenlilr@users.noreply.github.com> Date: Tue, 30 Jul 2024 06:45:54 +0000 Subject: [PATCH 09/11] added to changelog_entry.yaml Fixes #352 --- changelog_entry.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..96ca407de 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: minor + changes: + added: + - New Brunswick Spouse or Common-law Partner base amount for the years 2022, 2023, and 2024; nb_spouse_and_common_law_partner_amount_credit to calculate the credit dynamically based on parameters; test cases; parameter configurations for base_amount and max_credit in the parameters file. \ No newline at end of file From 949d624d5f328647e832efc9e6a6609ffb83ab83 Mon Sep 17 00:00:00 2001 From: karenlilr <167912915+karenlilr@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:21:03 +0000 Subject: [PATCH 10/11] Fixes #352 --- changelog_entry.yaml | 3 +-- .../base_amount.yaml | 2 +- .../{max_credit.yaml => max_amount.yaml} | 4 ++-- ...use_and_common_law_partner_amount_credit.yaml | 16 +--------------- ...pouse_and_common_law_partner_amount_credit.py | 8 +++----- 5 files changed, 8 insertions(+), 25 deletions(-) rename policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/{max_credit.yaml => max_amount.yaml} (68%) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index 96ca407de..673fb484b 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -1,4 +1,3 @@ - bump: minor changes: - added: - - New Brunswick Spouse or Common-law Partner base amount for the years 2022, 2023, and 2024; nb_spouse_and_common_law_partner_amount_credit to calculate the credit dynamically based on parameters; test cases; parameter configurations for base_amount and max_credit in the parameters file. \ No newline at end of file + added: New Brunswick Spouse or Common-law Partner base amount. \ No newline at end of file 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 8461f366c..dd8e66ec3 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 @@ -6,7 +6,7 @@ values: metadata: unit: currency-CAD period: year - label: New Brunswick Spouse or Common-law Partner Base Amount + label: New Brunswick Spouse or Common-law Partner base Amount reference: - title: Worksheet for the 2022 New Brunswick Personal Tax Credits Return href: https://www.cchwebsites.com/content/pdf/tax_forms/ca/en/td1nbws_en.pdf#page=1 diff --git a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_credit.yaml b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_amount.yaml similarity index 68% rename from policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_credit.yaml rename to policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_amount.yaml index 07b47f064..4e17ef1c1 100644 --- a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_credit.yaml +++ b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_amount.yaml @@ -1,4 +1,4 @@ -description: The New Brunswick spouse or common-law partner amount credit is calculated by taking into account the spouse's net income and comparing it to a base amount. The maximum credit is the highest amount that can be claimed as a credit. +description: New Brunswick provides the following maximum spouse or common-law partner amount. values: 2022-01-01: 9_186 2023-01-01: 9_764 @@ -6,7 +6,7 @@ values: metadata: unit: currency-CAD period: year - label: New Brunswick Spouse or Common-law Partner Max Credit + label: New Brunswick Spouse or Common-law Partner max Credit reference: - title: Worksheet for the 2022 New Brunswick Personal Tax Credits Return href: https://www.cchwebsites.com/content/pdf/tax_forms/ca/en/td1nbws_en.pdf#page=1 diff --git a/policyengine_canada/tests/gov/provinces/nb/tax/income/credits/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 index 8e58e83a7..9dd73769d 100644 --- a/policyengine_canada/tests/gov/provinces/nb/tax/income/credits/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 @@ -61,19 +61,5 @@ 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 index 7bb6ed75d..b10a1a42a 100644 --- 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 @@ -10,10 +10,8 @@ class nb_spouse_and_common_law_partner_amount_credit(Variable): 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) - return min(max_credit, reduced_amount) + reduced_amount = max_(p.base_amount - spouse_income, 0) + return min(p.max_credit, reduced_amount) From 5005fb22ba6853ae731976c7fd5867b075f7ad04 Mon Sep 17 00:00:00 2001 From: karenlilr <167912915+karenlilr@users.noreply.github.com> Date: Thu, 8 Aug 2024 06:33:48 +0000 Subject: [PATCH 11/11] Fixes #352 --- changelog_entry.yaml | 3 ++- .../spouse_or_common_law_partner_amount/base_amount.yaml | 2 +- .../spouse_or_common_law_partner_amount/max_amount.yaml | 2 +- .../income/nb_spouse_and_common_law_partner_amount_credit.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index 673fb484b..a80d1a8f2 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -1,3 +1,4 @@ - bump: minor changes: - added: New Brunswick Spouse or Common-law Partner base amount. \ No newline at end of file + added: + - New Brunswick Spouse or Common-law Partner base amount. \ No newline at end of file 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 dd8e66ec3..2d6cee8ca 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 @@ -6,7 +6,7 @@ values: metadata: unit: currency-CAD period: year - label: New Brunswick Spouse or Common-law Partner base Amount + label: New Brunswick Spouse or Common-law Partner base amount reference: - title: Worksheet for the 2022 New Brunswick Personal Tax Credits Return href: https://www.cchwebsites.com/content/pdf/tax_forms/ca/en/td1nbws_en.pdf#page=1 diff --git a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_amount.yaml b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_amount.yaml index 4e17ef1c1..6d313fce3 100644 --- a/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_amount.yaml +++ b/policyengine_canada/parameters/gov/provinces/nb/tax/income/credits/spouse_or_common_law_partner_amount/max_amount.yaml @@ -6,7 +6,7 @@ values: metadata: unit: currency-CAD period: year - label: New Brunswick Spouse or Common-law Partner max Credit + label: New Brunswick Spouse or Common-law Partner max credit reference: - title: Worksheet for the 2022 New Brunswick Personal Tax Credits Return href: https://www.cchwebsites.com/content/pdf/tax_forms/ca/en/td1nbws_en.pdf#page=1 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 index b10a1a42a..090dfc7be 100644 --- 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 @@ -13,5 +13,5 @@ def formula(household, period, parameters): spouse_income = add(household, period, ["spouse_income"]) reduced_amount = max_(p.base_amount - spouse_income, 0) - return min(p.max_credit, reduced_amount) + return min_(p.max_credit, reduced_amount)