/
extend_tcja.py
143 lines (135 loc) · 5.79 KB
/
extend_tcja.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
"""
This script generates a JSON reform file, which could be called
extend_tcja.json, that can serve as an alternative baseline to
current-law policy (which ends TCJA temporary provisions after 2025).
USAGE: (taxcalc-dev) ~% python extend_tcja.py
IMPORTANT NOTE: be sure to remove the trailing comma after the last item
in the reform JSON object generated by this script.
"""
import sys
import numpy
import taxcalc
TCJA_CATEGORY = None # set to None to generate all TCJA temporary provisions
TCJA_PARAMETERS = {
# category 1 ...
"II_rt1": {"indexed": False, "category": 1},
"II_brk1": {"indexed": True, "category": 1},
"PT_rt1": {"indexed": False, "category": 1},
"PT_brk1": {"indexed": True, "category": 1},
"II_rt2": {"indexed": False, "category": 1},
"II_brk2": {"indexed": True, "category": 1},
"PT_rt2": {"indexed": False, "category": 1},
"PT_brk2": {"indexed": True, "category": 1},
"II_rt3": {"indexed": False, "category": 1},
"II_brk3": {"indexed": True, "category": 1},
"PT_rt3": {"indexed": False, "category": 1},
"PT_brk3": {"indexed": True, "category": 1},
"II_rt4": {"indexed": False, "category": 1},
"II_brk4": {"indexed": True, "category": 1},
"PT_rt4": {"indexed": False, "category": 1},
"PT_brk4": {"indexed": True, "category": 1},
"II_rt5": {"indexed": False, "category": 1},
"II_brk5": {"indexed": True, "category": 1},
"PT_rt5": {"indexed": False, "category": 1},
"PT_brk5": {"indexed": True, "category": 1},
"II_rt6": {"indexed": False, "category": 1},
"II_brk6": {"indexed": True, "category": 1},
"PT_rt6": {"indexed": False, "category": 1},
"PT_brk6": {"indexed": True, "category": 1},
"II_rt7": {"indexed": False, "category": 1},
"II_brk7": {"indexed": True, "category": 1},
"PT_rt7": {"indexed": False, "category": 1},
"PT_brk7": {"indexed": True, "category": 1},
# category 2 ...
"CTC_c": {"indexed": False, "category": 2},
"ACTC_c": {"indexed": False, "category": 2},
"ODC_c": {"indexed": False, "category": 2},
"CTC_ps": {"indexed": False, "category": 2},
"ACTC_Income_thd": {"indexed": False, "category": 2},
# category 3 ...
"AMT_em": {"indexed": True, "category": 3},
"AMT_em_ps": {"indexed": True, "category": 3},
"AMT_em_pe": {"indexed": True, "category": 3},
# category 4 ...
"STD": {"indexed": True, "category": 4},
# category 5 ...
"ID_AllTaxes_c": {"indexed": False, "category": 5},
"ID_Charity_crt_all": {"indexed": False, "category": 5},
"ID_Casualty_hc": {"indexed": False, "category": 5},
"ID_Miscellaneous_hc": {"indexed": False, "category": 5},
"ID_ps": {"indexed": True, "category": 5},
"ID_prt": {"indexed": False, "category": 5},
"ID_crt": {"indexed": False, "category": 5},
# category 6 ...
"II_em": {"indexed": True, "category": 6},
"II_em_ps": {"indexed": True, "category": 6},
# category 7 ...
"PT_qbid_rt": {"indexed": False, "category": 7},
"PT_qbid_taxinc_thd": {"indexed": True, "category": 7},
"PT_qbid_taxinc_gap": {"indexed": False, "category": 7},
"PT_qbid_w2_wages_rt": {"indexed": False, "category": 7},
"PT_qbid_alt_w2_wages_rt": {"indexed": False, "category": 7},
"PT_qbid_alt_property_rt": {"indexed": False, "category": 7},
# category 8 ...
"ALD_BusinessLosses_c": {"indexed": True, "category": 8},
"ALD_DomesticProduction_hc": {"indexed": False, "category": 8},
}
def main():
"""
High-level script logic.
"""
# calculate 2025-to-2026 parameters indexing factor
pol = taxcalc.Policy()
pirates = pol.inflation_rates()
ifactor = 1.0 + pirates[2025-taxcalc.Policy.JSON_START_YEAR]
# specify extend-TCJA-beyond-2025 reform
# ... get 2025 parameter values
pol.set_year(2025)
pdata = dict(pol.items())
# ... write reform header comments
print( '// REFORM TO EXTEND TEMPORARY TCJA PROVISIONS BEYOND 2025')
print(f'// USING TAX-CALCULATOR {taxcalc.__version__}')
print(f'// WITH 2025-to-2026 INDEXING FACTOR = {ifactor:.6f}')
if TCJA_CATEGORY:
print(f'// ONLY TCJA PROVISIONS IN CATEGORY {TCJA_CATEGORY}')
print('{')
# ... set 2026 nonreverted values for the parameters set to revert
for pname, pinfo in TCJA_PARAMETERS.items():
if TCJA_CATEGORY and pinfo['category'] != TCJA_CATEGORY:
continue # skip this parameter
if pinfo['indexed']:
pval = pdata[pname][0] * ifactor
if isinstance(pval, numpy.ndarray):
# handle vector parameter
pval = numpy.minimum(9e99, pval.round(2))
sys.stdout.write(f' "{pname}": ')
sys.stdout.write('{"2026": ')
sys.stdout.write(f'{pval.tolist()}')
sys.stdout.write('},\n')
else:
# handle scalar parameter
pval = min(9e99, pval)
sys.stdout.write(f' "{pname}": ')
sys.stdout.write('{"2026": ')
sys.stdout.write(f'{pval*ifactor:.2f}')
sys.stdout.write('},\n')
else: # if parameter is not indexed
pval = pdata[pname][0]
if isinstance(pval, numpy.ndarray):
# handle vector parameter
pval = numpy.minimum(9e99, pval.round(2))
sys.stdout.write(f' "{pname}": ')
sys.stdout.write('{"2026": ')
sys.stdout.write(f'{pval.tolist()}')
sys.stdout.write('},\n')
else:
# handle scalar parameter
sys.stdout.write(f' "{pname}": ')
sys.stdout.write('{"2026": ')
sys.stdout.write(f'{pval:.2f}')
sys.stdout.write('},\n')
print('}')
return 0
# end main function code
if __name__ == '__main__':
sys.exit(main())