Skip to content

Commit

Permalink
Merge pull request #2823 from martinholmer/simplify-qbid-logic
Browse files Browse the repository at this point in the history
Remove PT_qbid_limit_switch parameter and it's assocated False code
  • Loading branch information
martinholmer authored Oct 11, 2024
2 parents af96206 + 9ecf038 commit e35dae3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 79 deletions.
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ markers =
extend_tcja
itmded_vars
pufcsv_agg
qbid
reforms
rtr
stded
16 changes: 4 additions & 12 deletions taxcalc/calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
PT_binc_w2_wages, PT_ubia_property, 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,
PT_qbid_ps, PT_qbid_prt, qbided, PT_qbid_limit_switch):
PT_qbid_ps, PT_qbid_prt, qbided):
"""
Calculates taxable income, c04800, and
qualified business income deduction, qbided.
Expand Down Expand Up @@ -1275,8 +1275,6 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
QBID phaseout rate
qbided: float
Qualified Business Income (QBI) deduction
PT_qbid_limit_switch: bool
QBID wage and capital limitations switch
Returns
-------
Expand All @@ -1300,9 +1298,7 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
upper_thd = lower_thd + pre_qbid_taxinc_gap
if PT_SSTB_income == 1 and pre_qbid_taxinc >= upper_thd:
qbided = 0.
# if PT_qbid_limit_switch is True, apply wage/capital
# limitations.
elif PT_qbid_limit_switch:
else:
wage_cap = PT_binc_w2_wages * PT_qbid_w2_wages_rt
alt_cap = (PT_binc_w2_wages * PT_qbid_alt_w2_wages_rt +
PT_ubia_property * PT_qbid_alt_property_rt)
Expand All @@ -1323,12 +1319,8 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
prt = (pre_qbid_taxinc - lower_thd) / pre_qbid_taxinc_gap
adj = prt * (qbid_adjusted - cap_adjusted)
qbided = qbid_adjusted - adj
# if PT_qbid_limit_switch is False, assume all taxpayers
# have sufficient wage expenses and capital income to avoid
# QBID limitations.
else:
qbided = qbid_before_limits
# apply taxinc cap (assuning cap rate is equal to PT_qbid_rt)

# apply taxinc cap (assuming cap rate is equal to PT_qbid_rt)
net_cg = e00650 + c01000 # per line 34 in 2018 Pub 535 Worksheet 12-A
taxinc_cap = PT_qbid_rt * max(0., pre_qbid_taxinc - net_cg)
qbided = min(qbided, taxinc_cap)
Expand Down
26 changes: 0 additions & 26 deletions taxcalc/policy_current_law.json
Original file line number Diff line number Diff line change
Expand Up @@ -18379,32 +18379,6 @@
"cps": false
}
},
"PT_qbid_limit_switch": {
"title": "QBID wage and capital limitations switch.",
"description": "A value of True imposes wage/capital limitations. Note that neither the PUF nor CPS have data on wage expenses or capital income, and therefore all taxpayers are fully subject to the QBID limitations. A value of False assumes sufficient wage and capital income to avoid QBID limitations.",
"notes": "",
"section_1": "Personal Income",
"section_2": "Pass-Through",
"indexable": false,
"indexed": false,
"type": "bool",
"value": [
{
"year": 2013,
"value": true
}
],
"validators": {
"range": {
"min": false,
"max": true
}
},
"compatible_data": {
"puf": false,
"cps": false
}
},
"PT_qbid_ps": {
"title": "QBID phaseout taxable income start",
"description": "QBID begins to decrease when pre-QBID taxable income is above this level.",
Expand Down
9 changes: 4 additions & 5 deletions taxcalc/tests/test_calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ def test_EITC(test_tuple, expected_value, skip_jit):
PT_qbid_alt_property_rt = 0.025
PT_qbid_ps = [9e99, 9e99, 9e99, 9e99, 9e99]
PT_qbid_prt = 0.0
PT_qbid_limit_switch = True # will want to test with False also

# Input variable values for tests
c00100 = [527860.66, 337675.10, 603700.00, 90700.00]
Expand Down Expand Up @@ -579,7 +578,7 @@ def test_EITC(test_tuple, expected_value, skip_jit):
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)
PT_qbid_ps, PT_qbid_prt, qbided[0])
expected0 = (490860.66, 0)
tuple1 = (
c00100[1], standard[1], c04470[1], c04600[1], MARS[1], e00900[1],
Expand All @@ -588,7 +587,7 @@ def test_EITC(test_tuple, expected_value, skip_jit):
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)
PT_qbid_ps, PT_qbid_prt, qbided[1])
expected1 = (284400.08, 4275.02)
tuple2 = (
c00100[2], standard[2], c04470[2], c04600[2], MARS[2], e00900[2],
Expand All @@ -597,7 +596,7 @@ def test_EITC(test_tuple, expected_value, skip_jit):
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)
PT_qbid_ps, PT_qbid_prt, qbided[2])
expected2 = (579300.00, 0)
tuple3 = (
c00100[3], standard[3], c04470[3], c04600[3], MARS[3], e00900[3],
Expand All @@ -607,7 +606,7 @@ def test_EITC(test_tuple, expected_value, skip_jit):
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)
PT_qbid_ps, PT_qbid_prt, qbided[3])
expected3 = (57500.00, 1200)


Expand Down
37 changes: 1 addition & 36 deletions taxcalc/tests/test_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ def test_itemded_component_amounts(year, cvname, hcname, puf_fullsample):
raise ValueError(msg)


@pytest.mark.qbid
def test_qbid_calculation():
"""
Test Calculator's QBID calculations using the six example filing units
Expand Down Expand Up @@ -886,42 +887,6 @@ def test_qbid_calculation():
assert np.allclose(tc_df.qbided, tpc_df.qbid)


def test_qbid_limit_switch():
"""
Test Calculator's switch to implement wage/capital limitations
on QBI deduction.
"""
cy = 2019
ref = {"PT_qbid_limit_switch": {2019: False}}

# filing unit has $500,000 in wages and $100,000 in QBI. Since
# the household is above the taxable income limitation threshold,
# with full wage/capital limitations, it does not receive a QBI
# deduction. With sufficent wage/capital to avoid the limitation,
# the filing unit receives a deduction of:
# $100,000 * 20% = $20,000.
VARS = 'RECID,MARS,e00200s,e00200p,e00200,e26270,e02000\n'
FUNIT = '1,2,250000,250000,500000,100000,100000'

funit_df = pd.read_csv(StringIO(VARS + FUNIT))
recs = Records(data=funit_df, start_year=cy,
gfactors=None, weights=None)

calc_base = Calculator(policy=Policy(), records=recs)
calc_base.calc_all()

qbid_base = calc_base.array('qbided')
assert np.equal(qbid_base, 0)

pol_ref = Policy()
pol_ref.implement_reform(ref)
calc_ref = Calculator(policy=pol_ref, records=recs)
calc_ref.calc_all()

qbid_ref = calc_ref.array('qbided')
assert np.equal(qbid_ref, 20000)


def test_calc_all_benefits_amounts(cps_subsample):
'''
Testing how benefits are handled in the calc_all method
Expand Down

0 comments on commit e35dae3

Please sign in to comment.