From ec87f401346d8e8956ce740dadc073eae260ab7b Mon Sep 17 00:00:00 2001 From: martinholmer Date: Fri, 11 Nov 2016 11:28:03 -0500 Subject: [PATCH 01/15] Clarify Adj function documentation. --- taxcalc/functions.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/taxcalc/functions.py b/taxcalc/functions.py index b74ffd41a..c3969f8c6 100644 --- a/taxcalc/functions.py +++ b/taxcalc/functions.py @@ -120,51 +120,51 @@ def Adj(e03150, e03210, c03260, ALD_EarlyWithdraw_hc, ALD_Alimony_hc, c02900): """ - Adj calculated Form 1040 adjustments + Adj calculates Form 1040 AGI adjustments (i.e., Above-the-Line Deductions) Notes ----- Taxpayer characteristics: - e03210 : Student loan interst deduction - e03220 : Education Expense deduction + e03210 : Student loan interest deduction - e03150 : Total deduction IRA contributions + e03220 : Educator expense deduction - e03230 : Education credit adjustments + e03150 : Total deductible IRA plan contributions - e03240 : Domestic Production Activity Deduction + e03230 : Tuition and fees (Form 8917) - c03260 : Self-employment tax AGI deduction (after haircut) + e03240 : Domestic production activity deduction (Form 8903) - e03270 : Self employed health insurance deduction + c03260 : Self-employment tax deduction (after haircut) - e03290 : HSA deduction computer amount + e03270 : Self-employed health insurance deduction - e03300 : Payments to a KEOGH plan and SEP deduction + e03290 : HSA deduction (Form 8889) - e03400 : Forfeited interest penalty early withdraw + e03300 : Total deductible KEOGH/SEP/SIMPLE/etc. plan contributions - e03500 : Alimony withdraw + e03400 : Penalty on early withdrawal of savings deduction - care_deduction : Deduction for dependent care + e03500 : Alimony paid deduction + + care_deduction : Dependent care expense deduction Tax law parameters: - ALD_StudentLoan_hc : Deduction for student loan interest haircut - ALD_SelfEmp_HealthIns_hc : - Deduction for self employed health insurance haircut + ALD_StudentLoan_hc : Student loan interest deduction haircut + + ALD_SelfEmp_HealthIns_hc : Self-employed h.i. deduction haircut - ALD_KEOGH_SEP_hc : - Deduction for payment to either KEOGH or SEP plan haircut + ALD_KEOGH_SEP_hc : KEOGH/etc. plan contribution deduction haircut - ALD_EarlyWithdraw_hc : Deduction for forfeited interest penalty haricut + ALD_EarlyWithdraw_hc : Penalty on early withdrawl deduction haricut - ALD_Alimony_hc : Deduction for alimony payment haircut + ALD_Alimony_hc : Alimony paid deduction haircut Returns ------- - c02900 : total Form 1040 adjustments + c02900 : total Form 1040 adjustments, which are not included in AGI """ # Form 2555 foreign earned income deduction is always zero # Form 1040 adjustments From 19c9ea7bb1794d53f1f0b65c883621f00e998be8 Mon Sep 17 00:00:00 2001 From: martinholmer Date: Fri, 11 Nov 2016 12:12:25 -0500 Subject: [PATCH 02/15] Add invinc_agi_ec variable and use it in ExpandIncome function. --- taxcalc/functions.py | 21 +++++++++++++-------- taxcalc/records.py | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/taxcalc/functions.py b/taxcalc/functions.py index c3969f8c6..83f1859d1 100644 --- a/taxcalc/functions.py +++ b/taxcalc/functions.py @@ -185,7 +185,7 @@ def CapGains(p23250, p22250, _sep, ALD_Investment_ec_rt, ALD_StudentLoan_hc, CG_nodiff, CG_ec, CG_reinvest_ec_rt, e00900, e01100, e01200, e01400, e01700, e02000, e02100, e02300, e00400, e02400, c02900, e03210, e03230, e03240, - c01000, c23650, ymod, ymod1): + c01000, c23650, ymod, ymod1, invinc_agi_ec): """ CapGains function: ... """ @@ -194,9 +194,10 @@ def CapGains(p23250, p22250, _sep, ALD_Investment_ec_rt, ALD_StudentLoan_hc, # limitation on capital losses c01000 = max((-3000. / _sep), c23650) # compute ymod1 variable that is included in AGI + invinc = e00300 + e00600 + c01000 + e01100 + e01200 + invinc_agi_ec = ALD_Investment_ec_rt * invinc ymod1 = (e00200 + e00700 + e00800 + e00900 + e01400 + e01700 + - (1. - ALD_Investment_ec_rt) * (e00300 + e00600 + - c01000 + e01100 + e01200) + + invinc - invinc_agi_ec + e02000 + e02100 + e02300) if CG_nodiff: # apply QDIV+CG exclusion if QDIV+LTCG receive no special tax treatment @@ -204,11 +205,12 @@ def CapGains(p23250, p22250, _sep, ALD_Investment_ec_rt, ALD_StudentLoan_hc, qdcg_exclusion = (max(CG_ec, qdcg_pos) + CG_reinvest_ec_rt * max(0., qdcg_pos - CG_ec)) ymod1 = max(0., ymod1 - qdcg_exclusion) + invinc_agi_ec += qdcg_exclusion # compute ymod variable that is used in OASDI benefit taxation logic ymod2 = e00400 + (0.50 * e02400) - c02900 ymod3 = (1. - ALD_StudentLoan_hc) * e03210 + e03230 + e03240 ymod = ymod1 + ymod2 + ymod3 - return (c01000, c23650, ymod, ymod1) + return (c01000, c23650, ymod, ymod1, invinc_agi_ec) @iterate_jit(nopython=True) @@ -1376,7 +1378,8 @@ def FairShareTax(c00100, MARS, ptax_was, setax, ptax_amc, @iterate_jit(nopython=True) -def ExpandIncome(ptax_was, c03260, e02400, c02500, c00100, e00400, +def ExpandIncome(c00100, ptax_was, e02400, c02500, + c03260, e00400, invinc_agi_ec, _expanded_income): """ ExpandIncome function: calculates and returns _expanded_income. @@ -1387,8 +1390,10 @@ def ExpandIncome(ptax_was, c03260, e02400, c02500, c00100, e00400, employer_share = 0.5 * ptax_was # share of payroll tax on wages & salary non_taxable_ss_benefits = e02400 - c02500 _expanded_income = (c00100 + # adjusted gross income - c03260 + # "employer share" of setax + c03260 + # "employer share" of setax ===> c02900 e00400 + # non-taxable interest income - non_taxable_ss_benefits + - employer_share) + invinc_agi_ec + # investment income excluded from AGI + employer_share + + non_taxable_ss_benefits) + return _expanded_income diff --git a/taxcalc/records.py b/taxcalc/records.py index f57ac3928..8f47556eb 100644 --- a/taxcalc/records.py +++ b/taxcalc/records.py @@ -142,7 +142,7 @@ class instance: Records 'c07200', 'c00100', 'pre_c04600', 'c04600', 'c04470', 'c21060', 'c21040', 'c17000', - 'c18300', 'c20800', 'c02900', 'c23650', + 'c18300', 'c20800', 'c02900', 'c23650', 'invinc_agi_ec', 'c01000', 'c02500', 'c19700', '_sey', '_earned', '_earned_p', '_earned_s', 'ymod', 'ymod1', From 4978900c774179a542b4a00a7d3f5d67d706be77 Mon Sep 17 00:00:00 2001 From: martinholmer Date: Fri, 11 Nov 2016 13:33:59 -0500 Subject: [PATCH 03/15] Add cmbtp amount to the _expanded_income variable. --- taxcalc/functions.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/taxcalc/functions.py b/taxcalc/functions.py index 83f1859d1..706c658b4 100644 --- a/taxcalc/functions.py +++ b/taxcalc/functions.py @@ -1379,7 +1379,8 @@ def FairShareTax(c00100, MARS, ptax_was, setax, ptax_amc, @iterate_jit(nopython=True) def ExpandIncome(c00100, ptax_was, e02400, c02500, - c03260, e00400, invinc_agi_ec, + c02900, e00400, invinc_agi_ec, + f6251, _standard, cmbtp_itemizer, cmbtp_standard, _expanded_income): """ ExpandIncome function: calculates and returns _expanded_income. @@ -1387,13 +1388,24 @@ def ExpandIncome(c00100, ptax_was, e02400, c02500, Note: if behavioral responses to a policy reform are specified, then be sure this function is called after the behavioral responses are calculated. """ - employer_share = 0.5 * ptax_was # share of payroll tax on wages & salary + # compute Form 6251 items not in AGI but added into AMT taxable income + if f6251 == 1: + if _standard == 0.0: + cmbtp = cmbtp_itemizer + else: + cmbtp = cmbtp_standard + else: + cmbtp = 0. + # compute employer share of OASDI+HI payroll tax on wages and salaries + employer_share = 0.5 * ptax_was + # compute OASDI benefits not included in AGI non_taxable_ss_benefits = e02400 - c02500 + # compute expanded income as AGI plus several additional amounts _expanded_income = (c00100 + # adjusted gross income - c03260 + # "employer share" of setax ===> c02900 + c02900 + # ajustments to AGI e00400 + # non-taxable interest income - invinc_agi_ec + # investment income excluded from AGI + invinc_agi_ec + # AGI-excluded taxable invest income + cmbtp + # AMT taxable income items from Form 6251 employer_share + non_taxable_ss_benefits) - return _expanded_income From c6e4030dd9e257db92bb83bde6570e8f0a7ceae2 Mon Sep 17 00:00:00 2001 From: martinholmer Date: Fri, 11 Nov 2016 13:38:41 -0500 Subject: [PATCH 04/15] Non-substantive change in order of ExpandIncome statements. --- taxcalc/functions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/taxcalc/functions.py b/taxcalc/functions.py index 706c658b4..c6ee9bb1a 100644 --- a/taxcalc/functions.py +++ b/taxcalc/functions.py @@ -1388,6 +1388,10 @@ def ExpandIncome(c00100, ptax_was, e02400, c02500, Note: if behavioral responses to a policy reform are specified, then be sure this function is called after the behavioral responses are calculated. """ + # compute employer share of OASDI+HI payroll tax on wages and salaries + employer_share = 0.5 * ptax_was + # compute OASDI benefits not included in AGI + non_taxable_ss_benefits = e02400 - c02500 # compute Form 6251 items not in AGI but added into AMT taxable income if f6251 == 1: if _standard == 0.0: @@ -1396,10 +1400,6 @@ def ExpandIncome(c00100, ptax_was, e02400, c02500, cmbtp = cmbtp_standard else: cmbtp = 0. - # compute employer share of OASDI+HI payroll tax on wages and salaries - employer_share = 0.5 * ptax_was - # compute OASDI benefits not included in AGI - non_taxable_ss_benefits = e02400 - c02500 # compute expanded income as AGI plus several additional amounts _expanded_income = (c00100 + # adjusted gross income c02900 + # ajustments to AGI From 89a88ec1f5c2dbc585112635675498c35f2e412a Mon Sep 17 00:00:00 2001 From: martinholmer Date: Fri, 11 Nov 2016 13:40:38 -0500 Subject: [PATCH 05/15] More non-substantive changes in order of ExpandIncome statements. --- taxcalc/functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/taxcalc/functions.py b/taxcalc/functions.py index c6ee9bb1a..36eb80a74 100644 --- a/taxcalc/functions.py +++ b/taxcalc/functions.py @@ -1406,6 +1406,6 @@ def ExpandIncome(c00100, ptax_was, e02400, c02500, e00400 + # non-taxable interest income invinc_agi_ec + # AGI-excluded taxable invest income cmbtp + # AMT taxable income items from Form 6251 - employer_share + - non_taxable_ss_benefits) + non_taxable_ss_benefits + + employer_share) return _expanded_income From 6a1422ff9855d05341bbfb5339c7c4717651fbd2 Mon Sep 17 00:00:00 2001 From: martinholmer Date: Fri, 11 Nov 2016 20:34:07 -0500 Subject: [PATCH 06/15] Remove behavior comment from ExpandIncome docstring. --- taxcalc/functions.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/taxcalc/functions.py b/taxcalc/functions.py index 36eb80a74..aa2a12549 100644 --- a/taxcalc/functions.py +++ b/taxcalc/functions.py @@ -1383,10 +1383,7 @@ def ExpandIncome(c00100, ptax_was, e02400, c02500, f6251, _standard, cmbtp_itemizer, cmbtp_standard, _expanded_income): """ - ExpandIncome function: calculates and returns _expanded_income. - - Note: if behavioral responses to a policy reform are specified, then be - sure this function is called after the behavioral responses are calculated. + ExpandIncome function calculates and returns _expanded_income. """ # compute employer share of OASDI+HI payroll tax on wages and salaries employer_share = 0.5 * ptax_was From 75b5730867e50a2dd36477122360d0defb67792d Mon Sep 17 00:00:00 2001 From: martinholmer Date: Sat, 12 Nov 2016 18:54:30 -0500 Subject: [PATCH 07/15] Implement JCT-rules about pensions/h.ins. AGI adjustemts in expanded income. --- taxcalc/functions.py | 41 ++++++++++++++++++++++++----------------- taxcalc/records.py | 2 +- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/taxcalc/functions.py b/taxcalc/functions.py index aa2a12549..3e2553d46 100644 --- a/taxcalc/functions.py +++ b/taxcalc/functions.py @@ -118,7 +118,7 @@ def Adj(e03150, e03210, c03260, e03220, e03230, e03240, e03290, care_deduction, ALD_StudentLoan_hc, ALD_SelfEmp_HealthIns_hc, ALD_KEOGH_SEP_hc, ALD_EarlyWithdraw_hc, ALD_Alimony_hc, - c02900): + c02900, c02900_less): """ Adj calculates Form 1040 AGI adjustments (i.e., Above-the-Line Deductions) @@ -165,18 +165,25 @@ def Adj(e03150, e03210, c03260, Returns ------- c02900 : total Form 1040 adjustments, which are not included in AGI - """ - # Form 2555 foreign earned income deduction is always zero - # Form 1040 adjustments - c02900 = (e03150 + - (1. - ALD_StudentLoan_hc) * e03210 + - c03260 + - (1. - ALD_SelfEmp_HealthIns_hc) * e03270 + - (1. - ALD_KEOGH_SEP_hc) * e03300 + - (1. - ALD_EarlyWithdraw_hc) * e03400 + - (1. - ALD_Alimony_hc) * e03500 + - e03220 + e03230 + e03240 + e03290 + care_deduction) - return c02900 + + c02900_less : total adjustments less those not included in expanded income + """ + # Form 2555 foreign earned income deduction is assumed to be zero + # Form 1040 adjustments that are included in expanded income: + # NOTE: add e03270 after health-insurance imputations are available + # NOTE: add e03150,e03300 after pension-contribution imputations avail + c02900_less = ((1. - ALD_StudentLoan_hc) * e03210 + + c03260 + + (1. - ALD_EarlyWithdraw_hc) * e03400 + + (1. - ALD_Alimony_hc) * e03500 + + e03220 + e03230 + e03240 + e03290 + care_deduction) + # add in Form 1040 adjustments that are not included in expanded income: + # NOTE: remove e03270 after health-insurance imputations are available + # NOTE: remove e03150,e03300 after pension-contribution imputations avail + c02900 = c02900_less + ((1. - ALD_SelfEmp_HealthIns_hc) * e03270 + + e03150 + # deductible IRA contributions + (1. - ALD_KEOGH_SEP_hc) * e03300) + return (c02900, c02900_less) @iterate_jit(nopython=True) @@ -1379,14 +1386,14 @@ def FairShareTax(c00100, MARS, ptax_was, setax, ptax_amc, @iterate_jit(nopython=True) def ExpandIncome(c00100, ptax_was, e02400, c02500, - c02900, e00400, invinc_agi_ec, + c02900_less, e00400, invinc_agi_ec, f6251, _standard, cmbtp_itemizer, cmbtp_standard, _expanded_income): """ ExpandIncome function calculates and returns _expanded_income. """ # compute employer share of OASDI+HI payroll tax on wages and salaries - employer_share = 0.5 * ptax_was + employer_fica_share = 0.5 * ptax_was # compute OASDI benefits not included in AGI non_taxable_ss_benefits = e02400 - c02500 # compute Form 6251 items not in AGI but added into AMT taxable income @@ -1399,10 +1406,10 @@ def ExpandIncome(c00100, ptax_was, e02400, c02500, cmbtp = 0. # compute expanded income as AGI plus several additional amounts _expanded_income = (c00100 + # adjusted gross income - c02900 + # ajustments to AGI + c02900_less + # ajustments to AGI e00400 + # non-taxable interest income invinc_agi_ec + # AGI-excluded taxable invest income cmbtp + # AMT taxable income items from Form 6251 non_taxable_ss_benefits + - employer_share) + employer_fica_share) return _expanded_income diff --git a/taxcalc/records.py b/taxcalc/records.py index 8f47556eb..85a103a73 100644 --- a/taxcalc/records.py +++ b/taxcalc/records.py @@ -142,7 +142,7 @@ class instance: Records 'c07200', 'c00100', 'pre_c04600', 'c04600', 'c04470', 'c21060', 'c21040', 'c17000', - 'c18300', 'c20800', 'c02900', 'c23650', 'invinc_agi_ec', + 'c18300', 'c20800', 'c02900', 'c02900_less', 'c23650', 'invinc_agi_ec', 'c01000', 'c02500', 'c19700', '_sey', '_earned', '_earned_p', '_earned_s', 'ymod', 'ymod1', From 55f210d85aa06a4fae78a43c06d79cc739dce89d Mon Sep 17 00:00:00 2001 From: martinholmer Date: Sat, 12 Nov 2016 22:10:53 -0500 Subject: [PATCH 08/15] Add filer to USABLE_READ_VARS set. --- taxcalc/records.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taxcalc/records.py b/taxcalc/records.py index 85a103a73..560b5fad5 100644 --- a/taxcalc/records.py +++ b/taxcalc/records.py @@ -118,7 +118,7 @@ class instance: Records 'e58990', 'e62900', 'p87521', 'e87530', - 'MARS', 'MIDR', 'RECID', + 'MARS', 'MIDR', 'RECID', 'filer', 'cmbtp_standard', 'cmbtp_itemizer', 'age_head', 'age_spouse', 'blind_head', 'blind_spouse', 'nu13', 'elderly_dependent', From f11b0a0e1547b25b14902750acb612f59587f804 Mon Sep 17 00:00:00 2001 From: martinholmer Date: Sat, 12 Nov 2016 22:29:35 -0500 Subject: [PATCH 09/15] Add FILER to var_label.txt file. --- taxcalc/var_labels.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/taxcalc/var_labels.txt b/taxcalc/var_labels.txt index 7181c0d83..a918ed40e 100644 --- a/taxcalc/var_labels.txt +++ b/taxcalc/var_labels.txt @@ -67,6 +67,7 @@ EIC = Earned Income Credit code: categorical variable ELDERLY_DEPENDENT = 1 if unit has elderly dependent; 0 if no elderly dependent F2441 = Form 2441 number of Child Care Credit qualified individuals F6251 = Form 6251, Alternative Minimum Tax, attached to return or not +FILER = zero/one indicator for filing unit being in the IRS-SOI PUF sample FLPDYR = Filing (accounting) period (i.e., tax year) MARS = Marital (filing) status: categorical variable MIDR = Married filing separately itemized deductions requirement indicator From 48139bb605857568bde85e99bb34635016895c3b Mon Sep 17 00:00:00 2001 From: martinholmer Date: Sun, 13 Nov 2016 12:46:13 -0500 Subject: [PATCH 10/15] Revise Calculator test to increase code coverage. --- taxcalc/functions.py | 8 ++++---- taxcalc/tests/test_calculate.py | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/taxcalc/functions.py b/taxcalc/functions.py index 3e2553d46..1afd18559 100644 --- a/taxcalc/functions.py +++ b/taxcalc/functions.py @@ -170,19 +170,19 @@ def Adj(e03150, e03210, c03260, """ # Form 2555 foreign earned income deduction is assumed to be zero # Form 1040 adjustments that are included in expanded income: - # NOTE: add e03270 after health-insurance imputations are available - # NOTE: add e03150,e03300 after pension-contribution imputations avail c02900_less = ((1. - ALD_StudentLoan_hc) * e03210 + c03260 + (1. - ALD_EarlyWithdraw_hc) * e03400 + (1. - ALD_Alimony_hc) * e03500 + e03220 + e03230 + e03240 + e03290 + care_deduction) # add in Form 1040 adjustments that are not included in expanded income: - # NOTE: remove e03270 after health-insurance imputations are available - # NOTE: remove e03150,e03300 after pension-contribution imputations avail c02900 = c02900_less + ((1. - ALD_SelfEmp_HealthIns_hc) * e03270 + e03150 + # deductible IRA contributions (1. - ALD_KEOGH_SEP_hc) * e03300) + # TODO: move e03270 term into c02900_less after health-insurance-premium + # imputations are available + # TODO: move e03150 and e03300 term into c02900_less after pension- + # contribution imputations are available return (c02900, c02900_less) diff --git a/taxcalc/tests/test_calculate.py b/taxcalc/tests/test_calculate.py index 15886ba10..18c9a7e6a 100644 --- a/taxcalc/tests/test_calculate.py +++ b/taxcalc/tests/test_calculate.py @@ -24,18 +24,19 @@ RAWINPUTFILE_FUNITS = 4 RAWINPUTFILE_YEAR = 2015 RAWINPUTFILE_CONTENTS = ( - 'RECID,MARS\n' - '1,2\n' - '2,1\n' - '3,4\n' - '4,6\n' + 'RECID,MARS,extraneous\n' + '1,2,0\n' + '2,1,1\n' + '3,4,0\n' + '4,6,1\n' ) @pytest.yield_fixture def rawinputfile(): """ - Temporary input file that contains minimum required input varaibles. + Temporary input file that contains the minimum required input varaibles + plus one completely unrelated variable. """ ifile = tempfile.NamedTemporaryFile(mode='a', delete=False) ifile.write(RAWINPUTFILE_CONTENTS) From 6b0af3cdb9df83e0dda0d41d1e7a1561303e1c02 Mon Sep 17 00:00:00 2001 From: martinholmer Date: Sun, 13 Nov 2016 13:08:09 -0500 Subject: [PATCH 11/15] Revise different Calculator test to increase code coverage. --- taxcalc/tests/test_calculate.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/taxcalc/tests/test_calculate.py b/taxcalc/tests/test_calculate.py index 18c9a7e6a..df83ef32a 100644 --- a/taxcalc/tests/test_calculate.py +++ b/taxcalc/tests/test_calculate.py @@ -24,19 +24,18 @@ RAWINPUTFILE_FUNITS = 4 RAWINPUTFILE_YEAR = 2015 RAWINPUTFILE_CONTENTS = ( - 'RECID,MARS,extraneous\n' - '1,2,0\n' - '2,1,1\n' - '3,4,0\n' - '4,6,1\n' + 'RECID,MARS\n' + '1,2\n' + '2,1\n' + '3,4\n' + '4,6\n' ) @pytest.yield_fixture def rawinputfile(): """ - Temporary input file that contains the minimum required input varaibles - plus one completely unrelated variable. + Temporary input file that contains the minimum required input varaibles. """ ifile = tempfile.NamedTemporaryFile(mode='a', delete=False) ifile.write(RAWINPUTFILE_CONTENTS) @@ -296,8 +295,8 @@ def test_Calculator_mtr_when_PT_rates_differ(): '_PT_rt6': [0.30], '_PT_rt7': [0.30]}} funit = ( - u'RECID,MARS,FLPDYR,e00200,e00200p,e00900,e00900p\n' - u'1, 1, 2015, 200000,200000, 100000,100000\n' + u'RECID,MARS,FLPDYR,e00200,e00200p,e00900,e00900p,extraneous\n' + u'1, 1, 2009, 200000,200000, 100000,100000, 9999999999\n' ) pol1 = Policy() rec1 = Records(pd.read_csv(StringIO(funit))) From 0b21524aac93619297c35400ff97cd254783cc25 Mon Sep 17 00:00:00 2001 From: martinholmer Date: Mon, 14 Nov 2016 10:48:35 -0500 Subject: [PATCH 12/15] Fix typo in validation/CSV_INPUT_VARS.md file. --- taxcalc/validation/CSV_INPUT_VARS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taxcalc/validation/CSV_INPUT_VARS.md b/taxcalc/validation/CSV_INPUT_VARS.md index 1449b94bc..ef4991b5b 100644 --- a/taxcalc/validation/CSV_INPUT_VARS.md +++ b/taxcalc/validation/CSV_INPUT_VARS.md @@ -36,7 +36,7 @@ in the IRS-SOI Public Use File (PUF). | e01400 | 1040 | 15b | taxable IRA distributions | e01500 | 1040 | 16a | some (not all) nontaxable pensions and annuities | e01700 | 1040 | 16b | taxable pensions and annuities -| e02000 | 1040 | 17 | Sch E rental, royalty, S-corp, etc, income +| e02000 | 1040 | 17 | Sch E rental, royalty, S-corp, etc, income/loss | e02100 | 1040 | 18 | farm net income/loss for filing unit (Sch F) | e02100p | 1040 | 18* | farm net income/loss for taxpayer | e02100s | 1040 | 18* | farm net income/loss for spouse From b0a69f5f1e450e6c3d53e54710eb5e631939e3c7 Mon Sep 17 00:00:00 2001 From: martinholmer Date: Mon, 14 Nov 2016 10:59:29 -0500 Subject: [PATCH 13/15] Fix typo and change c02900_less to c02900_in_ei. --- taxcalc/functions.py | 32 +++++++++++++------------- taxcalc/records.py | 4 ++-- taxcalc/validation/taxsim/a15.taxdiffs | 11 --------- taxcalc/validation/taxsim/d15.taxdiffs | 13 ----------- 4 files changed, 18 insertions(+), 42 deletions(-) diff --git a/taxcalc/functions.py b/taxcalc/functions.py index 1afd18559..495eb4bd4 100644 --- a/taxcalc/functions.py +++ b/taxcalc/functions.py @@ -118,7 +118,7 @@ def Adj(e03150, e03210, c03260, e03220, e03230, e03240, e03290, care_deduction, ALD_StudentLoan_hc, ALD_SelfEmp_HealthIns_hc, ALD_KEOGH_SEP_hc, ALD_EarlyWithdraw_hc, ALD_Alimony_hc, - c02900, c02900_less): + c02900, c02900_in_ei): """ Adj calculates Form 1040 AGI adjustments (i.e., Above-the-Line Deductions) @@ -158,7 +158,7 @@ def Adj(e03150, e03210, c03260, ALD_KEOGH_SEP_hc : KEOGH/etc. plan contribution deduction haircut - ALD_EarlyWithdraw_hc : Penalty on early withdrawl deduction haricut + ALD_EarlyWithdraw_hc : Penalty on early withdrawal deduction haricut ALD_Alimony_hc : Alimony paid deduction haircut @@ -166,24 +166,24 @@ def Adj(e03150, e03210, c03260, ------- c02900 : total Form 1040 adjustments, which are not included in AGI - c02900_less : total adjustments less those not included in expanded income + c02900_in_ei : total adjustments included in expanded income """ # Form 2555 foreign earned income deduction is assumed to be zero # Form 1040 adjustments that are included in expanded income: - c02900_less = ((1. - ALD_StudentLoan_hc) * e03210 + - c03260 + - (1. - ALD_EarlyWithdraw_hc) * e03400 + - (1. - ALD_Alimony_hc) * e03500 + - e03220 + e03230 + e03240 + e03290 + care_deduction) + c02900_in_ei = ((1. - ALD_StudentLoan_hc) * e03210 + + c03260 + + (1. - ALD_EarlyWithdraw_hc) * e03400 + + (1. - ALD_Alimony_hc) * e03500 + + e03220 + e03230 + e03240 + e03290 + care_deduction) # add in Form 1040 adjustments that are not included in expanded income: - c02900 = c02900_less + ((1. - ALD_SelfEmp_HealthIns_hc) * e03270 + - e03150 + # deductible IRA contributions - (1. - ALD_KEOGH_SEP_hc) * e03300) - # TODO: move e03270 term into c02900_less after health-insurance-premium + c02900 = c02900_in_ei + ((1. - ALD_SelfEmp_HealthIns_hc) * e03270 + + e03150 + # deductible IRA contributions + (1. - ALD_KEOGH_SEP_hc) * e03300) + # TODO: move e03270 term into c02900_in_ei after health-insurance-premium # imputations are available - # TODO: move e03150 and e03300 term into c02900_less after pension- + # TODO: move e03150 and e03300 term into c02900_in_ei after pension- # contribution imputations are available - return (c02900, c02900_less) + return (c02900, c02900_in_ei) @iterate_jit(nopython=True) @@ -1386,7 +1386,7 @@ def FairShareTax(c00100, MARS, ptax_was, setax, ptax_amc, @iterate_jit(nopython=True) def ExpandIncome(c00100, ptax_was, e02400, c02500, - c02900_less, e00400, invinc_agi_ec, + c02900_in_ei, e00400, invinc_agi_ec, f6251, _standard, cmbtp_itemizer, cmbtp_standard, _expanded_income): """ @@ -1406,7 +1406,7 @@ def ExpandIncome(c00100, ptax_was, e02400, c02500, cmbtp = 0. # compute expanded income as AGI plus several additional amounts _expanded_income = (c00100 + # adjusted gross income - c02900_less + # ajustments to AGI + c02900_in_ei + # ajustments to AGI e00400 + # non-taxable interest income invinc_agi_ec + # AGI-excluded taxable invest income cmbtp + # AMT taxable income items from Form 6251 diff --git a/taxcalc/records.py b/taxcalc/records.py index 560b5fad5..785f18327 100644 --- a/taxcalc/records.py +++ b/taxcalc/records.py @@ -142,8 +142,8 @@ class instance: Records 'c07200', 'c00100', 'pre_c04600', 'c04600', 'c04470', 'c21060', 'c21040', 'c17000', - 'c18300', 'c20800', 'c02900', 'c02900_less', 'c23650', 'invinc_agi_ec', - 'c01000', 'c02500', 'c19700', + 'c18300', 'c20800', 'c02900', 'c02900_in_ei', 'c23650', + 'c01000', 'c02500', 'c19700', 'invinc_agi_ec', '_sey', '_earned', '_earned_p', '_earned_s', 'ymod', 'ymod1', 'c04800', 'c19200', 'c20500', diff --git a/taxcalc/validation/taxsim/a15.taxdiffs b/taxcalc/validation/taxsim/a15.taxdiffs index e6dd4c079..e69de29bb 100644 --- a/taxcalc/validation/taxsim/a15.taxdiffs +++ b/taxcalc/validation/taxsim/a15.taxdiffs @@ -1,11 +0,0 @@ -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 7 14 14 0.01 [6064] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 9 9 0 0.90 [8665] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 14 492 492 -1.28 [421] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 15 492 492 1.28 [438] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 18 492 492 1.28 [421] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 19 497 497 0.43 [5018] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 25 75 75 0.01 [35400] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 26 3 0 -2900.00 [63254] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 27 593 593 -0.43 [5018] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 28 496 496 0.43 [5018] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 4 184 184 -0.01 [21008] diff --git a/taxcalc/validation/taxsim/d15.taxdiffs b/taxcalc/validation/taxsim/d15.taxdiffs index b5f09a677..e69de29bb 100644 --- a/taxcalc/validation/taxsim/d15.taxdiffs +++ b/taxcalc/validation/taxsim/d15.taxdiffs @@ -1,13 +0,0 @@ -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 7 1 1 0.01 [11965] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 9 4 0 0.90 [16808] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 14 604 604 -1.28 [2349] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 15 604 604 1.28 [56716] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 17 146 0 25000.00 [66962] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 18 750 604 -12400.00 [66962] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 19 1382 1236 -1415.00 [41106] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 24 142 0 -1030.00 [41106] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 25 3 3 0.01 [12248] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 26 151 0 -17702.00 [86307] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 27 1606 1606 -0.43 [2168] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 28 1344 1202 -1030.00 [41106] -TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 4 703 703 -0.01 [647] From 58463354d57899af95a72978018b654309bc55f4 Mon Sep 17 00:00:00 2001 From: martinholmer Date: Mon, 14 Nov 2016 11:20:31 -0500 Subject: [PATCH 14/15] Revert erroneous change in validation results. --- taxcalc/validation/taxsim/a15.taxdiffs | 11 +++++++++++ taxcalc/validation/taxsim/d15.taxdiffs | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/taxcalc/validation/taxsim/a15.taxdiffs b/taxcalc/validation/taxsim/a15.taxdiffs index e69de29bb..e6dd4c079 100644 --- a/taxcalc/validation/taxsim/a15.taxdiffs +++ b/taxcalc/validation/taxsim/a15.taxdiffs @@ -0,0 +1,11 @@ +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 7 14 14 0.01 [6064] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 9 9 0 0.90 [8665] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 14 492 492 -1.28 [421] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 15 492 492 1.28 [438] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 18 492 492 1.28 [421] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 19 497 497 0.43 [5018] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 25 75 75 0.01 [35400] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 26 3 0 -2900.00 [63254] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 27 593 593 -0.43 [5018] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 28 496 496 0.43 [5018] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 4 184 184 -0.01 [21008] diff --git a/taxcalc/validation/taxsim/d15.taxdiffs b/taxcalc/validation/taxsim/d15.taxdiffs index e69de29bb..b5f09a677 100644 --- a/taxcalc/validation/taxsim/d15.taxdiffs +++ b/taxcalc/validation/taxsim/d15.taxdiffs @@ -0,0 +1,13 @@ +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 7 1 1 0.01 [11965] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 9 4 0 0.90 [16808] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 14 604 604 -1.28 [2349] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 15 604 604 1.28 [56716] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 17 146 0 25000.00 [66962] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 18 750 604 -12400.00 [66962] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 19 1382 1236 -1415.00 [41106] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 24 142 0 -1030.00 [41106] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 25 3 3 0.01 [12248] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 26 151 0 -17702.00 [86307] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 27 1606 1606 -0.43 [2168] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 28 1344 1202 -1030.00 [41106] +TAXDIFF:ovar,#diffs,#smdiffs,maxdiff[id]= 4 703 703 -0.01 [647] From 6a9f9ea473406f988c682a9fb7ef402465645c17 Mon Sep 17 00:00:00 2001 From: martinholmer Date: Mon, 14 Nov 2016 11:21:44 -0500 Subject: [PATCH 15/15] Change docstring in anticipation of CG_nodiff becoming a boolean. --- taxcalc/functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taxcalc/functions.py b/taxcalc/functions.py index 495eb4bd4..d45c0542e 100644 --- a/taxcalc/functions.py +++ b/taxcalc/functions.py @@ -575,7 +575,7 @@ def GainsTax(e00650, c01000, c23650, p23250, e01100, e58990, """ GainsTax function implements (2015) Schedule D Tax Worksheet logic for the special taxation of long-term capital gains and qualified dividends - if CG_nodiff is false (that is, zero) + if CG_nodiff is false """ # pylint: disable=too-many-statements,too-many-branches if c01000 > 0. or c23650 > 0. or p23250 > 0. or e01100 > 0. or e00650 > 0.: