taxcalc 4.6.3__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)
@@ -606,7 +661,7 @@ def CapGains(p23250, p22250, sep, ALD_StudentLoan_hc,
606
661
 
607
662
 
608
663
  @iterate_jit(nopython=True)
609
- def SSBenefits(MARS, ymod, e02400, SS_all_in_agi, SS_thd50, SS_thd85,
664
+ def SSBenefits(MARS, ymod, e02400, SS_all_in_agi, SS_thd1, SS_thd2,
610
665
  SS_percentage1, SS_percentage2, c02500):
611
666
  """
612
667
  Calculates OASDI benefits included in AGI, c02500.
@@ -622,9 +677,9 @@ def SSBenefits(MARS, ymod, e02400, SS_all_in_agi, SS_thd50, SS_thd85,
622
677
  Total social security (OASDI) benefits
623
678
  SS_all_in_agi: bool
624
679
  Whether all social security benefits are included in AGI
625
- SS_thd50: list
680
+ SS_thd1: list
626
681
  Threshold for social security benefit taxability (1)
627
- SS_thd85: list
682
+ SS_thd2: list
628
683
  Threshold for social security benefit taxability (2)
629
684
  SS_percentage1: float
630
685
  Social security taxable income decimal fraction (1)
@@ -638,15 +693,15 @@ def SSBenefits(MARS, ymod, e02400, SS_all_in_agi, SS_thd50, SS_thd85,
638
693
  c02500: float
639
694
  Social security (OASDI) benefits included in AGI
640
695
  """
641
- if ymod < SS_thd50[MARS - 1]:
696
+ if ymod < SS_thd1[MARS - 1]:
642
697
  c02500 = 0.
643
- elif ymod < SS_thd85[MARS - 1]:
644
- c02500 = SS_percentage1 * min(ymod - SS_thd50[MARS - 1], e02400)
698
+ elif ymod < SS_thd2[MARS - 1]:
699
+ c02500 = SS_percentage1 * min(ymod - SS_thd1[MARS - 1], e02400)
645
700
  else:
646
- c02500 = min(SS_percentage2 * (ymod - SS_thd85[MARS - 1]) +
701
+ c02500 = min(SS_percentage2 * (ymod - SS_thd2[MARS - 1]) +
647
702
  SS_percentage1 *
648
- min(e02400, SS_thd85[MARS - 1] -
649
- SS_thd50[MARS - 1]), SS_percentage2 * e02400)
703
+ min(e02400, SS_thd2[MARS - 1] -
704
+ SS_thd1[MARS - 1]), SS_percentage2 * e02400)
650
705
  if SS_all_in_agi:
651
706
  c02500 = e02400
652
707
  return c02500
@@ -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,10 +831,10 @@ 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)
@@ -787,145 +842,65 @@ def AGI(ymod1, c02500, c02900, XTOT, MARS, sep, DSI, exact, nu18, taxable_ubi,
787
842
 
788
843
 
789
844
  @iterate_jit(nopython=True)
790
- def ItemDedCap(e17500, e18400, e18500, e19200, e19800, e20100, e20400, g20500,
791
- c00100, ID_AmountCap_rt, ID_AmountCap_Switch, e17500_capped,
792
- e18400_capped, e18500_capped, e19200_capped, e19800_capped,
793
- e20100_capped, e20400_capped, g20500_capped):
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):
794
851
  """
795
- Applies a cap to gross itemized deductions.
852
+ Calculates below-the-line deduction on qualified auto loan interest paid.
796
853
 
797
854
  Parameters
798
855
  ----------
799
- e17500: float
800
- Itemizable medical and dental expenses
801
- e18400: float
802
- Itemizable state and local income/sales taxes
803
- e18500: float
804
- Itemizable real-estate taxes paid
805
- e19200: float
806
- Itemizable interest paid
807
- e19800: float
808
- Itemizable charitable giving: cash/check contributions
809
- e20100: float
810
- Itemizable charitable giving: other than cash/check contributions
811
- e20400: float
812
- Itemizable gross (before 10% AGI disregard) casualty or theft loss
813
- g20500: float
814
- Itemizable gross (before 10% AGI disregard) casualty or theft loss
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))
815
861
  c00100: float
816
- Adjusted gross income (AGI)
817
- ID_AmountCap_rt: float
818
- Ceiling on the gross amount of itemized deductions allowed;
819
- expressed as decimal fraction of AGI
820
- ID_AmountCap_Switch: list
821
- Deductions subject to the cap on itemized deduction benefits
822
- e17500_capped: float
823
- Schedule A: medical expenses, capped by
824
- ItemDedCap as a decimal fraction of AGI
825
- e18400_capped: float
826
- Schedule A: state and local income taxes deductlbe, capped by
827
- ItemDedCap as a decimal fraction of AGI
828
- e18500_capped: float
829
- Schedule A: state and local real estate taxes deductible, capped by
830
- ItemDedCap as a decimal fraction of AGI
831
- e19200_capped: float
832
- Schedule A: interest deduction deductible, capped by
833
- ItemDedCap as decimal fraction of AGI
834
- e19800_capped: float
835
- Schedule A: charity cash contributions deductible, capped by
836
- ItemDedCap as a decimal fraction of AGI
837
- e20100_capped: float
838
- Schedule A: charity noncash contributions deductible, capped by
839
- ItemDedCap s a decimal fraction of AGI
840
- e20400_capped: float
841
- Schedule A: gross miscellaneous deductions deductible, capped by
842
- ItemDedCap as a decimal fraction of AGI
843
- g20500_capped: float
844
- Schedule A: gross casualty or theft loss deductible, capped by
845
- ItemDedCap s a decimal fraction of AGI
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
846
875
 
847
876
  Returns
848
877
  -------
849
- e17500_capped: float
850
- Schedule A: medical expenses, capped by
851
- ItemDedCap as a decimal fraction of AGI
852
- e18400_capped: float
853
- Schedule A: state and local income taxes deductlbe, capped by
854
- ItemDedCap as a decimal fraction of AGI
855
- e18500_capped: float
856
- Schedule A: state and local real estate taxes deductible, capped by
857
- ItemDedCap as a decimal fraction of AGI
858
- e19200_capped: float
859
- Schedule A: interest deduction deductible, capped by
860
- ItemDedCap as decimal fraction of AGI
861
- e19800_capped: float
862
- Schedule A: charity cash contributions deductible, capped by
863
- ItemDedCap as a decimal fraction of AGI
864
- e20100_capped: float
865
- Schedule A: charity noncash contributions deductible, capped by
866
- ItemDedCap as a decimal fraction of AGI
867
- e20400_capped: float
868
- Schedule A: gross miscellaneous deductions deductible, capped by
869
- ItemDedCap as a decimal fraction of AGI
870
- g20500_capped: float
871
- Schedule A: gross casualty or theft loss deductible, capped by
872
- ItemDedCap as a decimal fraction of AGI
873
- """
874
- # pylint: disable=too-many-branches
875
-
876
- cap = max(0., ID_AmountCap_rt * c00100)
877
-
878
- gross_ded_amt = 0
879
- if ID_AmountCap_Switch[0]: # medical
880
- gross_ded_amt += e17500
881
- if ID_AmountCap_Switch[1]: # statelocal
882
- gross_ded_amt += e18400
883
- if ID_AmountCap_Switch[2]: # realestate
884
- gross_ded_amt += e18500
885
- if ID_AmountCap_Switch[3]: # casualty
886
- gross_ded_amt += g20500
887
- if ID_AmountCap_Switch[4]: # misc
888
- gross_ded_amt += e20400
889
- if ID_AmountCap_Switch[5]: # interest
890
- gross_ded_amt += e19200
891
- if ID_AmountCap_Switch[6]: # charity
892
- gross_ded_amt += e19800 + e20100
893
-
894
- overage = max(0., gross_ded_amt - cap)
895
-
896
- e17500_capped = e17500
897
- e18400_capped = e18400
898
- e18500_capped = e18500
899
- g20500_capped = g20500
900
- e20400_capped = e20400
901
- e19200_capped = e19200
902
- e19800_capped = e19800
903
- e20100_capped = e20100
904
-
905
- if overage > 0. and c00100 > 0.:
906
- if ID_AmountCap_Switch[0]: # medical
907
- e17500_capped -= (e17500 / gross_ded_amt) * overage
908
- if ID_AmountCap_Switch[1]: # statelocal
909
- e18400_capped -= (e18400 / (gross_ded_amt) * overage)
910
- if ID_AmountCap_Switch[2]: # realestate
911
- e18500_capped -= (e18500 / gross_ded_amt) * overage
912
- if ID_AmountCap_Switch[3]: # casualty
913
- g20500_capped -= (g20500 / gross_ded_amt) * overage
914
- if ID_AmountCap_Switch[4]: # misc
915
- e20400_capped -= (e20400 / gross_ded_amt) * overage
916
- if ID_AmountCap_Switch[5]: # interest
917
- e19200_capped -= (e19200 / gross_ded_amt) * overage
918
- if ID_AmountCap_Switch[6]: # charity
919
- e19800_capped -= (e19800 / gross_ded_amt) * overage
920
- e20100_capped -= (e20100 / gross_ded_amt) * overage
921
-
922
- return (e17500_capped, e18400_capped, e18500_capped, g20500_capped,
923
- e20400_capped, e19200_capped, e19800_capped, e20100_capped)
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
924
899
 
925
900
 
926
901
  @iterate_jit(nopython=True)
927
- def ItemDed(e17500_capped, e18400_capped, e18500_capped, e19200_capped,
928
- e19800_capped, e20100_capped, e20400_capped, g20500_capped,
902
+ def ItemDed(e17500, e18400, e18500, e19200,
903
+ e19800, e20100, e20400, g20500,
929
904
  MARS, age_head, age_spouse, c00100, c04470, c21040, c21060,
930
905
  c17000, c18300, c19200, c19700, c20500, c20800,
931
906
  ID_ps, ID_Medical_frt, ID_Medical_frt_add4aged, ID_Medical_hc,
@@ -942,30 +917,22 @@ def ItemDed(e17500_capped, e18400_capped, e18500_capped, e19200_capped,
942
917
 
943
918
  Parameters
944
919
  ----------
945
- e17500_capped: float
946
- Schedule A: medical expenses, capped by
947
- ItemDedCap as a decimal fraction of AGI
948
- e18400_capped: float
949
- Schedule A: state and local income taxes deductlbe, capped by
950
- ItemDedCap as a decimal fraction of AGI
951
- e18500_capped: float
952
- Schedule A: state and local real estate taxes deductible, capped by
953
- ItemDedCap as a decimal fraction of AGI
954
- e19200_capped: float
955
- Schedule A: interest deduction deductible, capped by
956
- ItemDedCap as decimal fraction of AGI
957
- e19800_capped: float
958
- Schedule A: charity cash contributions deductible, capped by
959
- ItemDedCap as a decimal fraction of AGI
960
- e20100_capped: float
961
- Schedule A: charity noncash contributions deductible, capped by
962
- ItemDedCap as a decimal fraction of AGI
963
- e20400_capped: float
964
- Schedule A: gross miscellaneous deductions deductible, capped by
965
- ItemDedCap as a decimal fraction of AGI
966
- g20500_capped: float
967
- Schedule A: gross casualty or theft loss deductible, capped by
968
- ItemDedCap as a decimal fraction of AGI
920
+ e17500: float
921
+ Schedule A: medical expenses
922
+ e18400: float
923
+ Schedule A: state and local income taxes deductlbe
924
+ e18500: float
925
+ Schedule A: state and local real estate taxes deductible
926
+ e19200: float
927
+ Schedule A: interest deduction deductible
928
+ e19800: float
929
+ Schedule A: charity cash contributions deductible
930
+ e20100: float
931
+ Schedule A: charity noncash contributions deductible
932
+ e20400: float
933
+ Schedule A: gross miscellaneous deductions deductible
934
+ g20500: float
935
+ Schedule A: gross casualty or theft loss deductible
969
936
  MARS: int
970
937
  Filing marital status (1=single, 2=joint, 3=separate,
971
938
  4=household-head, 5=widow(er))
@@ -1093,12 +1060,12 @@ def ItemDed(e17500_capped, e18400_capped, e18500_capped, e19200_capped,
1093
1060
  if age_head >= 65 or (MARS == 2 and age_spouse >= 65):
1094
1061
  medical_frt += ID_Medical_frt_add4aged
1095
1062
  c17750 = medical_frt * posagi
1096
- c17000 = max(0., e17500_capped - c17750) * (1. - ID_Medical_hc)
1063
+ c17000 = max(0., e17500 - c17750) * (1. - ID_Medical_hc)
1097
1064
  c17000 = min(c17000, ID_Medical_c[MARS - 1])
1098
1065
  # State and local taxes
1099
- c18400 = min((1. - ID_StateLocalTax_hc) * max(e18400_capped, 0.),
1066
+ c18400 = min((1. - ID_StateLocalTax_hc) * max(e18400, 0.),
1100
1067
  ID_StateLocalTax_c[MARS - 1])
1101
- c18500 = min((1. - ID_RealEstate_hc) * e18500_capped,
1068
+ c18500 = min((1. - ID_RealEstate_hc) * e18500,
1102
1069
  ID_RealEstate_c[MARS - 1])
1103
1070
  # following two statements implement a cap on c18400 and c18500 in a way
1104
1071
  # that those with negative AGI, c00100, are not capped under current law,
@@ -1108,22 +1075,22 @@ def ItemDed(e17500_capped, e18400_capped, e18500_capped, e19200_capped,
1108
1075
  c18300 = (c18400 + c18500) * (1. - ID_AllTaxes_hc)
1109
1076
  c18300 = min(c18300, ID_AllTaxes_c[MARS - 1])
1110
1077
  # Interest paid
1111
- c19200 = e19200_capped * (1. - ID_InterestPaid_hc)
1078
+ c19200 = e19200 * (1. - ID_InterestPaid_hc)
1112
1079
  c19200 = min(c19200, ID_InterestPaid_c[MARS - 1])
1113
1080
  # Charity
1114
- charity_ded_cash = min(ID_Charity_crt_cash * posagi, e19800_capped)
1115
- charity_ded_noncash = min(ID_Charity_crt_noncash * posagi, e20100_capped)
1081
+ charity_ded_cash = min(ID_Charity_crt_cash * posagi, e19800)
1082
+ charity_ded_noncash = min(ID_Charity_crt_noncash * posagi, e20100)
1116
1083
  c19700 = charity_ded_cash + charity_ded_noncash
1117
1084
  # charity floor is zero in present law
1118
1085
  charity_floor = max(ID_Charity_frt * posagi, ID_Charity_f[MARS - 1])
1119
1086
  c19700 = max(0., c19700 - charity_floor) * (1. - ID_Charity_hc)
1120
1087
  c19700 = min(c19700, ID_Charity_c[MARS - 1])
1121
1088
  # Casualty
1122
- c20500 = (max(0., g20500_capped - ID_Casualty_frt * posagi) *
1089
+ c20500 = (max(0., g20500 - ID_Casualty_frt * posagi) *
1123
1090
  (1. - ID_Casualty_hc))
1124
1091
  c20500 = min(c20500, ID_Casualty_c[MARS - 1])
1125
1092
  # Miscellaneous
1126
- c20400 = e20400_capped
1093
+ c20400 = e20400
1127
1094
  c20750 = ID_Miscellaneous_frt * posagi
1128
1095
  c20800 = max(0., c20400 - c20750) * (1. - ID_Miscellaneous_hc)
1129
1096
  c20800 = min(c20800, ID_Miscellaneous_c[MARS - 1])
@@ -1278,8 +1245,9 @@ def StdDed(DSI, earned, STD, age_head, age_spouse, STD_Aged, STD_Dep,
1278
1245
 
1279
1246
  @iterate_jit(nopython=True)
1280
1247
  def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
1281
- e02100, e27200, e00650, c01000, PT_SSTB_income,
1282
- 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,
1283
1251
  PT_qbid_taxinc_thd, PT_qbid_taxinc_gap, PT_qbid_w2_wages_rt,
1284
1252
  PT_qbid_alt_w2_wages_rt, PT_qbid_alt_property_rt, c04800,
1285
1253
  PT_qbid_ps, PT_qbid_prt, qbided):
@@ -1314,6 +1282,8 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
1314
1282
  Qualified dividends included in ordinary dividends
1315
1283
  c01000: float
1316
1284
  Limitation on capital losses
1285
+ auto_loan_interest_deduction: float
1286
+ Deduction for qualified auto loan interest paid
1317
1287
  PT_SSTB_income: int
1318
1288
  Value of one implies business income is from a specified service
1319
1289
  trade or business (SSTB)
@@ -1327,6 +1297,8 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
1327
1297
  pass-through business
1328
1298
  PT_qbid_rt: float
1329
1299
  Pass-through qualified business income deduction rate
1300
+ PT_qbid_limited: bool
1301
+ Whether or not TCJA QBID limits are active
1330
1302
  PT_qbid_taxinc_thd: list
1331
1303
  Lower threshold of pre-QBID taxable income
1332
1304
  PT_qbid_taxinc_gap: list
@@ -1356,10 +1328,9 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
1356
1328
  # calculate taxable income before qualified business income deduction
1357
1329
  pre_qbid_taxinc = max(0., c00100 - max(c04470, standard) - c04600)
1358
1330
  # calculate qualified business income deduction
1359
- qbided = 0.
1360
1331
  qbinc = max(0., e00900 - c03260 + e26270 + e02100 + e27200)
1361
- if qbinc > 0. and PT_qbid_rt > 0.:
1362
- qbid_before_limits = qbinc * PT_qbid_rt
1332
+ qbid_before_limits = qbinc * PT_qbid_rt
1333
+ if PT_qbid_limited:
1363
1334
  lower_thd = PT_qbid_taxinc_thd[MARS - 1]
1364
1335
  if pre_qbid_taxinc <= lower_thd:
1365
1336
  qbided = qbid_before_limits
@@ -1389,189 +1360,117 @@ def TaxInc(c00100, standard, c04470, c04600, MARS, e00900, c03260, e26270,
1389
1360
  prt = (pre_qbid_taxinc - lower_thd) / pre_qbid_taxinc_gap
1390
1361
  adj = prt * (qbid_adjusted - cap_adjusted)
1391
1362
  qbided = qbid_adjusted - adj
1392
-
1393
1363
  # apply taxinc cap (assuming cap rate is equal to PT_qbid_rt)
1394
- 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
1395
1366
  taxinc_cap = PT_qbid_rt * max(0., pre_qbid_taxinc - net_cg)
1396
1367
  qbided = min(qbided, taxinc_cap)
1397
-
1398
1368
  # apply qbid phaseout
1399
1369
  if qbided > 0. and pre_qbid_taxinc > PT_qbid_ps[MARS - 1]:
1400
1370
  excess = pre_qbid_taxinc - PT_qbid_ps[MARS - 1]
1401
1371
  qbided = max(0., qbided - PT_qbid_prt * excess)
1372
+ else: # if PT_qbid_limited is false
1373
+ qbided = qbid_before_limits
1402
1374
 
1403
1375
  # calculate taxable income after qualified business income deduction
1404
- c04800 = max(0., pre_qbid_taxinc - qbided)
1376
+ c04800 = max(0., pre_qbid_taxinc - qbided - auto_loan_interest_deduction)
1405
1377
  return (c04800, qbided)
1406
1378
 
1407
1379
 
1408
1380
  @JIT(nopython=True)
1409
- def SchXYZ(taxable_income, MARS, e00900, e26270, e02000, e00200,
1410
- PT_rt1, PT_rt2, PT_rt3, PT_rt4, PT_rt5,
1411
- PT_rt6, PT_rt7, PT_rt8,
1412
- PT_brk1, PT_brk2, PT_brk3, PT_brk4, PT_brk5,
1413
- PT_brk6, PT_brk7,
1381
+ def SchXYZ(taxable_income, MARS,
1414
1382
  II_rt1, II_rt2, II_rt3, II_rt4, II_rt5,
1415
1383
  II_rt6, II_rt7, II_rt8,
1416
1384
  II_brk1, II_brk2, II_brk3, II_brk4, II_brk5,
1417
- II_brk6, II_brk7, PT_EligibleRate_active,
1418
- PT_EligibleRate_passive, PT_wages_active_income,
1419
- PT_top_stacking):
1385
+ II_brk6, II_brk7):
1420
1386
  """
1421
- 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).
1422
1390
 
1423
1391
  Parameters
1424
1392
  ----------
1425
1393
  taxable_income: float
1426
- Taxable income
1394
+ Regular taxable income
1427
1395
  MARS: int
1428
1396
  Filing (marital) status. (1=single, 2=joint, 3=separate,
1429
1397
  4=household-head, 5=widow(er))
1430
- e00900: float
1431
- Schedule C business net profit/loss for filing unit
1432
- e26270: float
1433
- Schedule E: combined partnership and S-corporation net income/loss
1434
- e02000: float
1435
- Schedule E total rental, royalty, parternship, S-corporation,
1436
- etc, income/loss
1437
- e00200: float
1438
- Wages, salaries, and tips for filing unit net of pension contributions
1439
- PT_rt1: float
1440
- Pass through income tax rate 1
1441
- PT_rt2: float
1442
- Pass through income tax rate 2
1443
- PT_rt3: float
1444
- Pass through income tax rate 3
1445
- PT_rt4: float
1446
- Pass through income tax rate 4
1447
- PT_rt5: float
1448
- Pass through income tax rate 5
1449
- PT_rt6: float
1450
- Pass through income tax rate 6
1451
- PT_rt7: float
1452
- Pass through income tax rate 7
1453
- PT_rt8: float
1454
- Pass through income tax rate 8
1455
- PT_brk1: list
1456
- Pass through income tax bracket (upper threshold) 1
1457
- PT_brk2: list
1458
- Pass through income tax bracket (upper threshold) 2
1459
- PT_brk3: list
1460
- Pass through income tax bracket (upper threshold) 3
1461
- PT_brk4: list
1462
- Pass through income tax bracket (upper threshold) 4
1463
- PT_brk5: list
1464
- Pass through income tax bracket (upper threshold) 5
1465
- PT_brk6: list
1466
- Pass through income tax bracket (upper threshold) 6
1467
- PT_brk7: list
1468
- Pass through income tax bracket (upper threshold) 7
1469
1398
  II_rt1: float
1470
- Personal income (regular/non-AMT/non-pass-through) tax rate 1
1399
+ Personal income (regular/non-AMT) tax rate 1
1471
1400
  II_rt2: float
1472
- Personal income (regular/non-AMT/non-pass-through) tax rate 2
1401
+ Personal income (regular/non-AMT) tax rate 2
1473
1402
  II_rt3: float
1474
- Personal income (regular/non-AMT/non-pass-through) tax rate 3
1403
+ Personal income (regular/non-AMT) tax rate 3
1475
1404
  II_rt4: float
1476
- Personal income (regular/non-AMT/non-pass-through) tax rate 4
1405
+ Personal income (regular/non-AMT) tax rate 4
1477
1406
  II_rt5: float
1478
- Personal income (regular/non-AMT/non-pass-through) tax rate 5
1407
+ Personal income (regular/non-AMT) tax rate 5
1479
1408
  II_rt6: float
1480
- Personal income (regular/non-AMT/non-pass-through) tax rate 6
1409
+ Personal income (regular/non-AMT) tax rate 6
1481
1410
  II_rt7: float
1482
- Personal income (regular/non-AMT/non-pass-through) tax rate 7
1411
+ Personal income (regular/non-AMT) tax rate 7
1483
1412
  II_rt8: float
1484
- Personal income (regular/non-AMT/non-pass-through) tax rate 8
1413
+ Personal income (regular/non-AMT) tax rate 8
1485
1414
  II_brk1: list
1486
- Personal income (regular/non-AMT/non-pass/through)
1487
- tax bracket (upper threshold) 1
1415
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 1
1488
1416
  II_brk2: list
1489
- Personal income (regular/non-AMT/non-pass/through)
1490
- tax bracket (upper threshold) 2
1417
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 2
1491
1418
  II_brk3: list
1492
- Personal income (regular/non-AMT/non-pass/through)
1493
- tax bracket (upper threshold) 3
1419
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 3
1494
1420
  II_brk4: list
1495
- Personal income (regular/non-AMT/non-pass/through)
1496
- tax bracket (upper threshold) 4
1421
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 4
1497
1422
  II_brk5: list
1498
- Personal income (regular/non-AMT/non-pass/through)
1499
- tax bracket (upper threshold) 5
1423
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 5
1500
1424
  II_brk6: list
1501
- Personal income (regular/non-AMT/non-pass/through)
1502
- tax bracket (upper threshold) 6
1425
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 6
1503
1426
  II_brk7: list
1504
- Personal income (regular/non-AMT/non-pass/through)
1505
- tax bracket (upper threshold) 7
1506
- PT_EligibleRate_active: float
1507
- Share of active business income eligible for PT rate schedule
1508
- PT_EligibleRate_passive: float
1509
- Share of passive business income eligible for PT rate schedule
1510
- PT_wages_active_income: bool
1511
- Wages included in (positive) active business eligible for PT rates
1512
- PT_top_stacking: bool
1513
- PT taxable income stacked on top of regular taxable income
1427
+ Personal income (regular/non-AMT) tax bracket (upper threshold) 7
1514
1428
 
1515
1429
  Returns
1516
1430
  -------
1517
- reg_tax: float
1518
- Individual income tax liability on non-pass-through income
1519
- pt_tax: float
1520
- Individual income tax liability from pass-through income
1521
- """
1522
- # separate non-negative taxable income into two non-negative components,
1523
- # doing this in a way so that the components add up to taxable income
1524
- # define pass-through income eligible for PT schedule
1525
- pt_passive = PT_EligibleRate_passive * (e02000 - e26270)
1526
- pt_active_gross = e00900 + e26270
1527
- if (pt_active_gross > 0) and PT_wages_active_income:
1528
- pt_active_gross = pt_active_gross + e00200
1529
- pt_active = PT_EligibleRate_active * pt_active_gross
1530
- pt_active = min(pt_active, e00900 + e26270)
1531
- pt_taxinc = max(0., pt_passive + pt_active)
1532
- if pt_taxinc >= taxable_income:
1533
- pt_taxinc = taxable_income
1534
- reg_taxinc = 0.
1535
- else:
1536
- # pt_taxinc is unchanged
1537
- reg_taxinc = taxable_income - pt_taxinc
1538
- # determine stacking order
1539
- if PT_top_stacking:
1540
- reg_tbase = 0.
1541
- pt_tbase = reg_taxinc
1542
- else:
1543
- reg_tbase = pt_taxinc
1544
- pt_tbase = 0.
1545
- # compute Schedule X,Y,Z tax using the two components of taxable income
1546
- if reg_taxinc > 0.:
1547
- reg_tax = Taxes(reg_taxinc, MARS, reg_tbase,
1548
- II_rt1, II_rt2, II_rt3, II_rt4,
1549
- II_rt5, II_rt6, II_rt7, II_rt8, II_brk1, II_brk2,
1550
- II_brk3, II_brk4, II_brk5, II_brk6, II_brk7)
1551
- else:
1552
- reg_tax = 0.
1553
- if pt_taxinc > 0.:
1554
- pt_tax = Taxes(pt_taxinc, MARS, pt_tbase,
1555
- PT_rt1, PT_rt2, PT_rt3, PT_rt4,
1556
- PT_rt5, PT_rt6, PT_rt7, PT_rt8, PT_brk1, PT_brk2,
1557
- PT_brk3, PT_brk4, PT_brk5, PT_brk6, PT_brk7)
1558
- else:
1559
- pt_tax = 0.
1560
- return reg_tax + pt_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)
1561
1466
 
1562
1467
 
1563
1468
  @iterate_jit(nopython=True)
1564
- def SchXYZTax(c04800, MARS, e00900, e26270, e02000, e00200,
1565
- PT_rt1, PT_rt2, PT_rt3, PT_rt4, PT_rt5,
1566
- PT_rt6, PT_rt7, PT_rt8,
1567
- PT_brk1, PT_brk2, PT_brk3, PT_brk4, PT_brk5,
1568
- PT_brk6, PT_brk7,
1469
+ def SchXYZTax(c04800, MARS,
1569
1470
  II_rt1, II_rt2, II_rt3, II_rt4, II_rt5,
1570
1471
  II_rt6, II_rt7, II_rt8,
1571
1472
  II_brk1, II_brk2, II_brk3, II_brk4, II_brk5,
1572
- II_brk6, II_brk7, PT_EligibleRate_active,
1573
- PT_EligibleRate_passive, PT_wages_active_income,
1574
- PT_top_stacking, c05200):
1473
+ II_brk6, II_brk7, c05200):
1575
1474
  """
1576
1475
  SchXYZTax calls SchXYZ function and sets c05200 to returned amount.
1577
1476
 
@@ -1582,120 +1481,65 @@ def SchXYZTax(c04800, MARS, e00900, e26270, e02000, e00200,
1582
1481
  MARS: int
1583
1482
  Filing (marital) status. (1=single, 2=joint, 3=separate,
1584
1483
  4=household-head, 5=widow(er))
1585
- e00900: float
1586
- Schedule C business net profit/loss for filing unit
1587
- e26270: float
1588
- Schedule E: combined partnership and S-corporation net income/loss
1589
- e02000: float
1590
- Farm net income/loss for filing unit from Schedule F
1591
- e00200: float
1592
- Farm net income/loss for filing unit from Schedule F
1593
- PT_rt1: float
1594
- Pass through income tax rate 1
1595
- PT_rt2: float
1596
- Pass through income tax rate 2
1597
- PT_rt3: float
1598
- Pass through income tax rate 3
1599
- PT_rt4: float
1600
- Pass through income tax rate 4
1601
- PT_rt5: float
1602
- Pass through income tax rate 5
1603
- PT_rt6: float
1604
- Pass through income tax rate 6
1605
- PT_rt7: float
1606
- Pass through income tax rate 7
1607
- PT_rt8: float
1608
- Pass through income tax rate 8
1609
- PT_brk1: list
1610
- Pass through income tax bracket (upper threshold) 1
1611
- PT_brk2: list
1612
- Pass through income tax bracket (upper threshold) 2
1613
- PT_brk3: list
1614
- Pass through income tax bracket (upper threshold) 3
1615
- PT_brk4: list
1616
- Pass through income tax bracket (upper threshold) 4
1617
- PT_brk5: list
1618
- Pass through income tax bracket (upper threshold) 5
1619
- PT_brk6: list
1620
- Pass through income tax bracket (upper threshold) 6
1621
- PT_brk7: list
1622
- Pass through income tax bracket (upper threshold) 7
1623
1484
  II_rt1: float
1624
- Personal income (regular/non-AMT/non-pass-through) tax rate 1
1485
+ Personal income (regular/non-AMT) tax rate 1
1625
1486
  II_rt2: float
1626
- Personal income (regular/non-AMT/non-pass-through) tax rate 2
1487
+ Personal income (regular/non-AMT) tax rate 2
1627
1488
  II_rt3: float
1628
- Personal income (regular/non-AMT/non-pass-through) tax rate 3
1489
+ Personal income (regular/non-AMT) tax rate 3
1629
1490
  II_rt4: float
1630
- Personal income (regular/non-AMT/non-pass-through) tax rate 4
1491
+ Personal income (regular/non-AMT) tax rate 4
1631
1492
  II_rt5: float
1632
- Personal income (regular/non-AMT/non-pass-through) tax rate 5
1493
+ Personal income (regular/non-AMT) tax rate 5
1633
1494
  II_rt6: float
1634
- Personal income (regular/non-AMT/non-pass-through) tax rate 6
1495
+ Personal income (regular/non-AMT) tax rate 6
1635
1496
  II_rt7: float
1636
- Personal income (regular/non-AMT/non-pass-through) tax rate 7
1497
+ Personal income (regular/non-AMT) tax rate 7
1637
1498
  II_rt8: float
1638
- Personal income (regular/non-AMT/non-pass-through) tax rate 8
1499
+ Personal income (regular/non-AMT) tax rate 8
1639
1500
  II_brk1: list
1640
- Personal income (regular/non-AMT/non-pass/through)
1501
+ Personal income (regular/non-AMT)
1641
1502
  tax bracket (upper threshold) 1
1642
1503
  II_brk2: list
1643
- Personal income (regular/non-AMT/non-pass/through)
1504
+ Personal income (regular/non-AMT)
1644
1505
  tax bracket (upper threshold) 2
1645
1506
  II_brk3: list
1646
- Personal income (regular/non-AMT/non-pass/through)
1507
+ Personal income (regular/non-AMT)
1647
1508
  tax bracket (upper threshold) 3
1648
1509
  II_brk4: list
1649
- Personal income (regular/non-AMT/non-pass/through)
1510
+ Personal income (regular/non-AMT)
1650
1511
  tax bracket (upper threshold) 4
1651
1512
  II_brk5: list
1652
- Personal income (regular/non-AMT/non-pass/through)
1513
+ Personal income (regular/non-AMT)
1653
1514
  tax bracket (upper threshold) 5
1654
1515
  II_brk6: list
1655
- Personal income (regular/non-AMT/non-pass/through)
1516
+ Personal income (regular/non-AMT)
1656
1517
  tax bracket (upper threshold) 6
1657
1518
  II_brk7: list
1658
- Personal income (regular/non-AMT/non-pass/through)
1519
+ Personal income (regular/non-AMT)
1659
1520
  tax bracket (upper threshold) 7
1660
- PT_EligibleRate_active: float
1661
- Share of active business income eligible for PT rate schedule
1662
- PT_EligibleRate_passive: float
1663
- Share of passive business income eligible for PT rate schedule
1664
- PT_wages_active_income: bool
1665
- Wages included in (positive) active business eligible for PT rates
1666
- PT_top_stacking: bool
1667
- PT taxable income stacked on top of regular taxable income
1668
1521
  c05200: float
1669
1522
  Tax amount from Schedule X,Y,Z tables
1670
1523
 
1671
1524
  Returns
1672
1525
  -------
1673
1526
  c05200: float
1674
- Tax aount from Schedule X, Y, Z tables
1675
- """
1676
- c05200 = SchXYZ(c04800, MARS, e00900, e26270, e02000, e00200,
1677
- PT_rt1, PT_rt2, PT_rt3, PT_rt4, PT_rt5,
1678
- PT_rt6, PT_rt7, PT_rt8,
1679
- PT_brk1, PT_brk2, PT_brk3, PT_brk4, PT_brk5,
1680
- PT_brk6, PT_brk7,
1681
- II_rt1, II_rt2, II_rt3, II_rt4, II_rt5,
1682
- II_rt6, II_rt7, II_rt8,
1683
- II_brk1, II_brk2, II_brk3, II_brk4, II_brk5,
1684
- II_brk6, II_brk7, PT_EligibleRate_active,
1685
- PT_EligibleRate_passive, PT_wages_active_income,
1686
- PT_top_stacking)
1527
+ Tax amount from Schedule X, Y, Z tables
1528
+ """
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
+ )
1687
1534
  return c05200
1688
1535
 
1689
1536
 
1690
1537
  @iterate_jit(nopython=True)
1691
- def GainsTax(e00650, c01000, c23650, p23250, e01100, e58990, e00200,
1692
- e24515, e24518, MARS, c04800, c05200, e00900, e26270, e02000,
1538
+ def GainsTax(e00650, c01000, c23650, p23250, e01100, e58990,
1539
+ e24515, e24518, MARS, c04800, c05200,
1693
1540
  II_rt1, II_rt2, II_rt3, II_rt4, II_rt5, II_rt6, II_rt7, II_rt8,
1694
1541
  II_brk1, II_brk2, II_brk3, II_brk4, II_brk5, II_brk6, II_brk7,
1695
- PT_rt1, PT_rt2, PT_rt3, PT_rt4, PT_rt5, PT_rt6, PT_rt7, PT_rt8,
1696
- PT_brk1, PT_brk2, PT_brk3, PT_brk4, PT_brk5, PT_brk6, PT_brk7,
1697
- CG_nodiff, PT_EligibleRate_active, PT_EligibleRate_passive,
1698
- PT_wages_active_income, PT_top_stacking,
1542
+ CG_nodiff,
1699
1543
  CG_rt1, CG_rt2, CG_rt3, CG_rt4, CG_brk1, CG_brk2, CG_brk3,
1700
1544
  dwks10, dwks13, dwks14, dwks19, dwks43, c05700, taxbc):
1701
1545
  """
@@ -1717,8 +1561,6 @@ def GainsTax(e00650, c01000, c23650, p23250, e01100, e58990, e00200,
1717
1561
  Capital gains distributions not reported on Schedule D
1718
1562
  e58990: float
1719
1563
  Investment income elected amount from Form 4952
1720
- e00200: float
1721
- Wages, salaries, and tips for filing unit net of pension contributions
1722
1564
  e24515: float
1723
1565
  Schedule D: un-recaptured section 1250 Gain
1724
1566
  e24518: float
@@ -1730,91 +1572,46 @@ def GainsTax(e00650, c01000, c23650, p23250, e01100, e58990, e00200,
1730
1572
  Regular taxable income
1731
1573
  c05200: float
1732
1574
  Tax amount from Schedule X,Y,Z tables
1733
- e00900: float
1734
- Schedule C business net profit/loss for filing unit
1735
- e26270: float
1736
- Schedule E: combined partnership and S-corporation net income/loss
1737
- e02000: float
1738
- Schedule E total rental, royalty, partnership, S-corporation,
1739
- etc, income/loss
1740
1575
  II_rt1: float
1741
- Personal income (regular/non-AMT/non-pass-through) tax rate 1
1576
+ Personal income (regular/non-AMT) tax rate 1
1742
1577
  II_rt2: float
1743
- Personal income (regular/non-AMT/non-pass-through) tax rate 2
1578
+ Personal income (regular/non-AMT) tax rate 2
1744
1579
  II_rt3: float
1745
- Personal income (regular/non-AMT/non-pass-through) tax rate 3
1580
+ Personal income (regular/non-AMT) tax rate 3
1746
1581
  II_rt4: float
1747
- Personal income (regular/non-AMT/non-pass-through) tax rate 4
1582
+ Personal income (regular/non-AMT) tax rate 4
1748
1583
  II_rt5: float
1749
- Personal income (regular/non-AMT/non-pass-through) tax rate 5
1584
+ Personal income (regular/non-AMT) tax rate 5
1750
1585
  II_rt6: float
1751
- Personal income (regular/non-AMT/non-pass-through) tax rate 6
1586
+ Personal income (regular/non-AMT) tax rate 6
1752
1587
  II_rt7: float
1753
- Personal income (regular/non-AMT/non-pass-through) tax rate 7
1588
+ Personal income (regular/non-AMT) tax rate 7
1754
1589
  II_rt8: float
1755
- Personal income (regular/non-AMT/non-pass-through) tax rate 8
1590
+ Personal income (regular/non-AMT) tax rate 8
1756
1591
  II_brk1: list
1757
- Personal income (regular/non-AMT/non-pass/through)
1592
+ Personal income (regular/non-AMT)
1758
1593
  tax bracket (upper threshold) 1
1759
1594
  II_brk2: list
1760
- Personal income (regular/non-AMT/non-pass/through)
1595
+ Personal income (regular/non-AMT)
1761
1596
  tax bracket (upper threshold) 2
1762
1597
  II_brk3: list
1763
- Personal income (regular/non-AMT/non-pass/through)
1598
+ Personal income (regular/non-AMT)
1764
1599
  tax bracket (upper threshold) 3
1765
1600
  II_brk4: list
1766
- Personal income (regular/non-AMT/non-pass/through)
1601
+ Personal income (regular/non-AMT)
1767
1602
  tax bracket (upper threshold) 4
1768
1603
  II_brk5: list
1769
- Personal income (regular/non-AMT/non-pass/through)
1604
+ Personal income (regular/non-AMT)
1770
1605
  tax bracket (upper threshold) 5
1771
1606
  II_brk6: list
1772
- Personal income (regular/non-AMT/non-pass/through)
1607
+ Personal income (regular/non-AMT)
1773
1608
  tax bracket (upper threshold) 6
1774
1609
  II_brk7: list
1775
- Personal income (regular/non-AMT/non-pass/through)
1610
+ Personal income (regular/non-AMT)
1776
1611
  tax bracket (upper threshold) 7
1777
- PT_rt1: float
1778
- Pass through income tax rate 1
1779
- PT_rt2: float
1780
- Pass through income tax rate 2
1781
- PT_rt3: float
1782
- Pass through income tax rate 3
1783
- PT_rt4: float
1784
- Pass through income tax rate 4
1785
- PT_rt5: float
1786
- Pass through income tax rate 5
1787
- PT_rt6: float
1788
- Pass through income tax rate 6
1789
- PT_rt7: float
1790
- Pass through income tax rate 7
1791
- PT_rt8: float
1792
- Pass through income tax rate 8
1793
- PT_brk1: list
1794
- Pass through income tax bracket (upper threshold) 1
1795
- PT_brk2: list
1796
- Pass through income tax bracket (upper threshold) 2
1797
- PT_brk3: list
1798
- Pass through income tax bracket (upper threshold) 3
1799
- PT_brk4: list
1800
- Pass through income tax bracket (upper threshold) 4
1801
- PT_brk5: list
1802
- Pass through income tax bracket (upper threshold) 5
1803
- PT_brk6: list
1804
- Pass through income tax bracket (upper threshold) 6
1805
- PT_brk7: list
1806
- Pass through income tax bracket (upper threshold) 7
1807
1612
  CG_nodiff: bool
1808
1613
  Long term capital gains and qualified dividends taxed no differently
1809
1614
  than regular taxable income
1810
- PT_EligibleRate_active: float
1811
- Share of active business income eligible for PT rate schedule
1812
- PT_EligibleRate_passive: float
1813
- Share of passive business income eligible for PT rate schedule
1814
- PT_wages_active_income: bool
1815
- Wages included in (positive) active business eligible for PT rates
1816
- PT_top_stacking: bool
1817
- PT taxable income stacked on top of regular taxable income
1818
1615
  CG_rt1: float
1819
1616
  Long term capital gain and qualified dividends (regular/non-AMT) rate 1
1820
1617
  CG_rt2: float
@@ -1929,17 +1726,11 @@ def GainsTax(e00650, c01000, c23650, p23250, e01100, e58990, e00200,
1929
1726
  dwks39 = dwks19 + dwks20 + dwks28 + dwks31 + dwks37
1930
1727
  dwks40 = dwks1 - dwks39
1931
1728
  dwks41 = 0.28 * dwks40
1932
- dwks42 = SchXYZ(dwks19, MARS, e00900, e26270, e02000, e00200,
1933
- PT_rt1, PT_rt2, PT_rt3, PT_rt4, PT_rt5,
1934
- PT_rt6, PT_rt7, PT_rt8,
1935
- PT_brk1, PT_brk2, PT_brk3, PT_brk4, PT_brk5,
1936
- PT_brk6, PT_brk7,
1729
+ dwks42 = SchXYZ(dwks19, MARS,
1937
1730
  II_rt1, II_rt2, II_rt3, II_rt4, II_rt5,
1938
1731
  II_rt6, II_rt7, II_rt8,
1939
1732
  II_brk1, II_brk2, II_brk3, II_brk4, II_brk5,
1940
- II_brk6, II_brk7, PT_EligibleRate_active,
1941
- PT_EligibleRate_passive, PT_wages_active_income,
1942
- PT_top_stacking)
1733
+ II_brk6, II_brk7)
1943
1734
  dwks43 = (dwks29 + dwks32 + dwks38 + dwks41 + dwks42 +
1944
1735
  lowest_rate_tax + highest_rate_incremental_tax)
1945
1736
  dwks44 = c05200
@@ -2245,9 +2036,10 @@ def NetInvIncTax(e00300, e00600, e02000, e26270, c01000,
2245
2036
 
2246
2037
 
2247
2038
  @iterate_jit(nopython=True)
2248
- def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
2249
- exact, c00100, CDCC_ps, CDCC_ps2, CDCC_crt, CDCC_frt,
2250
- 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,
2251
2043
  c05800, e07300, c32800, c07180, CDCC_refund):
2252
2044
  """
2253
2045
  Calculates Form 2441 child and dependent care expense credit, c07180.
@@ -2271,16 +2063,20 @@ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
2271
2063
  Whether or not to do rounding of phaseout fraction
2272
2064
  c00100: float
2273
2065
  Adjusted Gross Income (AGI)
2274
- CDCC_ps: float
2066
+ CDCC_ps1: float
2275
2067
  Child/dependent care credit first phaseout start
2276
- CDCC_ps2: float
2068
+ CDCC_ps2: list[float]
2277
2069
  Child/dependent care credit second phaseout start
2278
- CDCC_crt: float
2279
- Child/dependent care credit phaseout rate ceiling
2280
- CDCC_frt: float
2281
- Child/dependent care credit phaseout rate floor
2282
- CDCC_po_step_size: float
2283
- 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
2284
2080
  CDCC_po_rate_per_step: float
2285
2081
  Child/dependent care credit phaseout rate per step size
2286
2082
  CDCC_refundable: bool
@@ -2314,21 +2110,32 @@ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
2314
2110
  c32890 = earned_p
2315
2111
  c33000 = max(0., min(c32800, c32880, c32890))
2316
2112
  # credit rate is limited at high AGI
2317
- # ... first phase-down from CDCC_crt to CDCC_frt
2318
- steps_fractional = max(0., c00100 - CDCC_ps) / CDCC_po_step_size
2319
- if exact == 1: # exact calculation as on tax forms
2320
- steps = math.ceil(steps_fractional)
2321
- else:
2322
- steps = steps_fractional
2323
- crate = max(CDCC_frt, CDCC_crt - steps * CDCC_po_rate_per_step)
2324
- # ... second phase-down from CDCC_frt to zero
2325
- if c00100 > CDCC_ps2:
2326
- 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
2327
2118
  if exact == 1: # exact calculation as on tax forms
2328
2119
  steps = math.ceil(steps_fractional)
2329
2120
  else:
2330
2121
  steps = steps_fractional
2331
- 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
+ )
2332
2139
  c33200 = c33000 * crate
2333
2140
  # credit is limited by tax liability if not refundable
2334
2141
  if CDCC_refundable:
@@ -3536,202 +3343,6 @@ def IITAX(c59660, c11070, c10960, personal_refundable_credit, ctc_new, rptc,
3536
3343
  iitax, combined)
3537
3344
 
3538
3345
 
3539
- @JIT(nopython=True)
3540
- def Taxes(income, MARS, tbrk_base,
3541
- rate1, rate2, rate3, rate4, rate5, rate6, rate7, rate8,
3542
- tbrk1, tbrk2, tbrk3, tbrk4, tbrk5, tbrk6, tbrk7):
3543
- """
3544
- Taxes function returns tax amount given the progressive tax rate
3545
- schedule specified by the rate* and (upper) tbrk* parameters and
3546
- given income, filing status (MARS), and tax bracket base (tbrk_base).
3547
-
3548
- Parameters
3549
- ----------
3550
- income: float
3551
- Taxable income
3552
- MARS: int
3553
- Filing (marital) status. (1=single, 2=joint, 3=separate,
3554
- 4=household-head, 5=widow(er))
3555
- tbrk_base: float
3556
- Amount of income used to determine the braket the filer is in
3557
- rate1: list
3558
- Income tax rate 1
3559
- rate2: list
3560
- Income tax rate 2
3561
- rate3: list
3562
- Income tax rate 3
3563
- rate4: list
3564
- Income tax rate 4
3565
- rate5: list
3566
- Income tax rate 5
3567
- rate6: list
3568
- Income tax rate 6
3569
- rate7: list
3570
- Income tax rate 7
3571
- rate8: list
3572
- Income tax rate 8
3573
- tbrk1: list
3574
- Income tax bracket (upper threshold) 1
3575
- tbrk2: list
3576
- Income tax bracket (upper threshold) 2
3577
- tbrk3: list
3578
- Income tax bracket (upper threshold) 3
3579
- tbrk4: list
3580
- Income tax bracket (upper threshold) 4
3581
- tbrk5: list
3582
- Income tax bracket (upper threshold) 5
3583
- tbrk6: list
3584
- Income tax bracket (upper threshold) 6
3585
- tbrk7: list
3586
- Income tax bracket (upper threshold) 7
3587
-
3588
- Returns
3589
- -------
3590
- None
3591
- """
3592
- if tbrk_base > 0.:
3593
- brk1 = max(tbrk1[MARS - 1] - tbrk_base, 0.)
3594
- brk2 = max(tbrk2[MARS - 1] - tbrk_base, 0.)
3595
- brk3 = max(tbrk3[MARS - 1] - tbrk_base, 0.)
3596
- brk4 = max(tbrk4[MARS - 1] - tbrk_base, 0.)
3597
- brk5 = max(tbrk5[MARS - 1] - tbrk_base, 0.)
3598
- brk6 = max(tbrk6[MARS - 1] - tbrk_base, 0.)
3599
- brk7 = max(tbrk7[MARS - 1] - tbrk_base, 0.)
3600
- else:
3601
- brk1 = tbrk1[MARS - 1]
3602
- brk2 = tbrk2[MARS - 1]
3603
- brk3 = tbrk3[MARS - 1]
3604
- brk4 = tbrk4[MARS - 1]
3605
- brk5 = tbrk5[MARS - 1]
3606
- brk6 = tbrk6[MARS - 1]
3607
- brk7 = tbrk7[MARS - 1]
3608
- return (rate1 * min(income, brk1) +
3609
- rate2 * min(brk2 - brk1, max(0., income - brk1)) +
3610
- rate3 * min(brk3 - brk2, max(0., income - brk2)) +
3611
- rate4 * min(brk4 - brk3, max(0., income - brk3)) +
3612
- rate5 * min(brk5 - brk4, max(0., income - brk4)) +
3613
- rate6 * min(brk6 - brk5, max(0., income - brk5)) +
3614
- rate7 * min(brk7 - brk6, max(0., income - brk6)) +
3615
- rate8 * max(0., income - brk7))
3616
-
3617
-
3618
- def ComputeBenefit(calc, ID_switch):
3619
- """
3620
- Calculates the value of the benefits accrued from itemizing.
3621
-
3622
- Parameters
3623
- ----------
3624
- calc: Calculator object
3625
- calc represents the reform while self represents the baseline
3626
- ID_switch: list
3627
- Deductions subject to the surtax on itemized deduction benefits
3628
-
3629
- Returns
3630
- -------
3631
- benefit: float
3632
- Imputed benefits from itemizing deductions
3633
- """
3634
- # compute income tax liability with no itemized deductions allowed for
3635
- # the types of itemized deductions covered under the BenefitSurtax
3636
- no_ID_calc = copy.deepcopy(calc)
3637
- if ID_switch[0]:
3638
- no_ID_calc.policy_param('ID_Medical_hc', [1.])
3639
- if ID_switch[1]:
3640
- no_ID_calc.policy_param('ID_StateLocalTax_hc', [1.])
3641
- if ID_switch[2]:
3642
- no_ID_calc.policy_param('ID_RealEstate_hc', [1.])
3643
- if ID_switch[3]:
3644
- no_ID_calc.policy_param('ID_Casualty_hc', [1.])
3645
- if ID_switch[4]:
3646
- no_ID_calc.policy_param('ID_Miscellaneous_hc', [1.])
3647
- if ID_switch[5]:
3648
- no_ID_calc.policy_param('ID_InterestPaid_hc', [1.])
3649
- if ID_switch[6]:
3650
- no_ID_calc.policy_param('ID_Charity_hc', [1.])
3651
- no_ID_calc._calc_one_year() # pylint: disable=protected-access
3652
- diff_iitax = no_ID_calc.array('iitax') - calc.array('iitax')
3653
- benefit = np.where(diff_iitax > 0., diff_iitax, 0.)
3654
- return benefit
3655
-
3656
-
3657
- def BenefitSurtax(calc):
3658
- """
3659
- Computes itemized-deduction-benefit surtax and adds the surtax amount
3660
- to income tax, combined tax, and surtax liabilities.
3661
-
3662
- Parameters
3663
- ----------
3664
- calc: Calculator object
3665
- calc represents the reform while self represents the baseline
3666
-
3667
- Returns
3668
- -------
3669
- None:
3670
- The function modifies calc
3671
- """
3672
- if calc.policy_param('ID_BenefitSurtax_crt') != 1.:
3673
- ben = ComputeBenefit(calc,
3674
- calc.policy_param('ID_BenefitSurtax_Switch'))
3675
- agi = calc.array('c00100')
3676
- ben_deduct = calc.policy_param('ID_BenefitSurtax_crt') * agi
3677
- ben_exempt_array = calc.policy_param('ID_BenefitSurtax_em')
3678
- ben_exempt = ben_exempt_array[calc.array('MARS') - 1]
3679
- ben_dedem = ben_deduct + ben_exempt
3680
- ben_surtax = (calc.policy_param('ID_BenefitSurtax_trt') *
3681
- np.where(ben > ben_dedem, ben - ben_dedem, 0.))
3682
- # add ben_surtax to income & combined taxes and to surtax subtotal
3683
- calc.incarray('iitax', ben_surtax)
3684
- calc.incarray('combined', ben_surtax)
3685
- calc.incarray('surtax', ben_surtax)
3686
-
3687
-
3688
- def BenefitLimitation(calc):
3689
- """
3690
- Limits the benefits of select itemized deductions to a fraction of
3691
- deductible expenses.
3692
-
3693
- Parameters
3694
- ----------
3695
- calc: Calculator object
3696
- calc represents the reform while self represents the baseline
3697
-
3698
- Returns
3699
- -------
3700
- None:
3701
- The function modifies calc
3702
- """
3703
- if calc.policy_param('ID_BenefitCap_rt') != 1.:
3704
- benefit = ComputeBenefit(calc,
3705
- calc.policy_param('ID_BenefitCap_Switch'))
3706
- # Calculate total deductible expenses under the cap
3707
- deduct_exps = 0.
3708
- if calc.policy_param('ID_BenefitCap_Switch')[0]: # medical
3709
- deduct_exps += calc.array('c17000')
3710
- if calc.policy_param('ID_BenefitCap_Switch')[1]: # statelocal
3711
- one_minus_hc = 1. - calc.policy_param('ID_StateLocalTax_hc')
3712
- deduct_exps += (one_minus_hc *
3713
- np.maximum(calc.array('e18400_capped'), 0.))
3714
- if calc.policy_param('ID_BenefitCap_Switch')[2]: # realestate
3715
- one_minus_hc = 1. - calc.policy_param('ID_RealEstate_hc')
3716
- deduct_exps += one_minus_hc * calc.array('e18500_capped')
3717
- if calc.policy_param('ID_BenefitCap_Switch')[3]: # casualty
3718
- deduct_exps += calc.array('c20500')
3719
- if calc.policy_param('ID_BenefitCap_Switch')[4]: # misc
3720
- deduct_exps += calc.array('c20800')
3721
- if calc.policy_param('ID_BenefitCap_Switch')[5]: # interest
3722
- deduct_exps += calc.array('c19200')
3723
- if calc.policy_param('ID_BenefitCap_Switch')[6]: # charity
3724
- deduct_exps += calc.array('c19700')
3725
- # Calculate cap value for itemized deductions
3726
- benefit_limit = deduct_exps * calc.policy_param('ID_BenefitCap_rt')
3727
- # Add the difference between the actual benefit and capped benefit
3728
- # to income tax and combined tax liabilities.
3729
- excess_benefit = np.maximum(benefit - benefit_limit, 0)
3730
- calc.incarray('iitax', excess_benefit)
3731
- calc.incarray('surtax', excess_benefit)
3732
- calc.incarray('combined', excess_benefit)
3733
-
3734
-
3735
3346
  @iterate_jit(nopython=True)
3736
3347
  def FairShareTax(c00100, MARS, ptax_was, setax, ptax_amc,
3737
3348
  FST_AGI_trt, FST_AGI_thd_lo, FST_AGI_thd_hi,