Skip to content

Commit

Permalink
Merge pull request #2779 from martinholmer/fix-cdcc
Browse files Browse the repository at this point in the history
Fix CDCC phase-out calculations
  • Loading branch information
martinholmer authored Jul 24, 2024
2 parents e9900f2 + f272eee commit 1d21162
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 32 deletions.
7 changes: 0 additions & 7 deletions taxcalc.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: setuptools
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: bokeh
Requires-Dist: numba
Requires-Dist: requests
Requires-Dist: paramtools

| | |
| --- | --- |
Expand Down
41 changes: 22 additions & 19 deletions taxcalc/calcfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,8 @@ def NetInvIncTax(e00300, e00600, e02000, e26270, c01000,
@iterate_jit(nopython=True)
def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
exact, c00100, CDCC_ps, CDCC_ps2, CDCC_crt, CDCC_frt,
CDCC_prt, CDCC_refundable, c05800, e07300, c07180, CDCC_refund):
CDCC_po_step_size, CDCC_po_rate_per_step, CDCC_refundable,
c05800, e07300, c07180, CDCC_refund):
"""
Calculates Form 2441 child and dependent care expense credit, c07180.
Expand Down Expand Up @@ -2166,16 +2167,18 @@ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
Child/dependent care credit phaseout rate ceiling
CDCC_frt: float
Child/dependent care credit phaseout rate floor
CDCC_prt: float
Child/dependent care credit phaseout rate
CDCC_po_step_size: float
Child/dependent care credit phaseout AGI step size
CDCC_po_rate_per_step: float
Child/dependent care credit phaseout rate per step size
CDCC_refund: bool
Indicator for whether CDCC is refundable
c05800: float
Total (regular + AMT) income tax liability before credits
e07300: float
Foreign tax credit from Form 1116
c07180: float
Credit for child and dependent care expenses from Form 2441
CDCC_refund: bool
Indicator for whether CDCC is refundable
Returns
-------
Expand All @@ -2192,22 +2195,22 @@ def F2441(MARS, earned_p, earned_s, f2441, CDCC_c, e32800,
else:
c32890 = earned_p
c33000 = max(0., min(c32800, min(c32880, c32890)))
# credit is limited by AGI-related fraction
# credit rate is limited at high AGI
# ... first phase-down from CDCC_crt to CDCC_frt
steps_fractional = max(0., c00100 - CDCC_ps) / CDCC_po_step_size
if exact == 1: # exact calculation as on tax forms
# first phase-down from 35 to 20 percent
tratio1 = math.ceil(max(((c00100 - CDCC_ps) * CDCC_prt), 0.))
crate = max(CDCC_frt, CDCC_crt - min(CDCC_crt - CDCC_frt, tratio1))
# second phase-down from 20 percent to zero
if c00100 > CDCC_ps2:
tratio2 = math.ceil(max(((c00100 - CDCC_ps2) * CDCC_prt), 0.))
crate = max(0., CDCC_frt - min(CDCC_frt, tratio2))
steps = math.ceil(steps_fractional)
else:
crate = max(CDCC_frt, CDCC_crt -
max(((c00100 - CDCC_ps) * CDCC_prt), 0.))
if c00100 > CDCC_ps2:
crate = max(0., CDCC_frt -
max(((c00100 - CDCC_ps2) * CDCC_prt), 0.))

steps = steps_fractional
crate = max(CDCC_frt, CDCC_crt - steps * CDCC_po_rate_per_step)
# ... second phase-down from CDCC_frt to zero
if c00100 > CDCC_ps2:
steps_fractional = (c00100 - CDCC_ps2) / CDCC_po_step_size
if exact == 1: # exact calculation as on tax forms
steps = math.ceil(steps_fractional)
else:
steps = steps_fractional
crate = max(0., CDCC_frt - steps * CDCC_po_rate_per_step)
c33200 = c33000 * crate
# credit is limited by tax liability if not refundable
if CDCC_refundable:
Expand Down
36 changes: 31 additions & 5 deletions taxcalc/policy_current_law.json
Original file line number Diff line number Diff line change
Expand Up @@ -16461,10 +16461,36 @@
"cps": true
}
},
"CDCC_prt": {
"title": "Child & dependent care credit phaseout rate",
"description": "The CDCC credit rate is reduced by this many percentage points for each dollar of AGI over the phase-out thresholds.",
"notes": "In the law, the credit rate is reduced by 1 percentage point for every $2,000 of AGI over the limit. 0.01 / 2000 = 0.000005",
"CDCC_po_step_size": {
"title": "Child & dependent care credit phaseout step size",
"description": "The CDCC credit rate is reduced by CDCC_po_rate_per_step for each step (including fractional steps) above the phase-out start thresholds.",
"notes": "In the law, the credit rate is reduced by 1 percentage point for every $2,000 of AGI over the phase-out start thresholds",
"section_1": "Nonrefundable Credits",
"section_2": "Child And Dependent Care",
"indexable": true,
"indexed": false,
"type": "float",
"value": [
{
"year": 2013,
"value": 2000
}
],
"validators": {
"range": {
"min": 0,
"max": 9e99
}
},
"compatible_data": {
"puf": true,
"cps": true
}
},
"CDCC_po_rate_per_step": {
"title": "Child & dependent care credit phaseout rate per step",
"description": "The CDCC credit rate is reduced by this rate for for each step (including fractional steps) above the phase-out start thresholds.",
"notes": "In the law, the credit rate is reduced by 1 percentage point for every $2,000 of AGI over the phase-out start thresholds",
"section_1": "Nonrefundable Credits",
"section_2": "Child And Dependent Care",
"indexable": false,
Expand All @@ -16473,7 +16499,7 @@
"value": [
{
"year": 2013,
"value": 5e-06
"value": 0.01
}
],
"validators": {
Expand Down
4 changes: 4 additions & 0 deletions taxcalc/taxcalcio.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ def write_output_file(self, output_dump, dump_varset,
self.calc, dump_varset, mtr_inctax, mtr_paytax
)
column_order = sorted(outdf.columns)
# place RECID at start of column_order list
assert 'RECID' in column_order, 'RECID not in dump output list'
column_order.remove('RECID')
column_order.insert(0, 'RECID')
else:
outdf = self.minimal_output()
column_order = outdf.columns
Expand Down
2 changes: 1 addition & 1 deletion taxcalc/tests/test_taxcalcio.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def test_output_options(reformfile1, assumpfile1):
# --dump output with partial dump
try:
tcio.analyze(writing_output_file=True,
dump_varset=set(['combined']),
dump_varset=set(['RECID', 'combined']),
output_dump=True)
except Exception: # pylint: disable=broad-except
if os.path.isfile(outfilepath):
Expand Down

0 comments on commit 1d21162

Please sign in to comment.