forked from PSLmodels/Tax-Calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simtax.py
91 lines (86 loc) · 4.55 KB
/
simtax.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
"""
SIMple input-output capabilities for TAX-calculator.
"""
# CODING-STYLE CHECKS:
# pep8 --ignore=E402 simtax.py
# pylint --disable=locally-disabled simtax.py
# (when importing numpy, add "--extension-pkg-whitelist=numpy" pylint option)
import argparse
import sys
from taxcalc import SimpleTaxIO
def main():
"""
Contains command-line interface to the Tax-Calculator SimpleTaxIO class.
"""
# parse command-line arguments:
parser = argparse.ArgumentParser(
prog='python simtax.py',
description=('Writes to a file the federal tax OUTPUT for the tax '
'filing units specified in the INPUT file with the '
'OUTPUT computed from the INPUT using the Tax-Calculator.'
' Both the INPUT and OUTPUT files use Internet-TAXSIM '
'format. The OUTPUT filename is the INPUT filename '
'with the ".out-simtax" string appended if no --reform '
'option is specified; otherwise the OUTPUT filename is '
'the INPUT filename with the ".out-simtax-REFORM" string '
'appended (excluding any ".json" ending to the REFORM '
'filename). The OUTPUT file contains the first 28 '
'Internet-TAXSIM output variables. Use --iohelp flag '
'for more information. For details on Internet-TAXSIM '
'version 9.3 INPUT and OUTPUT formats, go to '
'http://users.nber.org/~taxsim/taxsim-calc9/'))
parser.add_argument('--iohelp',
help=('optional flag to show INPUT and OUTPUT '
'variable definitions and exit without trying '
'to read the INPUT file, so INPUT can be any '
'meaningless character (e.g., x or ?'),
default=False,
action="store_true")
parser.add_argument('--reform',
help=('REFORM is name of optional file that contains '
'tax reform provisions; the provisions are '
'specified using JSON that may include '
'//-comments. No REFORM filename implies use '
'of current-law policy.'),
default=None)
parser.add_argument('--taxsim2441',
help=('optional flag to emulate the Internet-TAXSIM '
'practice of approximating the number of '
'children eligible for the child care expense '
'credit on Form 2441 by the total number of '
'dependents of any age. The default practice '
'is to approximate with the number of '
'dependents under age 17.'),
default=False,
action="store_true")
parser.add_argument('--records',
help=('optional flag that causes the output file to '
'be a CSV-formatted file containing for each '
'INPUT filing unit the TAXYEAR values of each '
'variable in the Records.VALID_READ_VARS set. '
'If the --records option is specified, the '
'output file name will be the same as if the '
'option was not specified, except that the '
'".out-simtax" part is replaced by ".records"'),
default=False,
action="store_true")
parser.add_argument('INPUT',
help=('INPUT is name of required file that contains '
'tax-filing-unit information in Internet-TAXSIM '
'format.'))
args = parser.parse_args()
# optionally show INPUT and OUTPUT variable definitions and exit
if args.iohelp:
SimpleTaxIO.show_iovar_definitions()
return 0
# instantiate SimpleTaxIO object and do tax calculations
simtax = SimpleTaxIO(input_filename=args.INPUT,
reform=args.reform,
emulate_taxsim_2441_logic=args.taxsim2441,
output_records=args.records)
simtax.calculate(writing_output_file=True)
# return no-error exit code
return 0
# end of main function code
if __name__ == '__main__':
sys.exit(main())