diff --git a/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/education_property_tax_credit/mb_education_property_tax_credit_amount.yaml b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/education_property_tax_credit/mb_education_property_tax_credit_amount.yaml index f9f49b3aa..f7b91dc98 100644 --- a/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/education_property_tax_credit/mb_education_property_tax_credit_amount.yaml +++ b/policyengine_canada/tests/gov/provinces/mb/tax/income/credits/education_property_tax_credit/mb_education_property_tax_credit_amount.yaml @@ -1,23 +1,35 @@ - name: Education property tax credit with eligible age amount period: 2022 input: - province_code: MB - education_property_tax_received: 2_000 - net_school_tax: 3_000 - age: 70 - adjusted_family_net_income: 100_000 - days_owning_education_property: 1_825 + people: + head: + age: 70 + spouse: + age: 72 + household: + members: [head, spouse] + province_code: MB + education_property_tax_received: 2_000 + net_school_tax: 3_000 + adjusted_family_net_income: 100_000 + days_owning_education_property: 1_825 output: mb_education_property_tax_credit_amount: 187.5 - name: Education property tax credit with ineligible age amount period: 2022 input: - province_code: MB - education_property_tax_received: 2_000 - net_school_tax: 3_000 - age: 60 - adjusted_family_net_income: 100_000 - days_owning_education_property: 365 + people: + head: + age: 60 + spouse: + age: 62 + household: + members: [head, spouse] + province_code: MB + education_property_tax_received: 2_000 + net_school_tax: 3_000 + adjusted_family_net_income: 100_000 + days_owning_education_property: 1_825 output: mb_education_property_tax_credit_amount: 187.5 diff --git a/policyengine_canada/variables/household/expenses/housing/number_of_days_owning_education_property.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/days_owning_education_property.py similarity index 90% rename from policyengine_canada/variables/household/expenses/housing/number_of_days_owning_education_property.py rename to policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/days_owning_education_property.py index d1c3aa672..a94b5f74c 100644 --- a/policyengine_canada/variables/household/expenses/housing/number_of_days_owning_education_property.py +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/days_owning_education_property.py @@ -3,7 +3,7 @@ class days_owning_education_property(Variable): value_type = float - entity = Person + entity = Household label = "Number of days at addresses of education property owned" unit = CAD definition_period = YEAR diff --git a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/education_property_tax_credit_amount.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/education_property_tax_credit_amount.py index 2ba913b5d..88b68acdb 100644 --- a/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/education_property_tax_credit_amount.py +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/education_property_tax_credit_amount.py @@ -3,30 +3,32 @@ class mb_education_property_tax_credit_amount(Variable): value_type = float - entity = Person + entity = Household label = "Manitoba education property tax credit" unit = CAD definition_period = YEAR defined_for = ProvinceCode.MB - def formula(person, period, parameters): + def formula(household, period, parameters): p = parameters( period ).gov.provinces.mb.tax.income.credits.education_property_tax_credit - property_tax = p.applicable_percentage * ( - person("education_property_tax_received", period) - + person("net_school_tax", period) - ) + person = household.members age = person("age", period) age_eligible = age >= p.age_amount - age_ineligible = age < p.age_amount + age_ineligible = ~age_eligible + + property_tax = p.applicable_percentage * ( + household("education_property_tax_received", period) + + household("net_school_tax", period) + ) # household net income - net_income = person("adjusted_family_net_income", period) + net_income = household("adjusted_family_net_income", period) - eligible_age_credit = age_eligible * ( + eligible_age_credit = max_(1,age_eligible) * ( p.basic_credit_age_eligible - p.family_income_applicable_rate * net_income ) @@ -34,21 +36,22 @@ def formula(person, period, parameters): eligible_age_credit, p.basic_credit_age_ineligible ) - ineligible_age_credit = age_ineligible * p.basic_credit_age_ineligible + ineligible_age_credit = max_(1,age_ineligible) * p.basic_credit_age_ineligible time_at_education_property = ( - person("days_owning_education_property", period) / p.time_amount + household("days_owning_education_property", period) / p.time_amount ) + education_property_tax_credit_amount = max_( 0, ( min_( - ineligible_age_credit * time_at_education_property, + eligible_age_credit_max * time_at_education_property, property_tax, ) ) - - person("education_property_tax_received", period), + - household("education_property_tax_received", period), ) - return education_property_tax_credit_amount + return household.sum(education_property_tax_credit_amount) diff --git a/policyengine_canada/variables/household/expenses/tax/education_property_tax_credit_ received.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/education_property_tax_received.py similarity index 90% rename from policyengine_canada/variables/household/expenses/tax/education_property_tax_credit_ received.py rename to policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/education_property_tax_received.py index c39446a39..ce2a147f3 100644 --- a/policyengine_canada/variables/household/expenses/tax/education_property_tax_credit_ received.py +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/education_property_tax_received.py @@ -3,7 +3,7 @@ class education_property_tax_received(Variable): value_type = float - entity = Person + entity = Household label = "Education property taxes received" unit = CAD definition_period = YEAR diff --git a/policyengine_canada/variables/household/expenses/tax/net_school_tax.py b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/net_school_tax.py similarity index 88% rename from policyengine_canada/variables/household/expenses/tax/net_school_tax.py rename to policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/net_school_tax.py index 697d82130..db54a2758 100644 --- a/policyengine_canada/variables/household/expenses/tax/net_school_tax.py +++ b/policyengine_canada/variables/gov/provinces/mb/tax/income/credits/education_property_tax_credit/net_school_tax.py @@ -3,7 +3,7 @@ class net_school_tax(Variable): value_type = float - entity = Person + entity = Household label = "Net school tax paid" unit = CAD definition_period = YEAR