From a0e6b3946066a0c506e23ef44dbf015dd7e079ac Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Sun, 15 Oct 2023 18:26:49 +0000 Subject: [PATCH 01/11] Nova Scotia Age amount supplement Add new files Fixes #455 --- changelog_entry.yaml | 1 + .../credits/age/age_supplement/base.yaml | 13 ++++++ .../age/age_supplement/phase_out_rate.yaml | 24 ++++++++++ .../credits/age/ns_age_amount_supplement.yaml | 44 +++++++++++++++++++ .../credits/age/ns_age_amount_supplement.py | 32 ++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/base.yaml create mode 100644 policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/phase_out_rate.yaml create mode 100644 policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml create mode 100644 policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..8b1378917 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1 @@ + diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/base.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/base.yaml new file mode 100644 index 000000000..fa9316611 --- /dev/null +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/base.yaml @@ -0,0 +1,13 @@ +description: Nova Scotia adds this additional amount to the basic personal amount. +values: + 2022-01-01: 1_465 +metadata: + unit: currency-CAD + label: Nova Scotia basic personal amount additional 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-d/5003-d-22e.pdf#page=1 + - title: Nova Scotia income tax act - subdivision c - Deduction for employment out of Canada + 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/age/age_supplement/phase_out_rate.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/phase_out_rate.yaml new file mode 100644 index 000000000..851cc7eaf --- /dev/null +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/phase_out_rate.yaml @@ -0,0 +1,24 @@ +description: Nova Scotia phases its age amount supplement out at this rate. +brackets: + - threshold: + 2022-01-01: 0 + rate: + 2022-01-01: 0 + - threshold: + 2022-01-01: 25_000 + rate: + 2022-01-01: 0.0293 + +metadata: + type: marginal_rate + rate_unit: /1 + threshold_unit: currency-CAD + period: year + label: Nova Scotia basic personal amount phase out rate + 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-d/5003-d-22e.pdf#page=1 + - title: Nova Scotia income tax act - subdivision c - Deduction for employment out of Canada + 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/age/ns_age_amount_supplement.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml new file mode 100644 index 000000000..3d2951df7 --- /dev/null +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml @@ -0,0 +1,44 @@ +- name: Nova Scotia Age amonut supplement; eligible age with eligible taxable income below 25_000 + period: 2023 + input: + province_code: NS + age: 65 + ns_taxable_income: 24_999 + output: + ns_age_tax_credit: 1_465 + +- name: Nova Scotia Age amonut supplement; eligible age with eligible taxable income between 25_000 and 75_000 + period: 2023 + input: + province_code: NS + age: 65 + ns_taxable_income: 65_000 + output: + ns_age_tax_credit: 295 + +- name: Nova Scotia Age tax credit; eligible age with ineligible taxable income more than 75_000 + period: 2023 + input: + province_code: NS + age: 65 + ns_taxable_income: 75_001 + output: + ns_age_tax_credit: 0 + +- name: Nova Scotia Age tax credit; ineligible age with eligible taxable income + period: 2023 + input: + province_code: NS + age: 64 + ns_taxable_income: 24_999 + output: + ns_age_tax_credit: 0 + +- name: Nova Scotia Age tax credit; ineligible age with ineligible taxable income + period: 2023 + input: + province_code: NS + age: 64 + ns_taxable_income: 75_001 + output: + ns_age_tax_credit: 0 diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py new file mode 100644 index 000000000..cd0cda386 --- /dev/null +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py @@ -0,0 +1,32 @@ +from policyengine_canada.model_api import * + + +class ns_age_amount_supplement(Variable): + value_type = float + entity = Person + label = "Nova Scotia Basic Personal Amount" + 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-d/5003-d-22e.pdf#page=1", + "https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=24", + ) + + def formula(person, period, parameters): + p = parameters(period).gov.provinces.ns.tax.income.credits.age + age = person("age", period) + taxable_income = person("ns_taxable_income", period) + + # is eligible for age amount supplement + eligibility = age >= p.age_eligibility + + # Calculate additional amount added to base amount + reduced_additional_amount = max_( + 0, + p.age_supplement.base + - p.age_supplement.phase_out_rate.calc(taxable_income), + ) + + return reduced_additional_amount From 8414dded4de0d50292e3a1db2da8f5a35082f0a3 Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Sun, 15 Oct 2023 18:37:48 +0000 Subject: [PATCH 02/11] Nova Scotia Age Amount Supplement Create pr and new files Fix #issue455 --- changelog_entry.yaml | 5 ++++- .../ns/tax/income/credits/age/age_supplement/base.yaml | 8 ++++---- .../credits/age/age_supplement/phase_out_rate.yaml | 9 +++++---- .../tax/income/credits/age/ns_age_amount_supplement.py | 6 +++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index 8b1378917..46a9ff36a 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -1 +1,4 @@ - +- bump: minor + changes: + added: + - Nova Scotia age amount supplement. diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/base.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/base.yaml index fa9316611..f083bd00e 100644 --- a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/base.yaml +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/base.yaml @@ -1,4 +1,4 @@ -description: Nova Scotia adds this additional amount to the basic personal amount. +description: Nova Scotia adds this additional amount to the age amount. values: 2022-01-01: 1_465 metadata: @@ -7,7 +7,7 @@ metadata: 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-d/5003-d-22e.pdf#page=1 + - title: Worksheet for the 2023 Nova Scotia TD1NS-WS Personal Tax Credits Return -- Age Amount Supplement + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1ns-ws/td1ns-ws-23e.pdf#page=1 - title: Nova Scotia income tax act - subdivision c - Deduction for employment out of Canada - href: https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=24 + href: https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=28 diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/phase_out_rate.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/phase_out_rate.yaml index 851cc7eaf..4c0b478e0 100644 --- a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/phase_out_rate.yaml +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/phase_out_rate.yaml @@ -14,11 +14,12 @@ metadata: rate_unit: /1 threshold_unit: currency-CAD period: year - label: Nova Scotia basic personal amount phase out rate + label: Nova Scotia age amount supplement phase out rate 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-d/5003-d-22e.pdf#page=1 + - title: Worksheet for the 2023 Nova Scotia TD1NS-WS Personal Tax Credits Return -- Age Amount Supplement + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1ns-ws/td1ns-ws-23e.pdf#page=1 - title: Nova Scotia income tax act - subdivision c - Deduction for employment out of Canada - href: https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=24 + href: https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=28 + diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py index cd0cda386..27692d5c6 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py @@ -10,8 +10,8 @@ class ns_age_amount_supplement(Variable): 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-d/5003-d-22e.pdf#page=1", - "https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=24", + "https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1ns-ws/td1ns-ws-23e.pdf#page=1", + "https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=28", ) def formula(person, period, parameters): @@ -29,4 +29,4 @@ def formula(person, period, parameters): - p.age_supplement.phase_out_rate.calc(taxable_income), ) - return reduced_additional_amount + return eligibility * reduced_additional_amount From eb44ae5a7b22eccbc870554a8f18c7fa965a4429 Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Sun, 15 Oct 2023 18:47:00 +0000 Subject: [PATCH 03/11] Nova Scotia Age Amount Supplement Fix the test fail --- .../income/credits/age/ns_age_amount_supplement.yaml | 10 +++++----- .../tax/income/credits/age/ns_age_amount_supplement.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml index 3d2951df7..538df869d 100644 --- a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml @@ -5,7 +5,7 @@ age: 65 ns_taxable_income: 24_999 output: - ns_age_tax_credit: 1_465 + ns_age_amount_supplement: 1_465 - name: Nova Scotia Age amonut supplement; eligible age with eligible taxable income between 25_000 and 75_000 period: 2023 @@ -14,7 +14,7 @@ age: 65 ns_taxable_income: 65_000 output: - ns_age_tax_credit: 295 + ns_age_amount_supplement: 293 - name: Nova Scotia Age tax credit; eligible age with ineligible taxable income more than 75_000 period: 2023 @@ -23,7 +23,7 @@ age: 65 ns_taxable_income: 75_001 output: - ns_age_tax_credit: 0 + ns_age_amount_supplement: 0 - name: Nova Scotia Age tax credit; ineligible age with eligible taxable income period: 2023 @@ -32,7 +32,7 @@ age: 64 ns_taxable_income: 24_999 output: - ns_age_tax_credit: 0 + ns_age_amount_supplement: 0 - name: Nova Scotia Age tax credit; ineligible age with ineligible taxable income period: 2023 @@ -41,4 +41,4 @@ age: 64 ns_taxable_income: 75_001 output: - ns_age_tax_credit: 0 + ns_age_amount_supplement: 0 diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py index 27692d5c6..107b57ae4 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py @@ -4,7 +4,7 @@ class ns_age_amount_supplement(Variable): value_type = float entity = Person - label = "Nova Scotia Basic Personal Amount" + label = "Nova Scotia Age Amount Supplement" unit = CAD definition_period = YEAR defined_for = ProvinceCode.NS From 6623b84c005e08ca5b0de36fa9431d3d38615534 Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Tue, 17 Oct 2023 23:06:41 +0000 Subject: [PATCH 04/11] Nova Scotia Age amount supplement change name Fixes #455 --- .../income/credits/age/{age_supplement => supplement}/base.yaml | 2 +- .../age/{age_supplement => supplement}/phase_out_rate.yaml | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/{age_supplement => supplement}/base.yaml (91%) rename policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/{age_supplement => supplement}/phase_out_rate.yaml (100%) diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/base.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/base.yaml similarity index 91% rename from policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/base.yaml rename to policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/base.yaml index f083bd00e..b8c7918ea 100644 --- a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/base.yaml +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/base.yaml @@ -1,4 +1,4 @@ -description: Nova Scotia adds this additional amount to the age amount. +description: Nova Scotia adds this supplement amount to the age amount. values: 2022-01-01: 1_465 metadata: diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/phase_out_rate.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/phase_out_rate.yaml similarity index 100% rename from policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/age_supplement/phase_out_rate.yaml rename to policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/phase_out_rate.yaml From cf091d2f7cd8460f53bac214dfe29f7f62ceb3be Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Tue, 17 Oct 2023 23:23:44 +0000 Subject: [PATCH 05/11] Nova Scotia Age Amount Supplement fix name --- .../ns/tax/income/credits/age/ns_age_amount_supplement.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py index 107b57ae4..1693273c3 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py @@ -25,8 +25,8 @@ def formula(person, period, parameters): # Calculate additional amount added to base amount reduced_additional_amount = max_( 0, - p.age_supplement.base - - p.age_supplement.phase_out_rate.calc(taxable_income), + p.supplement.base + - p.supplement.phase_out_rate.calc(taxable_income), ) return eligibility * reduced_additional_amount From e73b3c0fcc0bf83792a3d8ac9f1c65494a51cc57 Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Sun, 10 Dec 2023 17:11:52 +0000 Subject: [PATCH 06/11] Issue458 Add ns_age_amount_supplement_eligible --- .../income/credits/age/supplement/base.yaml | 2 +- .../age/supplement/phase_out_rate.yaml | 2 +- .../credits/age/ns_age_amount_supplement.py | 10 ++------- .../age/ns_age_amount_supplement_eligible.py | 22 +++++++++++++++++++ 4 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/base.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/base.yaml index b8c7918ea..a345e1d45 100644 --- a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/base.yaml +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/base.yaml @@ -3,7 +3,7 @@ values: 2022-01-01: 1_465 metadata: unit: currency-CAD - label: Nova Scotia basic personal amount additional base + label: Nova Scotia maximum age amount supplement 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/age/supplement/phase_out_rate.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/phase_out_rate.yaml index 4c0b478e0..7bbaed423 100644 --- a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/phase_out_rate.yaml +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/phase_out_rate.yaml @@ -1,4 +1,4 @@ -description: Nova Scotia phases its age amount supplement out at this rate. +description: Nova Scotia phases its age amount supplement out at this rate, based on taxable income. brackets: - threshold: 2022-01-01: 0 diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py index 1693273c3..93a7f8b99 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py @@ -7,7 +7,7 @@ class ns_age_amount_supplement(Variable): label = "Nova Scotia Age Amount Supplement" unit = CAD definition_period = YEAR - defined_for = ProvinceCode.NS + defined_for = ns_age_amount_supplement_eligible 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/td1ns-ws/td1ns-ws-23e.pdf#page=1", @@ -16,17 +16,11 @@ class ns_age_amount_supplement(Variable): def formula(person, period, parameters): p = parameters(period).gov.provinces.ns.tax.income.credits.age - age = person("age", period) taxable_income = person("ns_taxable_income", period) - # is eligible for age amount supplement - eligibility = age >= p.age_eligibility - # Calculate additional amount added to base amount - reduced_additional_amount = max_( + return max_( 0, p.supplement.base - p.supplement.phase_out_rate.calc(taxable_income), ) - - return eligibility * reduced_additional_amount diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py new file mode 100644 index 000000000..4acdbee1b --- /dev/null +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py @@ -0,0 +1,22 @@ +from policyengine_canada.model_api import * + + +class ns_age_amount_supplement_eligible(Variable): + value_type = float + entity = Person + label = "Nova Scotia Age Amount Supplement Eligible" + 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/td1ns-ws/td1ns-ws-23e.pdf#page=1", + "https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=28", + ) + + def formula(person, period, parameters): + p = parameters(period).gov.provinces.ns.tax.income.credits.age + age = person("age", period) + + # is eligible for age amount supplement + return age >= p.age_eligibility From 8dfc00c6d2bf92379bd803ef9309930b5422ea8e Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Sun, 24 Dec 2023 03:29:01 +0000 Subject: [PATCH 07/11] Nova Scotia Age Amount Supplement Fix #455 Add a new check for age eligibility --- .../credits/age/ns_age_amount_supplement.yaml | 15 +++++---------- .../credits/age/ns_age_amount_supplement.py | 2 +- .../age/ns_age_amount_supplement_eligible.py | 5 ++--- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml index 538df869d..e239929f2 100644 --- a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml @@ -1,44 +1,39 @@ - name: Nova Scotia Age amonut supplement; eligible age with eligible taxable income below 25_000 period: 2023 input: - province_code: NS - age: 65 ns_taxable_income: 24_999 + ns_age_amount_supplement_eligible: true output: ns_age_amount_supplement: 1_465 - name: Nova Scotia Age amonut supplement; eligible age with eligible taxable income between 25_000 and 75_000 period: 2023 input: - province_code: NS - age: 65 ns_taxable_income: 65_000 + ns_age_amount_supplement_eligible: true output: ns_age_amount_supplement: 293 - name: Nova Scotia Age tax credit; eligible age with ineligible taxable income more than 75_000 period: 2023 input: - province_code: NS - age: 65 ns_taxable_income: 75_001 + ns_age_amount_supplement_eligible: true output: ns_age_amount_supplement: 0 - name: Nova Scotia Age tax credit; ineligible age with eligible taxable income period: 2023 input: - province_code: NS - age: 64 ns_taxable_income: 24_999 + ns_age_amount_supplement_eligible: false output: ns_age_amount_supplement: 0 - name: Nova Scotia Age tax credit; ineligible age with ineligible taxable income period: 2023 input: - province_code: NS - age: 64 ns_taxable_income: 75_001 + ns_age_amount_supplement_eligible: false output: ns_age_amount_supplement: 0 diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py index 93a7f8b99..63bb3b117 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py @@ -7,7 +7,7 @@ class ns_age_amount_supplement(Variable): label = "Nova Scotia Age Amount Supplement" unit = CAD definition_period = YEAR - defined_for = ns_age_amount_supplement_eligible + defined_for = "ns_age_amount_supplement_eligible" 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/td1ns-ws/td1ns-ws-23e.pdf#page=1", diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py index 4acdbee1b..b497e582c 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py @@ -2,10 +2,9 @@ class ns_age_amount_supplement_eligible(Variable): - value_type = float + value_type = bool entity = Person - label = "Nova Scotia Age Amount Supplement Eligible" - unit = CAD + label = "Eligible for the Nova Scotia Age Amount Supplement" definition_period = YEAR defined_for = ProvinceCode.NS reference = ( From cfbca801e2070f1094f5763e31e1c3eb72f8ac87 Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:15:47 +0000 Subject: [PATCH 08/11] PR #458 Add unit test for age amount supplement --- .../income/credits/age/supplement/base.yaml | 7 +++--- .../ns_age_amount_supplement_eligible.yaml | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/base.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/base.yaml index a345e1d45..c33c31e5a 100644 --- a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/base.yaml +++ b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/base.yaml @@ -1,13 +1,14 @@ -description: Nova Scotia adds this supplement amount to the age amount. +description: Nova Scotia provides this supplement amount credit base amount. values: 2022-01-01: 1_465 metadata: unit: currency-CAD - label: Nova Scotia maximum age amount supplement base + period: year + label: Nova Scotia age amount supplement 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: Worksheet for the 2023 Nova Scotia TD1NS-WS Personal Tax Credits Return -- Age Amount Supplement href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1ns-ws/td1ns-ws-23e.pdf#page=1 - - title: Nova Scotia income tax act - subdivision c - Deduction for employment out of Canada + - title: Nova Scotia income tax act - subdivision c - Deduction for employment out of Canada - 10G href: https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=28 diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml new file mode 100644 index 000000000..f0fa2d999 --- /dev/null +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml @@ -0,0 +1,24 @@ +- name: Nova Scotia Age amonut supplement; 65 is eligible age + period: 2023 + input: + province_code: NS + age: 65 + output: + ns_age_amount_supplement_eligible: true + + +- name: Nova Scotia Age amonut supplement; 64 is not an eligible age + period: 2023 + input: + province_code: NS + age: 64 + output: + ns_age_amount_supplement_eligible: false + +- name: Nova Scotia Age amonut supplement; 67 is eligible age + period: 2023 + input: + province_code: NS + age: 67 + output: + ns_age_amount_supplement_eligible: true From bd27e96d4bf171b32a5a3528e740309cdd5aab04 Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:18:33 +0000 Subject: [PATCH 09/11] PR #458 Add unit test for age amount supplement --- .../ns_age_amount_supplement_eligible.yaml | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml index f0fa2d999..285f1040a 100644 --- a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml @@ -7,7 +7,7 @@ ns_age_amount_supplement_eligible: true -- name: Nova Scotia Age amonut supplement; 64 is not an eligible age +- name: Nova Scotia Age amonut supplement; lower than 65 is not an eligible age period: 2023 input: province_code: NS @@ -15,10 +15,26 @@ output: ns_age_amount_supplement_eligible: false -- name: Nova Scotia Age amonut supplement; 67 is eligible age +- name: Nova Scotia Age amonut supplement; lower than 65 is not an eligible age + period: 2023 + input: + province_code: NS + age: 50 + output: + ns_age_amount_supplement_eligible: false + +- name: Nova Scotia Age amonut supplement; higher than 65 is eligible age period: 2023 input: province_code: NS age: 67 output: ns_age_amount_supplement_eligible: true + +- name: Nova Scotia Age amonut supplement; higher than 65 is eligible age + period: 2023 + input: + province_code: NS + age: 70 + output: + ns_age_amount_supplement_eligible: true From 53d2cfe908a0e2958973afd50f0041e4ef62b7f1 Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Thu, 1 Feb 2024 23:08:27 +0000 Subject: [PATCH 10/11] Fixes #455 change file name and add age eligibility to be depencies as all files --- .../{phase_out_rate.yaml => reduction.yaml} | 0 .../age/ns_age_amount_supplement_eligible.yaml | 2 +- .../income/credits/age/ns_age_amount_supplement.py | 10 ++++------ .../ns/tax/income/credits/age/ns_age_tax_credit.py | 11 +++++++---- 4 files changed, 12 insertions(+), 11 deletions(-) rename policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/{phase_out_rate.yaml => reduction.yaml} (100%) diff --git a/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/phase_out_rate.yaml b/policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/reduction.yaml similarity index 100% rename from policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/phase_out_rate.yaml rename to policyengine_canada/parameters/gov/provinces/ns/tax/income/credits/age/supplement/reduction.yaml diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml index 285f1040a..c4461912e 100644 --- a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml @@ -1,4 +1,4 @@ -- name: Nova Scotia Age amonut supplement; 65 is eligible age +- name: Nova Scotia Age amount supplement; 65 is eligible age period: 2023 input: province_code: NS diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py index 63bb3b117..b1074a8b5 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py @@ -15,12 +15,10 @@ class ns_age_amount_supplement(Variable): ) def formula(person, period, parameters): - p = parameters(period).gov.provinces.ns.tax.income.credits.age + p = parameters(period).gov.provinces.ns.tax.income.credits.age.supplement taxable_income = person("ns_taxable_income", period) # Calculate additional amount added to base amount - return max_( - 0, - p.supplement.base - - p.supplement.phase_out_rate.calc(taxable_income), - ) + reduction = p.reduction.calc(taxable_income) + + return max_(p.base - reduction, 0) diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_tax_credit.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_tax_credit.py index c189bc687..ce348f92d 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_tax_credit.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_tax_credit.py @@ -6,14 +6,17 @@ class ns_age_tax_credit(Variable): entity = Person label = "Nova Scotia Age tax credit" definition_period = YEAR - defined_for = ProvinceCode.NS + defined_for = "ns_age_amount_supplement_eligible" + 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/td1ns-ws/td1ns-ws-23e.pdf#page=1", + "https://nslegislature.ca/sites/default/files/legc/statutes/income%20tax.pdf#page=28", + ) def formula(person, period, parameters): age = person("age", period) income = person("ns_taxable_income", period) p = parameters(period).gov.provinces.ns.tax.income.credits.age - eligibility = (age >= p.age_eligibility) & ( - income < p.income_eligibility - ) + eligibility = (income < p.income_eligibility) return eligibility * p.amount From 30210462c954c0718bbd81c42f985f34c244215c Mon Sep 17 00:00:00 2001 From: okeyiii <96802936+okeyiii@users.noreply.github.com> Date: Thu, 15 Feb 2024 23:14:44 +0000 Subject: [PATCH 11/11] Change name of eligibility var Fixes #455 --- .../income/credits/age/ns_age_amount_supplement.yaml | 10 +++++----- .../credits/age/ns_age_amount_supplement_eligible.yaml | 10 +++++----- .../tax/income/credits/age/ns_age_amount_supplement.py | 8 +++++--- .../credits/age/ns_age_amount_supplement_eligible.py | 4 ++-- .../ns/tax/income/credits/age/ns_age_tax_credit.py | 4 ++-- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml index e239929f2..3e2525887 100644 --- a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.yaml @@ -2,7 +2,7 @@ period: 2023 input: ns_taxable_income: 24_999 - ns_age_amount_supplement_eligible: true + ns_age_amount_eligible: true output: ns_age_amount_supplement: 1_465 @@ -10,7 +10,7 @@ period: 2023 input: ns_taxable_income: 65_000 - ns_age_amount_supplement_eligible: true + ns_age_amount_eligible: true output: ns_age_amount_supplement: 293 @@ -18,7 +18,7 @@ period: 2023 input: ns_taxable_income: 75_001 - ns_age_amount_supplement_eligible: true + ns_age_amount_eligible: true output: ns_age_amount_supplement: 0 @@ -26,7 +26,7 @@ period: 2023 input: ns_taxable_income: 24_999 - ns_age_amount_supplement_eligible: false + ns_age_amount_eligible: false output: ns_age_amount_supplement: 0 @@ -34,6 +34,6 @@ period: 2023 input: ns_taxable_income: 75_001 - ns_age_amount_supplement_eligible: false + ns_age_amount_eligible: false output: ns_age_amount_supplement: 0 diff --git a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml index c4461912e..6cb218658 100644 --- a/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml +++ b/policyengine_canada/tests/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.yaml @@ -4,7 +4,7 @@ province_code: NS age: 65 output: - ns_age_amount_supplement_eligible: true + ns_age_amount_eligible: true - name: Nova Scotia Age amonut supplement; lower than 65 is not an eligible age @@ -13,7 +13,7 @@ province_code: NS age: 64 output: - ns_age_amount_supplement_eligible: false + ns_age_amount_eligible: false - name: Nova Scotia Age amonut supplement; lower than 65 is not an eligible age period: 2023 @@ -21,7 +21,7 @@ province_code: NS age: 50 output: - ns_age_amount_supplement_eligible: false + ns_age_amount_eligible: false - name: Nova Scotia Age amonut supplement; higher than 65 is eligible age period: 2023 @@ -29,7 +29,7 @@ province_code: NS age: 67 output: - ns_age_amount_supplement_eligible: true + ns_age_amount_eligible: true - name: Nova Scotia Age amonut supplement; higher than 65 is eligible age period: 2023 @@ -37,4 +37,4 @@ province_code: NS age: 70 output: - ns_age_amount_supplement_eligible: true + ns_age_amount_eligible: true diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py index b1074a8b5..a68b21c6a 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement.py @@ -4,10 +4,10 @@ class ns_age_amount_supplement(Variable): value_type = float entity = Person - label = "Nova Scotia Age Amount Supplement" + label = "Nova Scotia age amount supplement" unit = CAD definition_period = YEAR - defined_for = "ns_age_amount_supplement_eligible" + defined_for = "ns_age_amount_eligible" 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/td1ns-ws/td1ns-ws-23e.pdf#page=1", @@ -15,7 +15,9 @@ class ns_age_amount_supplement(Variable): ) def formula(person, period, parameters): - p = parameters(period).gov.provinces.ns.tax.income.credits.age.supplement + p = parameters( + period + ).gov.provinces.ns.tax.income.credits.age.supplement taxable_income = person("ns_taxable_income", period) # Calculate additional amount added to base amount diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py index b497e582c..05b4e4330 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_amount_supplement_eligible.py @@ -1,10 +1,10 @@ from policyengine_canada.model_api import * -class ns_age_amount_supplement_eligible(Variable): +class ns_age_amount_eligible(Variable): value_type = bool entity = Person - label = "Eligible for the Nova Scotia Age Amount Supplement" + label = "Eligible for the Nova Scotia age amount and age amount supplement" definition_period = YEAR defined_for = ProvinceCode.NS reference = ( diff --git a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_tax_credit.py b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_tax_credit.py index ce348f92d..ff7c0dcf2 100644 --- a/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_tax_credit.py +++ b/policyengine_canada/variables/gov/provinces/ns/tax/income/credits/age/ns_age_tax_credit.py @@ -6,7 +6,7 @@ class ns_age_tax_credit(Variable): entity = Person label = "Nova Scotia Age tax credit" definition_period = YEAR - defined_for = "ns_age_amount_supplement_eligible" + defined_for = "ns_age_amount_eligible" 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/td1ns-ws/td1ns-ws-23e.pdf#page=1", @@ -17,6 +17,6 @@ def formula(person, period, parameters): age = person("age", period) income = person("ns_taxable_income", period) p = parameters(period).gov.provinces.ns.tax.income.credits.age - eligibility = (income < p.income_eligibility) + eligibility = income < p.income_eligibility return eligibility * p.amount