Skip to content

Commit

Permalink
test file, code in python file, and max credit file added Fixes #352
Browse files Browse the repository at this point in the history
  • Loading branch information
karenlilr committed Jul 9, 2024
1 parent 2e953f1 commit bb187be
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 110 deletions.
Original file line number Diff line number Diff line change
@@ -1,113 +1,23 @@
description: New Brunswick provides the following Spouse or Common-law partner base amount.
values:
2022-01-01: x
2023-01-01: 10_741
2024-01-01: 11_246
metadata:
unit: currency-CAD
period: year
label: New Brunswick Spouse or Common-law Partner Base Amount
reference:
- title: Worksheet for the 2022 New Brunswick Personal Tax Credits Return
href: https://www.cchwebsites.com/content/pdf/tax_forms/ca/en/td1nbws_en.pdf#page=1
- title: 2022 New Brunswick Personal Tax Credits Return
href: https://www.vitalitenb.ca/sites/default/files/documents/employes/td1nb_nb_personal_tax_credits_return.pdf#page=1
- title: Worksheet for the 2023 New Brunswick Personal Tax Credits Return
href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf#page=1
- title: 2023 New Brunswick Personal Tax Credits Return
href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf#page=1
- title: 2024 New Brunswick Personal Tax Credits Return
href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb/td1nb-24e.pdf#page=1
- title: Worksheet for the 2024 New Brunswick Personal Tax Credits Return
href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-24e.pdf#page=1

- name: No spouse income
period: 2023
input:
people:
head:
spouse_income: 0
spouse:
spouse_income: 0
household:
members: [head, spouse]
province_code: NB
output:
ab_spouse_and_common_law_partner_amount_credit: 9_764

- name: Spouse income of $1,000
period: 2023
input:
province_code: NB
spouse_income: 1_000
output:
ab_spouse_and_common_law_partner_amount_credit: 9_741

- name: Spouse income of $10,000
period: 2023
input:
province_code: NB
spouse_income: 10_000
output:
ab_spouse_and_common_law_partner_amount_credit: 741

- name: Capped at 0
period: 2023
input:
province_code: AB
spouse_income: 40_000
output:
ab_spouse_and_common_law_partner_amount_credit: 0

SPOUSE_INCOME
- name: One person eligible and one not
period: 2023
input:
people:
head:
is_spouse: false
individual_net_income: 10_000
spouse:
is_spouse: true
individual_net_income: 1_000
household:
members: [head, spouse]
province_code: NB
output:
spouse_income: [0, 1_000]

- name: Eligible spouse
period: 2023
input:
province_code: NB
is_spouse: true
individual_net_income: 10_000
output:
spouse_income: 10_000

- name: Ineligible spouse
period: 2023
input:
province_code: NB
is_spouse: false
individual_net_income: 10_000
output:
spouse_income: 0


from policyengine_canada.model_api import *

class nb_spouse_and_common_law_partner_amount_credit(Variable):
value_type = float
entity = Household
label = "New Brunswick spouse and common-law partner amount credit"
definition_period = YEAR
defined_for = ProvinceCode.NB

def formula(household, period, parameters):
spouse_income = add(household, period, ["spouse_income"])
base_amount = 10_741
max_credit = 9_764
result = base_amount - spouse_income
return min(max_credit, max(0, result))

class spouse_income(Variable):
value_type = float
entity = Person
label = "Spouse and commonlaw partner income"
definition_period = YEAR

def formula(person, period, parameters):
spouse = person("is_spouse", period)
income = person("individual_net_income", period)
return spouse * income

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
description: The New Brunswick spouse or common-law partner amount credit is calculated by taking into account the spouse's net income and comparing it to a base amount. The maximum credit is the highest amount that can be claimed as a credit.
values:
2022-01-01: 9_186
2023-01-01: 9_764
2024-01-01: 10_223
metadata:
unit: currency-CAD
period: year
label: New Brunswick Spouse or Common-law Partner Max Credit
reference:
- title: Worksheet for the 2022 New Brunswick Personal Tax Credits Return
href: https://www.cchwebsites.com/content/pdf/tax_forms/ca/en/td1nbws_en.pdf#page=1
- title: Worksheet for the 2023 New Brunswick Personal Tax Credits Return
href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-23e.pdf#page=1
- title: Worksheet for the 2024 New Brunswick Personal Tax Credits Return
href: https://www.canada.ca/content/dam/cra-arc/formspubs/pbg/td1nb-ws/td1nb-ws-24e.pdf#page=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from policyengine_canada.model_api import *

class nb_spouse_and_common_law_partner_amount_credit(Variable):
value_type = float
entity = Household
label = "New Brunswick spouse and common-law partner amount credit"
definition_period = YEAR
defined_for = ProvinceCode.NB

p = parameters(period).gov.provinces.nb.tax.income.credits.spouse_or_common_law_partner_amount
base_amount = p.base_amount
max_credit = p.max_credit

def formula(household, period, parameters):
year = period.start.year
if year == 2022:
base_amount = 10_105
max_credit = 9_186
elif year == 2023:
base_amount = 10_741
max_credit = 9_764
elif year == 2024:
base_amount = 11_246
max_credit = 10_223
else:
raise ValueError(f"Year {year} not supported.")

spouse_income = add(household, period, ["spouse_income"])
result = base_amount - spouse_income
return min(max_credit, max(0, result))

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
- name: No spouse income in 2022
period: 2022
input:
people:
head:
spouse_income: 0
spouse:
spouse_income: 0
household:
members: [head, spouse]
province_code: NB
output:
nb_spouse_and_common_law_partner_amount_credit: 9_186

- name: Spouse income of $1,000 in 2022
period: 2022
input:
province_code: NB
spouse_income: 1_000
output:
nb_spouse_and_common_law_partner_amount_credit: 9_105

- name: Spouse income of $10,000 in 2022
period: 2022
input:
province_code: NB
spouse_income: 10_000
output:
nb_spouse_and_common_law_partner_amount_credit: 105

- name: Capped at 0 in 2022
period: 2022
input:
province_code: NB
spouse_income: 40_000
output:
nb_spouse_and_common_law_partner_amount_credit: 0


- name: No spouse income
period: 2023
input:
people:
head:
spouse_income: 0
spouse:
spouse_income: 0
household:
members: [head, spouse]
province_code: NB
output:
nb_spouse_and_common_law_partner_amount_credit: 9_764

- name: Spouse income of $1,000
period: 2023
input:
province_code: NB
spouse_income: 1_000
output:
nb_spouse_and_common_law_partner_amount_credit: 9_741

- name: Spouse income of $10,000
period: 2023
input:
province_code: NB
spouse_income: 10_000
output:
nb_spouse_and_common_law_partner_amount_credit: 741

- name: Capped at 0
period: 2023
input:
province_code: AB
spouse_income: 40_000
output:
nb_spouse_and_common_law_partner_amount_credit: 0


Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
- name: One person eligible and one not
period: 2022
period: 2023
period: 2024
input:
people:
head:
is_spouse: false
individual_net_income: 10_000
spouse:
is_spouse: true
individual_net_income: 1_000
household:
members: [head, spouse]
province_code: NB
output:
spouse_income: [0, 1_000]

- name: Eligible spouse
period: 2022
period: 2023
period: 2024
input:
province_code: NB
is_spouse: true
individual_net_income: 10_000
output:
spouse_income: 10_000

- name: Ineligible spouse
period: 2022
period: 2023
period: 2024
input:
province_code: NB
is_spouse: false
individual_net_income: 10_000
output:
spouse_income: 0

0 comments on commit bb187be

Please sign in to comment.