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

Fix qualified business income calculation #2785

Merged
merged 5 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 10 additions & 6 deletions taxcalc/calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ def StdDed(DSI, earned, STD, age_head, age_spouse, STD_Aged, STD_Dep,


@iterate_jit(nopython=True)
def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, e26270,
def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
e02100, e27200, e00650, c01000, PT_SSTB_income,
PT_binc_w2_wages, PT_ubia_property, PT_qbid_rt,
PT_qbid_taxinc_thd, PT_qbid_taxinc_gap, PT_qbid_w2_wages_rt,
Expand All @@ -1236,6 +1236,8 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, e26270,
Filing (marital) status. (1=single, 2=joint, 3=separate, 4=household-head, 5=widow(er))
e00900: float
Schedule C business net profit/loss for filing unit
c03260: float
Self-employment (SECA) tax above-the-line deduction
e26270: float
Schedule E: combined partnership and S-corporation net income/loss
e02100: float
Expand Down Expand Up @@ -1287,7 +1289,7 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, e26270,
pre_qbid_taxinc = max(0., c00100 - max(c04470, standard) - c04600)
# calculate qualified business income deduction
qbided = 0.
qbinc = max(0., e00900 + e26270 + e02100 + e27200)
qbinc = max(0., e00900 - c03260 + e26270 + e02100 + e27200)
if qbinc > 0. and PT_qbid_rt > 0.:
qbid_before_limits = qbinc * PT_qbid_rt
lower_thd = PT_qbid_taxinc_thd[MARS - 1]
Expand Down Expand Up @@ -1906,7 +1908,7 @@ def AGIsurtax(c00100, MARS, AGI_surtax_trt, AGI_surtax_thd, taxbc, surtax):
def AMT(e07300, dwks13, standard, f6251, c00100, c18300, taxbc,
c04470, c17000, c20800, c21040, e24515, MARS, sep, dwks19,
dwks14, c05700, e62900, e00700, dwks10, age_head, age_spouse,
earned, cmbtp,
earned, cmbtp, qbided,
AMT_child_em_c_age, AMT_brk1,
AMT_em, AMT_prt, AMT_rt1, AMT_rt2,
AMT_child_em, AMT_em_ps, AMT_em_pe,
Expand Down Expand Up @@ -1943,7 +1945,7 @@ def AMT(e07300, dwks13, standard, f6251, c00100, c18300, taxbc,
c20800: float
Schedule A: net limited miscellaneous deductions deducted
c21040: float
Itemized deductiosn that are phased out
Itemized deductions that are phased out
e24515: float
Schedule D: Un-Recaptured Section 1250 Gain
MARS: int
Expand All @@ -1970,6 +1972,8 @@ def AMT(e07300, dwks13, standard, f6251, c00100, c18300, taxbc,
Earned income for filing unit
cmbtp: float
Estimate of income on (AMT) Form 6251 but not in AGI
qbided: float
Qualified business income deduction
AMT_child_em_c_age: float
Age ceiling for special AMT exemption
AMT_brk1: float
Expand Down Expand Up @@ -2021,11 +2025,11 @@ def AMT(e07300, dwks13, standard, f6251, c00100, c18300, taxbc,
# pylint: disable=too-many-statements,too-many-branches
# Form 6251, Part I
if standard == 0.0:
c62100 = (c00100 - e00700 - c04470 +
c62100 = (c00100 - e00700 - qbided - c04470 +
max(0., min(c17000, 0.025 * c00100)) +
c18300 + c20800 - c21040)
if standard > 0.0:
c62100 = c00100 - e00700
c62100 = c00100 - e00700 - qbided
c62100 += cmbtp # add income not in AGI but considered income for AMT
if MARS == 3:
amtsepadd = max(0.,
Expand Down
125 changes: 0 additions & 125 deletions taxcalc/policy_current_law.json
Original file line number Diff line number Diff line change
Expand Up @@ -14701,106 +14701,6 @@
"MARS": "widow",
"value": 1.0
},
{
"year": 2014,
"MARS": "single",
"value": 1.0
},
{
"year": 2014,
"MARS": "mjoint",
"value": 1.0
},
{
"year": 2014,
"MARS": "mseparate",
"value": 1.0
},
{
"year": 2014,
"MARS": "headhh",
"value": 1.0
},
{
"year": 2014,
"MARS": "widow",
"value": 1.0
},
{
"year": 2015,
"MARS": "single",
"value": 1.0
},
{
"year": 2015,
"MARS": "mjoint",
"value": 1.0
},
{
"year": 2015,
"MARS": "mseparate",
"value": 1.0
},
{
"year": 2015,
"MARS": "headhh",
"value": 1.0
},
{
"year": 2015,
"MARS": "widow",
"value": 1.0
},
{
"year": 2016,
"MARS": "single",
"value": 1.0
},
{
"year": 2016,
"MARS": "mjoint",
"value": 1.0
},
{
"year": 2016,
"MARS": "mseparate",
"value": 1.0
},
{
"year": 2016,
"MARS": "headhh",
"value": 1.0
},
{
"year": 2016,
"MARS": "widow",
"value": 1.0
},
{
"year": 2017,
"MARS": "single",
"value": 1.0
},
{
"year": 2017,
"MARS": "mjoint",
"value": 1.0
},
{
"year": 2017,
"MARS": "mseparate",
"value": 1.0
},
{
"year": 2017,
"MARS": "headhh",
"value": 1.0
},
{
"year": 2017,
"MARS": "widow",
"value": 1.0
},
{
"year": 2018,
"MARS": "single",
Expand All @@ -14826,31 +14726,6 @@
"MARS": "widow",
"value": 100000.0
},
{
"year": 2019,
"MARS": "single",
"value": 50000.0
},
{
"year": 2019,
"MARS": "mjoint",
"value": 100000.0
},
{
"year": 2019,
"MARS": "mseparate",
"value": 50000.0
},
{
"year": 2019,
"MARS": "headhh",
"value": 50000.0
},
{
"year": 2019,
"MARS": "widow",
"value": 100000.0
},
{
"year": 2026,
"MARS": "single",
Expand Down
26 changes: 13 additions & 13 deletions taxcalc/tests/cpscsv_agg_expect.csv
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026
Returns (#m),187.1,199.2,201.9,204.5,207.1,209.7,212.3,214.9,217.5,220.1
AGI ($b),9087.6,10714.8,11167.0,11573.2,13174.9,13543.8,14390.3,15077.5,15785.3,16457.7
Itemizers (#m),62.8,24.0,25.1,27.5,31.2,31.2,29.8,29.4,30.4,81.1
Itemized Deduction ($b),1218.6,613.4,656.3,746.7,863.7,883.2,888.9,915.0,964.2,2180.7
Standard Deduction Filers (#m),124.3,175.3,176.8,176.8,175.7,178.4,182.4,185.4,187.1,139.1
Standard Deduction ($b),1092.1,2949.5,3024.6,3079.1,3090.6,3229.8,3547.8,3805.0,3936.4,1613.3
Itemizers (#m),62.8,23.9,25.0,27.5,31.2,31.2,29.8,29.4,30.4,81.1
Itemized Deduction ($b),1218.6,612.0,655.1,745.4,862.7,881.9,887.6,913.8,963.1,2180.7
Standard Deduction Filers (#m),124.3,175.3,176.9,176.9,175.8,178.5,182.5,185.5,187.2,139.1
Standard Deduction ($b),1092.1,2951.3,3026.1,3080.8,3091.9,3231.4,3549.4,3806.5,3937.8,1613.3
Personal Exemption ($b),1383.6,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,2081.6
Taxable Income ($b),6230.6,7957.8,8321.4,8613.9,10048.2,10330.4,10946.5,11424.4,11988.0,11782.5
Regular Tax ($b),1108.0,1379.8,1448.8,1497.1,1762.5,1837.0,1937.1,2016.1,2122.9,2339.6
AMT Income ($b),8319.8,10261.9,10680.3,11016.8,12528.9,12879.7,13716.5,14379.0,15047.4,15074.1
AMT Liability ($b),8.1,0.8,0.7,0.9,1.9,1.1,1.1,1.0,1.0,17.2
AMT Filers (#m),2.6,0.2,0.2,0.2,0.3,0.2,0.2,0.2,0.2,4.1
Tax before Credits ($b),1116.0,1380.6,1449.5,1498.0,1764.4,1838.1,1938.2,2017.1,2123.8,2356.8
Taxable Income ($b),6230.6,7959.2,8322.8,8615.4,10049.9,10332.2,10948.3,11426.3,11990.0,11782.5
Regular Tax ($b),1108.0,1380.0,1449.0,1497.4,1762.8,1837.4,1937.4,2016.4,2123.2,2339.6
AMT Income ($b),8319.8,10212.6,10630.3,10965.7,12473.9,12821.8,13658.8,14318.8,14984.7,15074.1
AMT Liability ($b),8.1,0.4,0.4,0.5,1.4,0.7,0.7,0.6,0.6,17.2
AMT Filers (#m),2.6,0.1,0.1,0.1,0.2,0.1,0.1,0.1,0.1,4.1
Tax before Credits ($b),1116.0,1380.4,1449.4,1497.9,1764.3,1838.0,1938.1,2017.0,2123.8,2356.8
Refundable Credits ($b),70.8,102.5,102.7,655.0,827.1,98.5,106.4,111.6,112.1,97.7
Nonrefundable Credits ($b),32.7,97.2,99.1,99.2,0.0,107.7,108.3,109.3,111.2,29.9
Nonrefundable Credits ($b),32.7,97.2,99.2,99.2,0.0,107.7,108.3,109.3,111.2,29.9
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),5.5,10.7,11.3,12.6,13.9,14.4,16.5,17.6,18.8,19.9
Ind Income Tax ($b),1018.1,1191.5,1259.0,756.4,951.1,1646.2,1740.0,1813.7,1919.2,2249.0
Ind Income Tax ($b),1018.1,1191.4,1258.9,756.3,951.0,1646.2,1740.0,1813.7,1919.2,2249.0
Payroll Taxes ($b),1040.8,1141.6,1194.9,1217.9,1318.7,1421.6,1506.7,1582.0,1656.7,1730.7
Combined Liability ($b),2059.0,2333.1,2453.9,1974.3,2269.8,3067.8,3246.7,3395.7,3575.9,3979.7
Combined Liability ($b),2059.0,2333.0,2453.8,1974.2,2269.7,3067.8,3246.6,3395.7,3575.9,3979.7
With Income Tax <= 0 (#m),88.1,96.2,97.0,135.4,127.8,96.1,97.9,99.2,99.6,97.4
With Combined Tax <= 0 (#m),62.8,65.4,66.4,98.2,97.7,67.9,69.3,70.5,71.3,70.7
UBI Benefits ($b),0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
Expand Down
28 changes: 14 additions & 14 deletions taxcalc/tests/pufcsv_agg_expect.csv
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026
Returns (#m),190.9,194.3,197.3,200.1,202.9,205.6,208.4,211.2,214.0,216.8
AGI ($b),11078.7,11816.6,12247.2,12722.3,14930.0,14973.9,15955.0,16597.5,17310.2,17852.5
Itemizers (#m),45.7,19.5,20.1,21.1,22.7,22.9,21.7,21.2,21.3,51.9
Itemized Deduction ($b),1274.3,605.3,636.4,694.6,764.2,784.9,789.0,808.3,834.6,2047.9
Standard Deduction Filers (#m),145.2,174.7,177.1,178.4,179.5,182.7,186.7,189.9,192.6,164.8
Standard Deduction ($b),1239.3,2862.1,2951.5,3023.0,3078.3,3231.2,3546.7,3807.7,3963.4,1856.2
Itemizers (#m),45.7,19.4,20.0,21.0,22.6,22.8,21.6,21.1,21.2,51.9
Itemized Deduction ($b),1274.3,602.7,633.9,692.3,761.9,782.7,786.5,805.6,831.9,2047.9
Standard Deduction Filers (#m),145.2,174.8,177.2,178.5,179.6,182.8,186.8,190.0,192.8,164.8
Standard Deduction ($b),1239.3,2865.3,2954.5,3025.8,3081.1,3234.0,3549.8,3811.2,3966.7,1856.2
Personal Exemption ($b),1365.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1959.2
Taxable Income ($b),8112.2,9178.5,9519.7,9906.4,12002.2,11926.7,12691.5,13123.9,13696.5,13377.8
Regular Tax ($b),1656.8,1712.2,1778.1,1838.2,2281.4,2282.6,2421.6,2488.0,2599.1,2792.6
AMT Income ($b),10512.4,11427.2,11835.2,12265.2,14423.4,14452.5,15424.7,16049.3,16741.5,16934.0
AMT Liability ($b),51.3,23.2,24.1,26.2,29.0,28.6,30.0,31.5,33.0,85.1
AMT Filers (#m),5.7,0.6,0.6,0.6,0.7,0.6,0.6,0.6,0.6,7.4
Tax before Credits ($b),1708.1,1735.4,1802.2,1864.4,2310.4,2311.2,2451.6,2519.4,2632.1,2877.6
Refundable Credits ($b),102.9,117.5,118.5,642.0,802.6,119.2,127.1,133.0,135.2,121.9
Nonrefundable Credits ($b),67.0,127.3,129.2,128.5,47.6,140.8,143.3,144.0,145.9,78.0
Taxable Income ($b),8112.2,9179.2,9520.5,9907.3,12003.2,11927.7,12692.4,13124.8,13697.6,13377.8
Regular Tax ($b),1656.8,1712.3,1778.2,1838.3,2281.5,2282.7,2421.7,2488.0,2599.2,2792.6
AMT Income ($b),10512.4,11343.5,11749.7,12180.1,14330.8,14356.1,15324.3,15944.7,16632.8,16934.0
AMT Liability ($b),51.3,22.1,23.0,25.1,27.8,27.4,28.8,30.3,31.8,85.1
AMT Filers (#m),5.7,0.2,0.2,0.3,0.4,0.3,0.3,0.3,0.3,7.4
Tax before Credits ($b),1708.1,1734.4,1801.1,1863.4,2309.4,2310.1,2450.5,2518.3,2631.0,2877.6
Refundable Credits ($b),102.9,117.5,118.5,642.0,802.6,119.2,127.0,133.0,135.2,121.9
Nonrefundable Credits ($b),67.0,127.3,129.2,128.5,47.6,140.9,143.3,144.0,145.9,78.0
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),40.0,44.8,43.6,52.9,84.9,61.5,66.5,65.2,66.0,64.2
Ind Income Tax ($b),1578.2,1535.4,1598.1,1146.8,1545.0,2112.7,2247.8,2307.6,2417.0,2742.0
Ind Income Tax ($b),1578.2,1534.3,1597.0,1145.8,1544.0,2111.6,2246.7,2306.5,2415.9,2742.0
Payroll Taxes ($b),1083.8,1133.3,1185.4,1209.0,1306.0,1403.4,1489.3,1563.9,1637.9,1711.0
Combined Liability ($b),2662.0,2668.7,2783.5,2355.8,2851.0,3516.1,3737.1,3871.6,4054.9,4452.9
Combined Liability ($b),2662.0,2667.7,2782.4,2354.8,2850.0,3515.0,3736.0,3870.5,4053.8,4452.9
With Income Tax <= 0 (#m),92.8,98.6,99.7,131.7,125.0,100.3,101.9,103.4,104.4,101.0
With Combined Tax <= 0 (#m),63.4,65.6,66.8,102.1,94.5,68.9,70.2,71.6,72.6,72.4
UBI Benefits ($b),0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
Expand Down
17 changes: 12 additions & 5 deletions taxcalc/tests/test_calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ def test_EITC(test_tuple, expected_value, skip_jit):
c04600 = [0.00, 0.00, 0.00, 0.00]
MARS = [2, 2, 2, 4]
e00900 = [352000.00, 23000.00, 0.00, 0.00]
c03260 = [13516.17, 1624.90, 0.00, 0.00]
e26270 = [0.00, 0.00, 11000.00, 6000.00]
e02100 = [0.00, 0.00, 0.00, 0.00]
e27200 = [0.00, 0.00, 0.00, 0.00]
Expand All @@ -572,38 +573,44 @@ def test_EITC(test_tuple, expected_value, skip_jit):
qbided = [0.0, 0.0, 0.0, 0.0] # unimportant for function

tuple0 = (
c00100[0], standard[0], c04470[0], c04600[0], MARS[0], e00900[0], e26270[0],
c00100[0], standard[0], c04470[0], c04600[0], MARS[0], e00900[0],
c03260[0], e26270[0],
e02100[0], e27200[0], e00650[0], c01000[0], PT_SSTB_income[0],
PT_binc_w2_wages[0], PT_ubia_property[0], PT_qbid_rt,
PT_qbid_taxinc_thd, PT_qbid_taxinc_gap, PT_qbid_w2_wages_rt,
PT_qbid_alt_w2_wages_rt, PT_qbid_alt_property_rt, c04800[0],
PT_qbid_ps, PT_qbid_prt, qbided[0], PT_qbid_limit_switch)
expected0 = (490860.66, 0)
tuple1 = (
c00100[1], standard[1], c04470[1], c04600[1], MARS[1], e00900[1], e26270[1],
c00100[1], standard[1], c04470[1], c04600[1], MARS[1], e00900[1],
c03260[1], e26270[1],
e02100[1], e27200[1], e00650[1], c01000[1], PT_SSTB_income[1],
PT_binc_w2_wages[1], PT_ubia_property[1], PT_qbid_rt,
PT_qbid_taxinc_thd, PT_qbid_taxinc_gap, PT_qbid_w2_wages_rt,
PT_qbid_alt_w2_wages_rt, PT_qbid_alt_property_rt, c04800[1],
PT_qbid_ps, PT_qbid_prt, qbided[1], PT_qbid_limit_switch)
expected1 = (284075.10, 4600)
expected1 = (284400.08, 4275.02)
tuple2 = (
c00100[2], standard[2], c04470[2], c04600[2], MARS[2], e00900[2], e26270[2],
c00100[2], standard[2], c04470[2], c04600[2], MARS[2], e00900[2],
c03260[2], e26270[2],
e02100[2], e27200[2], e00650[2], c01000[2], PT_SSTB_income[2],
PT_binc_w2_wages[2], PT_ubia_property[2], PT_qbid_rt,
PT_qbid_taxinc_thd, PT_qbid_taxinc_gap, PT_qbid_w2_wages_rt,
PT_qbid_alt_w2_wages_rt, PT_qbid_alt_property_rt, c04800[2],
PT_qbid_ps, PT_qbid_prt, qbided[2], PT_qbid_limit_switch)
expected2 = (579300.00, 0)
tuple3 = (
c00100[3], standard[3], c04470[3], c04600[3], MARS[3], e00900[3], e26270[3],
c00100[3], standard[3], c04470[3], c04600[3], MARS[3], e00900[3],
c03260[3], e26270[3],

e02100[3], e27200[3], e00650[3], c01000[3], PT_SSTB_income[3],
PT_binc_w2_wages[3], PT_ubia_property[3], PT_qbid_rt,
PT_qbid_taxinc_thd, PT_qbid_taxinc_gap, PT_qbid_w2_wages_rt,
PT_qbid_alt_w2_wages_rt, PT_qbid_alt_property_rt, c04800[3],
PT_qbid_ps, PT_qbid_prt, qbided[3], PT_qbid_limit_switch)
expected3 = (57500.00, 1200)


@pytest.mark.parametrize(
'test_tuple,expected_value', [
(tuple0, expected0),
Expand Down
2 changes: 1 addition & 1 deletion taxcalc/tests/test_reforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,4 +382,4 @@ def test_ext_reform(tests_path):
iitax_ext = calc_ext.array('iitax')
rdiff = iitax_ext - iitax_end
weighted_sum_rdiff = (rdiff * calc_end.array('s006')).sum() * 1.0e-9
assert np.allclose([weighted_sum_rdiff], [-224.46], rtol=0.0, atol=0.01)
assert np.allclose([weighted_sum_rdiff], [-224.45], rtol=0.0, atol=0.01)
Loading