From 4a29d78d108f55c64b6bca967854922375bea217 Mon Sep 17 00:00:00 2001 From: laviniawo <132245041+laviniawo@users.noreply.github.com> Date: Mon, 14 Aug 2023 20:19:56 +0000 Subject: [PATCH 1/7] Manitoba Spouse or Common-law Partner Amount Fixes #340 --- changelog_entry.yaml | 4 +++ .../base_amount.yaml | 10 +++++++ .../mb_spouse_credit_amount.yaml | 19 ++++++++++++ .../mb_spouse_eligible.yaml | 29 +++++++++++++++++++ .../spouse_and_common_law_tax_amount.py | 27 +++++++++++++++++ .../spouse_income_eligibility.py | 24 +++++++++++++++ .../household/person/is_caregiver.py | 8 +++++ .../household/person/lived_together.py | 9 ++++++ 8 files changed, 130 insertions(+) create mode 100644 policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml create mode 100644 policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.yaml create 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/spouse_and_common_law_tax_amount.py create mode 100644 policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/spouse_income_eligibility.py create mode 100644 policyengine_canada/variables/household/person/is_caregiver.py create mode 100644 policyengine_canada/variables/household/person/lived_together.py diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..4ef0fa71f 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: minor + changes: + added: + - Manitoba spouse and common-law partner amount. diff --git a/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml b/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml new file mode 100644 index 000000000..18c5cdcf8 --- /dev/null +++ b/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml @@ -0,0 +1,10 @@ +description: Manitoba provides this spouse and common-law partner amount, which is equivalent to the spouses basic personal amount. +values: + 2023-01-01: 9_134 +metadata: + unit: currency-CAD + period: year + label: Manitoba spouse and commonlaw partner amount credit. + reference: + - title: Government of Canada - Manitoba spouse and commonlaw partner amount credit + href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1mb/td1mb-23e.pdf#page=1 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 new file mode 100644 index 000000000..bc98e0fa7 --- /dev/null +++ b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.yaml @@ -0,0 +1,19 @@ +- name: Eligible spouse with household's head not taking care of her + period: 2023 + input: + province_code: MB + spouse_income: 5_000 + is_caregiver: false + mb_spouse_eligibility: true + output: + mb_spouse_credit_amount: 0 + +- name: Eligible spouse with household's head taking care of her + period: 2023 + input: + province_code: MB + spouse_income: 5_000 + is_caregiver: true + mb_spouse_eligibility: true + output: + mb_spouse_credit_amount: 4_134 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 new file mode 100644 index 000000000..5a26f83a1 --- /dev/null +++ b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_eligible.yaml @@ -0,0 +1,29 @@ +- 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/spouse_and_common_law_tax_amount.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/spouse_and_common_law_tax_amount.py new file mode 100644 index 000000000..1d77f00d2 --- /dev/null +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/spouse_and_common_law_tax_amount.py @@ -0,0 +1,27 @@ +from policyengine_canada.model_api import * + + +class mb_spouse_credit_amount(Variable): + value_type = float + entity = Person + label = "Manitoba spouse and commonlaw partner net income" + 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 + + caregiver = person("is_caregiver", period) + + spouse_income = person("spouse_income", period) + + spouse_credit_amount = ( + caregiver + * person("mb_spouse_eligibility", period) + * (p.base_amount - spouse_income) + ) + + return spouse_credit_amount 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 new file mode 100644 index 000000000..6c6265dd8 --- /dev/null +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/spouse_income_eligibility.py @@ -0,0 +1,24 @@ +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/is_caregiver.py b/policyengine_canada/variables/household/person/is_caregiver.py new file mode 100644 index 000000000..5e348a8bc --- /dev/null +++ b/policyengine_canada/variables/household/person/is_caregiver.py @@ -0,0 +1,8 @@ +from policyengine_canada.model_api import * + + +class is_caregiver(Variable): + value_type = bool + entity = Person + label = "Is the caregiver" + definition_period = YEAR diff --git a/policyengine_canada/variables/household/person/lived_together.py b/policyengine_canada/variables/household/person/lived_together.py new file mode 100644 index 000000000..374fdfd45 --- /dev/null +++ b/policyengine_canada/variables/household/person/lived_together.py @@ -0,0 +1,9 @@ +from policyengine_canada.model_api import * + + +class lived_together(Variable): + value_type = bool + entity = Person + label = "Lived together with the tax filer" + unit = CAD + definition_period = YEAR 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 2/7] 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 From bf4547cb7915efe182eff8ac7650c9de4045323f Mon Sep 17 00:00:00 2001 From: laviniawo <132245041+laviniawo@users.noreply.github.com> Date: Mon, 21 Aug 2023 21:16:54 +0000 Subject: [PATCH 3/7] modifications --- .../spouse_or_common_law_partner_amount/base_amount.yaml | 9 +++++++-- .../mb_spouse_credit_amount.yaml | 6 +++--- .../mb_spouse_credit_amount.py | 6 ++++-- .../variables/household/person/cohabitating_spouses.py | 8 ++++++++ .../variables/household/person/is_caregiver.py | 2 +- .../variables/household/person/lived_together.py | 8 -------- 6 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 policyengine_canada/variables/household/person/cohabitating_spouses.py delete mode 100644 policyengine_canada/variables/household/person/lived_together.py diff --git a/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml b/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml index 18c5cdcf8..59b505ac6 100644 --- a/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml +++ b/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml @@ -1,10 +1,15 @@ description: Manitoba provides this spouse and common-law partner amount, which is equivalent to the spouses basic personal amount. values: + 2022-01-01: 9_134 2023-01-01: 9_134 metadata: unit: currency-CAD period: year - label: Manitoba spouse and commonlaw partner amount credit. + label: Manitoba spouse and commonlaw partner amount credit reference: - - title: Government of Canada - Manitoba spouse and commonlaw partner amount credit + - title: Government of Canada - 2023 Manitoba spouse and commonlaw partner amount credit href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1mb/td1mb-23e.pdf#page=1 + - title: Government of Canada - 2022 Manitoba spouse and commonlaw partner amount credit + href: https://www.gov.mb.ca/finance/personal/pcredits.html#nrtc + - title: Government of Canada - Manitoba individual income tax + href: https://www.gov.mb.ca/finance/personal/ptaxes.html#mb#page=1 \ No newline at end of file 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 c5f446057..a1a5df9c7 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 @@ -3,7 +3,7 @@ input: province_code: MB spouse_income: 5_000 - lived_together: true + cohabitating_spouses: true mb_head_eligibility: true output: mb_spouse_credit_amount: 4_134 @@ -13,7 +13,7 @@ input: province_code: MB spouse_income: 5_000 - lived_together: false + cohabitating_spouses: false mb_head_eligibility: true output: mb_spouse_credit_amount: 0 @@ -23,7 +23,7 @@ input: province_code: MB spouse_income: 10_000 - lived_together: true + cohabitating_spouses: true mb_head_eligibility: true output: mb_spouse_credit_amount: 0 diff --git a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py index e51923813..45d21470a 100644 --- a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py @@ -15,6 +15,8 @@ def formula(person, period, parameters): ).gov.provinces.mb.tax.income.credits.spouse_or_common_law_partner_amount spouse_income = person("spouse_income", period) - living_together = person("lived_together", period) + living_together = person("cohabitating_spouses", period) ###household? - return living_together * (max_(0, (p.base_amount - spouse_income))) + credit_amount = max_(0, (p.base_amount - spouse_income)) + + return living_together * credit_amount \ No newline at end of file diff --git a/policyengine_canada/variables/household/person/cohabitating_spouses.py b/policyengine_canada/variables/household/person/cohabitating_spouses.py new file mode 100644 index 000000000..ad6781f33 --- /dev/null +++ b/policyengine_canada/variables/household/person/cohabitating_spouses.py @@ -0,0 +1,8 @@ +from policyengine_canada.model_api import * + + +class cohabitating_spouses(Variable): + value_type = bool + entity = Person #Household + label = "Cohabitating spouses" + definition_period = YEAR diff --git a/policyengine_canada/variables/household/person/is_caregiver.py b/policyengine_canada/variables/household/person/is_caregiver.py index 5e348a8bc..e93e2a867 100644 --- a/policyengine_canada/variables/household/person/is_caregiver.py +++ b/policyengine_canada/variables/household/person/is_caregiver.py @@ -4,5 +4,5 @@ class is_caregiver(Variable): value_type = bool entity = Person - label = "Is the caregiver" + label = "Tax filer is the primary caregiver" definition_period = YEAR diff --git a/policyengine_canada/variables/household/person/lived_together.py b/policyengine_canada/variables/household/person/lived_together.py deleted file mode 100644 index e280a5e24..000000000 --- a/policyengine_canada/variables/household/person/lived_together.py +++ /dev/null @@ -1,8 +0,0 @@ -from policyengine_canada.model_api import * - - -class lived_together(Variable): - value_type = bool - entity = Person - label = "Lived together with the tax filer" - definition_period = YEAR From 95c7a553c49f1862e8c7eb07a3fe5ed2266357b7 Mon Sep 17 00:00:00 2001 From: laviniawo <132245041+laviniawo@users.noreply.github.com> Date: Mon, 21 Aug 2023 21:25:38 +0000 Subject: [PATCH 4/7] modifications on reference --- .../spouse_or_common_law_partner_amount/base_amount.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml b/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml index 59b505ac6..ff25de4f4 100644 --- a/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml +++ b/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml @@ -11,5 +11,5 @@ metadata: href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1mb/td1mb-23e.pdf#page=1 - title: Government of Canada - 2022 Manitoba spouse and commonlaw partner amount credit href: https://www.gov.mb.ca/finance/personal/pcredits.html#nrtc - - title: Government of Canada - Manitoba individual income tax - href: https://www.gov.mb.ca/finance/personal/ptaxes.html#mb#page=1 \ No newline at end of file + - title: Government of Canada - Manitoba individual income tax C.C.S.M C.l.10 Division II Section4.6(5) + href: https://web2.gov.mb.ca/laws/statutes/archive/i010(2020-11-05)e.php#4.6(5) \ No newline at end of file From 81239af1edbf5ee566d42baf616a9aa93afc9031 Mon Sep 17 00:00:00 2001 From: laviniawo <132245041+laviniawo@users.noreply.github.com> Date: Mon, 21 Aug 2023 22:25:34 +0000 Subject: [PATCH 5/7] fixes --- .../{base_amount.yaml => base.yaml} | 3 +-- .../mb_spouse_credit_amount.yaml | 6 +++--- ...ad_eligible.yaml => mb_spouse_credit_eligible.yaml} | 4 ++-- .../mb_spouse_credit_amount.py | 10 +++++----- ...ead_eligibility.py => mb_spouse_credit_eligible.py} | 2 +- .../variables/household/person/cohabitating_spouses.py | 2 +- 6 files changed, 13 insertions(+), 14 deletions(-) rename policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/{base_amount.yaml => base.yaml} (95%) rename policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/{mb_head_eligible.yaml => mb_spouse_credit_eligible.yaml} (78%) rename policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/{mb_head_eligibility.py => mb_spouse_credit_eligible.py} (88%) diff --git a/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml b/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base.yaml similarity index 95% rename from policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml rename to policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base.yaml index ff25de4f4..303072d36 100644 --- a/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base_amount.yaml +++ b/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base.yaml @@ -1,7 +1,6 @@ description: Manitoba provides this spouse and common-law partner amount, which is equivalent to the spouses basic personal amount. values: 2022-01-01: 9_134 - 2023-01-01: 9_134 metadata: unit: currency-CAD period: year @@ -12,4 +11,4 @@ metadata: - title: Government of Canada - 2022 Manitoba spouse and commonlaw partner amount credit href: https://www.gov.mb.ca/finance/personal/pcredits.html#nrtc - title: Government of Canada - Manitoba individual income tax C.C.S.M C.l.10 Division II Section4.6(5) - href: https://web2.gov.mb.ca/laws/statutes/archive/i010(2020-11-05)e.php#4.6(5) \ No newline at end of file + href: https://web2.gov.mb.ca/laws/statutes/archive/i010(2020-11-05)e.php#4.6(5) 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 a1a5df9c7..c1af34894 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 @@ -4,7 +4,7 @@ province_code: MB spouse_income: 5_000 cohabitating_spouses: true - mb_head_eligibility: true + mb_spouse_credit_eligible: true output: mb_spouse_credit_amount: 4_134 @@ -14,7 +14,7 @@ province_code: MB spouse_income: 5_000 cohabitating_spouses: false - mb_head_eligibility: true + mb_spouse_credit_eligible: true output: mb_spouse_credit_amount: 0 @@ -24,6 +24,6 @@ province_code: MB spouse_income: 10_000 cohabitating_spouses: true - mb_head_eligibility: true + mb_spouse_credit_eligible: 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_head_eligible.yaml b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.yaml similarity index 78% rename from policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_head_eligible.yaml rename to policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.yaml index b753c5f26..cee75b7e0 100644 --- 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_spouse_credit_eligible.yaml @@ -4,7 +4,7 @@ province_code: MB is_caregiver: true output: - mb_head_eligibility: true + mb_spouse_credit_eligible: true - name: Household's head is not taking care of the spouse period: 2023 @@ -12,4 +12,4 @@ province_code: MB is_caregiver: false output: - mb_head_eligibility: false + mb_spouse_credit_eligible: false diff --git a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py index 45d21470a..d0d3e2a93 100644 --- a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py @@ -4,9 +4,9 @@ class mb_spouse_credit_amount(Variable): value_type = float entity = Person - label = "Manitoba spouse and commonlaw partner net income" + label = "Manitoba spouse and common law partner amount" definition_period = YEAR - defined_for = "mb_head_eligibility" + defined_for = "mb_spouse_credit_eligible" def formula(person, period, parameters): @@ -15,8 +15,8 @@ def formula(person, period, parameters): ).gov.provinces.mb.tax.income.credits.spouse_or_common_law_partner_amount spouse_income = person("spouse_income", period) - living_together = person("cohabitating_spouses", period) ###household? + living_together = person("cohabitating_spouses", period) - credit_amount = max_(0, (p.base_amount - spouse_income)) + credit_amount = max_(0, (p.base - spouse_income)) - return living_together * credit_amount \ No newline at end of file + return living_together * credit_amount 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_spouse_credit_eligible.py similarity index 88% rename from policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_head_eligibility.py rename to policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.py index 115d009db..c3e465115 100644 --- 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_spouse_credit_eligible.py @@ -1,7 +1,7 @@ from policyengine_canada.model_api import * -class mb_head_eligibility(Variable): +class mb_spouse_credit_eligible(Variable): value_type = bool entity = Person label = "Manitoba head eligiblility for recieving spouse's tax credit" diff --git a/policyengine_canada/variables/household/person/cohabitating_spouses.py b/policyengine_canada/variables/household/person/cohabitating_spouses.py index ad6781f33..4cc1d2ee1 100644 --- a/policyengine_canada/variables/household/person/cohabitating_spouses.py +++ b/policyengine_canada/variables/household/person/cohabitating_spouses.py @@ -3,6 +3,6 @@ class cohabitating_spouses(Variable): value_type = bool - entity = Person #Household + entity = Person # Household label = "Cohabitating spouses" definition_period = YEAR From c77e1c30ce499a00d254d639bae925cbec024f19 Mon Sep 17 00:00:00 2001 From: laviniawo <132245041+laviniawo@users.noreply.github.com> Date: Wed, 13 Sep 2023 04:11:46 +0000 Subject: [PATCH 6/7] resolve comments --- .../base.yaml | 6 +++--- .../mb_spouse_credit_amount.yaml | 21 ++++++++----------- .../mb_spouse_credit_eligible.yaml | 8 +++---- .../mb_spouse_credit_amount.py | 9 +++----- .../mb_spouse_credit_eligible.py | 6 +++--- .../household/person/cohabitating_spouses.py | 2 +- 6 files changed, 23 insertions(+), 29 deletions(-) diff --git a/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base.yaml b/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base.yaml index 303072d36..d9462a729 100644 --- a/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base.yaml +++ b/policyengine_canada/parameters/gov/provinces/mb/tax/income/credits/spouse_or_common_law_partner_amount/base.yaml @@ -1,14 +1,14 @@ -description: Manitoba provides this spouse and common-law partner amount, which is equivalent to the spouses basic personal amount. +description: Manitoba provides this spouse and common-law partner amount, equivalent to the spouses basic personal amount. values: 2022-01-01: 9_134 metadata: unit: currency-CAD period: year - label: Manitoba spouse and commonlaw partner amount credit + label: Manitoba spouse and common-law partner credit amount reference: - title: Government of Canada - 2023 Manitoba spouse and commonlaw partner amount credit href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1mb/td1mb-23e.pdf#page=1 - title: Government of Canada - 2022 Manitoba spouse and commonlaw partner amount credit href: https://www.gov.mb.ca/finance/personal/pcredits.html#nrtc - - title: Government of Canada - Manitoba individual income tax C.C.S.M C.l.10 Division II Section4.6(5) + - title: Government of Canada - Manitoba individual income tax C.C.S.M C.l.10 Division II Section4.6(5)(i) href: https://web2.gov.mb.ca/laws/statutes/archive/i010(2020-11-05)e.php#4.6(5) 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 c1af34894..696f75936 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,29 +1,26 @@ -- name: Eligible income spouse lived with household's head +- name: Eligible income spouse lived with and being taken care of household's head period: 2023 input: - province_code: MB - spouse_income: 5_000 - cohabitating_spouses: true mb_spouse_credit_eligible: true + spouse_income: 5_000 + is_caregiver: true output: mb_spouse_credit_amount: 4_134 -- name: Eligible income spouse does not lived with household's head +- name: Eligible income spouse lived with but not being taken care of household's head period: 2023 input: - province_code: MB - spouse_income: 5_000 - cohabitating_spouses: false mb_spouse_credit_eligible: true + spouse_income: 5_000 + is_caregiver: false output: mb_spouse_credit_amount: 0 -- name: ineligible income spouse lived with household's head +- name: Ineligible income spouse lived with and being taken care of household's head period: 2023 input: - province_code: MB - spouse_income: 10_000 - cohabitating_spouses: true mb_spouse_credit_eligible: true + spouse_income: 10_000 + is_caregiver: 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_credit_eligible.yaml b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.yaml index cee75b7e0..a46822b88 100644 --- a/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.yaml +++ b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.yaml @@ -1,15 +1,15 @@ -- name: Household's head is taking care of the spouse +- name: Household's head and spouse is living together period: 2023 input: province_code: MB - is_caregiver: true + cohabitating_spouses: true output: mb_spouse_credit_eligible: true -- name: Household's head is not taking care of the spouse +- name: Household's head and spouse is not living together period: 2023 input: province_code: MB - is_caregiver: false + cohabitating_spouses: false output: mb_spouse_credit_eligible: false diff --git a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py index d0d3e2a93..a15ec04a4 100644 --- a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py @@ -4,19 +4,16 @@ class mb_spouse_credit_amount(Variable): value_type = float entity = Person - label = "Manitoba spouse and common law partner amount" + label = "Manitoba spouse and common-law partner amoount" definition_period = YEAR defined_for = "mb_spouse_credit_eligible" def formula(person, period, parameters): - p = parameters( period ).gov.provinces.mb.tax.income.credits.spouse_or_common_law_partner_amount spouse_income = person("spouse_income", period) - living_together = person("cohabitating_spouses", period) - - credit_amount = max_(0, (p.base - spouse_income)) + is_caregiver = person("is_caregiver", period) - return living_together * credit_amount + return is_caregiver * (max_(0, (p.base - spouse_income))) diff --git a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.py index c3e465115..e2d0639fb 100644 --- a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.py +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.py @@ -3,10 +3,10 @@ class mb_spouse_credit_eligible(Variable): value_type = bool - entity = Person + entity = Household 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) + def formula(household, period, parameters): + return household("cohabitating_spouses", period) diff --git a/policyengine_canada/variables/household/person/cohabitating_spouses.py b/policyengine_canada/variables/household/person/cohabitating_spouses.py index 4cc1d2ee1..ffb2582f9 100644 --- a/policyengine_canada/variables/household/person/cohabitating_spouses.py +++ b/policyengine_canada/variables/household/person/cohabitating_spouses.py @@ -3,6 +3,6 @@ class cohabitating_spouses(Variable): value_type = bool - entity = Person # Household + entity = Household label = "Cohabitating spouses" definition_period = YEAR From 8363359aeb4f993b33ccea96264a9c3135fb876d Mon Sep 17 00:00:00 2001 From: laviniawo <132245041+laviniawo@users.noreply.github.com> Date: Tue, 3 Oct 2023 01:11:26 +0000 Subject: [PATCH 7/7] changes made upon request --- .../mb_spouse_credit_amount.yaml | 11 ----------- .../mb_spouse_credit_eligible.yaml | 15 +++++++++++++-- .../mb_spouse_credit_amount.py | 8 ++++---- .../mb_spouse_credit_eligible.py | 4 +++- 4 files changed, 20 insertions(+), 18 deletions(-) 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 696f75936..c2d530d92 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 @@ -3,24 +3,13 @@ input: mb_spouse_credit_eligible: true spouse_income: 5_000 - is_caregiver: true output: mb_spouse_credit_amount: 4_134 -- name: Eligible income spouse lived with but not being taken care of household's head - period: 2023 - input: - mb_spouse_credit_eligible: true - spouse_income: 5_000 - is_caregiver: false - output: - mb_spouse_credit_amount: 0 - - name: Ineligible income spouse lived with and being taken care of household's head period: 2023 input: mb_spouse_credit_eligible: true spouse_income: 10_000 - is_caregiver: 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_credit_eligible.yaml b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.yaml index a46822b88..90dcfbcbc 100644 --- a/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.yaml +++ b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.yaml @@ -1,15 +1,26 @@ -- name: Household's head and spouse is living together +- name: Household's head is taking care of and living together with spouse period: 2023 input: province_code: MB + is_caregiver: true cohabitating_spouses: true output: mb_spouse_credit_eligible: true -- name: Household's head and spouse is not living together +- name: Household's head is taking care of but not living together with spouse period: 2023 input: province_code: MB cohabitating_spouses: false + is_caregiver: true + output: + mb_spouse_credit_eligible: false + +- name: Household's head is not taking care of but living together with spouse + period: 2023 + input: + province_code: MB + cohabitating_spouses: true + is_caregiver: false output: mb_spouse_credit_eligible: false diff --git a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py index a15ec04a4..f2542ac28 100644 --- a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_amount.py @@ -3,17 +3,17 @@ class mb_spouse_credit_amount(Variable): value_type = float - entity = Person + entity = Household label = "Manitoba spouse and common-law partner amoount" definition_period = YEAR defined_for = "mb_spouse_credit_eligible" - def formula(person, period, parameters): + def formula(household, period, parameters): + person = household.members p = parameters( period ).gov.provinces.mb.tax.income.credits.spouse_or_common_law_partner_amount spouse_income = person("spouse_income", period) - is_caregiver = person("is_caregiver", period) - return is_caregiver * (max_(0, (p.base - spouse_income))) + return max_(0, p.base - spouse_income) diff --git a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.py index e2d0639fb..c1f186d89 100644 --- a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.py +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/spouse_and_common_law_partner_amount/mb_spouse_credit_eligible.py @@ -9,4 +9,6 @@ class mb_spouse_credit_eligible(Variable): defined_for = ProvinceCode.MB def formula(household, period, parameters): - return household("cohabitating_spouses", period) + person = household.members + is_caregiver = person("is_caregiver", period) + return is_caregiver * household("cohabitating_spouses", period)