Skip to content

Commit

Permalink
renaming variables and parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
hua7450 committed May 10, 2024
1 parent b39d77f commit c6bec6f
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 85 deletions.
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
added:
- Add Montana taxable social security benefits.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
description: Montana uses this amount when calculating the taxable social security benefits, based on filing status.
metadata:
period: year
unit: currency-USD
label: Montana social security benefits amount
breakdown:
- filing_status
reference:
- title: 2021 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/mdocs/form%202%202021.pdf#page=6
- title: 2022 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/dlm_uploads/2023/05/Montana-Idividiual-Income-Tax-Return-Form-2-2022v6.2.pdf#page=6
- title: 2023 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/dlm_uploads/2023/12/Form_2_2023.pdf#page=6
# These values only appear in the tax form
SINGLE:
2021-01-01: 25_000
HEAD_OF_HOUSEHOLD:
2021-01-01: 25_000
JOINT:
2021-01-01: 32_000
SEPARATE:
2021-01-01: 16_000
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
description: Montana uses this amount when calculating the taxable social security benefits, based on filing status.
metadata:
period: year
unit: currency-USD
label: Montana social security benefits amount
breakdown:
- filing_status
reference:
- title: 2021 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/mdocs/form%202%202021.pdf#page=6
- title: 2022 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/dlm_uploads/2023/05/Montana-Idividiual-Income-Tax-Return-Form-2-2022v6.2.pdf#page=6
- title: 2023 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/dlm_uploads/2023/12/Form_2_2023.pdf#page=6
# These values only appear in the tax form
SINGLE:
2021-01-01: 9_000
HEAD_OF_HOUSEHOLD:
2021-01-01: 9_000
JOINT:
2021-01-01: 12_000
SEPARATE:
2021-01-01: 6_000

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
description: Montana matches this fraction of social security benefits.
values:
2021-01-01: 0.85

metadata:
unit: /1
period: year
label: Montana social security benefits rate
reference:
- title: 2021 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/mdocs/form%202%202021.pdf#page=6
- title: 2022 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/dlm_uploads/2023/05/Montana-Idividiual-Income-Tax-Return-Form-2-2022v6.2.pdf#page=6
- title: 2023 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/dlm_uploads/2023/12/Form_2_2023.pdf#page=6
# This rate only appears in the tax form
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
description: Montana matches this fraction of social security benefits.
values:
2021-01-01: 0.5

metadata:
unit: /1
period: year
label: Montana social security benefits rate
reference:
- title: 2021 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/mdocs/form%202%202021.pdf#page=6
- title: 2022 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/dlm_uploads/2023/05/Montana-Idividiual-Income-Tax-Return-Form-2-2022v6.2.pdf#page=6
- title: 2023 Montana Individual Income Tax Return (Taxable Social Security Benefits Schedule)
href: https://mtrevenue.gov/wp-content/uploads/dlm_uploads/2023/12/Form_2_2023.pdf#page=6
# This rate only appears in the tax form

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,71 @@

class mt_taxable_social_security(Variable):
value_type = float
entity = TaxUnit
entity = TaxUnit
label = "Montana taxable social security benefits"
defined_for = StateCode.MT
definition_period = YEAR
reference = "https://mtrevenue.gov/wp-content/uploads/mdocs/form%202%202021.pdf#page=6"

def formula(tax_unit, period, parameters):
p = parameters(period).gov.states.mt.tax.income.social_security
# Compute the amount based on the schedule in tax form.
# line 1&2: 6a in tax form ?
social_security_benefit = tax_unit("social_security",period)
fraction_of_social_security_benefit= social_security_benefit*p.rate1
# line 3
tax_unit("total_income",period) - tax_unit("taxable_social_security",period)
# line 4: Additions Schedule line 15 - line 3
0
# line 5:
tax_emempt_interest_income = tax_unit("tax_exempt_interest_income",period)
social_security = tax_unit("social_security", period)
social_security_benefits_fraction = social_security * p.rate.lower
# line 3 total_income - taxable_social_security
# line 4: Additions Schedule line 15 - line 3 (0?)
# line 5:
tax_emempt_interest_income = tax_unit(
"tax_exempt_interest_income", period
)
# line 6: line 2+3+4+5
line_6 = fraction_of_social_security_benefit + tax_unit("total_income",period) - tax_unit("taxable_social_security",period) +tax_emempt_interest_income
us_ald = tax_unit("above_the_line_deductions",period) - tax_unit("student_loan_interest", period)
new_total_income = (
social_security_benefits_fraction
+ tax_unit("total_income", period)
- tax_unit("taxable_social_security", period)
+ tax_emempt_interest_income
)
us_ald_exclue_stduent_loan = tax_unit(
"above_the_line_deductions", period
) - tax_unit("student_loan_interest", period)
# line 8
person = tax_unit.members
line_8 = person("mt_subtractions", period) + us_ald
# line 9: line 8 -line 6, if line 8 >= line 6, return 0
line_9 = max(0, line_8 - line_6)
increased_subtractions = (
person("mt_subtractions", period) + us_ald_exclue_stduent_loan
)
# line 9: line 6 -line 8, if line 8 >= line 6, return 0
remaining_income = max(0, new_total_income - increased_subtractions)
# line 10: get amount based on filing status
amount_1 = p.social_security.amount1[filing_status]
amount_higher = p.social_security.amount.higher[filing_status]
# line 11: line 9 - line 10
# line 12: get amount based on filing status
amount_2 = p.social_security.amount2[filing_status]
# lien 13: line 11 - line 12
line_13 = max(0,amount_1 - line_9 - amount_2)
amount_lower = p.social_security.amount.lower[filing_status]
# lien 13: line 11 - line 12
minimum_tax_threshold = max_(
0, amount_higher - remaining_income - amount_lower
)
# line 14 & 15
line_15 = min(amount_1 - line_9,amount_2)*p.rate1
minimum_tax_threshold_fraction = (
min_(amount_higher - remaining_income, amount_lower) * p.rate.lower
)
# line 16
line_16 = min(line_15,fraction_of_social_security_benefit)
minimum_fraction = min_(
minimum_tax_threshold_fraction, social_security_benefits_fraction
)
# line 17 & 18 ## line_13*p.rate2 + line_16
# line 19 ## social_security_benefit*p.rate2
# line 20
lesser_of_18_or_19 = min(social_security_benefit*p.rate2, line_13*p.rate2 + line_16)
# line 11: line 10 - line 9, if line 10 >= line 9, return 0
adjusted_tax_amount = (
minimum_tax_threshold * p.rate.higher + minimum_fraction
)
# line 19 ## line_1*p.rate2
adjusted_taxable_amount = social_security * p.rate.higher
# line 20
lesser_of_taxable_amount = min_(
adjusted_taxable_amount, adjusted_tax_amount
)
# line 11: line 9 - line 10, if line 10 >= line 9, return 0. Else, proceed line 12 through 20
return select(
amount_1 < line_9,
lesser_of_18_or_19,
amount_higher < remaining_income,
lesser_of_taxable_amount,
default=0,
)

0 comments on commit c6bec6f

Please sign in to comment.