Skip to content

Commit

Permalink
Merge pull request #1328 from martinholmer/fix-summary-tables
Browse files Browse the repository at this point in the history
Fix calculated-variable documentation and fix diagnostic table
  • Loading branch information
martinholmer authored May 1, 2017
2 parents ba4fe85 + 67c4b87 commit ee602c1
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/index.html

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions taxcalc/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,21 +1294,22 @@ def AdditionalCTC(n24, prectc, earned, c07220, ptax_was,

@iterate_jit(nopython=True)
def C1040(c05800, c07180, c07200, c07220, c07230, c07240, c07260, c07300,
c07400, c07600, c08000, e09700, e09800, e09900, niit,
c07400, c07600, c08000, e09700, e09800, e09900, niit, othertaxes,
c07100, c09200, dep_credit):
"""
C1040 function computes total nonrefundable credits, c07100, and
C1040 function computes total used nonrefundable credits, c07100,
othertaxes, and
income tax before refundable credits, c09200
"""
# total nonrefundable credits (2015 Form 1040, line 55)
# total used nonrefundable credits (as computed in NonrefundableCredits)
c07100 = (c07180 + c07200 + c07600 + c07300 + c07400 + c07220 + c08000 +
c07230 + c07240 + c07260 + dep_credit)
# tax after credits (2015 Form 1040, line 56)
# tax after credits (2016 Form 1040, line 56)
tax_net_nonrefundable_credits = max(0., c05800 - c07100)
# tax before refundable credits
# tax (including othertaxes) before refundable credits
othertaxes = e09700 + e09800 + e09900 + niit
c09200 = othertaxes + tax_net_nonrefundable_credits
return (c07100, c09200)
return (c07100, othertaxes, c09200)


@iterate_jit(nopython=True)
Expand Down
18 changes: 12 additions & 6 deletions taxcalc/records_variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,12 @@
"desc": "2 when MARS is 2 (married filing jointly); otherwise 1",
"form": {"2013-2016": "1040 lines 1-5"}
},

"othertaxes": {
"type": "float",
"desc": "Other taxes: sum of niit, e09700, e09800 and e09900 (included in c09200)",
"form": {"2013-2013": "sum of 1040 lines 57 through 60",
"2014-2016": "sum of 1040 lines 58 through 62"}
},
"payrolltax": {
"type": "float",
"desc": "Total (employee + employer) payroll tax liability; appears as PAYTAX variable in tc CLI minimal output (payrolltax = ptax_was + setax + ptax_amc)",
Expand Down Expand Up @@ -607,8 +612,9 @@
},
"c07100": {
"type": "float",
"desc": "Total potential non-refundable credits whose use is limited by tax liability; non-refundable credits actually used equals c05800 minus c09200",
"form": {}
"desc": "Total non-refundable credits used to reduce positive tax liability",
"form": {"2013-2013": "1040 line 46 minus 1040 line 55",
"2014-2016": "1040 line 47 minus 1040 line 56"}
},
"c07180": {
"type": "float",
Expand Down Expand Up @@ -666,9 +672,9 @@
},
"c09200": {
"type": "float",
"desc": "Income tax liability after non-refundable credits are used, but before refundable credits are applied",
"form": {"2013-2013": "1040 line 55",
"2014-2016": "1040 line 56"}
"desc": "Income tax liability (including othertaxes) after non-refundable credits are used, but before refundable credits are applied",
"form": {"2013-2013": "1040 line 61",
"2014-2016": "1040 line 63"}
},
"c09600": {
"type": "float",
Expand Down
3 changes: 2 additions & 1 deletion taxcalc/tests/pufcsv_agg_expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ Standard Deduction Filers (#m) 108.4 108.0 109.1 110.2 111.9 1
Standard Deduction ($b) 930.1 937.4 963.1 974.0 996.2 1,034.2 1,073.2 1,110.4 1,150.7 1,192.6
Personal Exemption ($b) 1,117.1 1,116.3 1,139.0 1,164.0 1,175.7 1,214.4 1,254.3 1,295.0 1,336.5 1,378.9
Taxable Income ($b) 6,645.6 7,336.8 7,765.5 8,154.1 8,492.6 8,802.4 9,086.9 9,391.8 9,759.9 10,169.2
Regular Tax ($b) 1,459.8 1,673.9 1,788.2 1,883.6 1,956.6 2,017.9 2,074.0 2,136.6 2,217.9 2,311.8
Regular Tax ($b) 1,359.0 1,533.2 1,623.7 1,705.9 1,777.1 1,837.0 1,892.8 1,952.0 2,028.3 2,116.0
AMT Income ($b) 8,783.4 9,482.4 9,979.1 10,425.8 10,822.0 11,222.6 11,599.3 12,005.1 12,471.6 12,980.1
AMT Liability ($b) 36.5 38.6 40.4 42.7 44.9 47.2 49.6 51.5 54.3 57.6
AMT Filers (#m) 4.5 4.8 5.0 5.3 5.6 5.7 5.8 5.9 6.1 6.2
Tax before Credits ($b) 1,395.5 1,571.8 1,664.1 1,748.6 1,822.0 1,884.2 1,942.4 2,003.6 2,082.6 2,173.6
Refundable Credits ($b) 99.6 97.6 97.7 96.8 96.5 98.3 100.4 102.1 104.1 105.8
Nonrefundable Credits ($b) 72.9 73.4 73.7 73.8 74.6 75.0 75.5 76.0 76.7 77.8
Reform Surtaxes ($b) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Other Taxes ($b) 29.9 39.1 44.7 48.0 48.8 49.5 50.0 51.4 53.2 55.4
Ind Income Tax ($b) 1,253.0 1,439.9 1,537.4 1,625.9 1,699.8 1,760.4 1,816.6 1,876.8 1,955.2 2,045.5
Payroll Taxes ($b) 924.4 958.3 999.5 1,039.7 1,093.5 1,139.2 1,181.1 1,224.9 1,271.6 1,321.1
Combined Liability ($b) 2,177.4 2,398.2 2,536.9 2,665.6 2,793.3 2,899.5 2,997.7 3,101.7 3,226.7 3,366.6
Expand Down
3 changes: 3 additions & 0 deletions taxcalc/tests/test_pufcsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ def test_mtr(tests_path, puf_path):
crs.payrolltax)
assert np.allclose(crs.c21060 - crs.c21040, crs.c04470)
assert np.allclose(crs.taxbc + crs.c09600, crs.c05800)
assert np.allclose(crs.c05800 + crs.othertaxes - crs.c07100,
crs.c09200)
assert np.allclose(crs.c09200 - crs.refund, crs.iitax)
if var_str == 'e00200s':
# only MARS==2 filing units have valid MTR values
mtr_ptax = mtr_ptax[calc.records.MARS == 2]
Expand Down
4 changes: 2 additions & 2 deletions taxcalc/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def test_multiyear_diagnostic_table_wo_behv(records_2009):
adt = multiyear_diagnostic_table(calc, 1)
# extract combined liabilities as a float and
# adopt units of the raw calculator data in liabilities_x
liabilities_y = adt.iloc[18].tolist()[0] * 1000000000
liabilities_y = adt.iloc[19].tolist()[0] * 1000000000
npt.assert_almost_equal(liabilities_x, liabilities_y, 2)


Expand All @@ -698,7 +698,7 @@ def test_multiyear_diagnostic_table_w_behv(records_2009):
adt = multiyear_diagnostic_table(calc_behv, 1)
# extract combined liabilities as a float and
# adopt units of the raw calculator data in liabilities_x
liabilities_y = adt.iloc[18].tolist()[0] * 1000000000
liabilities_y = adt.iloc[19].tolist()[0] * 1000000000
npt.assert_almost_equal(liabilities_x, liabilities_y, 2)


Expand Down
15 changes: 9 additions & 6 deletions taxcalc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@


STATS_COLUMNS = ['expanded_income', 'c00100', 'standard',
'c04470', 'c04600', 'c04800', 'c05200', 'c62100', 'c09600',
'c05800', 'c09200', 'refund', 'c07100', 'iitax',
'c04470', 'c04600', 'c04800', 'taxbc', 'c62100', 'c09600',
'c05800', 'othertaxes', 'refund', 'c07100', 'iitax',
'payrolltax', 'combined', 's006']

# Items in the TABLE_COLUMNS list below correspond to the items in the
# TABLE_LABELS list below; this correspondence allows us to use TABLE_LABELS
# to map a label to the correct column in our distribution tables.
TABLE_COLUMNS = ['s006', 'c00100', 'num_returns_StandardDed', 'standard',
'num_returns_ItemDed', 'c04470', 'c04600', 'c04800', 'c05200',
'num_returns_ItemDed', 'c04470', 'c04600', 'c04800', 'taxbc',
'c62100', 'num_returns_AMT', 'c09600', 'c05800', 'c07100',
'c09200', 'refund', 'iitax', 'payrolltax', 'combined']
'othertaxes', 'refund', 'iitax', 'payrolltax', 'combined']

TABLE_LABELS = ['Returns', 'AGI', 'Standard Deduction Filers',
'Standard Deduction', 'Itemizers',
'Itemized Deduction', 'Personal Exemption',
'Taxable Income', 'Regular Tax', 'AMTI', 'AMT Filers', 'AMT',
'Tax before Credits', 'Non-refundable Credits',
'Tax before Refundable Credits', 'Refundable Credits',
'Other Taxes', 'Refundable Credits',
'Individual Income Tax Liabilities', 'Payroll Tax Liablities',
'Combined Payroll and Individual Income Tax Liabilities']

Expand Down Expand Up @@ -576,7 +576,7 @@ def diagnostic_table_odict(recs):
val = (recs.c04800 * recs.s006).sum()
odict['Taxable Income ($b)'] = val * in_billions
# regular tax liability
val = (recs.c05200 * recs.s006).sum()
val = (recs.taxbc * recs.s006).sum()
odict['Regular Tax ($b)'] = val * in_billions
# AMT taxable income
odict['AMT Income ($b)'] = (recs.c62100 * recs.s006).sum() * in_billions
Expand All @@ -596,6 +596,9 @@ def diagnostic_table_odict(recs):
# reform surtaxes (part of federal individual income tax liability)
val = (recs.surtax * recs.s006).sum()
odict['Reform Surtaxes ($b)'] = val * in_billions
# other taxes on Form 1040
val = (recs.othertaxes * recs.s006).sum()
odict['Other Taxes ($b)'] = val * in_billions
# federal individual income tax liability
val = (recs.iitax * recs.s006).sum()
odict['Ind Income Tax ($b)'] = val * in_billions
Expand Down

0 comments on commit ee602c1

Please sign in to comment.