From ae41e1e686796df4718fd7c81a64963b4b929983 Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Sun, 3 Dec 2023 18:28:16 +0000 Subject: [PATCH 1/5] Nova Scotia Spouse or Common-law Partner Amount Fixes #475 initiate the name of files/folders --- changelog_entry.yaml | 4 ++++ .../ns_spouse_and_common_law_partner_amount_credit.yaml | 0 .../credits/ns_spouse_and_common_law_partner_amount_credit.py | 0 3 files changed, 4 insertions(+) create mode 100644 policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml create mode 100644 policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.py diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..323a381c5 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: minor + changes: + added: + - Nova Scotia spouse and common law partner amount. \ No newline at end of file diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.py new file mode 100644 index 000000000..e69de29bb From 6e88be7434ae2873f239647ebae8b18ad48fc601 Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Sun, 10 Dec 2023 22:01:14 +0000 Subject: [PATCH 2/5] Nova Scotia Spouse or Common-law Partner Amount Fixes #475 Co-authored-by: Pavel Makarchuk --- changelog_entry.yaml | 2 +- .../base.yaml | 14 +++ .../cap.yaml | 14 +++ ..._and_common_law_partner_amount_credit.yaml | 102 ++++++++++++++++++ ...se_and_common_law_partner_amount_credit.py | 28 +++++ 5 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/base.yaml create mode 100644 policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml diff --git a/changelog_entry.yaml b/changelog_entry.yaml index 323a381c5..02ebb8aec 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -1,4 +1,4 @@ - bump: minor changes: added: - - Nova Scotia spouse and common law partner amount. \ No newline at end of file + - Nova Scotia spouse and common law partner amount. diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/base.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/base.yaml new file mode 100644 index 000000000..dfa653d5b --- /dev/null +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/base.yaml @@ -0,0 +1,14 @@ +description: Nova Scotia provides this spouse and common-law partner amount base +values: + 2023-01-01: 9_329 +metadata: + unit: currency-CAD + period: year + label: Nova Scotia spouse and commonlaw partner amount credit base + reference: + - title: 2022 Nova Scotia Personal Tax Credits Return + href: https://hr.acadiau.ca/files/sites/hr/Payroll/Pensions%20&%20Benefits/NS_TD1_2022.pdf#page=1 + - title: 2022 Worksheet NS428 + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/5003-c/5003-c-22e.pdf#page=1 + - title: Nova Scotia income tax act - subdivision c - Deduction for employment out of Canada - 10C + href: https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=24 diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml new file mode 100644 index 000000000..f23a09388 --- /dev/null +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml @@ -0,0 +1,14 @@ +description: Nova Scotia spouse and common-law partner amount cap +values: + 2023-01-01: 8_481 +metadata: + unit: currency-CAD + period: year + label: Nova Scotia spouse and commonlaw partner amount credit cap + reference: + - title: 2022 Nova Scotia Personal Tax Credits Return + href: https://hr.acadiau.ca/files/sites/hr/Payroll/Pensions%20&%20Benefits/NS_TD1_2022.pdf#page=1 + - title: 2022 Worksheet NS428 + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/5003-c/5003-c-22e.pdf#page=1 + - title: Nova Scotia income tax act - subdivision c - Deduction for employment out of Canada - 10C + href: https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=24 diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml index e69de29bb..4482d9096 100644 --- a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml @@ -0,0 +1,102 @@ +- name: Househod with no spouse income + period: 2023 + input: + people: + head: + spouse_income: 0 + spouse: + spouse_income: 0 + household: + members: [head, spouse] + province_code: NS + is_married: true + output: + ns_spouse_and_common_law_partner_amount_credit: 8_481 + +- name: Not married are not eligible for an amount + period: 2023 + input: + people: + head: + spouse_income: 0 + household: + members: [head] + province_code: NS + is_married: false + output: + ns_spouse_and_common_law_partner_amount_credit: 0 + +- name: House hold with spouse income lower than 848 + period: 2023 + input: + people: + spouse: + spouse_income: 847 + head: + spouse_income: 0 + household: + members: [head, spouse] + province_code: NS + is_married: true + output: + ns_spouse_and_common_law_partner_amount_credit: 8_481 + +- name: House hold with spouse income between (848, 9_329) + period: 2023 + input: + people: + spouse: + spouse_income: 849 + head: + spouse_income: 0 + household: + members: [head, spouse] + province_code: NS + is_married: true + output: + ns_spouse_and_common_law_partner_amount_credit: 8_480 + +- name: House hold with spouse income between (848, 9_329) + period: 2023 + input: + people: + spouse: + spouse_income: 9_328 + head: + spouse_income: 0 + household: + members: [head, spouse] + province_code: NS + is_married: true + output: + ns_spouse_and_common_law_partner_amount_credit: 1 + +- name: House hold with spouse income is 9_329 + period: 2023 + input: + people: + spouse: + spouse_income: 9_329 + head: + spouse_income: 0 + household: + members: [head, spouse] + province_code: NS + is_married: true + output: + ns_spouse_and_common_law_partner_amount_credit: 0 + +- name: House hold with spouse income more than 9_329 + period: 2023 + input: + people: + spouse: + spouse_income: 9_400 + head: + spouse_income: 0 + household: + members: [head, spouse] + province_code: NS + is_married: true + output: + ns_spouse_and_common_law_partner_amount_credit: 0 diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.py index e69de29bb..92da0786d 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.py @@ -0,0 +1,28 @@ +from policyengine_canada.model_api import * + + +class ns_spouse_and_common_law_partner_amount_credit(Variable): + value_type = float + entity = Household + label = "Nova Scotia spouse and commonlaw partner amount credit" + unit = CAD + definition_period = YEAR + defined_for = ProvinceCode.NS + reference = ( + "https://hr.acadiau.ca/files/sites/hr/Payroll/Pensions%20&%20Benefits/NS_TD1_2022.pdf#page=1", + "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/5003-c/5003-c-22e.pdf#page=1", + "https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=24", + ) + + def formula(household, period, parameters): + person = household.members + spouse_income = person("spouse_income", period) + total_spouse_income = household.sum(spouse_income) + p = parameters( + period + ).gov.provinces.ns.tax.income.credits.spouse_and_common_law_partner_amount + + reduced_base_amount = max_(0, (p.base - total_spouse_income)) + # Adding married condition to avoid amount for single filers + is_married = household("is_married", period) + return min_(p.cap, reduced_base_amount) * is_married From 73d6c6b7b32d923f755704fd92e9255cd8c28f4f Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Sun, 24 Dec 2023 03:15:57 +0000 Subject: [PATCH 3/5] Nova Scotia Spouse or Common-law Partner Amount Fixes #475 Add test cases --- ...ouse_and_common_law_partner_amount_credit.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml index 4482d9096..2c3c04a23 100644 --- a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml @@ -71,6 +71,21 @@ output: ns_spouse_and_common_law_partner_amount_credit: 1 +- name: House hold with spouse income between (848, 9_329) 2 + period: 2023 + input: + people: + spouse: + spouse_income: 9_000 + head: + spouse_income: 0 + household: + members: [head, spouse] + province_code: NS + is_married: true + output: + ns_spouse_and_common_law_partner_amount_credit: 329 + - name: House hold with spouse income is 9_329 period: 2023 input: From 320175f123f1e14b068dcdbe80229278fd8c6c4b Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:55:43 +0000 Subject: [PATCH 4/5] Nova Scotia Spouse or Common-law Partner Amount Fixes #475 Add integration test --- .../base.yaml | 6 +- .../cap.yaml | 2 +- .../integration.yaml | 56 +++++++++++++++++++ ..._and_common_law_partner_amount_credit.yaml | 0 4 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 policyengine_canada/tests/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount_credit/integration.yaml rename policyengine_canada/tests/gov/provinces/ns/tax/income/credits/{ => spouse_and_common_law_partner_amount_credit}/ns_spouse_and_common_law_partner_amount_credit.yaml (100%) diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/base.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/base.yaml index dfa653d5b..63072d79d 100644 --- a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/base.yaml +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/base.yaml @@ -1,10 +1,10 @@ -description: Nova Scotia provides this spouse and common-law partner amount base +description: Nova Scotia provides this spouse and common-law partner amount base credit amount. values: - 2023-01-01: 9_329 + 2022-01-01: 9_329 metadata: unit: currency-CAD period: year - label: Nova Scotia spouse and commonlaw partner amount credit base + label: Nova Scotia spouse and common-law partner amount credit base reference: - title: 2022 Nova Scotia Personal Tax Credits Return href: https://hr.acadiau.ca/files/sites/hr/Payroll/Pensions%20&%20Benefits/NS_TD1_2022.pdf#page=1 diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml index f23a09388..1775fbc32 100644 --- a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml @@ -1,4 +1,4 @@ -description: Nova Scotia spouse and common-law partner amount cap +description: Nova Scotia caps the spouse and common-law partner amount credit at this amount. values: 2023-01-01: 8_481 metadata: diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount_credit/integration.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount_credit/integration.yaml new file mode 100644 index 000000000..dbd196ea5 --- /dev/null +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount_credit/integration.yaml @@ -0,0 +1,56 @@ +- name: Integration - spouse with income <= 848 + period: 2023 + absolute_error_margin: 0.01 + input: + people: + parent1: + age: 40 + individual_net_income: 20_000 + parent2: + age: 39 + is_spouse: true + individual_net_income: 0 + household: + members: [parent1, parent2] + province_code: NS + is_married: true + output: + ns_spouse_and_common_law_partner_amount_credit: 8_481 + +- name: Integration - spouse with 848<= income <= 9329 + period: 2023 + absolute_error_margin: 0.01 + input: + people: + parent1: + age: 40 + individual_net_income: 20_000 + parent2: + age: 39 + is_spouse: true + individual_net_income: 849 + household: + members: [parent1, parent2] + province_code: NS + is_married: true + output: + ns_spouse_and_common_law_partner_amount_credit: 8_480 + +- name: Integration - spouse with income >= 9329 + period: 2023 + absolute_error_margin: 0.01 + input: + people: + parent1: + age: 40 + individual_net_income: 20_000 + parent2: + age: 39 + is_spouse: true + individual_net_income: 9_400 + household: + members: [parent1, parent2] + province_code: NS + is_married: true + output: + ns_spouse_and_common_law_partner_amount_credit: 0 \ No newline at end of file diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount_credit/ns_spouse_and_common_law_partner_amount_credit.yaml similarity index 100% rename from policyengine_canada/tests/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.yaml rename to policyengine_canada/tests/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount_credit/ns_spouse_and_common_law_partner_amount_credit.yaml From 3fdfc421a54f623e4a963213bfaf2695645adfc4 Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Sun, 4 Feb 2024 00:08:41 +0000 Subject: [PATCH 5/5] Nova Scotia Spouse or Common-law Partner Amount Fixes #475 --- .../credits/spouse_and_common_law_partner_amount/cap.yaml | 3 ++- .../integration.yaml | 2 +- .../ns_spouse_and_common_law_partner_amount_credit.py | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml index 1775fbc32..265c0d039 100644 --- a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount/cap.yaml @@ -4,11 +4,12 @@ values: metadata: unit: currency-CAD period: year - label: Nova Scotia spouse and commonlaw partner amount credit cap + label: Nova Scotia spouse and common-law partner amount credit cap reference: - title: 2022 Nova Scotia Personal Tax Credits Return href: https://hr.acadiau.ca/files/sites/hr/Payroll/Pensions%20&%20Benefits/NS_TD1_2022.pdf#page=1 - title: 2022 Worksheet NS428 href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/5003-c/5003-c-22e.pdf#page=1 + # The legal code does not specify the maximum credit amount - title: Nova Scotia income tax act - subdivision c - Deduction for employment out of Canada - 10C href: https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=24 diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount_credit/integration.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount_credit/integration.yaml index dbd196ea5..a383db26d 100644 --- a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount_credit/integration.yaml +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/spouse_and_common_law_partner_amount_credit/integration.yaml @@ -53,4 +53,4 @@ province_code: NS is_married: true output: - ns_spouse_and_common_law_partner_amount_credit: 0 \ No newline at end of file + ns_spouse_and_common_law_partner_amount_credit: 0 diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.py index 92da0786d..e2c456900 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/ns_spouse_and_common_law_partner_amount_credit.py @@ -4,7 +4,7 @@ class ns_spouse_and_common_law_partner_amount_credit(Variable): value_type = float entity = Household - label = "Nova Scotia spouse and commonlaw partner amount credit" + label = "Nova Scotia spouse and common-law partner amount credit" unit = CAD definition_period = YEAR defined_for = ProvinceCode.NS @@ -16,8 +16,7 @@ class ns_spouse_and_common_law_partner_amount_credit(Variable): def formula(household, period, parameters): person = household.members - spouse_income = person("spouse_income", period) - total_spouse_income = household.sum(spouse_income) + total_spouse_income = add(household, period, ["spouse_income"]) p = parameters( period ).gov.provinces.ns.tax.income.credits.spouse_and_common_law_partner_amount @@ -25,4 +24,5 @@ def formula(household, period, parameters): reduced_base_amount = max_(0, (p.base - total_spouse_income)) # Adding married condition to avoid amount for single filers is_married = household("is_married", period) - return min_(p.cap, reduced_base_amount) * is_married + capped_credit = min_(p.cap, reduced_base_amount) + return capped_credit * is_married