taxcalc 4.2.0__py3-none-any.whl → 4.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. taxcalc/__init__.py +1 -1
  2. taxcalc/calcfunctions.py +81 -57
  3. taxcalc/data.py +10 -5
  4. taxcalc/policy_current_law.json +2012 -219
  5. taxcalc/records_variables.json +6 -1
  6. taxcalc/reforms/2017_law.json +1 -1
  7. taxcalc/reforms/ARPA.json +4 -4
  8. taxcalc/reforms/CARES.json +7 -4
  9. taxcalc/reforms/TCJA.json +2 -10
  10. taxcalc/reforms/archive/TCJA_Reconciliation.json +1 -1
  11. taxcalc/reforms/archive/TCJA_Senate_111417.json +1 -1
  12. taxcalc/reforms/archive/TCJA_Senate_120117.json +1 -1
  13. taxcalc/reforms/ext.json +1 -1
  14. taxcalc/reforms/growfactors_ext.csv +65 -0
  15. taxcalc/reforms/rounding2022.json +14 -4
  16. taxcalc/taxcalcio.py +4 -0
  17. taxcalc/tests/cmpi_cps_expect.txt +3 -3
  18. taxcalc/tests/cmpi_puf_expect.txt +9 -9
  19. taxcalc/tests/cpscsv_agg_expect.csv +15 -15
  20. taxcalc/tests/puf_var_correl_coeffs_2016.csv +7 -7
  21. taxcalc/tests/puf_var_wght_means_by_year.csv +7 -7
  22. taxcalc/tests/pufcsv_agg_expect.csv +16 -16
  23. taxcalc/tests/pufcsv_mtr_expect.txt +18 -18
  24. taxcalc/tests/reforms_expect.csv +3 -3
  25. taxcalc/tests/test_calcfunctions.py +35 -27
  26. taxcalc/tests/test_reforms.py +2 -2
  27. taxcalc/tests/test_taxcalcio.py +1 -1
  28. taxcalc/tmd_growfactors.csv +54 -54
  29. taxcalc/tmd_weights.csv.gz +0 -0
  30. taxcalc/validation/taxsim35/expected_differences/a21-taxdiffs-expect.csv +2 -2
  31. taxcalc/validation/taxsim35/expected_differences/b18-taxdiffs-expect.csv +7 -7
  32. taxcalc/validation/taxsim35/expected_differences/b19-taxdiffs-expect.csv +7 -7
  33. taxcalc/validation/taxsim35/expected_differences/b20-taxdiffs-expect.csv +7 -7
  34. taxcalc/validation/taxsim35/expected_differences/b21-taxdiffs-expect.csv +25 -25
  35. taxcalc/validation/taxsim35/expected_differences/c18-taxdiffs-expect.csv +8 -8
  36. taxcalc/validation/taxsim35/expected_differences/c19-taxdiffs-expect.csv +8 -8
  37. {taxcalc-4.2.0.dist-info → taxcalc-4.2.2.dist-info}/METADATA +3 -4
  38. {taxcalc-4.2.0.dist-info → taxcalc-4.2.2.dist-info}/RECORD +42 -41
  39. {taxcalc-4.2.0.dist-info → taxcalc-4.2.2.dist-info}/WHEEL +1 -1
  40. {taxcalc-4.2.0.dist-info → taxcalc-4.2.2.dist-info}/LICENSE +0 -0
  41. {taxcalc-4.2.0.dist-info → taxcalc-4.2.2.dist-info}/entry_points.txt +0 -0
  42. {taxcalc-4.2.0.dist-info → taxcalc-4.2.2.dist-info}/top_level.txt +0 -0
taxcalc/__init__.py CHANGED
@@ -14,4 +14,4 @@ from taxcalc.taxcalcio import *
14
14
  from taxcalc.utils import *
15
15
  from taxcalc.cli import *
16
16
 
17
- __version__ = '4.2.0'
17
+ __version__ = '4.2.2'
taxcalc/calcfunctions.py CHANGED
@@ -781,7 +781,7 @@ def ItemDedCap(e17500, e18400, e18500, e19200, e19800, e20100, e20400, g20500,
781
781
  e19800: float
782
782
  Itemizable charitable giving: cash/check contributions
783
783
  e20100: float
784
- Itemizable charitalb giving: other than cash/check contributions
784
+ Itemizable charitable giving: other than cash/check contributions
785
785
  e20400: float
786
786
  Itemizable gross (before 10% AGI disregard) casualty or theft loss
787
787
  g20500: float
@@ -887,7 +887,7 @@ def ItemDed(e17500_capped, e18400_capped, e18500_capped, e19200_capped,
887
887
  c17000, c18300, c19200, c19700, c20500, c20800,
888
888
  ID_ps, ID_Medical_frt, ID_Medical_frt_add4aged, ID_Medical_hc,
889
889
  ID_Casualty_frt, ID_Casualty_hc, ID_Miscellaneous_frt,
890
- ID_Miscellaneous_hc, ID_Charity_crt_all, ID_Charity_crt_noncash,
890
+ ID_Miscellaneous_hc, ID_Charity_crt_cash, ID_Charity_crt_noncash,
891
891
  ID_prt, ID_crt, ID_c, ID_StateLocalTax_hc, ID_Charity_frt,
892
892
  ID_Charity_hc, ID_InterestPaid_hc, ID_RealEstate_hc,
893
893
  ID_Medical_c, ID_StateLocalTax_c, ID_RealEstate_c,
@@ -957,8 +957,8 @@ def ItemDed(e17500_capped, e18400_capped, e18500_capped, e19200_capped,
957
957
  Floor (as decimal fraction of AGI) for deductible miscellaneous expenses
958
958
  ID_Miscellaneous_hc: float
959
959
  Miscellaneous expense deduction haircut
960
- ID_Charity_crt_all: float
961
- Ceiling (as decimal fraction of AGI) for all charitable contribution deductions
960
+ ID_Charity_crt_cash: float
961
+ Ceiling (as decimal fraction of AGI) for cash charitable contribution deductions
962
962
  ID_Charity_crt_noncash: float
963
963
  Ceiling (as decimal fraction of AGI) for noncash charitable contribution deductions
964
964
  ID_prt: float
@@ -1047,8 +1047,9 @@ def ItemDed(e17500_capped, e18400_capped, e18500_capped, e19200_capped,
1047
1047
  c19200 = e19200_capped * (1. - ID_InterestPaid_hc)
1048
1048
  c19200 = min(c19200, ID_InterestPaid_c[MARS - 1])
1049
1049
  # Charity
1050
- lim30 = min(ID_Charity_crt_noncash * posagi, e20100_capped)
1051
- c19700 = min(ID_Charity_crt_all * posagi, lim30 + e19800_capped)
1050
+ charity_ded_cash = min(ID_Charity_crt_cash * posagi, e19800_capped)
1051
+ charity_ded_noncash = min(ID_Charity_crt_noncash * posagi, e20100_capped)
1052
+ c19700 = charity_ded_cash + charity_ded_noncash
1052
1053
  # charity floor is zero in present law
1053
1054
  charity_floor = max(ID_Charity_frt * posagi, ID_Charity_f[MARS - 1])
1054
1055
  c19700 = max(0., c19700 - charity_floor) * (1. - ID_Charity_hc)
@@ -1133,9 +1134,9 @@ def AdditionalMedicareTax(e00200, MARS,
1133
1134
 
1134
1135
  @iterate_jit(nopython=True)
1135
1136
  def StdDed(DSI, earned, STD, age_head, age_spouse, STD_Aged, STD_Dep,
1136
- MARS, MIDR, blind_head, blind_spouse, standard, c19700,
1137
- STD_allow_charity_ded_nonitemizers,
1138
- STD_charity_ded_nonitemizers_max):
1137
+ MARS, MIDR, blind_head, blind_spouse, standard,
1138
+ STD_allow_charity_ded_nonitemizers, e19800, ID_Charity_crt_cash,
1139
+ c00100, STD_charity_ded_nonitemizers_max):
1139
1140
  """
1140
1141
  Calculates standard deduction, including standard deduction for
1141
1142
  dependents, aged and bind.
@@ -1166,12 +1167,16 @@ def StdDed(DSI, earned, STD, age_head, age_spouse, STD_Aged, STD_Dep,
1166
1167
  1 if spouse is blind, 0 otherwise
1167
1168
  standard: float
1168
1169
  Standard deduction (zero for itemizers)
1169
- c19700: float
1170
- Schedule A: charity contributions deducted
1171
1170
  STD_allow_charity_ded_nonitemizers: bool
1172
1171
  Allow standard deduction filers to take the charitable contributions deduction
1172
+ e19800: float
1173
+ Schedule A: cash charitable contributions
1174
+ ID_Charity_crt_cash: float
1175
+ Fraction of AGI cap on cash charitable deductions
1176
+ c00100: float
1177
+ Federal AGI
1173
1178
  STD_charity_ded_nonitemizers_max: float
1174
- Ceiling amount (in dollars) for charitable deductions for non-itemizers
1179
+ Ceiling amount (in dollars) for charitable deductions for nonitemizers
1175
1180
 
1176
1181
  Returns
1177
1182
  -------
@@ -1199,13 +1204,15 @@ def StdDed(DSI, earned, STD, age_head, age_spouse, STD_Aged, STD_Dep,
1199
1204
  standard = basic_stded + extra_stded
1200
1205
  if MARS == 3 and MIDR == 1:
1201
1206
  standard = 0.
1207
+ # calculate CARES cash charity deduction for nonitemizers
1202
1208
  if STD_allow_charity_ded_nonitemizers:
1203
- standard += min(c19700, STD_charity_ded_nonitemizers_max)
1209
+ capped_ded = min(e19800, ID_Charity_crt_cash * c00100)
1210
+ standard += min(capped_ded, STD_charity_ded_nonitemizers_max[MARS - 1])
1204
1211
  return standard
1205
1212
 
1206
1213
 
1207
1214
  @iterate_jit(nopython=True)
1208
- def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, e26270,
1215
+ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
1209
1216
  e02100, e27200, e00650, c01000, PT_SSTB_income,
1210
1217
  PT_binc_w2_wages, PT_ubia_property, PT_qbid_rt,
1211
1218
  PT_qbid_taxinc_thd, PT_qbid_taxinc_gap, PT_qbid_w2_wages_rt,
@@ -1229,6 +1236,8 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, e26270,
1229
1236
  Filing (marital) status. (1=single, 2=joint, 3=separate, 4=household-head, 5=widow(er))
1230
1237
  e00900: float
1231
1238
  Schedule C business net profit/loss for filing unit
1239
+ c03260: float
1240
+ Self-employment (SECA) tax above-the-line deduction
1232
1241
  e26270: float
1233
1242
  Schedule E: combined partnership and S-corporation net income/loss
1234
1243
  e02100: float
@@ -1280,7 +1289,7 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, e26270,
1280
1289
  pre_qbid_taxinc = max(0., c00100 - max(c04470, standard) - c04600)
1281
1290
  # calculate qualified business income deduction
1282
1291
  qbided = 0.
1283
- qbinc = max(0., e00900 + e26270 + e02100 + e27200)
1292
+ qbinc = max(0., e00900 - c03260 + e26270 + e02100 + e27200)
1284
1293
  if qbinc > 0. and PT_qbid_rt > 0.:
1285
1294
  qbid_before_limits = qbinc * PT_qbid_rt
1286
1295
  lower_thd = PT_qbid_taxinc_thd[MARS - 1]
@@ -1899,7 +1908,7 @@ def AGIsurtax(c00100, MARS, AGI_surtax_trt, AGI_surtax_thd, taxbc, surtax):
1899
1908
  def AMT(e07300, dwks13, standard, f6251, c00100, c18300, taxbc,
1900
1909
  c04470, c17000, c20800, c21040, e24515, MARS, sep, dwks19,
1901
1910
  dwks14, c05700, e62900, e00700, dwks10, age_head, age_spouse,
1902
- earned, cmbtp,
1911
+ earned, cmbtp, qbided,
1903
1912
  AMT_child_em_c_age, AMT_brk1,
1904
1913
  AMT_em, AMT_prt, AMT_rt1, AMT_rt2,
1905
1914
  AMT_child_em, AMT_em_ps, AMT_em_pe,
@@ -1936,7 +1945,7 @@ def AMT(e07300, dwks13, standard, f6251, c00100, c18300, taxbc,
1936
1945
  c20800: float
1937
1946
  Schedule A: net limited miscellaneous deductions deducted
1938
1947
  c21040: float
1939
- Itemized deductiosn that are phased out
1948
+ Itemized deductions that are phased out
1940
1949
  e24515: float
1941
1950
  Schedule D: Un-Recaptured Section 1250 Gain
1942
1951
  MARS: int
@@ -1963,6 +1972,8 @@ def AMT(e07300, dwks13, standard, f6251, c00100, c18300, taxbc,
1963
1972
  Earned income for filing unit
1964
1973
  cmbtp: float
1965
1974
  Estimate of income on (AMT) Form 6251 but not in AGI
1975
+ qbided: float
1976
+ Qualified business income deduction
1966
1977
  AMT_child_em_c_age: float
1967
1978
  Age ceiling for special AMT exemption
1968
1979
  AMT_brk1: float
@@ -2014,11 +2025,11 @@ def AMT(e07300, dwks13, standard, f6251, c00100, c18300, taxbc,
2014
2025
  # pylint: disable=too-many-statements,too-many-branches
2015
2026
  # Form 6251, Part I
2016
2027
  if standard == 0.0:
2017
- c62100 = (c00100 - e00700 - c04470 +
2028
+ c62100 = (c00100 - e00700 - qbided - c04470 +
2018
2029
  max(0., min(c17000, 0.025 * c00100)) +
2019
2030
  c18300 + c20800 - c21040)
2020
2031
  if standard > 0.0:
2021
- c62100 = c00100 - e00700
2032
+ c62100 = c00100 - e00700 - qbided
2022
2033
  c62100 += cmbtp # add income not in AGI but considered income for AMT
2023
2034
  if MARS == 3:
2024
2035
  amtsepadd = max(0.,
@@ -2136,7 +2147,8 @@ def NetInvIncTax(e00300, e00600, e02000, e26270, c01000,
2136
2147
  @iterate_jit(nopython=True)
2137
2148
  def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
2138
2149
  exact, c00100, CDCC_ps, CDCC_ps2, CDCC_crt, CDCC_frt,
2139
- CDCC_prt, CDCC_refundable, c05800, e07300, c07180, CDCC_refund):
2150
+ CDCC_po_step_size, CDCC_po_rate_per_step, CDCC_refundable,
2151
+ c05800, e07300, c07180, CDCC_refund):
2140
2152
  """
2141
2153
  Calculates Form 2441 child and dependent care expense credit, c07180.
2142
2154
 
@@ -2166,16 +2178,18 @@ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
2166
2178
  Child/dependent care credit phaseout rate ceiling
2167
2179
  CDCC_frt: float
2168
2180
  Child/dependent care credit phaseout rate floor
2169
- CDCC_prt: float
2170
- Child/dependent care credit phaseout rate
2181
+ CDCC_po_step_size: float
2182
+ Child/dependent care credit phaseout AGI step size
2183
+ CDCC_po_rate_per_step: float
2184
+ Child/dependent care credit phaseout rate per step size
2185
+ CDCC_refund: bool
2186
+ Indicator for whether CDCC is refundable
2171
2187
  c05800: float
2172
2188
  Total (regular + AMT) income tax liability before credits
2173
2189
  e07300: float
2174
2190
  Foreign tax credit from Form 1116
2175
2191
  c07180: float
2176
2192
  Credit for child and dependent care expenses from Form 2441
2177
- CDCC_refund: bool
2178
- Indicator for whether CDCC is refundable
2179
2193
 
2180
2194
  Returns
2181
2195
  -------
@@ -2192,22 +2206,22 @@ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
2192
2206
  else:
2193
2207
  c32890 = earned_p
2194
2208
  c33000 = max(0., min(c32800, min(c32880, c32890)))
2195
- # credit is limited by AGI-related fraction
2209
+ # credit rate is limited at high AGI
2210
+ # ... first phase-down from CDCC_crt to CDCC_frt
2211
+ steps_fractional = max(0., c00100 - CDCC_ps) / CDCC_po_step_size
2196
2212
  if exact == 1: # exact calculation as on tax forms
2197
- # first phase-down from 35 to 20 percent
2198
- tratio1 = math.ceil(max(((c00100 - CDCC_ps) * CDCC_prt), 0.))
2199
- crate = max(CDCC_frt, CDCC_crt - min(CDCC_crt - CDCC_frt, tratio1))
2200
- # second phase-down from 20 percent to zero
2201
- if c00100 > CDCC_ps2:
2202
- tratio2 = math.ceil(max(((c00100 - CDCC_ps2) * CDCC_prt), 0.))
2203
- crate = max(0., CDCC_frt - min(CDCC_frt, tratio2))
2213
+ steps = math.ceil(steps_fractional)
2204
2214
  else:
2205
- crate = max(CDCC_frt, CDCC_crt -
2206
- max(((c00100 - CDCC_ps) * CDCC_prt), 0.))
2207
- if c00100 > CDCC_ps2:
2208
- crate = max(0., CDCC_frt -
2209
- max(((c00100 - CDCC_ps2) * CDCC_prt), 0.))
2210
-
2215
+ steps = steps_fractional
2216
+ crate = max(CDCC_frt, CDCC_crt - steps * CDCC_po_rate_per_step)
2217
+ # ... second phase-down from CDCC_frt to zero
2218
+ if c00100 > CDCC_ps2:
2219
+ steps_fractional = (c00100 - CDCC_ps2) / CDCC_po_step_size
2220
+ if exact == 1: # exact calculation as on tax forms
2221
+ steps = math.ceil(steps_fractional)
2222
+ else:
2223
+ steps = steps_fractional
2224
+ crate = max(0., CDCC_frt - steps * CDCC_po_rate_per_step)
2211
2225
  c33200 = c33000 * crate
2212
2226
  # credit is limited by tax liability if not refundable
2213
2227
  if CDCC_refundable:
@@ -2441,7 +2455,7 @@ def ChildDepTaxCredit(age_head, age_spouse, nu18, n24, MARS, c00100, XTOT, num,
2441
2455
  c07200,
2442
2456
  CTC_c, CTC_ps, CTC_prt, exact, ODC_c,
2443
2457
  CTC_c_under6_bonus, nu06,
2444
- CTC_refundable, CTC_include17,
2458
+ CTC_is_refundable, CTC_include17,
2445
2459
  c07220, odc, codtc_limited):
2446
2460
  """
2447
2461
  Computes amounts on "Child Tax Credit and Credit for Other Dependents
@@ -2540,7 +2554,7 @@ def ChildDepTaxCredit(age_head, age_spouse, nu18, n24, MARS, c00100, XTOT, num,
2540
2554
  line13 = line11 - line12
2541
2555
  line14 = 0.
2542
2556
  line15 = max(0., line13 - line14)
2543
- if CTC_refundable:
2557
+ if CTC_is_refundable:
2544
2558
  c07220 = line10 * line1 / line3
2545
2559
  odc = max(0., line10 - c07220)
2546
2560
  codtc_limited = max(0., line10 - c07220 - odc)
@@ -2795,7 +2809,7 @@ def SchR(age_head, age_spouse, MARS, c00100,
2795
2809
 
2796
2810
 
2797
2811
  @iterate_jit(nopython=True)
2798
- def EducationTaxCredit(exact, e87530, MARS, c00100, num, c05800,
2812
+ def EducationTaxCredit(exact, e87530, MARS, c00100, c05800,
2799
2813
  e07300, c07180, c07200, c87668,
2800
2814
  LLC_Expense_c, ETC_pe_Single, ETC_pe_Married,
2801
2815
  CR_Education_hc,
@@ -2814,8 +2828,6 @@ def EducationTaxCredit(exact, e87530, MARS, c00100, num, c05800,
2814
2828
  Filing (marital) status. (1=single, 2=joint, 3=separate, 4=household-head, 5=widow(er))
2815
2829
  c00100: float
2816
2830
  Adjusted Gross Income (AGI)
2817
- num: int
2818
- 2 when MARS is 2 (married filing jointly), otherwise 1
2819
2831
  c05800: float
2820
2832
  Total (regular + AMT) income tax liability before credits
2821
2833
  e07300: float
@@ -2846,14 +2858,19 @@ def EducationTaxCredit(exact, e87530, MARS, c00100, num, c05800,
2846
2858
  -----
2847
2859
  Tax Law Parameters that are not parameterized:
2848
2860
  0.2: Lifetime Learning Credit ratio against expense
2861
+ 10000.0: AGI range bewteen ETC_pe_Single and single phase-out start;
2862
+ twice this amount for ETC_pe_Married
2849
2863
  """
2850
2864
  c87560 = 0.2 * min(e87530, LLC_Expense_c)
2865
+ # on the following credit phase-out law see:
2866
+ # https://www.law.cornell.edu/uscode/text/26/25A#d_1
2851
2867
  if MARS == 2:
2852
2868
  c87570 = ETC_pe_Married * 1000.
2869
+ c87600 = 20000.
2853
2870
  else:
2854
2871
  c87570 = ETC_pe_Single * 1000.
2872
+ c87600 = 10000.
2855
2873
  c87590 = max(0., c87570 - c00100)
2856
- c87600 = 10000. * num
2857
2874
  if exact == 1: # exact calculation as on tax forms
2858
2875
  c87610 = min(1., round(c87590 / c87600, 3))
2859
2876
  else:
@@ -2910,7 +2927,7 @@ def CharityCredit(e19800, e20100, c00100, CR_Charity_rt, CR_Charity_f,
2910
2927
  def NonrefundableCredits(c05800, e07240, e07260, e07300, e07400,
2911
2928
  e07600, p08000, odc,
2912
2929
  personal_nonrefundable_credit,
2913
- CTC_refundable,
2930
+ CTC_is_refundable,
2914
2931
  CR_RetirementSavings_hc, CR_ForeignTax_hc,
2915
2932
  CR_ResidentialEnergy_hc, CR_GeneralBusiness_hc,
2916
2933
  CR_MinimumTax_hc, CR_OtherCredits_hc, charity_credit,
@@ -2939,7 +2956,7 @@ def NonrefundableCredits(c05800, e07240, e07260, e07300, e07400,
2939
2956
  Other Dependent Credit
2940
2957
  personal_nonrefundable_credit: float
2941
2958
  Personal nonrefundable credit
2942
- CTC_refundable: bool
2959
+ CTC_is_refundable: bool
2943
2960
  Whether the child tax credit is fully refundable
2944
2961
  CR_RetirementSavings_hc: float
2945
2962
  Credit for retirement savings haircut
@@ -3019,7 +3036,7 @@ def NonrefundableCredits(c05800, e07240, e07260, e07300, e07400,
3019
3036
  c07240 = min(e07240 * (1. - CR_RetirementSavings_hc), avail)
3020
3037
  avail = avail - c07240
3021
3038
  # Child tax credit
3022
- if not CTC_refundable:
3039
+ if not CTC_is_refundable:
3023
3040
  c07220 = min(c07220, avail)
3024
3041
  avail = avail - c07220
3025
3042
  # Other dependent credit
@@ -3053,7 +3070,8 @@ def NonrefundableCredits(c05800, e07240, e07260, e07300, e07400,
3053
3070
  @iterate_jit(nopython=True)
3054
3071
  def AdditionalCTC(codtc_limited, ACTC_c, n24, earned, ACTC_Income_thd,
3055
3072
  ACTC_rt, nu06, ACTC_rt_bonus_under6family, ACTC_ChildNum,
3056
- CTC_refundable, CTC_include17, age_head, age_spouse, MARS, nu18,
3073
+ CTC_is_refundable, CTC_include17,
3074
+ age_head, age_spouse, MARS, nu18,
3057
3075
  ptax_was, c03260, e09800, c59660, e11200,
3058
3076
  c11070):
3059
3077
  """
@@ -3101,7 +3119,7 @@ def AdditionalCTC(codtc_limited, ACTC_c, n24, earned, ACTC_Income_thd,
3101
3119
  # Part I
3102
3120
  line3 = codtc_limited
3103
3121
 
3104
- if CTC_refundable:
3122
+ if CTC_is_refundable:
3105
3123
  line4 = 0.
3106
3124
  else:
3107
3125
  if CTC_include17:
@@ -3142,7 +3160,8 @@ def AdditionalCTC(codtc_limited, ACTC_c, n24, earned, ACTC_Income_thd,
3142
3160
  def C1040(c05800, c07180, c07200, c07220, c07230, c07240, c07260, c07300,
3143
3161
  c07400, c07600, c08000, e09700, e09800, e09900, niit, othertaxes,
3144
3162
  c07100, c09200, odc, charity_credit,
3145
- personal_nonrefundable_credit, CTC_refundable, ODC_refundable):
3163
+ personal_nonrefundable_credit,
3164
+ CTC_is_refundable, ODC_is_refundable):
3146
3165
  """
3147
3166
  Computes total used nonrefundable credits, c07100, othertaxes, and
3148
3167
  income tax before refundable credits, c09200.
@@ -3203,8 +3222,9 @@ def C1040(c05800, c07180, c07200, c07220, c07230, c07240, c07260, c07300,
3203
3222
  """
3204
3223
  # total used nonrefundable credits (as computed in NonrefundableCredits)
3205
3224
  c07100 = (c07180 + c07200 + c07600 + c07300 + c07400 +
3206
- c07220 * (1. - CTC_refundable) + c08000 +
3207
- c07230 + c07240 + c07260 + odc * (1. - ODC_refundable) + charity_credit +
3225
+ c07220 * (1. - CTC_is_refundable) + c08000 +
3226
+ c07230 + c07240 + c07260 +
3227
+ odc * (1. - ODC_is_refundable) + charity_credit +
3208
3228
  personal_nonrefundable_credit)
3209
3229
  # tax after credits (2016 Form 1040, line 56)
3210
3230
  tax_net_nonrefundable_credits = max(0., c05800 - c07100)
@@ -3305,8 +3325,8 @@ def CTC_new(CTC_new_c, CTC_new_rt, CTC_new_c_under6_bonus,
3305
3325
  @iterate_jit(nopython=True)
3306
3326
  def IITAX(c59660, c11070, c10960, personal_refundable_credit, ctc_new, rptc,
3307
3327
  c09200, payrolltax, CDCC_refund, recovery_rebate_credit,
3308
- eitc, c07220, odc, CTC_refundable, ODC_refundable, refund,
3309
- ctc_total, ctc_refundable, iitax, combined):
3328
+ eitc, c07220, odc, CTC_is_refundable, ODC_is_refundable, refund,
3329
+ ctc_total, ctc_refundable, ctc_nonrefundable, iitax, combined):
3310
3330
  """
3311
3331
  Computes final taxes.
3312
3332
 
@@ -3352,17 +3372,19 @@ def IITAX(c59660, c11070, c10960, personal_refundable_credit, ctc_new, rptc,
3352
3372
  Total CTC amount (c07220 + c11070 + odc + ctc_new)
3353
3373
  ctc_refundable: float
3354
3374
  Portion of total CTC amount that is refundable
3375
+ ctc_nonrefundable: float
3376
+ Portion of total CTC amount that is nonrefundable
3355
3377
  iitax: float
3356
3378
  Total federal individual income tax liability
3357
3379
  combined: float
3358
3380
  Sum of iitax and payrolltax and lumpsum_tax
3359
3381
  """
3360
3382
  eitc = c59660
3361
- if CTC_refundable:
3383
+ if CTC_is_refundable:
3362
3384
  ctc_refund = c07220
3363
3385
  else:
3364
3386
  ctc_refund = 0.
3365
- if ODC_refundable:
3387
+ if ODC_is_refundable:
3366
3388
  odc_refund = odc
3367
3389
  else:
3368
3390
  odc_refund = 0.
@@ -3371,9 +3393,11 @@ def IITAX(c59660, c11070, c10960, personal_refundable_credit, ctc_new, rptc,
3371
3393
  odc_refund)
3372
3394
  ctc_total = c07220 + c11070 + odc + ctc_new
3373
3395
  ctc_refundable = ctc_refund + c11070 + odc_refund + ctc_new
3396
+ ctc_nonrefundable = max(0., ctc_total - ctc_refundable)
3374
3397
  iitax = c09200 - refund
3375
3398
  combined = iitax + payrolltax
3376
- return (eitc, refund, ctc_total, ctc_refundable, iitax, combined)
3399
+ return (eitc, refund, ctc_total, ctc_refundable, ctc_nonrefundable,
3400
+ iitax, combined)
3377
3401
 
3378
3402
 
3379
3403
  @JIT(nopython=True)
taxcalc/data.py CHANGED
@@ -102,7 +102,7 @@ class Data():
102
102
  # ... weights must be same size as data
103
103
  if self.array_length > len(self.WT.index):
104
104
  raise ValueError("Data has more records than weights.")
105
- elif self.array_length < len(self.WT.index):
105
+ if self.array_length < len(self.WT.index):
106
106
  # scale-up sub-sample weights by year-specific factor
107
107
  sum_full_weights = self.WT.sum()
108
108
  self.WT = self.WT.iloc[self.__index]
@@ -110,9 +110,11 @@ class Data():
110
110
  factor = sum_full_weights / sum_sub_weights
111
111
  self.WT *= factor
112
112
  # ... construct sample weights for current_year
113
- wt_colname = 'WT{}'.format(self.current_year)
114
- if wt_colname in self.WT.columns:
115
- self.s006 = self.WT[wt_colname] * 0.01
113
+ wt_colname = f'WT{self.current_year}'
114
+ assert wt_colname in self.WT.columns, (
115
+ f'no weights for start year {self.current_year}'
116
+ )
117
+ self.s006 = self.WT[wt_colname] * 0.01
116
118
 
117
119
  @property
118
120
  def data_year(self):
@@ -146,7 +148,10 @@ class Data():
146
148
  # ... apply variable extrapolation growth factors
147
149
  self._extrapolate(self.__current_year)
148
150
  # ... specify current-year sample weights
149
- wt_colname = 'WT{}'.format(self.__current_year)
151
+ wt_colname = f'WT{self.__current_year}'
152
+ assert wt_colname in self.WT.columns, (
153
+ f'no weights for new year {self.current_year}'
154
+ )
150
155
  self.s006 = self.WT[wt_colname] * 0.01
151
156
 
152
157
  # ----- begin private methods of Data class -----