From eb7e131d479ff0702f04986fbeae67f5fcffa9eb Mon Sep 17 00:00:00 2001 From: Peter-Metz Date: Wed, 7 Oct 2020 09:04:55 -0400 Subject: [PATCH 1/3] add switch for qbi limitations --- taxcalc/calcfunctions.py | 13 ++++++++++--- taxcalc/policy_current_law.json | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/taxcalc/calcfunctions.py b/taxcalc/calcfunctions.py index 2e0b2b7e3..be337dd8d 100644 --- a/taxcalc/calcfunctions.py +++ b/taxcalc/calcfunctions.py @@ -791,8 +791,8 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, 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, - PT_qbid_alt_w2_wages_rt, PT_qbid_alt_property_rt, + PT_qbid_w2_wages_rt, PT_qbid_alt_w2_wages_rt, + PT_qbid_alt_property_rt, PT_qbid_limit_switch, c04800, qbided): """ Calculates taxable income, c04800, and @@ -813,7 +813,9 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, e26270, upper_thd = lower_thd + pre_qbid_taxinc_gap if PT_SSTB_income == 1 and pre_qbid_taxinc >= upper_thd: qbided = 0. - else: + # if PT_qbid_limit_switch is True, apply wage/capital + # limitations. + elif PT_qbid_limit_switch: 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) @@ -834,6 +836,11 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, 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) 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) diff --git a/taxcalc/policy_current_law.json b/taxcalc/policy_current_law.json index 37e832b83..4de6f345a 100644 --- a/taxcalc/policy_current_law.json +++ b/taxcalc/policy_current_law.json @@ -12358,6 +12358,32 @@ "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 + } + }, "AMT_em": { "title": "AMT exemption amount", "description": "The amount of AMT taxable income exempted from AMT.", From 58283bb91fe95b87f62e7a8dcfb7f3d70bf55a51 Mon Sep 17 00:00:00 2001 From: Peter-Metz Date: Wed, 7 Oct 2020 09:05:14 -0400 Subject: [PATCH 2/3] add test for qbi limitation switch --- taxcalc/tests/test_calculator.py | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/taxcalc/tests/test_calculator.py b/taxcalc/tests/test_calculator.py index e82ce3cc9..c55780dc9 100644 --- a/taxcalc/tests/test_calculator.py +++ b/taxcalc/tests/test_calculator.py @@ -863,6 +863,42 @@ 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 From 365e1b16a4aaf853e7a83877188561818f49df8e Mon Sep 17 00:00:00 2001 From: Peter-Metz Date: Wed, 7 Oct 2020 09:38:37 -0400 Subject: [PATCH 3/3] pep8 --- taxcalc/calcfunctions.py | 6 +++--- taxcalc/tests/test_calculator.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/taxcalc/calcfunctions.py b/taxcalc/calcfunctions.py index be337dd8d..a18630280 100644 --- a/taxcalc/calcfunctions.py +++ b/taxcalc/calcfunctions.py @@ -791,7 +791,7 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, 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, PT_qbid_alt_w2_wages_rt, + PT_qbid_w2_wages_rt, PT_qbid_alt_w2_wages_rt, PT_qbid_alt_property_rt, PT_qbid_limit_switch, c04800, qbided): """ @@ -815,7 +815,7 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, e26270, qbided = 0. # if PT_qbid_limit_switch is True, apply wage/capital # limitations. - elif PT_qbid_limit_switch: + elif PT_qbid_limit_switch: 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) @@ -838,7 +838,7 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, e26270, 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. + # QBID limitations. else: qbided = qbid_before_limits # apply taxinc cap (assuning cap rate is equal to PT_qbid_rt) diff --git a/taxcalc/tests/test_calculator.py b/taxcalc/tests/test_calculator.py index c55780dc9..66e2d5ea5 100644 --- a/taxcalc/tests/test_calculator.py +++ b/taxcalc/tests/test_calculator.py @@ -872,7 +872,7 @@ def test_qbid_limit_switch(): 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, + # 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: @@ -882,7 +882,7 @@ def test_qbid_limit_switch(): funit_df = pd.read_csv(StringIO(VARS + FUNIT)) recs = Records(data=funit_df, start_year=cy, - gfactors=None, weights=None) + gfactors=None, weights=None) calc_base = Calculator(policy=Policy(), records=recs) calc_base.calc_all()