Skip to content

Commit

Permalink
Merge pull request #57 from austinperryfrancis/va_fix
Browse files Browse the repository at this point in the history
Merging
  • Loading branch information
rickecon authored Oct 25, 2023
2 parents 3122208 + 2225860 commit 51990dc
Show file tree
Hide file tree
Showing 26 changed files with 278 additions and 271 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.5] - 2023-10-24 22:00:00

### Added

- Updated environment.yml and build_and_test.yml to allow for python 3.11
- Updated Virginia tax logic with correct mapping from federal filing status to state filing status.

## [0.2.4] - 2023-10-24 10:00:00

### Added
Expand Down Expand Up @@ -178,6 +185,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- First prototype version based off of openfisca-us and tax-calculator.



[0.2.5]: https://github.com/TheCGO/fiscalsim-us/compare/v0.2.4...v0.2.5
[0.2.4]: https://github.com/TheCGO/fiscalsim-us/compare/v0.2.3...v0.2.4
[0.2.3]: https://github.com/TheCGO/fiscalsim-us/compare/v0.2.2...v0.2.3
[0.2.2]: https://github.com/TheCGO/fiscalsim-us/compare/v0.2.1...v0.2.2
Expand Down
6 changes: 6 additions & 0 deletions changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,9 @@
- Fixed circularity in CO tax logic
- Fixed circularity in MO tax logic
date: 2023-10-24 10:00:00
- bump: patch
changes:
added:
- Updated environment.yml and build_and_test.yml to allow for python 3.11
- Updated Virginia tax logic with correct mapping from federal filing status to state filing status.
date: 2023-10-24 22:00:00
7 changes: 4 additions & 3 deletions fiscalsim_us/variables/gov/states/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ If you do not write tests for new variables created, the code coverage tests wil

## Higher level variables to which you need to add (connect) your state variables
* [`state_income_tax`](https://github.com/TheCGO/fiscalsim-us/blob/main/fiscalsim_us/variables/gov/states/tax/income/state_income_tax.py): You need to add your state's `[2-letter-state-abbrev]_income_tax` variable to the list in the `adds` command.
* [`state_income_tax_before_refundable_credits`](https://github.com/TheCGO/fiscalsim-us/blob/main/fiscalsim_us/variables/gov/states/tax/income/state_income_tax_before_refundable_credits.py): You need to add your state's `[2-letter-state-abbrev]_income_tax_before_refundable_credits` variable to the list in the `adds` command.
* [`household_refundable_tax_credits`](https://github.com/TheCGO/fiscalsim-us/blob/main/fiscalsim_us/variables/household/income/household/household_refundable_tax_credits.py): You need to add your state's `[2-letter-state-abbrev]_refundable_credits` variable to the list in the `adds` command.
* [`household_tax_before_refundable_credits`](https://github.com/TheCGO/fiscalsim-us/blob/main/fiscalsim_us/variables/household/income/household/household_tax_before_refundable_credits.py): You need to add your state's `[2-letter-state-abbrev]_income_tax_before_refundable_credits` variable to the list in the `adds` command.
* [`state_income_tax_before_refundable_credits.py`](https://github.com/TheCGO/fiscalsim-us/blob/main/fiscalsim_us/variables/gov/states/tax/income/state_income_tax_before_refundable_credits.py): You need to add your state's `[2-letter-state-abbrev]_income_tax_before_refundable_credits` variable to the list in the `adds` command.
* [`household_refundable_tax_credits.py`](https://github.com/TheCGO/fiscalsim-us/blob/main/fiscalsim_us/variables/household/income/household/household_refundable_tax_credits.py): You need to add your state's `[2-letter-state-abbrev]_refundable_credits` variable to the list in the `adds` command.
* [`household_state_income_tax.py`](https://github.com/TheCGO/fiscalsim-us/blob/main/fiscalsim_us/variables/household/income/household/household_state_income_tax.py): You need to add your state's `[2-letter-state-abbrev]_income_tax_before_refundable_credits` variable to the list in the `adds` command and your state's `[2-letter-state-abbrev]_refundable_credits` variable to the list in the `subtracts` command.
* [`household_tax_before_refundable_credits.py`](https://github.com/TheCGO/fiscalsim-us/blob/main/fiscalsim_us/variables/household/income/household/household_tax_before_refundable_credits.py): You need to add your state's `[2-letter-state-abbrev]_income_tax_before_refundable_credits` variable to the list in the `adds` command.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ class state_income_tax(Variable):
"or_income_tax",
"pa_income_tax",
"ri_income_tax",
# "va_income_tax", --- temporarily deactivated until change if to where
"ut_income_tax",
"va_income_tax",
"vt_income_tax",
"wa_income_tax",
"wi_income_tax",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ class state_income_tax_before_refundable_credits(Variable):
unit = USD
definition_period = YEAR
adds = [
"ca_income_tax_before_refundable_credits",
"co_income_tax_before_refundable_credits",
"dc_income_tax_before_refundable_credits",
"ia_income_tax_before_refundable_credits",
"il_total_tax",
"in_income_tax_before_refundable_credits",
"ks_income_tax_before_refundable_credits",
"ky_income_tax_before_refundable_credits",
"la_income_tax_before_refundable_credits",
"ma_income_tax_before_refundable_credits",
"md_income_tax_before_refundable_credits",
"me_income_tax_before_refundable_credits",
"mn_income_tax_before_refundable_credits",
"mt_income_tax_before_refundable_credits",
"mo_income_tax_before_refundable_credits",
"nc_income_tax", # NC has no refundable credits.
"nd_income_tax_before_refundable_credits",
Expand All @@ -27,8 +30,10 @@ class state_income_tax_before_refundable_credits(Variable):
"nj_income_tax_before_refundable_credits",
"nm_income_tax_before_refundable_credits",
"ny_income_tax_before_refundable_credits",
"ok_income_tax_before_refundable_credits",
"or_income_tax_before_refundable_credits",
"pa_income_tax", # PA has no refundable credits.
"ri_income_tax_before_refundable_credits",
"ut_income_tax_before_refundable_credits",
"va_income_tax_before_refundable_credits",
"vt_income_tax_before_refundable_credits",
Expand Down
36 changes: 0 additions & 36 deletions fiscalsim_us/variables/gov/states/va/tax/income/calc_line_14.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ class va_additions_to_federal_agi(Variable):

def formula(tax_unit, period, parameters):
income_from_obligations_fed_exempt = tax_unit(
"income_from_obligations_fed_exempt", period
"va_income_from_obligations_fed_exempt", period
)

fixed_date_conformity_additions = tax_unit(
"fixed_date_conformity_additions", period
"va_fixed_date_conformity_additions", period
)

additions_to_fed_agi = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ class va_adj_gross_income(Variable):

def formula(tax_unit, period, parameters):
line3 = tax_unit("va_calc_line_3", period)

line8 = tax_unit("va_calc_line_8", period)

filing_status = tax_unit("filing_status", period)
filing_statuses = filing_status.possible_values

threshold = parameters(
period
Expand All @@ -24,18 +23,17 @@ def formula(tax_unit, period, parameters):

subtotal = line3 - line8

if filing_status == 1 or filing_status == 3:
if subtotal < single:
tax_owed = 0

return tax_owed

if filing_status == 2:
if subtotal < joint:
tax_owed = 0

return tax_owed

va_adj_gross_income = subtotal

return va_adj_gross_income
tax_owed = where(
(filing_status == filing_statuses.SINGLE)
| (filing_status == filing_statuses.SEPARATE)
| (filing_status == filing_statuses.HEAD_OF_HOUSEHOLD)
| (filing_status == filing_statuses.WIDOW),
where(subtotal < single, 0, subtotal),
where(
filing_status == filing_statuses.JOINT,
where(subtotal < joint, 0, subtotal),
subtotal,
),
)

return tax_owed
177 changes: 103 additions & 74 deletions fiscalsim_us/variables/gov/states/va/tax/income/va_age_deduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,84 +11,113 @@ class va_age_deduction(Variable):

def formula(tax_unit, period, parameters):
age_of_head = tax_unit("age_head", period)

age_of_spouse = tax_unit("age_spouse", period)

filing_status = tax_unit("filing_status", period)

filing_statuses = filing_status.possible_values
federal_agi = tax_unit("adjusted_gross_income", period)

spouse_agi = tax_unit("spouse_separate_adjusted_gross_income", period)

you_fdca = tax_unit("fixed_date_conformity_additions", period)

you_fdca = tax_unit("va_fixed_date_conformity_additions", period)
spouse_fdca = 0 # change this

you_fdcs = tax_unit("fixed_date_conformity_subtractions", period)

you_fdcs = tax_unit("va_fixed_date_conformity_subtractions", period)
spouse_fdcs = 0 # change this

if age_of_head > 65:
if filing_status == 1:
age_deduction_count = 1

if filing_status == 2 & age_of_spouse > 65:
age_deduction_count = 2

if filing_status == 1:
total_agi = federal_agi

else:
total_agi = federal_agi + spouse_agi

if filing_status == 1:
total_fda = you_fdca

else:
total_fda = you_fdca + spouse_fdca

if filing_status == 1:
total_fds = you_fdcs

else:
total_fds = you_fdcs + spouse_fdcs

line4 = total_agi + total_fda

line6 = line4 - total_fds

line7 = 0 # Taxable benefits from the tax return, change this.

line8 = line6 - line7

if filing_status == 1:
threshold_ln9 = (
parameters.gov.states.va.tax.income.va_age_deduction_threshold.single
)

if filing_status == 2:
threshold_ln9 = (
parameters.gov.states.va.tax.income.va_age_deduction_threshold.joint
)

if filing_status == 3:
threshold_ln9 = (
parameters.gov.states.va.tax.income.va_age_deduction_threshold.separate
)

if line8 > threshold_ln9:
line11 = line8 - threshold_ln9

line12 = age_deduction_count * 12000

if line11 > line12:
final_age_deduction = 0

if line11 < line12:
line14 = line12 - line11

if filing_status == 1 or filing_status == 2:
return line14

if filing_status == 3:
return line14 / 2
age_deduction_count = where(
(age_of_head > 65)
& (
(filing_status == filing_statuses.SINGLE)
| (filing_status == filing_statuses.HEAD_OF_HOUSEHOLD)
| (filing_status == filing_statuses.WIDOW)
),
1,
where(
(filing_status == filing_statuses.JOINT)
& (age_of_spouse > 65),
2,
0, # Default value if none of the conditions are met
),
)

total_agi = where(
age_deduction_count > 0, federal_agi + spouse_agi, federal_agi
)

total_fda = where(
(filing_status == filing_statuses.SINGLE)
| (filing_status == filing_statuses.HEAD_OF_HOUSEHOLD)
| (filing_status == filing_statuses.WIDOW),
you_fdca,
you_fdca + spouse_fdca,
)

total_fds = where(
(filing_status == filing_statuses.SINGLE)
| (filing_status == filing_statuses.HEAD_OF_HOUSEHOLD)
| (filing_status == filing_statuses.WIDOW),
you_fdcs,
you_fdcs + spouse_fdcs,
)

line4 = total_agi + total_fda
line6 = line4 - total_fds
line7 = 0 # Taxable benefits from the tax return, change this.
line8 = line6 - line7

threshold_ln9 = where(
(filing_status == filing_statuses.SINGLE)
| (filing_status == filing_statuses.HEAD_OF_HOUSEHOLD)
| (filing_status == filing_statuses.WIDOW),
parameters(
period
).gov.states.va.tax.income.va_age_deduction_threshold.SINGLE,
where(
filing_status == filing_statuses.JOINT,
parameters(
period
).gov.states.va.tax.income.va_age_deduction_threshold.JOINT,
parameters(
period
).gov.states.va.tax.income.va_age_deduction_threshold.SEPARATE,
),
)

line11 = where(
line8 >= threshold_ln9,
line8 - threshold_ln9,
where(
(filing_status == filing_statuses.SINGLE)
| (filing_status == filing_statuses.HEAD_OF_HOUSEHOLD)
| (filing_status == filing_statuses.WIDOW)
| (filing_status == filing_statuses.SEPARATE),
12_000,
where(filing_status == filing_statuses.JOINT, 24_000, 0),
),
)

line12 = age_deduction_count * 12_000

line14 = where(line11 < line12, line12 - line11, 0)

result = where(
(filing_status == filing_statuses.SINGLE)
| (filing_status == filing_statuses.HEAD_OF_HOUSEHOLD)
| (filing_status == filing_statuses.WIDOW)
| (
(filing_status == filing_statuses.SEPARATE)
& (age_of_spouse < 65)
)
| (
(filing_status == filing_statuses.JOINT) & (age_of_spouse < 65)
),
line14,
where(
(filing_status == filing_statuses.SEPARATE)
& (age_of_spouse >= 65),
line14 / 2,
0,
),
)

# Check if age_of_head is less than 65 and set result to 0 in that case
result = where(age_of_head < 65, 0, result)

return result
Loading

0 comments on commit 51990dc

Please sign in to comment.