From b55f78c1f829a20eaa58f259af4227499abf5162 Mon Sep 17 00:00:00 2001 From: laviniawo <132245041+laviniawo@users.noreply.github.com> Date: Mon, 14 Aug 2023 21:28:02 +0000 Subject: [PATCH] Manitoba Spouse or Common-law Partner Amount Fixes #340 --- changelog_entry.yaml | 4 +-- .../mb_head_eligible.yaml | 15 ++++++++++ .../mb_spouse_credit_amount.yaml | 26 ++++++++++++----- .../mb_spouse_eligible.yaml | 29 ------------------- .../mb_head_eligibility.py | 12 ++++++++ ...x_amount.py => mb_spouse_credit_amount.py} | 13 ++------- .../spouse_income_eligibility.py | 24 --------------- .../household/person/lived_together.py | 1 - 8 files changed, 50 insertions(+), 74 deletions(-) create mode 100644 policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_head_eligible.yaml delete mode 100644 policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_eligible.yaml create mode 100644 policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_head_eligibility.py rename policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/{spouse_and_common_law_tax_amount.py => mb_spouse_credit_amount.py} (61%) delete mode 100644 policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/spouse_income_eligibility.py diff --git a/changelog_entry.yaml b/changelog_entry.yaml index 4ef0fa71f..4c4f03192 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -1,4 +1,4 @@ - bump: minor changes: - added: - - Manitoba spouse and common-law partner amount. + added: + - Manitoba spouse and common-law partner amount. diff --git a/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_head_eligible.yaml b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_head_eligible.yaml new file mode 100644 index 000000000..b753c5f26 --- /dev/null +++ b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_head_eligible.yaml @@ -0,0 +1,15 @@ +- name: Household's head is taking care of the spouse + period: 2023 + input: + province_code: MB + is_caregiver: true + output: + mb_head_eligibility: true + +- name: Household's head is not taking care of the spouse + period: 2023 + input: + province_code: MB + is_caregiver: false + output: + mb_head_eligibility: false diff --git a/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.yaml b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.yaml index bc98e0fa7..c5f446057 100644 --- a/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.yaml +++ b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.yaml @@ -1,19 +1,29 @@ -- name: Eligible spouse with household's head not taking care of her +- name: Eligible income spouse lived with household's head period: 2023 input: province_code: MB spouse_income: 5_000 - is_caregiver: false - mb_spouse_eligibility: true + lived_together: true + mb_head_eligibility: true output: - mb_spouse_credit_amount: 0 + mb_spouse_credit_amount: 4_134 -- name: Eligible spouse with household's head taking care of her +- name: Eligible income spouse does not lived with household's head period: 2023 input: province_code: MB spouse_income: 5_000 - is_caregiver: true - mb_spouse_eligibility: true + lived_together: false + mb_head_eligibility: true output: - mb_spouse_credit_amount: 4_134 + mb_spouse_credit_amount: 0 + +- name: ineligible income spouse lived with household's head + period: 2023 + input: + province_code: MB + spouse_income: 10_000 + lived_together: true + mb_head_eligibility: true + output: + mb_spouse_credit_amount: 0 diff --git a/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_eligible.yaml b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_eligible.yaml deleted file mode 100644 index 5a26f83a1..000000000 --- a/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_eligible.yaml +++ /dev/null @@ -1,29 +0,0 @@ -- name: Spouse not living with household's head - period: 2023 - input: - province_code: MB - is_spouse: true - lived_together: false - spouse_income: 5_000 - output: - mb_spouse_eligibility: false - -- name: Spouse does not have eligible income and lived with household's head - period: 2023 - input: - province_code: MB - is_spouse: true - lived_together: true - spouse_income: 10_000 - output: - mb_spouse_eligibility: false - -- name: Spouse has eligible income and lived with household's head - period: 2023 - input: - province_code: MB - is_spouse: true - lived_together: true - spouse_income: 5_000 - output: - mb_spouse_eligibility: true diff --git a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_head_eligibility.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_head_eligibility.py new file mode 100644 index 000000000..115d009db --- /dev/null +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_head_eligibility.py @@ -0,0 +1,12 @@ +from policyengine_canada.model_api import * + + +class mb_head_eligibility(Variable): + value_type = bool + entity = Person + label = "Manitoba head eligiblility for recieving spouse's tax credit" + definition_period = YEAR + defined_for = ProvinceCode.MB + + def formula(person, period, parameters): + return person("is_caregiver", period) diff --git a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/spouse_and_common_law_tax_amount.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py similarity index 61% rename from policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/spouse_and_common_law_tax_amount.py rename to policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py index 1d77f00d2..e51923813 100644 --- a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/spouse_and_common_law_tax_amount.py +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py @@ -6,7 +6,7 @@ class mb_spouse_credit_amount(Variable): entity = Person label = "Manitoba spouse and commonlaw partner net income" definition_period = YEAR - defined_for = ProvinceCode.MB + defined_for = "mb_head_eligibility" def formula(person, period, parameters): @@ -14,14 +14,7 @@ def formula(person, period, parameters): period ).gov.provinces.mb.tax.income.credits.spouse_or_common_law_partner_amount - caregiver = person("is_caregiver", period) - spouse_income = person("spouse_income", period) + living_together = person("lived_together", period) - spouse_credit_amount = ( - caregiver - * person("mb_spouse_eligibility", period) - * (p.base_amount - spouse_income) - ) - - return spouse_credit_amount + return living_together * (max_(0, (p.base_amount - spouse_income))) diff --git a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/spouse_income_eligibility.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/spouse_income_eligibility.py deleted file mode 100644 index 6c6265dd8..000000000 --- a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/spouse_income_eligibility.py +++ /dev/null @@ -1,24 +0,0 @@ -from policyengine_canada.model_api import * - - -class mb_spouse_eligibility(Variable): - value_type = bool - entity = Person - label = "Manitoba spouse and commonlaw partner eligibility" - definition_period = YEAR - defined_for = ProvinceCode.MB - - def formula(person, period, parameters): - p = parameters( - period - ).gov.provinces.mb.tax.income.credits.spouse_or_common_law_partner_amount - - spouse = person("is_spouse", period) - living_together = person("lived_together", period) - spouse_income_eligible = ( - person("spouse_income", period) < p.base_amount - ) - - spouse_eligibility = spouse & living_together & spouse_income_eligible - - return spouse_eligibility diff --git a/policyengine_canada/variables/household/person/lived_together.py b/policyengine_canada/variables/household/person/lived_together.py index 374fdfd45..e280a5e24 100644 --- a/policyengine_canada/variables/household/person/lived_together.py +++ b/policyengine_canada/variables/household/person/lived_together.py @@ -5,5 +5,4 @@ class lived_together(Variable): value_type = bool entity = Person label = "Lived together with the tax filer" - unit = CAD definition_period = YEAR