From 823c2b47e37aebfebe457c45a369f0c538486f6e Mon Sep 17 00:00:00 2001 From: Kun Yao <90804230+Kenyaokun@users.noreply.github.com> Date: Wed, 19 Apr 2023 13:34:43 +0000 Subject: [PATCH] Northwest Territories Credit Fixes #229 --- .../threshold/middle/base.yaml | 2 +- .../threshold/middle/supplement.yaml | 2 +- .../nt_living_tax_credit.yaml | 42 ++++++++++++++++--- .../living_tax_credit/nt_living_tax_credit.py | 8 ++-- .../nt_ltc_higher_threshold.py | 10 ++--- .../nt_ltc_lower_threshold.py | 4 +- .../nt_ltc_middle_threshold.py | 6 +-- 7 files changed, 53 insertions(+), 21 deletions(-) diff --git a/policyengine_canada/parameters/gov/provinces/nt/tax/income/credits/living_tax_credit/threshold/middle/base.yaml b/policyengine_canada/parameters/gov/provinces/nt/tax/income/credits/living_tax_credit/threshold/middle/base.yaml index 1d7869a94..aa8079b7f 100644 --- a/policyengine_canada/parameters/gov/provinces/nt/tax/income/credits/living_tax_credit/threshold/middle/base.yaml +++ b/policyengine_canada/parameters/gov/provinces/nt/tax/income/credits/living_tax_credit/threshold/middle/base.yaml @@ -6,4 +6,4 @@ metadata: label: Northwest Territories living tax credit high income base reference: - title: Government of Canada - Credit - href: https://www.canada.ca/en/revenue-agency/services/forms-publications/tax-packages-years/general-income-tax-benefit-package/northwest-territories/5012-tc.html \ No newline at end of file + href: https://www.canada.ca/en/revenue-agency/services/forms-publications/tax-packages-years/general-income-tax-benefit-package/northwest-territories/5012-tc.html diff --git a/policyengine_canada/parameters/gov/provinces/nt/tax/income/credits/living_tax_credit/threshold/middle/supplement.yaml b/policyengine_canada/parameters/gov/provinces/nt/tax/income/credits/living_tax_credit/threshold/middle/supplement.yaml index 2023615c0..578cd9f6a 100644 --- a/policyengine_canada/parameters/gov/provinces/nt/tax/income/credits/living_tax_credit/threshold/middle/supplement.yaml +++ b/policyengine_canada/parameters/gov/provinces/nt/tax/income/credits/living_tax_credit/threshold/middle/supplement.yaml @@ -1,6 +1,6 @@ description: Northwest Territories living tax credit middle income supplement values: - 2022-12-31: 762 + 2022-12-31: 312 metadata: unit: currency-CAD label: Northwest Territories living tax credit middle income supplement diff --git a/policyengine_canada/tests/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_living_tax_credit.yaml b/policyengine_canada/tests/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_living_tax_credit.yaml index 1aec59614..f333fdae9 100644 --- a/policyengine_canada/tests/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_living_tax_credit.yaml +++ b/policyengine_canada/tests/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_living_tax_credit.yaml @@ -2,7 +2,15 @@ period: 2023 input: province_code: NT - nt_income_tax_before_credits: 10_000 + individual_net_income: 12_000 + output: + nt_living_tax_credit: 312 + +- name: Income below 12_000 + period: 2023 + input: + province_code: NT + individual_net_income: 10_000 output: nt_living_tax_credit: 260 @@ -10,22 +18,46 @@ period: 2023 input: province_code: NT - nt_income_tax_before_credits: 42_000 + individual_net_income: 42_000 output: nt_living_tax_credit: 687 +- name: Income between 12_000 and 48_000 + period: 2023 + input: + province_code: NT + individual_net_income: 48_000 + output: + nt_living_tax_credit: 762 + +- name: Income between 48_000 and 66_000 + period: 2023 + input: + province_code: NT + individual_net_income: 58_000 + output: + nt_living_tax_credit: 862 + - name: Income between 48_000 and 66_000 period: 2023 input: province_code: NT - nt_income_tax_before_credits: 58_000 + individual_net_income: 65_999 output: - nt_living_tax_credit: 772 + nt_living_tax_credit: 941.99 - name: Income above 66_000 period: 2023 input: province_code: NT - nt_income_tax_before_credits: 67_000 + individual_net_income: 67_000 + output: + nt_living_tax_credit: 942 + +- name: Income above 66_000 + period: 2023 + input: + province_code: NT + individual_net_income: 66_001 output: nt_living_tax_credit: 942 \ No newline at end of file diff --git a/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_living_tax_credit.py b/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_living_tax_credit.py index 563a335b4..0c7ad68f4 100644 --- a/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_living_tax_credit.py +++ b/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_living_tax_credit.py @@ -12,11 +12,11 @@ def formula(person, period, parameters): p = parameters( period ).gov.provinces.nt.tax.income.credits.living_tax_credit - net_income = person("individual_net_income", period) - lower = p.threshold.middle.base * p.threshold.low_income_rate - middle = (p.threshold.high.base - p.threshold.middle.base) * p.threshold.middle.rate + p.threshold.middle.supplement - higher = (net_income - p.income_threshold) * p.threshold.high.rate + p.threshold.high.supplement + lower = person("nt_ltc_lower_threshold", period) + middle = person("nt_ltc_middle_threshold", period) + higher = person("nt_ltc_higher_threshold", period) return ( min_(lower + middle + higher, p.max_amount) ) + diff --git a/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_higher_threshold.py b/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_higher_threshold.py index b04e12059..16d82d748 100644 --- a/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_higher_threshold.py +++ b/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_higher_threshold.py @@ -1,20 +1,20 @@ from policyengine_canada.model_api import * -class ntltc_high_base(Variable): +class nt_ltc_higher_threshold(Variable): value_type = float entity = Person label = "Higher income for living tax credit" definition_period = YEAR defined_for = ProvinceCode.NT - def formula(household, period, parameters): + def formula(person, period, parameters): p = parameters( period ).gov.provinces.nt.tax.income.credits.living_tax_credit net_income = person("individual_net_income", period) - eligible = (p.threshold.high.base < net_income) & (net_income < p.income_threshold) + eligible = (p.threshold.high.base < net_income ) - return ( - (net_income - p.threshold.high.base) * p.threshold.high.rate * eligible + p.threshold.high.supplement + return eligible * ( + (net_income - p.threshold.high.base) * p.threshold.high.rate + p.threshold.high.supplement ) \ No newline at end of file diff --git a/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_lower_threshold.py b/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_lower_threshold.py index 1a60ae699..dc4d36742 100644 --- a/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_lower_threshold.py +++ b/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_lower_threshold.py @@ -15,6 +15,6 @@ def formula(person, period, parameters): net_income = person("individual_net_income", period) eligible = p.threshold.middle.base >= net_income - return ( - net_income * p.threshold.low_income_rate * eligible + return eligible * ( + net_income * p.threshold.low_income_rate ) \ No newline at end of file diff --git a/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_middle_threshold.py b/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_middle_threshold.py index dba149819..fd4c883df 100644 --- a/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_middle_threshold.py +++ b/policyengine_canada/variables/gov/provinces/nt/tax/income/credits/living_tax_credit/nt_ltc_middle_threshold.py @@ -13,8 +13,8 @@ def formula(person, period, parameters): period ).gov.provinces.nt.tax.income.credits.living_tax_credit net_income = person("individual_net_income", period) - eligible = (p.threshold.middle.base < net_income) & (p.threshold.high.base >= net_income) + eligible = (p.threshold.middle.base < net_income <= p.threshold.high.base) - return ( - (net_income - p.threshold.middle.base) * p.threshold.middle.rate * eligible + p.threshold.middle.supplement + return eligible * ( + (net_income - p.threshold.middle.base) * p.threshold.middle.rate + p.threshold.middle.supplement ) \ No newline at end of file