taxcalc 5.0.0__py3-none-any.whl → 5.0.4__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.
taxcalc/calcfunctions.py CHANGED
@@ -16,7 +16,6 @@ Note: the parameter_indexing_CPI_offset parameter is no longer used.
16
16
  # pylint: disable=too-many-locals
17
17
 
18
18
  import math
19
- import copy
20
19
  import numpy as np
21
20
  from taxcalc.decorators import iterate_jit, JIT
22
21
 
@@ -349,7 +348,12 @@ def Adj(e03150, e03210, c03260,
349
348
  ALD_EarlyWithdraw_hc, ALD_AlimonyPaid_hc, ALD_AlimonyReceived_hc,
350
349
  ALD_EducatorExpenses_hc, ALD_HSADeduction_hc, ALD_IRAContributions_hc,
351
350
  ALD_DomesticProduction_hc, ALD_Tuition_hc,
352
- c02900):
351
+ MARS, earned,
352
+ overtime_income, ALD_OvertimeIncome_hc, ALD_OvertimeIncome_c,
353
+ ALD_OvertimeIncome_ps, ALD_OvertimeIncome_prt,
354
+ tip_income, ALD_TipIncome_hc, ALD_TipIncome_c,
355
+ ALD_TipIncome_ps, ALD_TipIncome_prt,
356
+ c02900, ALD_OvertimeIncome, ALD_TipIncome):
353
357
  """
354
358
  Adj calculates Form 1040 AGI adjustments (i.e., Above-the-Line Deductions).
355
359
 
@@ -403,11 +407,40 @@ def Adj(e03150, e03210, c03260,
403
407
  Domestic production haircut
404
408
  ALD_Tuition_hc: float
405
409
  Tuition and fees haircut
410
+ MARS: int
411
+ Filing marital status (1=single, 2=joint, 3=separate,
412
+ 4=household-head, 5=widow(er))
413
+ earned: float
414
+ Earned income used to phase-out ALD_OvertimeIncome and ALD_TipIncome
415
+ overtime_income: float
416
+ Overtime income qualified for an above-the-line deduction
417
+ ALD_OvertimeIncome_hc: float
418
+ ALD_OvertimeIncome haircut
419
+ ALD_OvertimeIncome_c: list[float]
420
+ ALD_OvertimeIncome cap
421
+ ALD_OvertimeIncome_ps: list[float]
422
+ ALD_OvertimeIncome phase-out earned income start
423
+ ALD_OvertimeIncome_prt: float
424
+ ALD_OvertimeIncome phase-out rate
425
+ tip_income: float
426
+ Tip income qualified for an above-the-line deduction
427
+ ALD_TipIncome_hc: float
428
+ ALD_TipIncome haircut
429
+ ALD_TipIncome_c: list[float]
430
+ ALD_TipIncome cap
431
+ ALD_TipIncome_ps: list[float]
432
+ ALD_TipIncome phase-out earned income start
433
+ ALD_TipIncome_prt: float
434
+ ALD_TipIncome phase-out rate
406
435
 
407
436
  Returns
408
437
  -------
409
438
  c02900: float
410
439
  Total of all "above the line" income adjustments to get AGI
440
+ ALD_OvertimeIncome: float
441
+ Overtime ALD amount included in c02900
442
+ ALD_TipIncome: float
443
+ Tip ALD amount included in c02900
411
444
  """
412
445
  # Form 2555 foreign earned income exclusion is assumed to be zero
413
446
  # Form 1040 adjustments that are included in expanded income:
@@ -424,7 +457,29 @@ def Adj(e03150, e03210, c03260,
424
457
  (1. - ALD_IRAContributions_hc) * e03150 +
425
458
  (1. - ALD_KEOGH_SEP_hc) * e03300 +
426
459
  care_deduction)
427
- return c02900
460
+ # calculate ALD_OvertimeIncome
461
+ ALD_OvertimeIncome = 0.
462
+ if overtime_income > 0. and ALD_OvertimeIncome_hc < 1.0:
463
+ ded = min(overtime_income, ALD_OvertimeIncome_c[MARS - 1])
464
+ po_start = ALD_OvertimeIncome_ps[MARS - 1]
465
+ if earned > po_start:
466
+ excess = earned - po_start
467
+ po_amount = excess * ALD_OvertimeIncome_prt
468
+ ded = max(0., ded - po_amount)
469
+ ALD_OvertimeIncome = ded
470
+ # calculate ALD_TipIncome
471
+ ALD_TipIncome = 0.
472
+ if tip_income > 0. and ALD_TipIncome_hc < 1.0:
473
+ ded = min(tip_income, ALD_TipIncome_c[MARS - 1])
474
+ po_start = ALD_TipIncome_ps[MARS - 1]
475
+ if earned > po_start:
476
+ excess = earned - po_start
477
+ po_amount = excess * ALD_TipIncome_prt
478
+ ded = max(0., ded - po_amount)
479
+ ALD_TipIncome = ded
480
+ # return results
481
+ c02900 += ALD_OvertimeIncome + ALD_TipIncome
482
+ return (c02900, ALD_OvertimeIncome, ALD_TipIncome)
428
483
 
429
484
 
430
485
  @iterate_jit(nopython=True)
@@ -698,7 +753,7 @@ def UBI(nu18, n1820, n21, UBI_u18, UBI_1820, UBI_21, UBI_ecrt,
698
753
 
699
754
  @iterate_jit(nopython=True)
700
755
  def AGI(ymod1, c02500, c02900, XTOT, MARS, sep, DSI, exact, nu18, taxable_ubi,
701
- II_em, II_em_ps, II_prt, II_no_em_nu18,
756
+ II_em, II_em_ps, II_em_prt, II_no_em_nu18,
702
757
  e02300, UI_thd, UI_em, c00100, pre_c04600, c04600):
703
758
  """
704
759
  Computes Adjusted Gross Income (AGI), c00100, and
@@ -731,7 +786,7 @@ def AGI(ymod1, c02500, c02900, XTOT, MARS, sep, DSI, exact, nu18, taxable_ubi,
731
786
  Personal and dependent exemption amount
732
787
  II_em_ps: list
733
788
  Personal exemption phaseout starting income
734
- II_prt: float
789
+ II_em_prt: float
735
790
  Personal exemption phaseout rate
736
791
  II_no_em_nu18: float
737
792
  Repeal personal exemptions for dependents under age 18
@@ -776,16 +831,73 @@ def AGI(ymod1, c02500, c02900, XTOT, MARS, sep, DSI, exact, nu18, taxable_ubi,
776
831
  if exact == 1: # exact calculation as on tax forms
777
832
  line5 = max(0., c00100 - II_em_ps[MARS - 1])
778
833
  line6 = math.ceil(line5 / (2500. / sep))
779
- line7 = II_prt * line6
834
+ line7 = II_em_prt * line6
780
835
  c04600 = max(0., pre_c04600 * (1. - line7))
781
836
  else: # smoothed calculation needed for sensible mtr calculation
782
- dispc_numer = II_prt * (c00100 - II_em_ps[MARS - 1])
837
+ dispc_numer = II_em_prt * (c00100 - II_em_ps[MARS - 1])
783
838
  dispc_denom = 2500. / sep
784
839
  dispc = min(1., max(0., dispc_numer / dispc_denom))
785
840
  c04600 = pre_c04600 * (1. - dispc)
786
841
  return (c00100, pre_c04600, c04600)
787
842
 
788
843
 
844
+ @iterate_jit(nopython=True)
845
+ def AutoLoanInterestDed(auto_loan_interest, MARS, c00100, exact,
846
+ AutoLoanInterestDed_c,
847
+ AutoLoanInterestDed_ps,
848
+ AutoLoanInterestDed_po_step_size,
849
+ AutoLoanInterestDed_po_rate_per_step,
850
+ auto_loan_interest_deduction):
851
+ """
852
+ Calculates below-the-line deduction on qualified auto loan interest paid.
853
+
854
+ Parameters
855
+ ----------
856
+ auto_loan_interest: float
857
+ Qualified auto loan interest paid
858
+ MARS: int
859
+ Filing marital status (1=single, 2=joint, 3=separate,
860
+ 4=household-head, 5=widow(er))
861
+ c00100: float
862
+ Adjusted gross income
863
+ exact: int
864
+ Whether or not to smooth the deduction phase out
865
+ AutoLoanInterestDed_c: float
866
+ Deduction cap
867
+ AutoLoanInterestDed_ps: float
868
+ Deduction phase-out starts above this AGI
869
+ AutoLoanInterestDed_po_step_size: float
870
+ Deduction phase-out AGI step size
871
+ AutoLoanInterestDed_po_rate_per_step: float
872
+ Deduction phase-out rate per AGI step
873
+ auto_loan_interest_deduction: float
874
+ Deduction available to both itemizers and nonitemizers
875
+
876
+ Returns
877
+ -------
878
+ auto_loan_interest_deduction: float
879
+ Deduction available to both itemizers and nonitemizers
880
+ """
881
+ auto_loan_interest_deduction = 0.
882
+ if AutoLoanInterestDed_c > 0. and auto_loan_interest > 0.:
883
+ # cap deduction
884
+ ded = min(auto_loan_interest, AutoLoanInterestDed_c)
885
+ po_start = AutoLoanInterestDed_ps[MARS - 1]
886
+ if c00100 > po_start:
887
+ # phase out deduction
888
+ excess_agi = c00100 - po_start
889
+ po_rate = AutoLoanInterestDed_po_rate_per_step
890
+ if exact == 1: # exact calculation as on tax forms
891
+ step_size = AutoLoanInterestDed_po_step_size
892
+ steps = math.ceil(excess_agi / step_size)
893
+ po_amount = steps * step_size * po_rate
894
+ else: # smoothed calculation needed for sensible mtr calculation
895
+ po_amount = excess_agi * po_rate
896
+ ded = max(0., ded - po_amount)
897
+ auto_loan_interest_deduction = ded
898
+ return auto_loan_interest_deduction
899
+
900
+
789
901
  @iterate_jit(nopython=True)
790
902
  def ItemDed(e17500, e18400, e18500, e19200,
791
903
  e19800, e20100, e20400, g20500,
@@ -1133,8 +1245,9 @@ def StdDed(DSI, earned, STD, age_head, age_spouse, STD_Aged, STD_Dep,
1133
1245
 
1134
1246
  @iterate_jit(nopython=True)
1135
1247
  def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
1136
- e02100, e27200, e00650, c01000, PT_SSTB_income,
1137
- PT_binc_w2_wages, PT_ubia_property, PT_qbid_rt,
1248
+ e02100, e27200, e00650, c01000, auto_loan_interest_deduction,
1249
+ PT_SSTB_income, PT_binc_w2_wages, PT_ubia_property,
1250
+ PT_qbid_rt, PT_qbid_limited,
1138
1251
  PT_qbid_taxinc_thd, PT_qbid_taxinc_gap, PT_qbid_w2_wages_rt,
1139
1252
  PT_qbid_alt_w2_wages_rt, PT_qbid_alt_property_rt, c04800,
1140
1253
  PT_qbid_ps, PT_qbid_prt, qbided):
@@ -1169,6 +1282,8 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
1169
1282
  Qualified dividends included in ordinary dividends
1170
1283
  c01000: float
1171
1284
  Limitation on capital losses
1285
+ auto_loan_interest_deduction: float
1286
+ Deduction for qualified auto loan interest paid
1172
1287
  PT_SSTB_income: int
1173
1288
  Value of one implies business income is from a specified service
1174
1289
  trade or business (SSTB)
@@ -1182,6 +1297,8 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
1182
1297
  pass-through business
1183
1298
  PT_qbid_rt: float
1184
1299
  Pass-through qualified business income deduction rate
1300
+ PT_qbid_limited: bool
1301
+ Whether or not TCJA QBID limits are active
1185
1302
  PT_qbid_taxinc_thd: list
1186
1303
  Lower threshold of pre-QBID taxable income
1187
1304
  PT_qbid_taxinc_gap: list
@@ -1211,10 +1328,9 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
1211
1328
  # calculate taxable income before qualified business income deduction
1212
1329
  pre_qbid_taxinc = max(0., c00100 - max(c04470, standard) - c04600)
1213
1330
  # calculate qualified business income deduction
1214
- qbided = 0.
1215
1331
  qbinc = max(0., e00900 - c03260 + e26270 + e02100 + e27200)
1216
- if qbinc > 0. and PT_qbid_rt > 0.:
1217
- qbid_before_limits = qbinc * PT_qbid_rt
1332
+ qbid_before_limits = qbinc * PT_qbid_rt
1333
+ if PT_qbid_limited:
1218
1334
  lower_thd = PT_qbid_taxinc_thd[MARS - 1]
1219
1335
  if pre_qbid_taxinc <= lower_thd:
1220
1336
  qbided = qbid_before_limits
@@ -1244,19 +1360,20 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
1244
1360
  prt = (pre_qbid_taxinc - lower_thd) / pre_qbid_taxinc_gap
1245
1361
  adj = prt * (qbid_adjusted - cap_adjusted)
1246
1362
  qbided = qbid_adjusted - adj
1247
-
1248
1363
  # apply taxinc cap (assuming cap rate is equal to PT_qbid_rt)
1249
- net_cg = e00650 + c01000 # per line 34 in 2018 Pub 535 Worksheet 12-A
1364
+ # net_cg is defined on line 34 of 2018 Pub 535 Worksheet 12-A
1365
+ net_cg = e00650 + c01000
1250
1366
  taxinc_cap = PT_qbid_rt * max(0., pre_qbid_taxinc - net_cg)
1251
1367
  qbided = min(qbided, taxinc_cap)
1252
-
1253
1368
  # apply qbid phaseout
1254
1369
  if qbided > 0. and pre_qbid_taxinc > PT_qbid_ps[MARS - 1]:
1255
1370
  excess = pre_qbid_taxinc - PT_qbid_ps[MARS - 1]
1256
1371
  qbided = max(0., qbided - PT_qbid_prt * excess)
1372
+ else: # if PT_qbid_limited is false
1373
+ qbided = qbid_before_limits
1257
1374
 
1258
1375
  # calculate taxable income after qualified business income deduction
1259
- c04800 = max(0., pre_qbid_taxinc - qbided)
1376
+ c04800 = max(0., pre_qbid_taxinc - qbided - auto_loan_interest_deduction)
1260
1377
  return (c04800, qbided)
1261
1378
 
1262
1379
 
@@ -1267,75 +1384,85 @@ def SchXYZ(taxable_income, MARS,
1267
1384
  II_brk1, II_brk2, II_brk3, II_brk4, II_brk5,
1268
1385
  II_brk6, II_brk7):
1269
1386
  """
1270
- Returns Schedule X, Y, Z tax amount for specified taxable_income.
1387
+ Taxes function returns tax amount given the progressive tax rate
1388
+ schedule specified by the II_rt? and (upper) II_brk? parameters and
1389
+ given taxable income and filing status (MARS).
1271
1390
 
1272
1391
  Parameters
1273
1392
  ----------
1274
1393
  taxable_income: float
1275
- Taxable income
1394
+ Regular taxable income
1276
1395
  MARS: int
1277
1396
  Filing (marital) status. (1=single, 2=joint, 3=separate,
1278
1397
  4=household-head, 5=widow(er))
1279
- e00900: float
1280
- Schedule C business net profit/loss for filing unit
1281
- e26270: float
1282
- Schedule E: combined partnership and S-corporation net income/loss
1283
- e02000: float
1284
- Schedule E total rental, royalty, parternship, S-corporation,
1285
- etc, income/loss
1286
- e00200: float
1287
- Wages, salaries, and tips for filing unit net of pension contributions
1288
1398
  II_rt1: float
1289
- Personal income (regular/non-AMT/non-pass-through) tax rate 1
1399
+ Personal income (regular/non-AMT) tax rate 1
1290
1400
  II_rt2: float
1291
- Personal income (regular/non-AMT/non-pass-through) tax rate 2
1401
+ Personal income (regular/non-AMT) tax rate 2
1292
1402
  II_rt3: float
1293
- Personal income (regular/non-AMT/non-pass-through) tax rate 3
1403
+ Personal income (regular/non-AMT) tax rate 3
1294
1404
  II_rt4: float
1295
- Personal income (regular/non-AMT/non-pass-through) tax rate 4
1405
+ Personal income (regular/non-AMT) tax rate 4
1296
1406
  II_rt5: float
1297
- Personal income (regular/non-AMT/non-pass-through) tax rate 5
1407
+ Personal income (regular/non-AMT) tax rate 5
1298
1408
  II_rt6: float
1299
- Personal income (regular/non-AMT/non-pass-through) tax rate 6
1409
+ Personal income (regular/non-AMT) tax rate 6
1300
1410
  II_rt7: float
1301
- Personal income (regular/non-AMT/non-pass-through) tax rate 7
1411
+ Personal income (regular/non-AMT) tax rate 7
1302
1412
  II_rt8: float
1303
- Personal income (regular/non-AMT/non-pass-through) tax rate 8
1413
+ Personal income (regular/non-AMT) tax rate 8
1304
1414
  II_brk1: list
1305
- Personal income (regular/non-AMT/non-pass/through)
1306
- tax bracket (upper threshold) 1
1415
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 1
1307
1416
  II_brk2: list
1308
- Personal income (regular/non-AMT/non-pass/through)
1309
- tax bracket (upper threshold) 2
1417
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 2
1310
1418
  II_brk3: list
1311
- Personal income (regular/non-AMT/non-pass/through)
1312
- tax bracket (upper threshold) 3
1419
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 3
1313
1420
  II_brk4: list
1314
- Personal income (regular/non-AMT/non-pass/through)
1315
- tax bracket (upper threshold) 4
1421
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 4
1316
1422
  II_brk5: list
1317
- Personal income (regular/non-AMT/non-pass/through)
1318
- tax bracket (upper threshold) 5
1423
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 5
1319
1424
  II_brk6: list
1320
- Personal income (regular/non-AMT/non-pass/through)
1321
- tax bracket (upper threshold) 6
1425
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 6
1322
1426
  II_brk7: list
1323
- Personal income (regular/non-AMT/non-pass/through)
1324
- tax bracket (upper threshold) 7
1427
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 7
1325
1428
 
1326
1429
  Returns
1327
1430
  -------
1328
- reg_tax: float
1329
- Individual income tax liability on all taxable income
1330
- """
1331
- # compute Schedule X,Y,Z tax using taxable income
1332
- reg_tax = 0.
1333
- if taxable_income > 0.:
1334
- reg_tax = Taxes(taxable_income, MARS, 0.0,
1335
- II_rt1, II_rt2, II_rt3, II_rt4,
1336
- II_rt5, II_rt6, II_rt7, II_rt8, II_brk1, II_brk2,
1337
- II_brk3, II_brk4, II_brk5, II_brk6, II_brk7)
1338
- return reg_tax
1431
+ Regular individual income tax liability on all taxable income
1432
+ """
1433
+ # pylint: disable=too-many-return-statements
1434
+ if taxable_income <= 0.:
1435
+ return 0.
1436
+ tax = 0.
1437
+ brk0 = 0.
1438
+ brk1 = II_brk1[MARS - 1]
1439
+ if taxable_income <= brk1:
1440
+ return tax + II_rt1 * (taxable_income - brk0)
1441
+ tax = tax + II_rt1 * (brk1 - brk0)
1442
+ brk2 = II_brk2[MARS - 1]
1443
+ if taxable_income <= brk2:
1444
+ return tax + II_rt2 * (taxable_income - brk1)
1445
+ tax = tax + II_rt2 * (brk2 - brk1)
1446
+ brk3 = II_brk3[MARS - 1]
1447
+ if taxable_income <= brk3:
1448
+ return tax + II_rt3 * (taxable_income - brk2)
1449
+ tax = tax + II_rt3 * (brk3 - brk2)
1450
+ brk4 = II_brk4[MARS - 1]
1451
+ if taxable_income <= brk4:
1452
+ return tax + II_rt4 * (taxable_income - brk3)
1453
+ tax = tax + II_rt4 * (brk4 - brk3)
1454
+ brk5 = II_brk5[MARS - 1]
1455
+ if taxable_income <= brk5:
1456
+ return tax + II_rt5 * (taxable_income - brk4)
1457
+ tax = tax + II_rt5 * (brk5 - brk4)
1458
+ brk6 = II_brk6[MARS - 1]
1459
+ if taxable_income <= brk6:
1460
+ return tax + II_rt6 * (taxable_income - brk5)
1461
+ tax = tax + II_rt6 * (brk6 - brk5)
1462
+ brk7 = II_brk7[MARS - 1]
1463
+ if taxable_income <= brk7:
1464
+ return tax + II_rt7 * (taxable_income - brk6)
1465
+ return tax + II_rt8 * (taxable_income - brk7)
1339
1466
 
1340
1467
 
1341
1468
  @iterate_jit(nopython=True)
@@ -1355,41 +1482,41 @@ def SchXYZTax(c04800, MARS,
1355
1482
  Filing (marital) status. (1=single, 2=joint, 3=separate,
1356
1483
  4=household-head, 5=widow(er))
1357
1484
  II_rt1: float
1358
- Personal income (regular/non-AMT/non-pass-through) tax rate 1
1485
+ Personal income (regular/non-AMT) tax rate 1
1359
1486
  II_rt2: float
1360
- Personal income (regular/non-AMT/non-pass-through) tax rate 2
1487
+ Personal income (regular/non-AMT) tax rate 2
1361
1488
  II_rt3: float
1362
- Personal income (regular/non-AMT/non-pass-through) tax rate 3
1489
+ Personal income (regular/non-AMT) tax rate 3
1363
1490
  II_rt4: float
1364
- Personal income (regular/non-AMT/non-pass-through) tax rate 4
1491
+ Personal income (regular/non-AMT) tax rate 4
1365
1492
  II_rt5: float
1366
- Personal income (regular/non-AMT/non-pass-through) tax rate 5
1493
+ Personal income (regular/non-AMT) tax rate 5
1367
1494
  II_rt6: float
1368
- Personal income (regular/non-AMT/non-pass-through) tax rate 6
1495
+ Personal income (regular/non-AMT) tax rate 6
1369
1496
  II_rt7: float
1370
- Personal income (regular/non-AMT/non-pass-through) tax rate 7
1497
+ Personal income (regular/non-AMT) tax rate 7
1371
1498
  II_rt8: float
1372
- Personal income (regular/non-AMT/non-pass-through) tax rate 8
1499
+ Personal income (regular/non-AMT) tax rate 8
1373
1500
  II_brk1: list
1374
- Personal income (regular/non-AMT/non-pass/through)
1501
+ Personal income (regular/non-AMT)
1375
1502
  tax bracket (upper threshold) 1
1376
1503
  II_brk2: list
1377
- Personal income (regular/non-AMT/non-pass/through)
1504
+ Personal income (regular/non-AMT)
1378
1505
  tax bracket (upper threshold) 2
1379
1506
  II_brk3: list
1380
- Personal income (regular/non-AMT/non-pass/through)
1507
+ Personal income (regular/non-AMT)
1381
1508
  tax bracket (upper threshold) 3
1382
1509
  II_brk4: list
1383
- Personal income (regular/non-AMT/non-pass/through)
1510
+ Personal income (regular/non-AMT)
1384
1511
  tax bracket (upper threshold) 4
1385
1512
  II_brk5: list
1386
- Personal income (regular/non-AMT/non-pass/through)
1513
+ Personal income (regular/non-AMT)
1387
1514
  tax bracket (upper threshold) 5
1388
1515
  II_brk6: list
1389
- Personal income (regular/non-AMT/non-pass/through)
1516
+ Personal income (regular/non-AMT)
1390
1517
  tax bracket (upper threshold) 6
1391
1518
  II_brk7: list
1392
- Personal income (regular/non-AMT/non-pass/through)
1519
+ Personal income (regular/non-AMT)
1393
1520
  tax bracket (upper threshold) 7
1394
1521
  c05200: float
1395
1522
  Tax amount from Schedule X,Y,Z tables
@@ -1399,11 +1526,11 @@ def SchXYZTax(c04800, MARS,
1399
1526
  c05200: float
1400
1527
  Tax amount from Schedule X, Y, Z tables
1401
1528
  """
1402
- c05200 = SchXYZ(c04800, MARS,
1403
- II_rt1, II_rt2, II_rt3, II_rt4, II_rt5,
1404
- II_rt6, II_rt7, II_rt8,
1405
- II_brk1, II_brk2, II_brk3, II_brk4, II_brk5,
1406
- II_brk6, II_brk7)
1529
+ c05200 = SchXYZ(
1530
+ c04800, MARS,
1531
+ II_rt1, II_rt2, II_rt3, II_rt4, II_rt5, II_rt6, II_rt7, II_rt8,
1532
+ II_brk1, II_brk2, II_brk3, II_brk4, II_brk5, II_brk6, II_brk7
1533
+ )
1407
1534
  return c05200
1408
1535
 
1409
1536
 
@@ -1434,8 +1561,6 @@ def GainsTax(e00650, c01000, c23650, p23250, e01100, e58990,
1434
1561
  Capital gains distributions not reported on Schedule D
1435
1562
  e58990: float
1436
1563
  Investment income elected amount from Form 4952
1437
- e00200: float
1438
- Wages, salaries, and tips for filing unit net of pension contributions
1439
1564
  e24515: float
1440
1565
  Schedule D: un-recaptured section 1250 Gain
1441
1566
  e24518: float
@@ -1447,49 +1572,42 @@ def GainsTax(e00650, c01000, c23650, p23250, e01100, e58990,
1447
1572
  Regular taxable income
1448
1573
  c05200: float
1449
1574
  Tax amount from Schedule X,Y,Z tables
1450
- e00900: float
1451
- Schedule C business net profit/loss for filing unit
1452
- e26270: float
1453
- Schedule E: combined partnership and S-corporation net income/loss
1454
- e02000: float
1455
- Schedule E total rental, royalty, partnership, S-corporation,
1456
- etc, income/loss
1457
1575
  II_rt1: float
1458
- Personal income (regular/non-AMT/non-pass-through) tax rate 1
1576
+ Personal income (regular/non-AMT) tax rate 1
1459
1577
  II_rt2: float
1460
- Personal income (regular/non-AMT/non-pass-through) tax rate 2
1578
+ Personal income (regular/non-AMT) tax rate 2
1461
1579
  II_rt3: float
1462
- Personal income (regular/non-AMT/non-pass-through) tax rate 3
1580
+ Personal income (regular/non-AMT) tax rate 3
1463
1581
  II_rt4: float
1464
- Personal income (regular/non-AMT/non-pass-through) tax rate 4
1582
+ Personal income (regular/non-AMT) tax rate 4
1465
1583
  II_rt5: float
1466
- Personal income (regular/non-AMT/non-pass-through) tax rate 5
1584
+ Personal income (regular/non-AMT) tax rate 5
1467
1585
  II_rt6: float
1468
- Personal income (regular/non-AMT/non-pass-through) tax rate 6
1586
+ Personal income (regular/non-AMT) tax rate 6
1469
1587
  II_rt7: float
1470
- Personal income (regular/non-AMT/non-pass-through) tax rate 7
1588
+ Personal income (regular/non-AMT) tax rate 7
1471
1589
  II_rt8: float
1472
- Personal income (regular/non-AMT/non-pass-through) tax rate 8
1590
+ Personal income (regular/non-AMT) tax rate 8
1473
1591
  II_brk1: list
1474
- Personal income (regular/non-AMT/non-pass/through)
1592
+ Personal income (regular/non-AMT)
1475
1593
  tax bracket (upper threshold) 1
1476
1594
  II_brk2: list
1477
- Personal income (regular/non-AMT/non-pass/through)
1595
+ Personal income (regular/non-AMT)
1478
1596
  tax bracket (upper threshold) 2
1479
1597
  II_brk3: list
1480
- Personal income (regular/non-AMT/non-pass/through)
1598
+ Personal income (regular/non-AMT)
1481
1599
  tax bracket (upper threshold) 3
1482
1600
  II_brk4: list
1483
- Personal income (regular/non-AMT/non-pass/through)
1601
+ Personal income (regular/non-AMT)
1484
1602
  tax bracket (upper threshold) 4
1485
1603
  II_brk5: list
1486
- Personal income (regular/non-AMT/non-pass/through)
1604
+ Personal income (regular/non-AMT)
1487
1605
  tax bracket (upper threshold) 5
1488
1606
  II_brk6: list
1489
- Personal income (regular/non-AMT/non-pass/through)
1607
+ Personal income (regular/non-AMT)
1490
1608
  tax bracket (upper threshold) 6
1491
1609
  II_brk7: list
1492
- Personal income (regular/non-AMT/non-pass/through)
1610
+ Personal income (regular/non-AMT)
1493
1611
  tax bracket (upper threshold) 7
1494
1612
  CG_nodiff: bool
1495
1613
  Long term capital gains and qualified dividends taxed no differently
@@ -1918,9 +2036,10 @@ def NetInvIncTax(e00300, e00600, e02000, e26270, c01000,
1918
2036
 
1919
2037
 
1920
2038
  @iterate_jit(nopython=True)
1921
- def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
1922
- exact, c00100, CDCC_ps, CDCC_ps2, CDCC_crt, CDCC_frt,
1923
- CDCC_po_step_size, CDCC_po_rate_per_step, CDCC_refundable,
2039
+ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800, exact, c00100,
2040
+ CDCC_ps1, CDCC_ps2, CDCC_po1_rate_max, CDCC_po1_rate_min,
2041
+ CDCC_po2_rate_min, CDCC_po1_step_size, CDCC_po2_step_size,
2042
+ CDCC_po_rate_per_step, CDCC_refundable,
1924
2043
  c05800, e07300, c32800, c07180, CDCC_refund):
1925
2044
  """
1926
2045
  Calculates Form 2441 child and dependent care expense credit, c07180.
@@ -1944,16 +2063,20 @@ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
1944
2063
  Whether or not to do rounding of phaseout fraction
1945
2064
  c00100: float
1946
2065
  Adjusted Gross Income (AGI)
1947
- CDCC_ps: float
2066
+ CDCC_ps1: float
1948
2067
  Child/dependent care credit first phaseout start
1949
- CDCC_ps2: float
2068
+ CDCC_ps2: list[float]
1950
2069
  Child/dependent care credit second phaseout start
1951
- CDCC_crt: float
1952
- Child/dependent care credit phaseout rate ceiling
1953
- CDCC_frt: float
1954
- Child/dependent care credit phaseout rate floor
1955
- CDCC_po_step_size: float
1956
- Child/dependent care credit phaseout AGI step size
2070
+ CDCC_po1_rate_max: float
2071
+ Child/dependent care credit first phaseout rate maximum
2072
+ CDCC_po1_rate_min: float
2073
+ Child/dependent care credit first phaseout rate minimum
2074
+ CDCC_po2_rate_min: float
2075
+ Child/dependent care credit second phaseout rate minimum
2076
+ CDCC_po1_step_size: float
2077
+ Child/dependent care credit first phaseout AGI step size
2078
+ CDCC_po2_step_size: float
2079
+ Child/dependent care credit second phaseout AGI step size
1957
2080
  CDCC_po_rate_per_step: float
1958
2081
  Child/dependent care credit phaseout rate per step size
1959
2082
  CDCC_refundable: bool
@@ -1987,21 +2110,32 @@ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
1987
2110
  c32890 = earned_p
1988
2111
  c33000 = max(0., min(c32800, c32880, c32890))
1989
2112
  # credit rate is limited at high AGI
1990
- # ... first phase-down from CDCC_crt to CDCC_frt
1991
- steps_fractional = max(0., c00100 - CDCC_ps) / CDCC_po_step_size
1992
- if exact == 1: # exact calculation as on tax forms
1993
- steps = math.ceil(steps_fractional)
1994
- else:
1995
- steps = steps_fractional
1996
- crate = max(CDCC_frt, CDCC_crt - steps * CDCC_po_rate_per_step)
1997
- # ... second phase-down from CDCC_frt to zero
1998
- if c00100 > CDCC_ps2:
1999
- steps_fractional = (c00100 - CDCC_ps2) / CDCC_po_step_size
2113
+ crate = CDCC_po1_rate_max
2114
+ ps1 = CDCC_ps1
2115
+ if c00100 > ps1:
2116
+ # ... first phase-down from CDCC_po1_rate_max to CDCC_po1_rate_min
2117
+ steps_fractional = (c00100 - ps1) / CDCC_po1_step_size
2000
2118
  if exact == 1: # exact calculation as on tax forms
2001
2119
  steps = math.ceil(steps_fractional)
2002
2120
  else:
2003
2121
  steps = steps_fractional
2004
- crate = max(0., CDCC_frt - steps * CDCC_po_rate_per_step)
2122
+ crate = max(
2123
+ CDCC_po1_rate_min,
2124
+ CDCC_po1_rate_max - steps * CDCC_po_rate_per_step
2125
+ )
2126
+ # ... second phase-down from CDCC_po1_rate_min to CDCC_po2_rate_min
2127
+ ps2 = CDCC_ps2[MARS - 1]
2128
+ assert ps2 >= ps1, "CDCC_ps2 must be no less than CDCC_ps1"
2129
+ if c00100 > ps2:
2130
+ steps_fractional = (c00100 - ps2) / CDCC_po2_step_size[MARS - 1]
2131
+ if exact == 1: # exact calculation as on tax forms
2132
+ steps = math.ceil(steps_fractional)
2133
+ else:
2134
+ steps = steps_fractional
2135
+ crate = max(
2136
+ CDCC_po2_rate_min,
2137
+ CDCC_po1_rate_min - steps * CDCC_po_rate_per_step
2138
+ )
2005
2139
  c33200 = c33000 * crate
2006
2140
  # credit is limited by tax liability if not refundable
2007
2141
  if CDCC_refundable:
@@ -3209,124 +3343,6 @@ def IITAX(c59660, c11070, c10960, personal_refundable_credit, ctc_new, rptc,
3209
3343
  iitax, combined)
3210
3344
 
3211
3345
 
3212
- @JIT(nopython=True)
3213
- def Taxes(income, MARS, tbrk_base,
3214
- rate1, rate2, rate3, rate4, rate5, rate6, rate7, rate8,
3215
- tbrk1, tbrk2, tbrk3, tbrk4, tbrk5, tbrk6, tbrk7):
3216
- """
3217
- Taxes function returns tax amount given the progressive tax rate
3218
- schedule specified by the rate* and (upper) tbrk* parameters and
3219
- given income, filing status (MARS), and tax bracket base (tbrk_base).
3220
-
3221
- Parameters
3222
- ----------
3223
- income: float
3224
- Taxable income
3225
- MARS: int
3226
- Filing (marital) status. (1=single, 2=joint, 3=separate,
3227
- 4=household-head, 5=widow(er))
3228
- tbrk_base: float
3229
- Amount of income used to determine the braket the filer is in
3230
- rate1: list
3231
- Income tax rate 1
3232
- rate2: list
3233
- Income tax rate 2
3234
- rate3: list
3235
- Income tax rate 3
3236
- rate4: list
3237
- Income tax rate 4
3238
- rate5: list
3239
- Income tax rate 5
3240
- rate6: list
3241
- Income tax rate 6
3242
- rate7: list
3243
- Income tax rate 7
3244
- rate8: list
3245
- Income tax rate 8
3246
- tbrk1: list
3247
- Income tax bracket (upper threshold) 1
3248
- tbrk2: list
3249
- Income tax bracket (upper threshold) 2
3250
- tbrk3: list
3251
- Income tax bracket (upper threshold) 3
3252
- tbrk4: list
3253
- Income tax bracket (upper threshold) 4
3254
- tbrk5: list
3255
- Income tax bracket (upper threshold) 5
3256
- tbrk6: list
3257
- Income tax bracket (upper threshold) 6
3258
- tbrk7: list
3259
- Income tax bracket (upper threshold) 7
3260
-
3261
- Returns
3262
- -------
3263
- None
3264
- """
3265
- if tbrk_base > 0.:
3266
- brk1 = max(tbrk1[MARS - 1] - tbrk_base, 0.)
3267
- brk2 = max(tbrk2[MARS - 1] - tbrk_base, 0.)
3268
- brk3 = max(tbrk3[MARS - 1] - tbrk_base, 0.)
3269
- brk4 = max(tbrk4[MARS - 1] - tbrk_base, 0.)
3270
- brk5 = max(tbrk5[MARS - 1] - tbrk_base, 0.)
3271
- brk6 = max(tbrk6[MARS - 1] - tbrk_base, 0.)
3272
- brk7 = max(tbrk7[MARS - 1] - tbrk_base, 0.)
3273
- else:
3274
- brk1 = tbrk1[MARS - 1]
3275
- brk2 = tbrk2[MARS - 1]
3276
- brk3 = tbrk3[MARS - 1]
3277
- brk4 = tbrk4[MARS - 1]
3278
- brk5 = tbrk5[MARS - 1]
3279
- brk6 = tbrk6[MARS - 1]
3280
- brk7 = tbrk7[MARS - 1]
3281
- return (rate1 * min(income, brk1) +
3282
- rate2 * min(brk2 - brk1, max(0., income - brk1)) +
3283
- rate3 * min(brk3 - brk2, max(0., income - brk2)) +
3284
- rate4 * min(brk4 - brk3, max(0., income - brk3)) +
3285
- rate5 * min(brk5 - brk4, max(0., income - brk4)) +
3286
- rate6 * min(brk6 - brk5, max(0., income - brk5)) +
3287
- rate7 * min(brk7 - brk6, max(0., income - brk6)) +
3288
- rate8 * max(0., income - brk7))
3289
-
3290
-
3291
- def ComputeBenefit(calc, ID_switch):
3292
- """
3293
- Calculates the value of the benefits accrued from itemizing.
3294
-
3295
- Parameters
3296
- ----------
3297
- calc: Calculator object
3298
- calc represents the reform while self represents the baseline
3299
- ID_switch: list
3300
- Deductions subject to the surtax on itemized deduction benefits
3301
-
3302
- Returns
3303
- -------
3304
- benefit: float
3305
- Imputed benefits from itemizing deductions
3306
- """
3307
- # compute income tax liability with no itemized deductions allowed for
3308
- # the types of itemized deductions covered under the BenefitSurtax
3309
- no_ID_calc = copy.deepcopy(calc)
3310
- if ID_switch[0]:
3311
- no_ID_calc.policy_param('ID_Medical_hc', [1.])
3312
- if ID_switch[1]:
3313
- no_ID_calc.policy_param('ID_StateLocalTax_hc', [1.])
3314
- if ID_switch[2]:
3315
- no_ID_calc.policy_param('ID_RealEstate_hc', [1.])
3316
- if ID_switch[3]:
3317
- no_ID_calc.policy_param('ID_Casualty_hc', [1.])
3318
- if ID_switch[4]:
3319
- no_ID_calc.policy_param('ID_Miscellaneous_hc', [1.])
3320
- if ID_switch[5]:
3321
- no_ID_calc.policy_param('ID_InterestPaid_hc', [1.])
3322
- if ID_switch[6]:
3323
- no_ID_calc.policy_param('ID_Charity_hc', [1.])
3324
- no_ID_calc._calc_one_year() # pylint: disable=protected-access
3325
- diff_iitax = no_ID_calc.array('iitax') - calc.array('iitax')
3326
- benefit = np.where(diff_iitax > 0., diff_iitax, 0.)
3327
- return benefit
3328
-
3329
-
3330
3346
  @iterate_jit(nopython=True)
3331
3347
  def FairShareTax(c00100, MARS, ptax_was, setax, ptax_amc,
3332
3348
  FST_AGI_trt, FST_AGI_thd_lo, FST_AGI_thd_hi,