Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added special cases for state_itemized_deductions #198

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated pre simulation case for
state_itemized_deductions
state_taxable_income
state_income_tax_before_non_refundable_credits

added special case for states which failed
noman404 committed Dec 20, 2024
commit e1c904745aa218b19ca36b3139202b87509f2e68
169 changes: 103 additions & 66 deletions policyengine_taxsim/config/variable_mappings.yaml
Original file line number Diff line number Diff line change
@@ -390,6 +390,9 @@ policyengine_to_taxsim:
- mn:
implemented: false
variable: na_pe
- ia:
implemented: false
variable: na_pe
- il:
implemented: true
variable: state_base_income
@@ -460,13 +463,48 @@ policyengine_to_taxsim:
group_order: 4
full_text_group: "State Tax Calculation"
group_column: 1
pre_simulation:
- ms:
implemented: true
pre_variable: ms_files_separately
variables:
- ms_itemized_deductions_indiv
- ms_itemized_deductions_joint
- ar:
implemented: true
pre_variable: ar_files_separately
variables:
- ar_itemized_deductions_indiv
- ar_itemized_deductions_joint
- mt:
implemented: true
pre_variable: mt_files_separately
variables:
- mt_itemized_deductions_indiv
- mt_itemized_deductions_joint
- ia:
implemented: true
pre_variable: ia_files_separately
variables:
- ia_itemized_deductions_indiv
- ia_itemized_deductions_joint
- ky:
implemented: true
pre_variable: ky_files_separately
variables:
- ky_itemized_deductions_indiv
- ky_itemized_deductions_joint
special_cases:
- il:
implemented: false
variable: na_pe
- ms:
- de:
implemented: false
variable: na_pe
- tx:
implemented: false
variable: na_pe

v36:
variable: state_taxable_income
implemented: true
@@ -477,8 +515,39 @@ policyengine_to_taxsim:
group_order: 4
full_text_group: "State Tax Calculation"
group_column: 1
special_cases:
pre_simulation:
- ms:
implemented: true
pre_variable: ms_files_separately
variables:
- ms_taxable_income_indiv
- ms_taxable_income_joint
- ar:
implemented: true
pre_variable: ar_files_separately
variables:
- ar_taxable_income_indiv
- ar_taxable_income_joint
- mt:
implemented: true
pre_variable: mt_files_separately
variables:
- mt_taxable_income_indiv
- mt_taxable_income_joint
- ia:
implemented: true
pre_variable: ia_files_separately
variables:
- ia_taxable_income_indiv
- ia_taxable_income_joint
- ky:
implemented: true
pre_variable: ky_files_separately
variables:
- ky_taxable_income_indiv
- ky_taxable_income_joint
special_cases:
- de:
implemented: false
variable: na_pe
tax_before_credits:
@@ -490,6 +559,35 @@ policyengine_to_taxsim:
group_order: 4
full_text_group: "State Tax Calculation"
group_column: 1
pre_simulation:
- ar:
implemented: true
pre_variable: ar_files_separately
variables:
- ar_income_tax_before_non_refundable_credits_indiv
- ar_income_tax_before_non_refundable_credits_joint
- mt:
implemented: true
pre_variable: mt_files_separately
variables:
- mt_income_tax_before_non_refundable_credits_indiv
- mt_income_tax_before_non_refundable_credits_joint
- ky:
implemented: true
pre_variable: ky_files_separately
variables:
- ky_income_tax_before_non_refundable_credits_indiv
- ky_income_tax_before_non_refundable_credits_joint
special_cases:
- ms:
implemented: false
variable: na_pe
- de:
implemented: false
variable: na_pe
- ia:
implemented: false
variable: na_pe
v41:
variable: na_pe
implemented: false
@@ -516,6 +614,9 @@ policyengine_to_taxsim:
- ms:
implemented: false
variable: na_pe
- ia:
implemented: false
variable: na_pe
rent_credit:
variable: na_pe
implemented: false
@@ -896,67 +997,3 @@ taxsim_to_policyengine:
- stcg
- social_security_retirement:
- gssi

taxsim_input_definition:
- taxsimid:
name: "1. Record ID"
- year:
name: "2. Tax Year"
- state:
name: "3. State Code"
- mstat:
name: "4. Marital Status"
type:
- single: 1
- joint: 2
- page:
name: "5. Age (Txpyr/Spouse)"
pair: sage
- dependent_exemption:
name: "6. Dependent Exemptions"
- depx:
name: "8. #deps for CCC/CTC/EIC"
- pwages:
name: "9. Wages (Txpyr/Spouse)"
pair: swages
- psemp:
name: "10. Self-employment income"
pair: ssemp
- dividends:
name: "11. Dividend Income"
- intrec:
name: "12. Interest Received"
- stcg:
name: "13. Short Term Gains"
- ltcg:
name: "14. Long Term Gains"
- otherprop:
name: "15. Other Property"
- nonprop:
name: "16. Other Non-Property"
- pensions:
name: "17. Taxable Pensions"
- gssi:
name: "18. Gross Social Security"
- pui:
name: "19. Tot/Txpy/Spouse UI"
pair: sui
- transfers:
name: "20. Non-taxable Transfers"
- rentpaid:
name: "21. Rent Paid"
- proptax:
name: "22. Property Taxes Paid"
- otheritem:
name: "23. Other Itemized Deds"
- childcare:
name: "24. Child Care Expenses"
- mortgage:
name: "25. Mortgage Interest"
- scorp:
name: "26. S-Corp profits"
- pbusinc:
name: "27. Txpy/Spouse QBI w/o PO"
- pprofinc:
name: "28. Txpy/Spouse SSTB w PO"

14 changes: 8 additions & 6 deletions policyengine_taxsim/core/output_mapper.py
Original file line number Diff line number Diff line change
@@ -62,8 +62,9 @@ def generate_non_description_output(taxsim_output, mappings, year, state_name, s
taxsim_output[key] = simulate(simulation, pe_variable, year)

outputs.append({'variable': pe_variable, 'value': taxsim_output[key]})
continue

elif 'pre_simulation' in each_item:
if 'pre_simulation' in each_item:
found_state = next((each for each in each_item['pre_simulation'] if state_initial in each),
None)
if found_state and found_state[state_initial]['implemented']:
@@ -183,8 +184,9 @@ def generate_text_description_output(taxsim_input, mappings, year, state_name, s
value = simulate(simulation, variable, year)

outputs.append({'variable': variable, 'value': value})
continue

elif 'pre_simulation' in each_item:
if 'pre_simulation' in each_item:
found_state = next((each for each in each_item['pre_simulation'] if state_initial in each),
None)
if found_state and found_state[state_initial]['implemented']:
@@ -224,7 +226,8 @@ def generate_text_description_output(taxsim_input, mappings, year, state_name, s
state_initial][
'variable'] else \
found_state[state_initial]['variable']
second_value = simulate(simulation_1dollar_more, variable, year)
second_value = simulate(simulation_1dollar_more, variable, year)
continue

if isinstance(second_value, (int, float)):
formatted_second_value = f"{second_value:>8.1f}"
@@ -411,13 +414,12 @@ def simulate_to_decide(simulation, variable, year) -> bool:

def simulate_multiple(simulation, variables, year, state):
try:
total = to_roundedup_number(
return to_roundedup_number(
sum(
sum(simulation.calculate(variable.replace("state", state), period=year))
for variable in variables
)
)
except Exception as error:
print(error)
total = 0.00
return to_roundedup_number(total)
return 0.00
Loading