diff --git a/changelog.d/federal-claim-of-right-1341.added.md b/changelog.d/federal-claim-of-right-1341.added.md new file mode 100644 index 00000000000..405a68a9668 --- /dev/null +++ b/changelog.d/federal-claim-of-right-1341.added.md @@ -0,0 +1 @@ +Add the federal claim of right repayment deduction and section 1341 credit (26 U.S.C. 1341), North Carolina's bar on its claim of right deduction when federal tax is computed under section 1341(a)(5), and North Carolina's tax payment for restored income (G.S. 105-266.2). Carry the federal claim of right deduction into California itemized deductions by default through Schedule CA column A. Require section 1341 eligibility for North Carolina's payment and deduction bar, including when the federal method is supplied as an input. Keep North Carolina's refundable payment in the state and household accounting totals. Apply statute-first federal-tax deduction treatment in Alabama, Missouri and Oregon, retain qualifying repayments in Wisconsin's itemized credit base, and complete Montana and Virginia repayment and historical miscellaneous-deduction treatment. diff --git a/changelog.d/mt-al-federal-base-scope.changed.md b/changelog.d/mt-al-federal-base-scope.changed.md new file mode 100644 index 00000000000..c703b2499a8 --- /dev/null +++ b/changelog.d/mt-al-federal-base-scope.changed.md @@ -0,0 +1 @@ +From 2024, Montana taxable income starts from federal AGI less the federal deduction for every Montana filer (with the QBI deduction added back), replacing the reconstructed Montana standard and itemized deductions. From 2015, Alabama's federal income tax deduction subtracts only the refundable part of the American Opportunity Credit for every AOC claimant, along with the net premium tax credit and the section 1341 credit. diff --git a/changelog.d/mt-taxable-income-adjustment-order.fixed.md b/changelog.d/mt-taxable-income-adjustment-order.fixed.md new file mode 100644 index 00000000000..d3ab54a7738 --- /dev/null +++ b/changelog.d/mt-taxable-income-adjustment-order.fixed.md @@ -0,0 +1 @@ +Apply Montana's capped state-income-tax adjustment before flooring the federal taxable-income base at zero in 2024 (Worksheet A), and from 2025 add it after the floor as a Schedule I addition. diff --git a/policyengine_us/parameters/gov/household/household_refundable_state_credits.yaml b/policyengine_us/parameters/gov/household/household_refundable_state_credits.yaml index 2fe90dbccf3..4bdde27f54f 100644 --- a/policyengine_us/parameters/gov/household/household_refundable_state_credits.yaml +++ b/policyengine_us/parameters/gov/household/household_refundable_state_credits.yaml @@ -26,7 +26,7 @@ values: - mo_refundable_credits # Missouri. - ms_refundable_credits # Mississippi. - mt_refundable_credits # Montana. - # Skip NC which has no refundable credits. + - nc_refundable_credits # North Carolina. - nd_refundable_credits # North Dakota. - ne_refundable_credits # Nebraska. - nh_refundable_credits # New Hampshire. diff --git a/policyengine_us/parameters/gov/irs/credits/refundable.yaml b/policyengine_us/parameters/gov/irs/credits/refundable.yaml index 7676cc12363..1f4a2415d29 100644 --- a/policyengine_us/parameters/gov/irs/credits/refundable.yaml +++ b/policyengine_us/parameters/gov/irs/credits/refundable.yaml @@ -6,6 +6,7 @@ values: - refundable_ctc - recovery_rebate_credit - refundable_payroll_tax_credit + - claim_of_right_credit # Currently, the premium tax credit is not included in the refundable tax credits. # Add CDCC in 2021. 2021-01-01: @@ -14,6 +15,7 @@ values: - refundable_ctc - recovery_rebate_credit - refundable_payroll_tax_credit + - claim_of_right_credit # Currently, the premium tax credit is not included in the refundable tax credits. - cdcc # Remove CDCC in 2022. @@ -23,6 +25,7 @@ values: - refundable_ctc - recovery_rebate_credit - refundable_payroll_tax_credit + - claim_of_right_credit # Currently, the premium tax credit is not included in the refundable tax credits. metadata: unit: list diff --git a/policyengine_us/parameters/gov/irs/deductions/itemized/claim_of_right/threshold.yaml b/policyengine_us/parameters/gov/irs/deductions/itemized/claim_of_right/threshold.yaml new file mode 100644 index 00000000000..fa0b89cd6de --- /dev/null +++ b/policyengine_us/parameters/gov/irs/deductions/itemized/claim_of_right/threshold.yaml @@ -0,0 +1,14 @@ +description: The IRS computes tax for the year of repayment as the lesser of the tax with a deduction for the repayment and the tax without it less the resulting decrease in prior-year tax, when the repayment of income held under a claim of right exceeds this amount. +values: + 1954-01-01: 3_000 +metadata: + unit: currency-USD + period: year + label: Claim of right repayment threshold + reference: + - title: 26 U.S. Code § 1341(a)(3) + href: https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapQ-partV-sec1341.htm + - title: 26 CFR 1.1341-1(a)(3) + href: https://www.ecfr.gov/current/title-26/chapter-I/subchapter-A/part-1/subject-group-ECFR4c74bc8cf7c11fb/section-1.1341-1 + - title: "Publication 525 (2025), Repayments #page 36-37" + href: https://www.irs.gov/pub/irs-prior/p525--2025.pdf#page=36 diff --git a/policyengine_us/parameters/gov/irs/deductions/itemized_deductions.yaml b/policyengine_us/parameters/gov/irs/deductions/itemized_deductions.yaml index 55972586fa8..c19e9f6664d 100644 --- a/policyengine_us/parameters/gov/irs/deductions/itemized_deductions.yaml +++ b/policyengine_us/parameters/gov/irs/deductions/itemized_deductions.yaml @@ -7,6 +7,7 @@ values: - medical_expense_deduction - casualty_loss_deduction - misc_deduction + - claim_of_right_deduction metadata: unit: list label: itemized deductions diff --git a/policyengine_us/parameters/gov/states/al/tax/income/deductions/federal_tax/credits.yaml b/policyengine_us/parameters/gov/states/al/tax/income/deductions/federal_tax/credits.yaml index 9ed4a463f26..3343bebc76c 100644 --- a/policyengine_us/parameters/gov/states/al/tax/income/deductions/federal_tax/credits.yaml +++ b/policyengine_us/parameters/gov/states/al/tax/income/deductions/federal_tax/credits.yaml @@ -1,17 +1,27 @@ description: Alabama subtracts the following credits for the federal tax deduction. values: - 2021-01-01: + # Ala. Admin. Code r. 810-3-15-.20(1)(d)2 subtracts all credits shown as + # payments on the federal return. Its current text dates from a 2010 + # amendment, so it governs every year from 2015. Each listed credit existed + # in all those years (the premium tax credit from 2014); a credit with no + # amount in a year contributes zero. + 2015-01-01: - eitc - - american_opportunity_credit + - refundable_american_opportunity_credit - refundable_ctc + - claim_of_right_credit + - net_premium_tax_credit + - al_other_federal_payment_credits metadata: unit: list period: year label: Alabama federal tax deduction subtractable credits reference: - - title: Alabama Code Title 40. Revenue and Taxation § 40-18-21 - href: https://law.justia.com/codes/alabama/title-40/chapter-18/article-1/section-40-18-21/ + - title: Alabama Code § 40-18-15(c) + href: https://alison.legislature.state.al.us/code-of-alabama?section=40-18-15 + - title: Alabama Administrative Code r. 810-3-15-.20(1)(d)2 + href: https://www.revenue.alabama.gov/wp-content/uploads/2021/12/810-3-15-.20.pdf#page=2 - title: 2021 Alabama Form 40A Instructions href: https://www.revenue.alabama.gov/wp-content/uploads/2022/06/21f40abk.pdf#page=20 - title: 2022 Alabama Form 40A Instructions diff --git a/policyengine_us/parameters/gov/states/household/state_income_tax_before_refundable_credits.yaml b/policyengine_us/parameters/gov/states/household/state_income_tax_before_refundable_credits.yaml index 9c16160e1a5..19313329b2f 100644 --- a/policyengine_us/parameters/gov/states/household/state_income_tax_before_refundable_credits.yaml +++ b/policyengine_us/parameters/gov/states/household/state_income_tax_before_refundable_credits.yaml @@ -29,7 +29,7 @@ values: - mo_income_tax_before_refundable_credits - ms_income_tax_before_refundable_credits - mt_income_tax_before_refundable_credits_unit - - nc_income_tax + - nc_income_tax_before_refundable_credits - nd_income_tax_before_refundable_credits - ne_income_tax_before_refundable_credits - nh_income_tax_before_refundable_credits diff --git a/policyengine_us/parameters/gov/states/household/state_refundable_credits.yaml b/policyengine_us/parameters/gov/states/household/state_refundable_credits.yaml index 75c3f95eee0..4dc2984441f 100644 --- a/policyengine_us/parameters/gov/states/household/state_refundable_credits.yaml +++ b/policyengine_us/parameters/gov/states/household/state_refundable_credits.yaml @@ -26,7 +26,7 @@ values: - mo_refundable_credits # Missouri. - ms_refundable_credits # Mississippi. - mt_refundable_credits # Montana. - # Skip NC which has no refundable credits. + - nc_refundable_credits # North Carolina. - nd_refundable_credits # North Dakota. - ne_refundable_credits # Nebraska. - nh_refundable_credits # New Hampshire. diff --git a/policyengine_us/parameters/gov/states/mo/tax/income/deductions/federal_income_tax/ignored_credits.yaml b/policyengine_us/parameters/gov/states/mo/tax/income/deductions/federal_income_tax/ignored_credits.yaml index f82c34178f1..80dc1f2b60d 100644 --- a/policyengine_us/parameters/gov/states/mo/tax/income/deductions/federal_income_tax/ignored_credits.yaml +++ b/policyengine_us/parameters/gov/states/mo/tax/income/deductions/federal_income_tax/ignored_credits.yaml @@ -7,6 +7,8 @@ description: Missouri ignores the following credits in federal income tax deduct # are added back here. The EIC is not added back: the Line 9 instructions say # "If you have an earned income credit, you must subtract the credit from the # tax on your federal return." +# Section 143.171 reduces the base for all credits except its listed exceptions; +# the section 1341 credit is not added back. values: 2018-01-01: - recovery_rebate_credit diff --git a/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/misc_deductions.yaml b/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/misc_deductions.yaml index c4744269768..064c3af1601 100644 --- a/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/misc_deductions.yaml +++ b/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/misc_deductions.yaml @@ -6,13 +6,21 @@ description: Montana counts these sources as miscellaneous deductions. values: 2021-01-01: - casualty_loss_deduction + # Form 2 itemized deductions line 18 follows federal Schedule A line 16. + - mt_claim_of_right_deduction + # From 2024 mt_taxable_income_joint starts from federal taxable income, + # which already reflects the full federal deduction. 2024-01-01: [] - + metadata: unit: list - label: Montana miscellaneous deductions + label: Montana miscellaneous deductions period: year reference: + - title: 2023 Montana Form 2 instructions, itemized deductions line 18 + href: https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2023_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=39 + - title: 2024 Montana Form 2 instructions, line 2 and Worksheet A + href: https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2024_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=15 - title: Montana Individual Income Tax Return (Form 2) 2024 href: https://revenuefiles.mt.gov/files/Forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2024_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=8 - title: Montana Individual Income Tax Return (Form 2) 2022 diff --git a/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/misc_floor.yaml b/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/misc_floor.yaml new file mode 100644 index 00000000000..29d8b09513b --- /dev/null +++ b/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/misc_floor.yaml @@ -0,0 +1,10 @@ +description: Montana subtracts this share of Montana adjusted gross income from the combined pool of floor-subject miscellaneous itemized deductions. +values: + 2017-01-01: 0.02 +metadata: + unit: /1 + period: year + label: Montana miscellaneous itemized deduction AGI floor + reference: + - title: 2017 Montana Form 2 with Legal References, Schedule III lines 21-26 + href: https://web.archive.org/web/20240107204047/https://mtrevenue.gov/wp-content/uploads/2018/02/2017-Form2-with-Legal-References.pdf#page=6 diff --git a/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/misc_floor_applies.yaml b/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/misc_floor_applies.yaml new file mode 100644 index 00000000000..360843de1f4 --- /dev/null +++ b/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/misc_floor_applies.yaml @@ -0,0 +1,14 @@ +description: Montana applies the modeled historical floor-subject miscellaneous itemized deduction component if this is true. +values: + 2015-01-01: false + 2017-01-01: true + 2018-01-01: false +metadata: + unit: bool + period: year + label: Montana historical miscellaneous itemized deduction applies + reference: + - title: 2017 Montana Form 2 with Legal References, Schedule III lines 21-26 + href: https://web.archive.org/web/20240107204047/https://mtrevenue.gov/wp-content/uploads/2018/02/2017-Form2-with-Legal-References.pdf#page=6 + - title: 26 U.S.C. 67, suspension of miscellaneous itemized deductions + href: https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapB-partI-sec67.htm diff --git a/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/state_income_tax_add_back_before_floor.yaml b/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/state_income_tax_add_back_before_floor.yaml new file mode 100644 index 00000000000..7e9114e3062 --- /dev/null +++ b/policyengine_us/parameters/gov/states/mt/tax/income/deductions/itemized/state_income_tax_add_back_before_floor.yaml @@ -0,0 +1,21 @@ +description: Montana adds back the state income tax included in federal itemized deductions before flooring federal taxable income at zero if this is true; otherwise it adds it back after the floor, with the other Montana additions. +# 2024: Worksheet A reduces the federal deduction on Form 2 line 2, before the +# line 3 zero floor. 2025: line 2 is the unadjusted federal deduction and the +# addback is reported on Schedule I, line 4 (from Worksheet B line 11), after +# the floor. By convention, 2026 follows the 2025 form until a 2026 form exists. +values: + 2024-01-01: true + 2025-01-01: false +metadata: + unit: bool + period: year + label: Montana state income tax addback precedes the taxable income floor + reference: + - title: MCA 15-30-2120(1), (2)(j) + href: https://mca.legmt.gov/bills/mca/title_0150/chapter_0300/part_0210/section_0200/0150-0300-0210-0200.html + - title: 2024 Montana Form 2 instructions, line 2 and Worksheet A + href: https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2024_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=15 + - title: "2025 Montana Form 2 instructions, what's new, line 2 and Worksheet B #page 5,13,22" + href: https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2025_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=5 + - title: 2025 Montana Form 2, lines 2-4 + href: https://revenuefiles.mt.gov/files/Forms/Montana-Individual-Income-Tax-Return-Form-2/2025_Montana_Individual_Income_Tax_Return_Form_2.pdf#page=1 diff --git a/policyengine_us/parameters/gov/states/nc/tax/income/credits/refundable.yaml b/policyengine_us/parameters/gov/states/nc/tax/income/credits/refundable.yaml new file mode 100644 index 00000000000..8d654cd21be --- /dev/null +++ b/policyengine_us/parameters/gov/states/nc/tax/income/credits/refundable.yaml @@ -0,0 +1,13 @@ +description: North Carolina provides these refundable income tax credits and payments. +values: + 1995-01-01: + - nc_claim_of_right_payment +metadata: + unit: list + period: year + label: North Carolina refundable income tax credits + reference: + - title: N.C. Gen. Stat. § 105-266.2 + href: https://www.ncleg.gov/EnactedLegislation/Statutes/HTML/BySection/Chapter_105/GS_105-266.2.html + - title: S.L. 1997-213, Section 2 (effective for taxable years beginning on or after January 1, 1995) + href: https://www.ncleg.gov/EnactedLegislation/SessionLaws/HTML/1997-1998/SL1997-213.html diff --git a/policyengine_us/parameters/gov/states/va/tax/income/deductions/itemized/reduction/applicable.yaml b/policyengine_us/parameters/gov/states/va/tax/income/deductions/itemized/reduction/applicable.yaml index 2c9e4102ca5..000810af023 100644 --- a/policyengine_us/parameters/gov/states/va/tax/income/deductions/itemized/reduction/applicable.yaml +++ b/policyengine_us/parameters/gov/states/va/tax/income/deductions/itemized/reduction/applicable.yaml @@ -7,11 +7,23 @@ values: - real_estate_taxes - casualty_loss_deduction - va_capped_state_and_local_sales_or_income_tax + # Schedule A line 16b, other itemized deductions. + - claim_of_right_deduction + # Already reduced by the federal AGI floor; zero from 2018. + - misc_deduction metadata: unit: list period: year label: Virginia itemized deductions reduction applicable deduction sources reference: + - title: Virginia Code Section 58.1-322.03(1)(a) + href: https://law.lis.virginia.gov/vacode/title58.1/chapter3/section58.1-322.03/ + - title: Virginia Code Section 58.1-301(B)(5) + href: https://law.lis.virginia.gov/vacode/title58.1/chapter3/section58.1-301/ + - title: 26 U.S.C. Section 68(a), (c), and (d), 2024 edition + href: https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapB-partI-sec68.htm + - title: "2025 Virginia Schedule A Itemized Deductions, line 16b and Limited Itemized Deduction Worksheet line 1 #page 1-2" + href: https://www.tax.virginia.gov/sites/default/files/taxforms/individual-income-tax/2025/schedule-2025.pdf#page=1 - title: 2024 Virginia Schedule A Itemized Deductions href: https://www.tax.virginia.gov/sites/default/files/taxforms/individual-income-tax/2024/schedule-2024.pdf#page=2 - title: 2023 Virginia Schedule A Itemized Deductions diff --git a/policyengine_us/reforms/states/nc/cdcc/nc_cdcc_reform.py b/policyengine_us/reforms/states/nc/cdcc/nc_cdcc_reform.py index 94e4efaf931..5ef1728228b 100644 --- a/policyengine_us/reforms/states/nc/cdcc/nc_cdcc_reform.py +++ b/policyengine_us/reforms/states/nc/cdcc/nc_cdcc_reform.py @@ -23,41 +23,35 @@ class nc_refundable_credits(Variable): unit = USD definition_period = YEAR defined_for = StateCode.NC + # Baseline computes this via `adds`; replacing it with a + # formula requires clearing the inherited computation mode + # (the core engine rejects `formula` + `adds`/`subtracts`). + adds = None + subtracts = None def formula(tax_unit, period, parameters): + # Preserve the baseline refundable credits and ADD the new + # CDCC (see #8775). Baseline nc_income_tax subtracts + # nc_refundable_credits and excludes nc_use_tax, which + # state_use_tax already counts, so no override of it is needed. + baseline_credits = parameters( + period + ).gov.states.nc.tax.income.credits.refundable + total = add(tax_unit, period, list(baseline_credits)) + tax_unit( + "nc_cdcc", period + ) # Stack with nc_eitc when the NC EITC contrib reform is also # active, so enabling both NC contrib credits sums rather than # overwrites. - total = tax_unit("nc_cdcc", period) variables = tax_unit.simulation.tax_benefit_system.variables if "nc_eitc" in variables: total = total + tax_unit("nc_eitc", period) return total - class nc_income_tax(Variable): - value_type = float - entity = TaxUnit - label = "North Carolina income tax" - unit = USD - definition_period = YEAR - defined_for = StateCode.NC - - def formula(tax_unit, period, parameters): - tax_before_credits = add( - tax_unit, period, ["nc_income_tax_before_credits", "nc_use_tax"] - ) - non_refundable_credits = tax_unit("nc_non_refundable_credits", period) - tax_before_refundable = max_(0, tax_before_credits - non_refundable_credits) - - refundable_credits = tax_unit("nc_refundable_credits", period) - - return tax_before_refundable - refundable_credits - class reform(Reform): def apply(self): self.update_variable(nc_cdcc) self.update_variable(nc_refundable_credits) - self.update_variable(nc_income_tax) return reform diff --git a/policyengine_us/reforms/states/nc/eitc/nc_eitc_reform.py b/policyengine_us/reforms/states/nc/eitc/nc_eitc_reform.py index c483b1dea26..31eff7aba40 100644 --- a/policyengine_us/reforms/states/nc/eitc/nc_eitc_reform.py +++ b/policyengine_us/reforms/states/nc/eitc/nc_eitc_reform.py @@ -23,35 +23,28 @@ class nc_refundable_credits(Variable): unit = USD definition_period = YEAR defined_for = StateCode.NC + # Baseline computes this via `adds`; replacing it with a + # formula requires clearing the inherited computation mode + # (the core engine rejects `formula` + `adds`/`subtracts`). + adds = None + subtracts = None def formula(tax_unit, period, parameters): - return tax_unit("nc_eitc", period) - - class nc_income_tax(Variable): - value_type = float - entity = TaxUnit - label = "North Carolina income tax" - unit = USD - definition_period = YEAR - defined_for = StateCode.NC - - def formula(tax_unit, period, parameters): - # Mirror baseline nc_income_tax, which uses - # nc_income_tax_before_credits and does NOT add nc_use_tax. This - # reform's only change is subtracting the new refundable EITC; - # adding use tax here would raise tax for every filer (even those - # with no EITC). See #8775. - tax_before_credits = tax_unit("nc_income_tax_before_credits", period) - non_refundable_credits = tax_unit("nc_non_refundable_credits", period) - tax_before_refundable = max_(0, tax_before_credits - non_refundable_credits) - refundable_credits = tax_unit("nc_refundable_credits", period) - return tax_before_refundable - refundable_credits + # Preserve the baseline refundable credits and ADD the new + # EITC. Baseline nc_income_tax subtracts nc_refundable_credits + # and excludes nc_use_tax, so no override of it is needed. + # See #8775. + baseline_credits = parameters( + period + ).gov.states.nc.tax.income.credits.refundable + return add(tax_unit, period, list(baseline_credits)) + tax_unit( + "nc_eitc", period + ) class reform(Reform): def apply(self): self.update_variable(nc_eitc) self.update_variable(nc_refundable_credits) - self.update_variable(nc_income_tax) return reform diff --git a/policyengine_us/tests/core/test_override_branches.py b/policyengine_us/tests/core/test_override_branches.py index a5379432b5a..4f3bc4fb5e1 100644 --- a/policyengine_us/tests/core/test_override_branches.py +++ b/policyengine_us/tests/core/test_override_branches.py @@ -29,7 +29,10 @@ on the seeded sample and on random households (Hypothesis). 3. Each comparison branch equals a fresh simulation that sets the overridden input before anything is calculated (a differential test of the branch - against the reference path). + against the reference path). These households repay no claim of right + income; with a qualifying repayment the itemizing branches also fix the + claim of right method, so a reference must fix it too + (``test_claim_of_right_section_1341_properties.py`` covers that case). 4. The same holds when the parent has already calculated the overridden input, and when an earlier year was calculated first. 5. When the branch drops what it copied, it keeps exactly the values set as diff --git a/policyengine_us/tests/core/test_state_income_tax_accounting_invariants.py b/policyengine_us/tests/core/test_state_income_tax_accounting_invariants.py index 10abc0b5d0e..cc3bc4f2bde 100644 --- a/policyengine_us/tests/core/test_state_income_tax_accounting_invariants.py +++ b/policyengine_us/tests/core/test_state_income_tax_accounting_invariants.py @@ -67,11 +67,6 @@ # Lower of the joint return and separate returns on one form, each after # refundable credits. "MT", - # No refundable credits in baseline, so the before-refundable list holds - # nc_income_tax itself. The contributed EITC and child care credit reforms - # net their refundable credits inside nc_income_tax, which keeps NC out of - # the refundable list. - "NC", # No tax at or below the filing threshold. The zero-out is in both # nj_income_tax_before_refundable_credits and nj_income_tax; the second # copy keeps tests that set the first as an input right. diff --git a/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/claim_of_right_credit.yaml b/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/claim_of_right_credit.yaml new file mode 100644 index 00000000000..511377a29dc --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/claim_of_right_credit.yaml @@ -0,0 +1,26 @@ +- name: Case 1, the credit is the prior-year decrease when tax is computed under section 1341(a)(5). + period: 2025 + input: + claim_of_right_section_1341_eligible: true + claim_of_right_credit_applies: true + claim_of_right_prior_year_tax_decrease: 1_234 + output: + claim_of_right_credit: 1_234 + +- name: Case 2, no credit under section 1341(a)(4). + period: 2025 + input: + claim_of_right_section_1341_eligible: true + claim_of_right_credit_applies: false + claim_of_right_prior_year_tax_decrease: 1_234 + output: + claim_of_right_credit: 0 + +- name: Case 3, no credit without a qualifying repayment. + period: 2025 + input: + claim_of_right_section_1341_eligible: false + claim_of_right_credit_applies: true + claim_of_right_prior_year_tax_decrease: 1_234 + output: + claim_of_right_credit: 0 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/claim_of_right_credit_applies.yaml b/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/claim_of_right_credit_applies.yaml new file mode 100644 index 00000000000..d380d895243 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/claim_of_right_credit_applies.yaml @@ -0,0 +1,128 @@ +# 26 CFR 1.1341-1(b)(3): when the two computations give the same tax, tax is +# computed under 1341(a)(4), with the deduction. The household is +# Publication 525 (2025) Example 40: $5,155.50 with the deduction and $5,903 +# without it. +- name: Case 1, equal tax under both methods keeps the deduction. + period: 2025 + input: + age: 40 + employment_income: 65_700 + charitable_cash_donations: 15_750 + claim_of_right_repayment: 5_000 + # $5,903 - $747.50 = $5,155.50, the tax with the deduction. + claim_of_right_prior_year_tax_decrease: 747.5 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + income_tax_if_claiming_claim_of_right_credit: 5_155.5 + income_tax_if_claiming_claim_of_right_deduction: 5_155.5 + claim_of_right_credit_applies: false + income_tax: 5_155.5 + +- name: Case 2, a prior-year decrease 50 cents larger makes the credit apply. + period: 2025 + input: + age: 40 + employment_income: 65_700 + charitable_cash_donations: 15_750 + claim_of_right_repayment: 5_000 + claim_of_right_prior_year_tax_decrease: 748 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + claim_of_right_credit_applies: true + claim_of_right_deduction: 0 + claim_of_right_credit: 748 + income_tax: 5_155 + +- name: Case 3, a repayment of $3,000 cannot use section 1341. + period: 2025 + input: + age: 40 + employment_income: 65_700 + charitable_cash_donations: 15_750 + claim_of_right_repayment: 3_000 + claim_of_right_prior_year_tax_decrease: 2_000 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + claim_of_right_credit_applies: false + claim_of_right_deduction: 0 + claim_of_right_credit: 0 + # Section 67(g) (now 67(h)) disallows the miscellaneous deduction, so tax is + # unchanged at the tax on $49,950. + income_tax: 5_903 + +- name: Case 4, with no prior-year decrease the deduction applies. + period: 2025 + input: + age: 40 + employment_income: 65_700 + charitable_cash_donations: 15_750 + # $3,001 is the smallest whole-dollar repayment that qualifies. + claim_of_right_repayment: 3_001 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + claim_of_right_credit_applies: false + claim_of_right_deduction: 3_001 + # $65,700 - $15,750 - $3,001 = $46,949; $1,192.50 + 12% x $35,024. + taxable_income: 46_949 + income_tax: 5_395.38 + +- name: Case 5, the credit applies when it gives one cent less tax. + period: 2025 + input: + age: 40 + employment_income: 65_700 + charitable_cash_donations: 15_750 + claim_of_right_repayment: 5_000 + # $5,903 - $747.51 = $5,155.49, one cent below the tax with the deduction. + claim_of_right_prior_year_tax_decrease: 747.51 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + claim_of_right_credit_applies: true + claim_of_right_credit: 747.51 + income_tax: 5_155.49 + +- name: Case 6, the method is the same when itemizing is decided by comparing deductions. + # Publication 525 (2025) Example 40 with + # gov.simulation.branch_to_determine_itemization off. + period: 2025 + input: + gov.simulation.branch_to_determine_itemization: false + age: 40 + employment_income: 65_700 + charitable_cash_donations: 15_750 + claim_of_right_repayment: 5_000 + claim_of_right_prior_year_tax_decrease: 568 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + income_tax_if_claiming_claim_of_right_deduction: 5_155.5 + income_tax_if_claiming_claim_of_right_credit: 5_335 + claim_of_right_credit_applies: false + income_tax: 5_155.5 + +- name: Case 7, the credit applies for a standard deduction filer when itemizing is decided by comparing deductions. + period: 2025 + input: + gov.simulation.branch_to_determine_itemization: false + age: 40 + employment_income: 40_000 + claim_of_right_repayment: 10_000 + claim_of_right_prior_year_tax_decrease: 2_200 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + claim_of_right_credit_applies: true + claim_of_right_credit: 2_200 + income_tax: 471.5 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/claim_of_right_section_1341_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/claim_of_right_section_1341_eligible.yaml new file mode 100644 index 00000000000..701c7120800 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/claim_of_right_section_1341_eligible.yaml @@ -0,0 +1,51 @@ +# 26 U.S.C. 1341(a)(3): the deduction must exceed $3,000. Publication 525 +# (2025), PDF page 36: "consider the total amount being repaid on the +# return. Each instance of repayment isn't considered separately." +- name: Case 1, a repayment of exactly $3,000 does not qualify. + period: 2025 + input: + tax_unit_claim_of_right_repayment: 3_000 + output: + claim_of_right_section_1341_eligible: false + +- name: Case 2, a repayment of $3,000.01 qualifies. + period: 2025 + input: + tax_unit_claim_of_right_repayment: 3_000.01 + output: + claim_of_right_section_1341_eligible: true + +- name: Case 3, no repayment. + period: 2025 + input: + tax_unit_claim_of_right_repayment: 0 + output: + claim_of_right_section_1341_eligible: false + +- name: Case 4, two repayments of $2,000 on a joint return qualify together. + period: 2025 + input: + people: + person1: + age: 45 + claim_of_right_repayment: 2_000 + person2: + age: 44 + claim_of_right_repayment: 2_000 + tax_units: + tax_unit: + members: [person1, person2] + households: + household: + members: [person1, person2] + state_code: TX + output: + tax_unit_claim_of_right_repayment: 4_000 + claim_of_right_section_1341_eligible: true + +- name: Case 5, the $3,000 threshold applied before 2018 too. + period: 2017 + input: + tax_unit_claim_of_right_repayment: 3_001 + output: + claim_of_right_section_1341_eligible: true diff --git a/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/integration.yaml b/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/integration.yaml new file mode 100644 index 00000000000..2f5c5abfded --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/integration.yaml @@ -0,0 +1,372 @@ +# Publication 525, Repayments, Example 40, in three editions. A single filer +# repaid $5,000 of income included in the prior year's income under a claim +# of right. Taxable income is $49,950 without the deduction and $44,950 with +# it; excluding the $5,000 cut the prior year's tax by $568 (2025, 2024) or +# $750 (2018). In each edition method 1, the deduction, gives less tax. +# Wages and charitable gifts are chosen to reproduce those taxable incomes: +# without the repayment, itemized deductions equal the standard deduction. +# Publication 525 figures tax with the Tax Table in 2024 and 2018 (the +# midpoint of each $50 row); PolicyEngine applies the rate schedule. + +- name: Case 1, Publication 525 (2025) Example 40, the deduction gives less tax. + # https://www.irs.gov/pub/irs-prior/p525--2025.pdf#page=36 + period: 2025 + input: + age: 40 + employment_income: 65_700 + charitable_cash_donations: 15_750 + claim_of_right_repayment: 5_000 + claim_of_right_prior_year_tax_decrease: 568 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + claim_of_right_section_1341_eligible: true + # Method 1: tax on $44,950 = $1,192.50 + 12% x ($44,950 - $11,925). + # Publication 525 rounds $5,155.50 to $5,156. + income_tax_if_claiming_claim_of_right_deduction: 5_155.5 + # Method 2: tax on $49,950, $5,903, less the $568 prior-year decrease. + income_tax_if_claiming_claim_of_right_credit: 5_335 + claim_of_right_credit_applies: false + claim_of_right_deduction: 5_000 + claim_of_right_credit: 0 + taxable_income: 44_950 + income_tax: 5_155.5 + +- name: Case 2, Publication 525 (2024) Example 40, the deduction gives less tax. + # https://www.irs.gov/pub/irs-prior/p525--2024.pdf#page=37 + period: 2024 + input: + age: 40 + employment_income: 64_550 + charitable_cash_donations: 14_600 + claim_of_right_repayment: 5_000 + claim_of_right_prior_year_tax_decrease: 568 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + # $1,160 + 12% x ($44,950 - $11,600) = $5,162; the Tax Table gives + # $5,165. + income_tax_if_claiming_claim_of_right_deduction: 5_162 + # $1,160 + $4,266 + 22% x ($49,950 - $47,150) = $6,042 (Tax Table + # $6,048), less $568 = $5,474 (Publication 525: $5,480). + income_tax_if_claiming_claim_of_right_credit: 5_474 + claim_of_right_credit_applies: false + claim_of_right_deduction: 5_000 + taxable_income: 44_950 + income_tax: 5_162 + +- name: Case 3, Publication 525 (2018) Example 40, the deduction gives less tax. + # https://www.irs.gov/pub/irs-prior/p525--2018.pdf#page=34 + period: 2018 + input: + age: 40 + employment_income: 61_950 + charitable_cash_donations: 12_000 + claim_of_right_repayment: 5_000 + claim_of_right_prior_year_tax_decrease: 750 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + # $952.50 + $3,501 + 22% x ($44,950 - $38,700) = $5,828.50 (Tax Table + # $5,834). + income_tax_if_claiming_claim_of_right_deduction: 5_828.5 + # $4,453.50 + 22% x ($49,950 - $38,700) = $6,928.50 (Tax Table $6,934), + # less $750 = $6,178.50 (Publication 525: $6,184). + income_tax_if_claiming_claim_of_right_credit: 6_178.5 + claim_of_right_credit_applies: false + claim_of_right_deduction: 5_000 + taxable_income: 44_950 + income_tax: 5_828.5 + +- name: Case 4, a filer who takes the standard deduction gains only from the credit. + # Publication 525 (2025) method 2 steps: tax without the deduction, less + # the decrease in the earlier year's tax. + period: 2025 + input: + age: 40 + employment_income: 40_000 + claim_of_right_repayment: 10_000 + claim_of_right_prior_year_tax_decrease: 2_200 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + # Itemizing $10,000 loses to the $15,750 standard deduction, so the + # deduction leaves tax on $24,250 at $1,192.50 + 12% x $12,325. + income_tax_if_claiming_claim_of_right_deduction: 2_671.5 + income_tax_if_claiming_claim_of_right_credit: 471.5 + claim_of_right_credit_applies: true + claim_of_right_deduction: 0 + claim_of_right_credit: 2_200 + taxable_income: 24_250 + income_tax: 471.5 + +- name: Case 5, a prior-year decrease above the year's tax is refunded. + # 26 U.S.C. 1341(b)(1): the excess is considered a payment of tax. + period: 2025 + input: + age: 40 + employment_income: 40_000 + claim_of_right_repayment: 10_000 + claim_of_right_prior_year_tax_decrease: 3_000 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + claim_of_right_credit_applies: true + claim_of_right_credit: 3_000 + income_tax_before_refundable_credits: 2_671.5 + income_tax: -328.5 + +- name: Case 6, a joint return counts the spouses' repayments, not a dependent's. + period: 2025 + input: + people: + person1: + age: 45 + employment_income: 90_000 + claim_of_right_repayment: 2_000 + person2: + age: 44 + claim_of_right_repayment: 2_000 + person3: + age: 30 + is_tax_unit_dependent: true + claim_of_right_repayment: 9_000 + tax_units: + tax_unit: + members: [person1, person2, person3] + # The decrease in the couple's earlier joint tax from excluding the + # $4,000 they repaid. + claim_of_right_prior_year_tax_decrease: 500 + state_sales_tax: 0 + local_sales_tax: 0 + households: + household: + members: [person1, person2, person3] + state_code: TX + output: + tax_unit_claim_of_right_repayment: 4_000 + claim_of_right_section_1341_eligible: true + # Taxable income $90,000 - $31,500 = $58,500; tax $2,385 + 12% x + # $34,650 = $6,543, less the $500 credit for other dependents. The + # $4,000 deduction loses to the standard deduction. + income_tax_if_claiming_claim_of_right_deduction: 6_043 + income_tax_if_claiming_claim_of_right_credit: 5_543 + claim_of_right_credit_applies: true + claim_of_right_credit: 500 + income_tax: 5_543 + +# Combined regression for section 1341 and the charitable deduction for +# non-itemizers. Wages of $120,000 phase out all pandemic rebates. New +# Hampshire and zero sales taxes leave no state or local tax deduction. +# The single-filer rate schedules give, throughout these cases: +# 2020: $14,605.50 + 24% x (taxable income - $85,525). +# 2021: $14,751 + 24% x (taxable income - $86,375). +# https://www.irs.gov/pub/irs-prior/i1040gi--2020.pdf#page=111 +# https://www.irs.gov/pub/irs-prior/i1040gi--2021.pdf + +- name: Case 7, 2020 section 1341 deduction itemizes cash gifts once and forgoes line 10b. + period: 2020 + input: + gov.simulation.branch_to_determine_itemization: true + age: 40 + employment_income: 120_000 + deductible_mortgage_interest: 10_000 + charitable_cash_donations: 300 + claim_of_right_repayment: 5_000 + claim_of_right_prior_year_tax_decrease: 100 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: NH + output: + claim_of_right_section_1341_eligible: true + # Deduction: Schedule A = 10,000 + 300 + 5,000 = 15,300; + # taxable income = 120,000 - 15,300 = 104,700; tax = + # 14,605.50 + 24% x 19,175 = 19,207.50. + income_tax_if_claiming_claim_of_right_deduction: 19_207.5 + # Credit: line 10b = 300; AGI = 119,700; taxable income = + # 119,700 - 12,400 = 107,300; tax = 14,605.50 + 24% x + # 21,775 = 19,831.50, less the prior-year decrease of 100. + income_tax_if_claiming_claim_of_right_credit: 19_731.5 + claim_of_right_credit_applies: false + claim_of_right_deduction: 5_000 + claim_of_right_credit: 0 + tax_unit_itemizes: true + charitable_contributions_ald: 0 + charitable_deduction_for_non_itemizers: 0 + adjusted_gross_income: 120_000 + total_itemized_taxable_income_deductions: 15_300 + taxable_income: 104_700 + # The forced-itemization branches must keep the deduction method: + # forcing the standard deduction does not introduce a 100 credit. + tax_liability_if_itemizing: 19_207.5 + tax_liability_if_not_itemizing: 19_831.5 + income_tax: 19_207.5 + +- name: Case 8, 2020 section 1341 credit preserves the above-the-line charitable deduction. + period: 2020 + input: + gov.simulation.branch_to_determine_itemization: true + age: 40 + employment_income: 120_000 + deductible_mortgage_interest: 10_000 + charitable_cash_donations: 300 + claim_of_right_repayment: 5_000 + claim_of_right_prior_year_tax_decrease: 1_000 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: NH + output: + # The deduction still gives Case 7's 19,207.50, but the credit now + # gives 19,831.50 - 1,000 = 18,831.50, so it wins. + income_tax_if_claiming_claim_of_right_deduction: 19_207.5 + income_tax_if_claiming_claim_of_right_credit: 18_831.5 + claim_of_right_credit_applies: true + claim_of_right_deduction: 0 + claim_of_right_credit: 1_000 + tax_unit_itemizes: false + charitable_contributions_ald: 300 + charitable_deduction_for_non_itemizers: 0 + adjusted_gross_income: 119_700 + taxable_income: 107_300 + # Keep the credit method even when forced to itemize: Schedule A = + # 10,000 + 300 = 10,300; taxable income = 109,700; tax = + # 14,605.50 + 24% x 24,175 - 1,000 = 19,407.50. + tax_liability_if_itemizing: 19_407.5 + tax_liability_if_not_itemizing: 18_831.5 + income_tax: 18_831.5 + +- name: Case 9, 2021 section 1341 deduction itemizes cash gifts without duplicating line 12b. + period: 2021 + input: + gov.simulation.branch_to_determine_itemization: true + age: 40 + employment_income: 120_000 + deductible_mortgage_interest: 10_000 + charitable_cash_donations: 300 + claim_of_right_repayment: 5_000 + claim_of_right_prior_year_tax_decrease: 100 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: NH + output: + # Schedule A = 10,000 + 300 + 5,000 = 15,300; taxable income = + # 120,000 - 15,300 = 104,700; tax = 14,751 + 24% x 18,325. + income_tax_if_claiming_claim_of_right_deduction: 19_149 + # The standard deduction plus line 12b is 12,550 + 300 = 12,850; + # taxable income = 107,150; tax = 14,751 + 24% x 20,775 = + # 19,737, less the prior-year decrease of 100. + income_tax_if_claiming_claim_of_right_credit: 19_637 + claim_of_right_credit_applies: false + claim_of_right_deduction: 5_000 + claim_of_right_credit: 0 + tax_unit_itemizes: true + charitable_contributions_ald: 0 + adjusted_gross_income: 120_000 + total_itemized_taxable_income_deductions: 15_300 + taxable_income_deductions: 15_300 + taxable_income: 104_700 + # Both forced-itemization branches retain the deduction method. + tax_liability_if_itemizing: 19_149 + tax_liability_if_not_itemizing: 19_737 + income_tax: 19_149 + +- name: Case 10, 2021 section 1341 credit keeps cash gifts below the line. + period: 2021 + input: + gov.simulation.branch_to_determine_itemization: true + age: 40 + employment_income: 120_000 + deductible_mortgage_interest: 10_000 + charitable_cash_donations: 300 + claim_of_right_repayment: 5_000 + claim_of_right_prior_year_tax_decrease: 1_000 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: NH + output: + # Case 9's deduction tax is 19,149; the credit gives + # 19,737 - 1,000 = 18,737, which is lower. + income_tax_if_claiming_claim_of_right_deduction: 19_149 + income_tax_if_claiming_claim_of_right_credit: 18_737 + claim_of_right_credit_applies: true + claim_of_right_deduction: 0 + claim_of_right_credit: 1_000 + tax_unit_itemizes: false + charitable_contributions_ald: 0 + adjusted_gross_income: 120_000 + charitable_deduction_for_non_itemizers: 300 + taxable_income_deductions: 12_850 + taxable_income: 107_150 + # Forced itemization retains the credit: taxable income = + # 120,000 - (10,000 + 300) = 109,700; tax = + # 14,751 + 24% x 23,325 - 1,000 = 19,349. + tax_liability_if_itemizing: 19_349 + tax_liability_if_not_itemizing: 18_737 + income_tax: 18_737 + +- name: Case 11, 2020 without branching counts line 10b against the section 1341 deduction. + period: 2020 + input: + gov.simulation.branch_to_determine_itemization: false + age: 40 + employment_income: 120_000 + deductible_mortgage_interest: 7_300 + charitable_cash_donations: 300 + claim_of_right_repayment: 5_000 + claim_of_right_prior_year_tax_decrease: 100 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: NH + output: + # With the repayment deduction, Schedule A = 7,300 + 300 + 5,000 = + # 12,600. Not itemizing deducts 12,400 plus 300 above the line = + # 12,700, so even the deduction method must use the standard deduction. + # Taxable income = 120,000 - 300 - 12,400 = 107,300; tax = + # 14,605.50 + 24% x 21,775 = 19,831.50. + income_tax_if_claiming_claim_of_right_deduction: 19_831.5 + # The credit lowers the same tax by 100. + income_tax_if_claiming_claim_of_right_credit: 19_731.5 + claim_of_right_credit_applies: true + claim_of_right_deduction: 0 + claim_of_right_credit: 100 + tax_unit_itemizes: false + charitable_contributions_ald: 300 + adjusted_gross_income: 119_700 + taxable_income: 107_300 + income_tax: 19_731.5 + +- name: Case 12, 2021 without branching counts line 12b against the section 1341 deduction. + period: 2021 + input: + gov.simulation.branch_to_determine_itemization: false + age: 40 + employment_income: 120_000 + deductible_mortgage_interest: 7_400 + charitable_cash_donations: 300 + claim_of_right_repayment: 5_000 + claim_of_right_prior_year_tax_decrease: 100 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: NH + output: + # With the repayment deduction, Schedule A = 7,400 + 300 + 5,000 = + # 12,700. The standard deduction plus line 12b is 12,550 + 300 = + # 12,850, so neither method itemizes. Taxable income = + # 120,000 - 12,850 = 107,150; tax = 14,751 + 24% x 20,775. + income_tax_if_claiming_claim_of_right_deduction: 19_737 + income_tax_if_claiming_claim_of_right_credit: 19_637 + claim_of_right_credit_applies: true + claim_of_right_deduction: 0 + claim_of_right_credit: 100 + tax_unit_itemizes: false + charitable_contributions_ald: 0 + adjusted_gross_income: 120_000 + charitable_deduction_for_non_itemizers: 300 + taxable_income_deductions: 12_850 + taxable_income: 107_150 + income_tax: 19_637 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/tax_unit_claim_of_right_repayment.yaml b/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/tax_unit_claim_of_right_repayment.yaml new file mode 100644 index 00000000000..20e1e01985c --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/credits/claim_of_right/tax_unit_claim_of_right_repayment.yaml @@ -0,0 +1,40 @@ +- name: Case 1, the head's and spouse's repayments add up. + period: 2025 + input: + people: + person1: + age: 45 + claim_of_right_repayment: 2_000 + person2: + age: 44 + claim_of_right_repayment: 1_500 + tax_units: + tax_unit: + members: [person1, person2] + households: + household: + members: [person1, person2] + state_code: TX + output: + tax_unit_claim_of_right_repayment: 3_500 + +- name: Case 2, a dependent's repayment belongs on the dependent's own return. + period: 2025 + input: + people: + person1: + age: 45 + claim_of_right_repayment: 1_000 + person2: + age: 20 + is_tax_unit_dependent: true + claim_of_right_repayment: 5_000 + tax_units: + tax_unit: + members: [person1, person2] + households: + household: + members: [person1, person2] + state_code: TX + output: + tax_unit_claim_of_right_repayment: 1_000 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/deductions/itemizing/claim_of_right_deduction.yaml b/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/deductions/itemizing/claim_of_right_deduction.yaml new file mode 100644 index 00000000000..8afcaf3dcbd --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/deductions/itemizing/claim_of_right_deduction.yaml @@ -0,0 +1,69 @@ +- name: Case 1, the whole repayment is deductible under section 1341(a)(4). + period: 2025 + input: + tax_unit_claim_of_right_repayment: 8_000 + claim_of_right_section_1341_eligible: true + claim_of_right_credit_applies: false + output: + claim_of_right_deduction: 8_000 + +- name: Case 2, no deduction under section 1341(a)(5). + # 26 U.S.C. 1341(b)(3). + period: 2025 + input: + tax_unit_claim_of_right_repayment: 8_000 + claim_of_right_section_1341_eligible: true + claim_of_right_credit_applies: true + output: + claim_of_right_deduction: 0 + +- name: Case 3, a repayment of $3,000 or less is not a section 1341 deduction. + period: 2025 + input: + tax_unit_claim_of_right_repayment: 3_000 + claim_of_right_section_1341_eligible: false + claim_of_right_credit_applies: false + output: + claim_of_right_deduction: 0 + +- name: Case 4, the deduction is subject to the overall limitation on itemized deductions before 2018. + # 2017 Schedule A instructions, Itemized Deductions Worksheet, PDF page 14: + # line 2 removes only gambling and casualty or theft losses on line 28, so + # the line 28 claim of right deduction stays in the limited base. + period: 2017 + input: + age: 40 + employment_income: 400_000 + claim_of_right_repayment: 50_000 + # Federal income tax is modeled from 2018, so fix the method here + # instead of deriving it from 2017 tax. + claim_of_right_credit_applies: false + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + claim_of_right_deduction: 50_000 + total_itemized_taxable_income_deductions: 50_000 + # min(3% x ($400,000 - $261,500), 80% x $50,000) = $4,155. + itemized_taxable_income_deductions_reduction: 4_155 + itemized_taxable_income_deductions: 45_845 + +- name: Case 5, the deduction is subject to the limitation on itemized deductions from 2026. + # 26 U.S.C. 68 as amended by P.L. 119-21, sec. 70111: 2/37 of the lesser + # of itemized deductions and taxable income plus itemized deductions above + # the $640,600 start of the 37% bracket for single filers in 2026. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + employment_income: 1_000_000 + claim_of_right_repayment: 100_000 + state_sales_tax: 0 + local_sales_tax: 0 + state_code: TX + output: + claim_of_right_deduction: 100_000 + total_itemized_taxable_income_deductions: 100_000 + # 2/37 x min($100,000, $1,000,000 - $640,600) = $5,405.41. + itemized_taxable_income_deductions_reduction: 5_405.41 + itemized_taxable_income_deductions: 94_594.59 diff --git a/policyengine_us/tests/policy/baseline/gov/states/al/tax/income/deductions/al_federal_income_tax_deduction.yaml b/policyengine_us/tests/policy/baseline/gov/states/al/tax/income/deductions/al_federal_income_tax_deduction.yaml index c2f67aca5f1..9a70f6175b8 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/al/tax/income/deductions/al_federal_income_tax_deduction.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/al/tax/income/deductions/al_federal_income_tax_deduction.yaml @@ -77,7 +77,7 @@ # no non-refundable add-backs. # Hand arithmetic: # federal_tax = 100; niit = 200 - # Part I = max(100 - eitc(200) - full_AOC(200) - refundable_ctc(0), 0) = 0 + # Part I = max(100 - eitc(200) - refundable_AOC(80) - refundable_ctc(0), 0) = 0 # regular_tax_basis = 100 - 200 = -100 # line_6 = max(-100, 0) = 0 <- floor before NIIT # refundable_AOC = 0.4 * 200 = 80 @@ -112,14 +112,14 @@ # # Hand arithmetic (all direct inputs): # federal_tax = income_tax_before_refundable_credits = 5,000; NIIT = 0 - # Part I = max(5,000 - eitc(0) - full_AOC(2,500) - refundable_ctc(0), 0) - # = 2,500 + # Part I = max(5,000 - eitc(0) - refundable_AOC(1,000) - refundable_ctc(0), 0) + # = 4,000 # regular_tax_basis = 5,000 - 0 = 5,000 # line_6 = max(5,000 + 0 + 0 - 0 - 0, 0) = 5,000 # refundable_AOC = 0.4 * 2,500 = 1,000 # Part II = max(5,000 + NIIT(0) - eitc(0) - refundable_ctc(0) # - refundable_AOC(1,000), 0) = 4,000 - # deduction = max(Part I 2,500, Part II 4,000) = 4,000 + # deduction = max(Part I 4,000, Part II 4,000) = 4,000 # Regression guard: the pre-fix code subtracted the full $2,500 AOC in Part II, # giving Part II = max(5,000 - 2,500, 0) = 2,500 and a deduction of 2,500. absolute_error_margin: 0.01 @@ -289,6 +289,114 @@ cdcc: 3_500 al_federal_income_tax_deduction: 4_390 +- name: Alabama subtracts payment credits and only refundable AOC + # Ala. Admin. Code r. 810-3-15-.20(1)(d)2 requires all payment credits. + # Federal tax already reflects the nonrefundable $1,500 of the total AOC. + # max(5,000 - 1,000 refundable AOC - 1,500 claim credit - 1,000 net PTC, 0). + period: 2025 + input: + state_code: AL + income_tax_before_refundable_credits: 5_000 + eitc: 0 + american_opportunity_credit: 2_500 + refundable_american_opportunity_credit: 1_000 + refundable_ctc: 0 + claim_of_right_credit: 1_500 + net_premium_tax_credit: 1_000 + al_other_federal_payment_credits: 0 + output: + al_federal_income_tax_deduction: 1_500 + +- name: Alabama applies the regulation's full payment-credit list before 2021 + # Ala. Admin. Code r. 810-3-15-.20(1)(d)2 (amended 2010) governs 2020 too. + # Federal tax already reflects the nonrefundable $1,500 of the total AOC. + # max(5,000 - 1,000 refundable AOC - 1,500 claim credit - 1,000 net PTC + # - 750 other payment credits - 0 EITC - 0 refundable CTC, 0) = 750. + period: 2020 + input: + state_code: AL + income_tax_before_refundable_credits: 5_000 + eitc: 0 + american_opportunity_credit: 2_500 + refundable_american_opportunity_credit: 1_000 + refundable_ctc: 0 + claim_of_right_credit: 1_500 + net_premium_tax_credit: 1_000 + al_other_federal_payment_credits: 750 + output: + al_federal_income_tax_deduction: 750 + +- name: Alabama payment credits cannot make the deduction negative + period: 2025 + input: + state_code: AL + income_tax_before_refundable_credits: 1_000 + eitc: 0 + refundable_american_opportunity_credit: 0 + refundable_ctc: 0 + claim_of_right_credit: 1_500 + net_premium_tax_credit: 0 + al_other_federal_payment_credits: 0 + output: + al_federal_income_tax_deduction: 0 + +- name: Alabama 2021 alternative subtracts claim credit and net PTC + # Childless $50,000 filer has no recomputed CTC, CDCC, or EITC. + # Both alternatives equal max(5,000 - 1,500 - 1,000, 0). + period: 2021 + input: + state_code: AL + age: 40 + employment_income: 50_000 + income_tax_before_refundable_credits: 5_000 + net_investment_income_tax: 0 + ctc: 0 + refundable_ctc: 0 + cdcc: 0 + eitc: 0 + refundable_american_opportunity_credit: 0 + claim_of_right_credit: 1_500 + net_premium_tax_credit: 1_000 + al_other_federal_payment_credits: 0 + output: + al_federal_income_tax_deduction: 2_500 + +- name: Alabama subtracts residual federal payment credits + # The residual input covers credits not otherwise named in the list. + period: 2025 + input: + state_code: AL + income_tax_before_refundable_credits: 5_000 + eitc: 0 + refundable_american_opportunity_credit: 0 + refundable_ctc: 0 + claim_of_right_credit: 0 + net_premium_tax_credit: 0 + al_other_federal_payment_credits: 750 + output: + al_federal_income_tax_deduction: 4_250 + +- name: Alabama 2021 alternative floors the deduction after all payment credits + # The line-6 floor protects NIIT before payment credits are subtracted. + # Both alternatives must still subtract the residual credits and floor at 0. + period: 2021 + input: + state_code: AL + age: 40 + employment_income: 50_000 + income_tax_before_refundable_credits: 0 + net_investment_income_tax: 1_900 + ctc: 0 + refundable_ctc: 0 + cdcc: 0 + eitc: 0 + refundable_american_opportunity_credit: 0 + claim_of_right_credit: 500 + net_premium_tax_credit: 500 + al_other_federal_payment_credits: 1_000 + output: + al_federal_income_tax_deduction: 0 + - name: 2021 head of household, one child - Part II recomputes the EITC only for a taker period: 2021 absolute_error_margin: 0.01 diff --git a/policyengine_us/tests/policy/baseline/gov/states/az/tax/income/deductions/itemized/az_itemized_deductions.yaml b/policyengine_us/tests/policy/baseline/gov/states/az/tax/income/deductions/itemized/az_itemized_deductions.yaml index 3cfeaae9e08..5f1570845b9 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/az/tax/income/deductions/itemized/az_itemized_deductions.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/az/tax/income/deductions/itemized/az_itemized_deductions.yaml @@ -127,6 +127,22 @@ # min($8,000, $10,000) = $8,000 az_itemized_deductions: 8_000 +- name: The federal claim of right repayment deduction gives no Arizona deduction + # A.R.S. 43-1021(9) adds the section 1341(a)(4) deduction back to Arizona + # gross income; A.R.S. 43-1029 computes Arizona tax without it. + absolute_error_margin: 0.01 + period: 2025 + input: + state_code: AZ + interest_deduction: 6_000 + claim_of_right_deduction: 5_000 + salt_deduction: 0 + charitable_deduction: 0 + az_charitable_contributions_credit_potential: 0 + itemized_medical_expenses: 0 + output: + az_itemized_deductions: 6_000 + - name: Arizona excludes self-employed premiums from its medical deduction without an AGI floor period: 2025 input: diff --git a/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/ca_income_tax.yaml b/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/ca_income_tax.yaml new file mode 100644 index 00000000000..7798c4dc0e6 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/ca_income_tax.yaml @@ -0,0 +1,29 @@ +- name: California carries the federal deduction for Publication 525 Example 40. + # IRS Publication 525 (2025), Example 40, as a California resident. + # https://www.irs.gov/pub/irs-prior/p525--2025.pdf#page=37 + # Schedule CA (540), Part II line 16, retains the federal deduction in + # column A when California also deducts the repayment. + # https://www.ftb.ca.gov/forms/2025/2025-540-ca-instructions.html + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 40 + employment_income: 65_700 + charitable_cash_donations: 15_750 + claim_of_right_repayment: 5_000 + tax_units: + tax_unit: + members: [head] + claim_of_right_prior_year_tax_decrease: 568 + households: + household: + members: [head] + state_code: CA + output: + ca_income_tax: 1_078.89 + claim_of_right_credit_applies: false + claim_of_right_deduction: 5_000 + ca_itemized_deductions_pre_limitation: 20_750 + ca_taxable_income: 44_950 diff --git a/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/deductions/itemized/ca_itemized_deductions_pre_limitation.yaml b/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/deductions/itemized/ca_itemized_deductions_pre_limitation.yaml index ad5f25b1b29..e4d3ba6d59e 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/deductions/itemized/ca_itemized_deductions_pre_limitation.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/deductions/itemized/ca_itemized_deductions_pre_limitation.yaml @@ -414,6 +414,18 @@ # not added to it. ca_itemized_deductions_pre_limitation: 4_900 +- name: The federal claim of right repayment deduction carries over by default. + # 2025 Schedule CA (540) instructions, Part II line 16: column A allows + # the federal deduction to remain when California also uses the deduction. + period: 2025 + input: + state_code: CA + interest_deduction: 6_000 + claim_of_right_deduction: 5_000 + output: + itemized_deductions_less_salt: 11_000 + ca_itemized_deductions_pre_limitation: 11_000 + - name: CA excludes mortgage insurance premiums in 2021. period: 2021 input: diff --git a/policyengine_us/tests/policy/baseline/gov/states/ks/tax/income/ks_itemized_deductions.yaml b/policyengine_us/tests/policy/baseline/gov/states/ks/tax/income/ks_itemized_deductions.yaml index 63a6603f62b..bdcf4857084 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ks/tax/income/ks_itemized_deductions.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ks/tax/income/ks_itemized_deductions.yaml @@ -19,3 +19,16 @@ state_code: KS output: ks_itemized_deductions: 12 + 9 + 2 + +- name: KS itemized deductions leave out the federal claim of right repayment deduction + # K.S.A. 79-32,120(a) lists charitable contributions, medical care, + # qualified residence interest and property taxes only. + period: 2025 + input: + real_estate_taxes: 3_000 + interest_deduction: 9_000 + claim_of_right_deduction: 5_000 + state_code: KS + output: + itemized_deductions_less_salt: 14_000 + ks_itemized_deductions: 12_000 diff --git a/policyengine_us/tests/policy/baseline/gov/states/mo/tax/income/deductions/mo_federal_income_tax_deduction.yaml b/policyengine_us/tests/policy/baseline/gov/states/mo/tax/income/deductions/mo_federal_income_tax_deduction.yaml index b1a7ebea29c..8e988da5ea3 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/mo/tax/income/deductions/mo_federal_income_tax_deduction.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/mo/tax/income/deductions/mo_federal_income_tax_deduction.yaml @@ -166,3 +166,35 @@ state_code: MO output: mo_federal_income_tax_deduction: 0 + +- name: The section 1341 credit reduces the federal income tax deduction base + # RSMo 143.171(2)(1) reduces federal tax by credits except its listed + # exceptions, so the section 1341 credit is not added back. + # Federal (as in the federal claim of right integration case 4): the + # $10,000 repayment does not beat the $15,750 standard deduction, so tax on + # 40,000 - 15,750 = 24,250 is 1,192.50 + 12% x 12,325 = 2,671.50, and the + # credit method subtracts the 2,200 prior-year decrease: 471.50. + # Missouri: AGI 40,000 is in the 25% bracket; 25% x 471.50 = 117.875. + # (Adding the credit back would give 25% x 2,671.50 = 667.875.) + period: 2025 + absolute_error_margin: 0.01 + input: + people: + person: + age: 40 + employment_income: 40_000 + claim_of_right_repayment: 10_000 + tax_units: + tax_unit: + members: [person] + claim_of_right_prior_year_tax_decrease: 2_200 + households: + household: + members: [person] + state_code: MO + output: + claim_of_right_credit_applies: true + claim_of_right_credit: 2_200 + income_tax_before_refundable_credits: 2_671.5 + income_tax: 471.5 + mo_federal_income_tax_deduction: 117.875 diff --git a/policyengine_us/tests/policy/baseline/gov/states/mt/tax/income/deductions/itemized/mt_claim_of_right_deduction.yaml b/policyengine_us/tests/policy/baseline/gov/states/mt/tax/income/deductions/itemized/mt_claim_of_right_deduction.yaml new file mode 100644 index 00000000000..23743f6fb17 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/mt/tax/income/deductions/itemized/mt_claim_of_right_deduction.yaml @@ -0,0 +1,687 @@ +# 2023 Form 2 instructions, itemized deductions line 18: "These deductions +# are the same deductions that are allowed on your federal Form 1040, +# Schedule A, line 16." +- name: Case 1, Montana follows the federal deduction through 2023. + period: 2023 + input: + people: + person1: + age: 40 + claim_of_right_repayment: 5_000 + tax_units: + tax_unit: + members: [person1] + claim_of_right_deduction: 5_000 + households: + household: + members: [person1] + state_code: MT + output: + mt_claim_of_right_deduction: 5_000 + mt_misc_deductions: 5_000 + +- name: Case 2, no Montana deduction when the federal deduction is zero. + period: 2023 + input: + people: + person1: + age: 40 + claim_of_right_repayment: 5_000 + tax_units: + tax_unit: + members: [person1] + claim_of_right_deduction: 0 + households: + household: + members: [person1] + state_code: MT + output: + mt_claim_of_right_deduction: 0 + +- name: Case 3, each spouse deducts their own repayment and a dependent's is left out. + period: 2023 + input: + people: + person1: + age: 45 + claim_of_right_repayment: 3_000 + person2: + age: 44 + claim_of_right_repayment: 1_500 + person3: + age: 20 + is_tax_unit_dependent: true + claim_of_right_repayment: 9_000 + tax_units: + tax_unit: + members: [person1, person2, person3] + claim_of_right_deduction: 4_500 + households: + household: + members: [person1, person2, person3] + state_code: MT + output: + mt_claim_of_right_deduction: [3_000, 1_500, 0] + +# 2024 Form 2 instructions, line 2, Worksheet A line 1: "Enter your total +# federal itemized deductions from Form 1040, line 12", which includes +# Schedule A line 16. +- name: Case 4, from 2024 Montana keeps the deduction within federal itemized deductions. + period: 2024 + input: + people: + person1: + age: 40 + claim_of_right_repayment: 5_000 + tax_units: + tax_unit: + members: [person1] + claim_of_right_deduction: 5_000 + households: + household: + members: [person1] + state_code: MT + output: + mt_claim_of_right_deduction: 5_000 + # From 2024 the full federal aggregate carries the deduction. + mt_misc_deductions: 0 + +- name: Case 5, the 2023 deduction reaches every Montana itemized aggregate once. + period: 2023 + input: + people: + person1: + age: 40 + claim_of_right_repayment: 5_000 + investment_interest_expense: 0 + deductible_mortgage_interest: 0 + mt_medical_expense_deduction_joint: 0 + mt_salt_deduction: 0 + tax_units: + tax_unit: + members: [person1] + claim_of_right_deduction: 5_000 + charitable_deduction: 10_000 + mt_child_dependent_care_expense_deduction_joint: 0 + mt_federal_income_tax_deduction_unit: 0 + mt_federal_income_tax_deduction_for_federal_itemization: 0 + households: + household: + members: [person1] + state_code: MT + output: + # Charity 10,000 + nonfloor repayment 5,000, each counted once. + mt_claim_of_right_deduction: 5_000 + mt_misc_deductions: 5_000 + mt_itemized_deductions_joint: 15_000 + mt_itemized_deductions_for_federal_itemization_joint: 15_000 + +- name: A partial positive federal deduction is allocated exactly once to its payers. + period: 2023 + input: + people: + head: + claim_of_right_repayment: 4_000 + spouse: + claim_of_right_repayment: 2_000 + tax_units: + unit: + members: [head, spouse] + claim_of_right_deduction: 3_000 + households: + household: + members: [head, spouse] + state_code: MT + output: + mt_claim_of_right_deduction: [2_000, 1_000] + +- name: The 2017 miscellaneous floor uses Montana AGI rather than federal AGI. + period: 2017 + input: + state_code: MT + claim_of_right_repayment: 3_000 + mt_agi_joint: 40_000 + adjusted_gross_income: 50_000 + unreimbursed_business_employee_expenses: 0 + tax_preparation_fees: 0 + output: + mt_misc_deductions_subject_to_floor_joint: 2_200 + +- name: The 2017 floor applies once to the combined raw expense pool. + period: 2017 + input: + state_code: MT + claim_of_right_repayment: 2_000 + mt_agi_joint: 40_000 + unreimbursed_business_employee_expenses: 1_000 + tax_preparation_fees: 300 + misc_deduction: 999 + claim_of_right_deduction: 0 + charitable_deduction: 10_000 + investment_interest_expense: 0 + deductible_mortgage_interest: 0 + mt_medical_expense_deduction_joint: 0 + mt_salt_deduction: 0 + casualty_loss_deduction: 400 + mt_child_dependent_care_expense_deduction_joint: 0 + mt_federal_income_tax_deduction_unit: 0 + mt_federal_income_tax_deduction_for_federal_itemization: 0 + output: + # 2,000 + 1,000 + 300 - 2% * 40,000 = 2,500; federal misc is unused. + mt_misc_deductions_subject_to_floor_joint: 2_500 + mt_misc_deductions: 400 + mt_itemized_deductions_joint: 12_900 + mt_itemized_deductions_for_federal_itemization_joint: 12_900 + +- name: Same-class spouse repayments are aggregated before the 2017 threshold test. + period: 2017 + input: + people: + head: + claim_of_right_repayment: 2_000 + mt_claim_of_right_repayment_income_class: 1 + spouse: + claim_of_right_repayment: 2_000 + mt_claim_of_right_repayment_income_class: 1 + tax_units: + unit: + members: [head, spouse] + mt_agi_joint: 60_000 + households: + household: + members: [head, spouse] + state_code: MT + output: + # The same income class totals 4,000, so neither repayment is in this pool. + mt_misc_claim_of_right_repayment: [0, 0] + mt_misc_deductions_subject_to_floor_joint: 0 + +- name: Distinct income classes have separate 2017 thresholds and separate Montana floors. + period: 2017 + input: + people: + head: + claim_of_right_repayment: 2_000 + mt_claim_of_right_repayment_income_class: 1 + mt_agi_indiv: 40_000 + mt_married_filing_separately_on_same_return_eligible: true + mt_child_dependent_care_expense_deduction: 0 + mt_medical_expense_deduction_indiv: 0 + mt_salt_deduction: 0 + mt_federal_income_tax_deduction_indiv: 0 + mt_federal_income_tax_deduction_for_federal_itemization_indiv: 0 + deductible_mortgage_interest: 0 + investment_interest_expense: 0 + spouse: + claim_of_right_repayment: 2_000 + mt_claim_of_right_repayment_income_class: 2 + mt_agi_indiv: 20_000 + mt_married_filing_separately_on_same_return_eligible: true + mt_child_dependent_care_expense_deduction: 0 + mt_medical_expense_deduction_indiv: 0 + mt_salt_deduction: 0 + mt_federal_income_tax_deduction_indiv: 0 + mt_federal_income_tax_deduction_for_federal_itemization_indiv: 0 + deductible_mortgage_interest: 0 + investment_interest_expense: 0 + tax_units: + unit: + members: [head, spouse] + casualty_loss_deduction: 0 + mt_agi_joint: 60_000 + charitable_deduction: 10_000 + # Preserve the federal aggregate approximation while testing the + # Montana classification, without calculating pre-2018 federal tax. + claim_of_right_deduction: 4_000 + households: + household: + members: [head, spouse] + state_code: MT + output: + mt_misc_claim_of_right_repayment: [2_000, 2_000] + mt_claim_of_right_deduction: [0, 0] + mt_misc_deductions: [0, 0] + mt_misc_deductions_subject_to_floor_joint: 2_800 + mt_misc_deductions_subject_to_floor_indiv: [1_200, 1_600] + mt_itemized_deductions_indiv: [6_200, 6_600] + mt_itemized_deductions_for_federal_itemization_indiv: [6_200, 6_600] + +- name: The 2017 floor pool excludes dependents and uses both spouses raw expenses. + period: 2017 + input: + people: + head: + unreimbursed_business_employee_expenses: 1_000 + tax_preparation_fees: 200 + spouse: + unreimbursed_business_employee_expenses: 1_500 + tax_preparation_fees: 300 + dependent: + is_tax_unit_dependent: true + claim_of_right_repayment: 2_000 + unreimbursed_business_employee_expenses: 9_000 + tax_units: + unit: + members: [head, spouse, dependent] + mt_agi_joint: 60_000 + households: + household: + members: [head, spouse, dependent] + state_code: MT + output: + mt_misc_deductions_subject_to_floor_joint: 1_800 + +- name: The 2017 miscellaneous floor cannot produce a negative deduction. + period: 2017 + input: + state_code: MT + claim_of_right_repayment: 500 + mt_agi_joint: 40_000 + output: + mt_misc_deductions_subject_to_floor_joint: 0 + +- name: The historical pool is explicitly outside the modeled pre-2017 scope. + period: 2016 + input: + state_code: MT + claim_of_right_repayment: 3_000 + mt_agi_joint: 40_000 + output: + mt_misc_deductions_subject_to_floor_joint: 0 + +- name: The historical floor pool is suspended from 2018. + period: 2018 + input: + state_code: MT + claim_of_right_repayment: 3_000 + mt_agi_joint: 40_000 + unreimbursed_business_employee_expenses: 1_000 + tax_preparation_fees: 300 + output: + mt_misc_deductions_subject_to_floor_joint: 0 + +- name: The 2024 state-income-tax ceiling uses the full federal itemized amount. + period: 2024 + input: + state_code: MT + tax_unit_itemizes: true + itemized_taxable_income_deductions: 20_000 + standard_deduction: 14_600 + salt_deduction: 6_000 + state_withheld_income_tax: 6_000 + local_income_tax: 0 + state_sales_tax: 0 + local_sales_tax: 0 + real_estate_taxes: 0 + output: + mt_state_income_tax_itemized_add_back: 5_400 + mt_federal_deductions: 14_600 + +- name: Federal repayment deduction remains in the 2024 taxable-income base once. + period: 2024 + input: + state_code: MT + claim_of_right_repayment: 5_000 + claim_of_right_deduction: 5_000 + tax_unit_itemizes: true + itemized_taxable_income_deductions: 20_000 + standard_deduction: 14_600 + salt_deduction: 0 + state_withheld_income_tax: 0 + adjusted_gross_income: 50_000 + mt_additions: 0 + mt_subtractions: 0 + # Legacy reconstructed deductions no longer determine the result. + mt_standard_deduction_joint: 25_000 + mt_itemized_deductions_joint: 30_000 + output: + mt_federal_deductions: 20_000 + mt_taxable_income_joint: 30_000 + +- name: The 2024 federal standard-deduction election is preserved. + period: 2024 + input: + state_code: MT + tax_unit_itemizes: false + itemized_taxable_income_deductions: 20_000 + standard_deduction: 14_600 + salt_deduction: 6_000 + state_withheld_income_tax: 6_000 + output: + mt_state_income_tax_itemized_add_back: 0 + mt_federal_deductions: 14_600 + +- name: Capped SALT is reduced by local income and property taxes before the addback. + period: 2025 + input: + state_code: MT + tax_unit_itemizes: true + itemized_taxable_income_deductions: 30_000 + standard_deduction: 15_750 + salt_deduction: 10_000 + state_withheld_income_tax: 8_000 + local_income_tax: 1_000 + real_estate_taxes: 5_000 + mt_federal_itemized_personal_property_taxes: 2_000 + state_sales_tax: 0 + local_sales_tax: 0 + output: + # 10,000 - 1,000 - 5,000 - 2,000 = 2,000 of deducted state income tax. + mt_state_income_tax_itemized_add_back: 2_000 + # From 2025 Form 2 line 2 is not reduced by the addback. + mt_federal_deductions: 30_000 + +- name: The 2024 addback is zero when sales tax was deducted instead of income tax. + period: 2024 + input: + state_code: MT + tax_unit_itemizes: true + itemized_taxable_income_deductions: 20_000 + standard_deduction: 14_600 + salt_deduction: 8_000 + state_withheld_income_tax: 6_000 + local_income_tax: 0 + state_sales_tax: 8_000 + local_sales_tax: 0 + output: + mt_state_income_tax_itemized_add_back: 0 + mt_federal_deductions: 20_000 + +- name: The 2024 addback ceiling uses allowed deductions after federal limitations. + period: 2024 + input: + state_code: MT + tax_unit_itemizes: true + total_itemized_taxable_income_deductions: 20_000 + itemized_taxable_income_deductions: 18_000 + standard_deduction: 14_600 + salt_deduction: 6_000 + state_withheld_income_tax: 6_000 + output: + mt_state_income_tax_itemized_add_back: 3_400 + mt_federal_deductions: 14_600 + +- name: The 2024 ceiling is zero when elected federal itemized deductions are below standard. + period: 2024 + input: + state_code: MT + tax_unit_itemizes: true + itemized_taxable_income_deductions: 10_000 + standard_deduction: 14_600 + salt_deduction: 6_000 + state_withheld_income_tax: 6_000 + output: + mt_state_income_tax_itemized_add_back: 0 + mt_federal_deductions: 10_000 + +- name: The federal-income-tax deduction still ends in 2024. + period: 2024 + input: + state_code: MT + income_tax_before_refundable_credits: 5_000 + output: + mt_federal_income_tax_deduction_unit: 0 + +- name: Business-level state-tax additions remain outside the itemized ceiling. + period: 2024 + input: + state_code: MT + adjusted_gross_income: 50_000 + mt_additions: 1_000 + mt_subtractions: 0 + tax_unit_itemizes: false + itemized_taxable_income_deductions: 20_000 + standard_deduction: 14_600 + salt_deduction: 6_000 + state_withheld_income_tax: 6_000 + output: + mt_state_income_tax_itemized_add_back: 0 + mt_federal_deductions: 14_600 + mt_taxable_income_joint: 36_400 + +- name: Federal taxable-income floor precedes Montana additions from 2024. + period: 2024 + input: + state_code: MT + adjusted_gross_income: 10_000 + mt_additions: 6_000 + mt_subtractions: 0 + tax_unit_itemizes: false + itemized_taxable_income_deductions: 0 + standard_deduction: 14_600 + output: + mt_federal_deductions: 14_600 + mt_taxable_income_joint: 6_000 + +- name: In 2024 excess deductions absorb the state-income-tax addback before the zero floor. + period: 2024 + input: + state_code: MT + adjusted_gross_income: 10_000 + mt_additions: 0 + mt_subtractions: 0 + tax_unit_itemizes: true + itemized_taxable_income_deductions: 20_000 + standard_deduction: 14_600 + salt_deduction: 6_000 + state_withheld_income_tax: 6_000 + output: + mt_state_income_tax_itemized_add_back: 5_400 + mt_federal_deductions: 14_600 + # max(10,000 - 20,000 + 5,400, 0) = 0. + mt_taxable_income_joint: 0 + +- name: The 2024 addback ordering is unchanged when the federal floor does not bind. + period: 2024 + input: + state_code: MT + adjusted_gross_income: 50_000 + mt_additions: 0 + mt_subtractions: 0 + tax_unit_itemizes: true + itemized_taxable_income_deductions: 20_000 + standard_deduction: 14_600 + salt_deduction: 6_000 + state_withheld_income_tax: 6_000 + output: + mt_state_income_tax_itemized_add_back: 5_400 + mt_federal_deductions: 14_600 + # Both orderings give 50,000 - 20,000 + 5,400 = 35,400. + mt_taxable_income_joint: 35_400 + +- name: From 2025 the state-income-tax addback follows the zero floor. + # 2025 Form 2 line 2 is the unreduced federal deduction; Worksheet B line 11 + # goes to Schedule I line 4, a Montana addition after the line 3 floor. + period: 2025 + input: + state_code: MT + adjusted_gross_income: 10_000 + mt_additions: 0 + mt_subtractions: 0 + tax_unit_itemizes: true + itemized_taxable_income_deductions: 20_000 + standard_deduction: 15_750 + salt_deduction: 6_000 + state_withheld_income_tax: 6_000 + local_income_tax: 0 + state_sales_tax: 0 + local_sales_tax: 0 + real_estate_taxes: 0 + output: + # min(6,000, 20,000 - 15,750) = 4,250. + mt_state_income_tax_itemized_add_back: 4_250 + mt_federal_deductions: 20_000 + # Line 3: max(10,000 - 20,000, 0) = 0; line 4 adds 4,250. + mt_taxable_income_joint: 4_250 + +- name: The 2025 addback ordering is unchanged when the federal floor does not bind. + period: 2025 + input: + state_code: MT + adjusted_gross_income: 50_000 + mt_additions: 0 + mt_subtractions: 0 + tax_unit_itemizes: true + itemized_taxable_income_deductions: 20_000 + standard_deduction: 15_750 + salt_deduction: 6_000 + state_withheld_income_tax: 6_000 + local_income_tax: 0 + state_sales_tax: 0 + local_sales_tax: 0 + real_estate_taxes: 0 + output: + mt_state_income_tax_itemized_add_back: 4_250 + mt_federal_deductions: 20_000 + # Both orderings give 50,000 - 20,000 + 4,250 = 34,250. + mt_taxable_income_joint: 34_250 + +- name: 2026 follows the 2025 form, adding the state-income-tax addback after the floor. + period: 2026 + input: + state_code: MT + adjusted_gross_income: 10_000 + mt_additions: 0 + mt_subtractions: 0 + tax_unit_itemizes: true + itemized_taxable_income_deductions: 20_000 + standard_deduction: 16_100 + salt_deduction: 6_000 + state_withheld_income_tax: 6_000 + local_income_tax: 0 + state_sales_tax: 0 + local_sales_tax: 0 + real_estate_taxes: 0 + output: + # min(6,000, 20,000 - 16,100) = 3,900; max(10,000 - 20,000, 0) + 3,900. + mt_state_income_tax_itemized_add_back: 3_900 + mt_federal_deductions: 20_000 + mt_taxable_income_joint: 3_900 + +- name: Small and large income classes enter separate Montana pools once in 2017. + period: 2017 + input: + people: + head: + claim_of_right_repayment: 2_000 + mt_claim_of_right_repayment_income_class: 1 + spouse: + claim_of_right_repayment: 5_000 + mt_claim_of_right_repayment_income_class: 2 + tax_units: + unit: + members: [head, spouse] + casualty_loss_deduction: 0 + claim_of_right_deduction: 7_000 + mt_agi_joint: 60_000 + households: + household: + members: [head, spouse] + state_code: MT + output: + mt_misc_claim_of_right_repayment: [2_000, 0] + mt_claim_of_right_deduction: [0, 5_000] + mt_misc_deductions: [0, 5_000] + mt_misc_deductions_subject_to_floor_joint: 800 + +- name: Wagering losses are included in the 2024 full federal itemized amount and ceiling. + period: 2024 + input: + state_code: MT + adjusted_gross_income: 50_000 + mt_additions: 0 + mt_subtractions: 0 + tax_unit_itemizes: true + itemized_taxable_income_deductions: 16_000 + wagering_losses_deduction: 4_000 + standard_deduction: 14_600 + salt_deduction: 6_000 + state_withheld_income_tax: 6_000 + output: + # The full itemized amount is 20,000, so the ceiling is 5,400. + mt_state_income_tax_itemized_add_back: 5_400 + mt_federal_deductions: 14_600 + mt_taxable_income_joint: 35_400 + +- name: Non-itemizer charitable deductions carry through the 2026 federal base. + period: 2026 + input: + state_code: MT + adjusted_gross_income: 50_000 + mt_additions: 0 + mt_subtractions: 0 + tax_unit_itemizes: false + standard_deduction: 16_100 + charitable_deduction_for_non_itemizers: 1_000 + qualified_business_income_deduction: 2_000 + output: + # QBI is not part of the Montana deduction. + mt_state_income_tax_itemized_add_back: 0 + mt_federal_deductions: 17_100 + mt_taxable_income_joint: 32_900 + +- name: Montana adds QBI back to the federal taxable-income base in 2024. + period: 2024 + input: + state_code: MT + adjusted_gross_income: 50_000 + mt_additions: 0 + mt_subtractions: 0 + tax_unit_itemizes: false + standard_deduction: 14_600 + qualified_business_income_deduction: 4_000 + output: + mt_federal_deductions: 14_600 + mt_taxable_income_joint: 35_400 + +- name: Schedule 1-A enters the federal floor before Montana additions and is deducted once. + period: 2025 + input: + state_code: MT + adjusted_gross_income: 20_000 + mt_additions: 3_000 + mt_subtractions: 6_000 + tax_unit_itemizes: false + standard_deduction: 15_750 + qualified_business_income_deduction: 0 + tip_income_deduction: 6_000 + overtime_income_deduction: 0 + additional_senior_deduction: 0 + auto_loan_interest_deduction: 0 + output: + taxable_income: 0 + mt_federal_obbba_subtraction: 6_000 + mt_federal_deductions: 15_750 + mt_taxable_income_joint: 3_000 + +- name: In 2026 the $400 minimum QBI deduction is added back before Montana's zero floor, so it doesn't survive a negative base. + # From 2026 the 26 U.S.C. 199A(i) minimum deduction ($400 once QBI reaches + # $1,000) applies even when taxable income is zero, so the order of the + # add-back and the floor decides the result. + # AGI: 5,000 - 5,000 x 0.9235 x 0.153 / 2 = 5,000 - 353.24 = 4,646.76. + # Deductions: 2026 standard deduction 16,100 + QBI deduction 400 = 16,500. + # Montana starts from federal taxable income (MCA 15-30-2101(22)) and adds + # back the QBI deduction claimed (MCA 15-30-2120(2)(i)). On the 2025 Form 2, + # the filer leaves that deduction out of line 2 (Form 1040 lines 12e and + # 13b) and enters line 1 minus line 2, or zero, on line 3. + # max(0, 4,646.76 - 16,500 + 400) = 0, not max(0, 4,646.76 - 16,500) + 400 = 400. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + head: + age: 40 + self_employment_income: 5_000 + tax_units: + tax_unit: + members: [head] + households: + household: + members: [head] + state_code: MT + output: + adjusted_gross_income: 4_646.76 + qualified_business_income_deduction: 400 + taxable_income_deductions: 16_500 + taxable_income: 0 + mt_taxable_income_joint: [0] diff --git a/policyengine_us/tests/policy/baseline/gov/states/mt/tax/income/mt_taxable_income_joint.yaml b/policyengine_us/tests/policy/baseline/gov/states/mt/tax/income/mt_taxable_income_joint.yaml index 49a6ab57ab3..efc3ee478ce 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/mt/tax/income/mt_taxable_income_joint.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/mt/tax/income/mt_taxable_income_joint.yaml @@ -69,33 +69,24 @@ is_tax_unit_head: true age: 45 adjusted_gross_income_person: 50_000 - mt_standard_deduction_joint: 5_000 - mt_itemized_deductions_joint: 3_000 - mt_personal_exemptions_joint: 0 person2: is_tax_unit_spouse: true age: 67 # Qualifies for old age subtraction adjusted_gross_income_person: 0 - mt_standard_deduction_joint: 0 - mt_itemized_deductions_joint: 0 - mt_personal_exemptions_joint: 0 tax_units: tax_unit: members: [person1, person2] filing_status: JOINT + adjusted_gross_income: 50_000 + taxable_income_deductions: 10_000 households: household: members: [person1, person2] state_code: MT output: - # Person 2 gets $5,500 old age subtraction (age 67 > 65) mt_old_age_subtraction: [0, 5_500] - # Federal AGI: 50,000 + 0 = 50,000 - # Total AGI after subtractions: 50,000 - 5,500 = 44,500 - # Deductions: max(5,000, 3,000) = 5,000 - # Exemptions: 0 + 0 = 0 - # Taxable income: 44,500 - 5,000 - 0 = 39,500 (allocated to head) - mt_taxable_income_joint: [39_500, 0] + # Federal taxable income less the pooled Montana age subtraction. + mt_taxable_income_joint: [34_500, 0] - name: Case 2 - Old age subtraction applies when AGI on spouse and head qualifies for subtraction period: 2024 @@ -105,33 +96,24 @@ is_tax_unit_head: true age: 70 # Qualifies for old age subtraction adjusted_gross_income_person: 0 - mt_standard_deduction_joint: 3_000 - mt_itemized_deductions_joint: 2_000 - mt_personal_exemptions_joint: 1_250 person2: is_tax_unit_spouse: true age: 40 adjusted_gross_income_person: 60_000 - mt_standard_deduction_joint: 3_000 - mt_itemized_deductions_joint: 2_000 - mt_personal_exemptions_joint: 1_250 tax_units: tax_unit: members: [person1, person2] filing_status: JOINT + adjusted_gross_income: 60_000 + taxable_income_deductions: 10_000 households: household: members: [person1, person2] state_code: MT output: - # Person 1 gets $5,500 old age subtraction (age 70 > 65) mt_old_age_subtraction: [5_500, 0] - # Federal AGI: 0 + 60,000 = 60,000 - # Total AGI after subtractions: 60,000 - 5,500 = 54,500 - # Deductions: max(6,000, 4,000) = 6,000 - # Exemptions: 1,250 + 1,250 = 2,500 - # Taxable income: 54,500 - 6,000 - 2,500 = 46,000 (allocated to head) - mt_taxable_income_joint: [46_000, 0] + # Federal taxable income less the pooled Montana age subtraction. + mt_taxable_income_joint: [44_500, 0] - name: Case 3 - Both spouses qualify for old age subtraction with split income period: 2024 @@ -141,33 +123,24 @@ is_tax_unit_head: true age: 72 # Qualifies for old age subtraction adjusted_gross_income_person: 30_000 - mt_standard_deduction_joint: 2_750 - mt_itemized_deductions_joint: 3_500 - mt_personal_exemptions_joint: 1_400 person2: is_tax_unit_spouse: true age: 68 # Qualifies for old age subtraction adjusted_gross_income_person: 25_000 - mt_standard_deduction_joint: 2_750 - mt_itemized_deductions_joint: 3_500 - mt_personal_exemptions_joint: 1_400 tax_units: tax_unit: members: [person1, person2] filing_status: JOINT + adjusted_gross_income: 55_000 + taxable_income_deductions: 10_000 households: household: members: [person1, person2] state_code: MT output: - # Both get $5,500 old age subtraction mt_old_age_subtraction: [5_500, 5_500] - # Federal AGI: 30,000 + 25,000 = 55,000 - # Total AGI after subtractions: 55,000 - 11,000 = 44,000 - # Deductions: max(5,500, 7,000) = 7,000 - # Exemptions: 1,400 + 1,400 = 2,800 - # Taxable income: 44,000 - 7,000 - 2,800 = 34,200 (allocated to head) - mt_taxable_income_joint: [34_200, 0] + # Federal taxable income less the pooled Montana age subtraction. + mt_taxable_income_joint: [34_000, 0] - name: Case 4 - Neither spouse qualifies for old age subtraction period: 2024 @@ -177,33 +150,24 @@ is_tax_unit_head: true age: 50 adjusted_gross_income_person: 40_000 - mt_standard_deduction_joint: 3_000 - mt_itemized_deductions_joint: 2_500 - mt_personal_exemptions_joint: 1_200 person2: is_tax_unit_spouse: true age: 48 adjusted_gross_income_person: 35_000 - mt_standard_deduction_joint: 3_000 - mt_itemized_deductions_joint: 2_500 - mt_personal_exemptions_joint: 1_200 tax_units: tax_unit: members: [person1, person2] filing_status: JOINT + adjusted_gross_income: 75_000 + taxable_income_deductions: 10_000 households: household: members: [person1, person2] state_code: MT output: - # Neither spouse gets old age subtraction (both under 65) mt_old_age_subtraction: [0, 0] - # Federal AGI: 40,000 + 35,000 = 75,000 - # No subtractions apply - # Deductions: max(6,000, 5,000) = 6,000 - # Exemptions: 1,200 + 1,200 = 2,400 - # Taxable income: 75,000 - 6,000 - 2,400 = 66,600 (allocated to head) - mt_taxable_income_joint: [66_600, 0] + # Federal taxable income less the pooled Montana age subtraction. + mt_taxable_income_joint: [65_000, 0] - name: Case 5 - Subtractions exceed total income (demonstrates unit-level pooling) period: 2024 @@ -213,31 +177,23 @@ is_tax_unit_head: true age: 70 adjusted_gross_income_person: 3_000 - mt_standard_deduction_joint: 2_000 - mt_itemized_deductions_joint: 1_000 - mt_personal_exemptions_joint: 500 person2: is_tax_unit_spouse: true age: 68 adjusted_gross_income_person: 2_000 - mt_standard_deduction_joint: 2_000 - mt_itemized_deductions_joint: 1_000 - mt_personal_exemptions_joint: 500 tax_units: tax_unit: members: [person1, person2] filing_status: JOINT + adjusted_gross_income: 5_000 + taxable_income_deductions: 10_000 households: household: members: [person1, person2] state_code: MT output: - # Both get $5,500 old age subtraction = $11,000 total mt_old_age_subtraction: [5_500, 5_500] - # Federal AGI: 3,000 + 2,000 = 5,000 - # Total subtractions: 11,000 (exceeds income) - # AGI after subtractions: max(5,000 - 11,000, 0) = 0 - # Even before deductions, taxable income is 0 + # Federal taxable income less the pooled Montana age subtraction. mt_taxable_income_joint: [0, 0] - name: Case 6 - Only one spouse over 65 with split income (partial subtraction) @@ -248,31 +204,21 @@ is_tax_unit_head: true age: 55 adjusted_gross_income_person: 25_000 - mt_standard_deduction_joint: 3_000 - mt_itemized_deductions_joint: 2_000 - mt_personal_exemptions_joint: 1_000 person2: is_tax_unit_spouse: true age: 67 adjusted_gross_income_person: 20_000 - mt_standard_deduction_joint: 3_000 - mt_itemized_deductions_joint: 2_000 - mt_personal_exemptions_joint: 1_000 tax_units: tax_unit: members: [person1, person2] filing_status: JOINT + adjusted_gross_income: 45_000 + taxable_income_deductions: 10_000 households: household: members: [person1, person2] state_code: MT output: - # Only person2 gets $5,500 old age subtraction mt_old_age_subtraction: [0, 5_500] - # Federal AGI: 25,000 + 20,000 = 45,000 - # Total subtractions: 0 + 5,500 = 5,500 - # AGI after subtractions: 45,000 - 5,500 = 39,500 - # Deductions: max(6,000, 4,000) = 6,000 - # Exemptions: 1,000 + 1,000 = 2,000 - # Taxable income: 39,500 - 6,000 - 2,000 = 31,500 - mt_taxable_income_joint: [31_500, 0] + # Federal taxable income less the pooled Montana age subtraction. + mt_taxable_income_joint: [29_500, 0] diff --git a/policyengine_us/tests/policy/baseline/gov/states/nc/tax/income/credits/claim_of_right/nc_claim_of_right_payment.yaml b/policyengine_us/tests/policy/baseline/gov/states/nc/tax/income/credits/claim_of_right/nc_claim_of_right_payment.yaml new file mode 100644 index 00000000000..caf56bdd555 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/nc/tax/income/credits/claim_of_right/nc_claim_of_right_payment.yaml @@ -0,0 +1,48 @@ +# N.C. Gen. Stat. 105-266.2: a filer subject to section 1341(a)(5) is +# considered to have paid North Carolina tax equal to the increase in the +# earlier year's North Carolina tax from including the restored item. +- name: Case 1, the payment is the prior-year North Carolina tax increase under section 1341(a)(5). + period: 2025 + input: + claim_of_right_section_1341_eligible: true + claim_of_right_credit_applies: true + nc_claim_of_right_prior_year_tax_increase: 300 + state_code: NC + output: + nc_claim_of_right_payment: 300 + +- name: Case 2, no payment under section 1341(a)(4). + period: 2025 + input: + claim_of_right_section_1341_eligible: true + claim_of_right_credit_applies: false + nc_claim_of_right_prior_year_tax_increase: 300 + state_code: NC + output: + nc_claim_of_right_payment: 0 + +- name: Case 3, the payment is modeled for current North Carolina residents only. + # A coverage limit of the model, not a rule of G.S. 105-266.2: a filer who + # paid the earlier North Carolina tax and has since moved away is not + # covered. + period: 2025 + input: + claim_of_right_section_1341_eligible: true + claim_of_right_credit_applies: true + nc_claim_of_right_prior_year_tax_increase: 300 + state_code: SC + output: + nc_claim_of_right_payment: 0 + +- name: An explicit credit method gives a payment only above the section 1341 threshold. + period: 2025 + input: + age: [40, 40, 40, 40] + claim_of_right_repayment: [0, 2_999, 3_000, 3_001] + adjusted_gross_income: [50_000, 50_000, 50_000, 50_000] + claim_of_right_credit_applies: [true, true, true, true] + nc_claim_of_right_prior_year_tax_increase: [300, 300, 300, 300] + state_code: [NC, NC, NC, NC] + output: + claim_of_right_section_1341_eligible: [false, false, false, true] + nc_claim_of_right_payment: [0, 0, 0, 300] diff --git a/policyengine_us/tests/policy/baseline/gov/states/nc/tax/income/deductions/itemized/nc_claim_of_right_deduction.yaml b/policyengine_us/tests/policy/baseline/gov/states/nc/tax/income/deductions/itemized/nc_claim_of_right_deduction.yaml index 927ded40a87..be27fe7f192 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nc/tax/income/deductions/itemized/nc_claim_of_right_deduction.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nc/tax/income/deductions/itemized/nc_claim_of_right_deduction.yaml @@ -369,3 +369,152 @@ nc_taxable_income: 63_000 # 63,000 * 4.25% = 2,677.50 (2,858.13 without the repayment). nc_income_tax: 2_677.50 + +- name: No deduction when federal tax is computed under section 1341(a)(5). + period: 2025 + input: + people: + head: + age: 40 + claim_of_right_repayment: 5_000 + tax_units: + tax_unit: + members: [head] + adjusted_gross_income: 80_000 + claim_of_right_credit_applies: true + households: + household: + members: [head] + state_code: NC + output: + nc_claim_of_right_deduction: 0 + +- name: The deduction is allowed when federal tax is computed under section 1341(a)(4). + period: 2025 + input: + people: + head: + age: 40 + claim_of_right_repayment: 5_000 + tax_units: + tax_unit: + members: [head] + adjusted_gross_income: 80_000 + claim_of_right_credit_applies: false + households: + household: + members: [head] + state_code: NC + output: + nc_claim_of_right_deduction: 5_000 + +- name: A filer the federal credit method suits loses the North Carolina deduction and is treated as paying the prior-year North Carolina tax on the item. + # The household above, now with a $1,100 decrease in 2024 federal tax and + # a $212.50 increase in 2024 North Carolina tax from the repaid $5,000. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 40 + employment_income: 80_000 + claim_of_right_repayment: 5_000 + real_estate_taxes: 4_000 + tax_units: + tax_unit: + members: [head] + charitable_deduction: 8_000 + claim_of_right_prior_year_tax_decrease: 1_100 + nc_claim_of_right_prior_year_tax_increase: 212.5 + households: + household: + members: [head] + state_code: NC + output: + claim_of_right_credit_applies: true + claim_of_right_credit: 1_100 + nc_claim_of_right_deduction: 0 + # 4,000 + 8,000 = 12,000 loses to the 12,750 standard deduction. + nc_standard_or_itemized_deductions: 12_750 + nc_taxable_income: 67_250 + # 67,250 * 4.25% = 2,858.13, less the 212.50 payment. + nc_income_tax_before_refundable_credits: 2_858.13 + nc_claim_of_right_payment: 212.5 + nc_income_tax: 2_645.63 + +- name: A filer the federal deduction method suits keeps the North Carolina deduction and gets no payment. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 40 + employment_income: 80_000 + claim_of_right_repayment: 5_000 + real_estate_taxes: 4_000 + tax_units: + tax_unit: + members: [head] + charitable_deduction: 8_000 + claim_of_right_prior_year_tax_decrease: 568 + nc_claim_of_right_prior_year_tax_increase: 212.5 + households: + household: + members: [head] + state_code: NC + output: + claim_of_right_credit_applies: false + nc_claim_of_right_deduction: 5_000 + nc_claim_of_right_payment: 0 + nc_income_tax: 2_677.50 + +- name: Before 2018 a repayment above $3,000 with no prior-year decrease keeps the deduction. + # No method is supplied: with no prior-year tax decrease the credit method + # cannot give less tax, so tax is computed with the deduction. + period: 2016 + input: + people: + head: + age: 40 + claim_of_right_repayment: 5_000 + tax_units: + tax_unit: + members: [head] + adjusted_gross_income: 50_000 + households: + household: + members: [head] + state_code: NC + output: + claim_of_right_credit_applies: false + nc_claim_of_right_deduction: 5_000 + +- name: An explicit credit method bars the deduction only above the section 1341 threshold. + period: 2025 + input: + age: [40, 40, 40, 40] + claim_of_right_repayment: [0, 2_999, 3_000, 3_001] + adjusted_gross_income: [50_000, 50_000, 50_000, 50_000] + claim_of_right_credit_applies: [true, true, true, true] + nc_claim_of_right_prior_year_tax_increase: [300, 300, 300, 300] + state_code: [NC, NC, NC, NC] + output: + claim_of_right_section_1341_eligible: [false, false, false, true] + # Ineligible repayments keep the deduction less the $1,000 AGI floor. + nc_claim_of_right_deduction: [0, 1_999, 2_000, 0] + +- name: Before 2018 an explicit credit method does not bar a small repayment deduction. + # Historical simulations can supply the federal method, but section + # 1341(a)(5) cannot apply to a repayment of $3,000 or less. + period: 2016 + input: + age: 40 + claim_of_right_repayment: 2_500 + adjusted_gross_income: 50_000 + claim_of_right_credit_applies: true + nc_claim_of_right_prior_year_tax_increase: 300 + state_code: NC + output: + claim_of_right_section_1341_eligible: false + # No other miscellaneous expenses absorb the 2% floor: 2,500 - 1,000. + nc_claim_of_right_deduction: 1_500 diff --git a/policyengine_us/tests/policy/baseline/gov/states/nc/tax/income/nc_income_tax.yaml b/policyengine_us/tests/policy/baseline/gov/states/nc/tax/income/nc_income_tax.yaml index 6957ae44fac..02a5fb29344 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nc/tax/income/nc_income_tax.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nc/tax/income/nc_income_tax.yaml @@ -27,3 +27,15 @@ state_code: NC output: nc_income_tax: 0 + +- name: The refundable claim of right payment can make North Carolina income tax negative + period: 2025 + input: + nc_income_tax_before_credits: 100 + nc_non_refundable_credits: 30 + nc_claim_of_right_payment: 500 + state_code: NC + output: + nc_income_tax_before_refundable_credits: 70 + nc_refundable_credits: 500 + nc_income_tax: -430 diff --git a/policyengine_us/tests/policy/baseline/gov/states/or/tax/income/subtractions/or_federal_tax_liability_subtraction.yaml b/policyengine_us/tests/policy/baseline/gov/states/or/tax/income/subtractions/or_federal_tax_liability_subtraction.yaml index 4e8190d3f01..fe5b498c964 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/or/tax/income/subtractions/or_federal_tax_liability_subtraction.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/or/tax/income/subtractions/or_federal_tax_liability_subtraction.yaml @@ -112,3 +112,38 @@ output: # 50% x 8,750 or_federal_tax_liability_subtraction: 4_375 + +- name: The section 1341 credit reduces the federal tax liability subtraction + # ORS 316.680(1)(b) and 316.685(1) allow federal taxes accrued and + # disregard only the EITC. Section 1341 relief reduces accrued tax. + # Federal (as in the federal claim of right integration case 4): tax on + # 40,000 - 15,750 = 24,250 is 2,671.50, less the 2,200 prior-year decrease + # under the credit method: 471.50. No EITC at this income. + # Oregon: min(max(0, 471.50 + 0), 8,500 cap) = 471.50. + # (Adding the credit back would give 2,671.50.) + # aca_ptc is pinned at 0 so the case isolates the section 1341 credit: an + # Oregon formula that also nets the premium tax credit would otherwise + # subtract this household's modeled credit. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + person: + age: 40 + employment_income: 40_000 + claim_of_right_repayment: 10_000 + tax_units: + tax_unit: + members: [person] + claim_of_right_prior_year_tax_decrease: 2_200 + aca_ptc: 0 + households: + household: + members: [person] + state_code: OR + output: + claim_of_right_credit_applies: true + claim_of_right_credit: 2_200 + eitc: 0 + income_tax: 471.5 + or_federal_tax_liability_subtraction: 471.5 diff --git a/policyengine_us/tests/policy/baseline/gov/states/va/tax/income/deductions/va_itemized_deductions.yaml b/policyengine_us/tests/policy/baseline/gov/states/va/tax/income/deductions/va_itemized_deductions.yaml index 8928e81776f..d75f22585a0 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/va/tax/income/deductions/va_itemized_deductions.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/va/tax/income/deductions/va_itemized_deductions.yaml @@ -66,3 +66,15 @@ state_code: VA output: va_itemized_deductions: 40_000 #20,000+20,000 + +- name: The 2018 unlimited branch retains federally allowable repayment deductions + period: 2018 + input: + filing_status: SINGLE + adjusted_gross_income: 500_000 + itemized_deductions_less_salt: 30_000 + state_and_local_sales_or_income_tax: 0 + real_estate_taxes: 0 + state_code: VA + output: + va_itemized_deductions: 30_000 diff --git a/policyengine_us/tests/policy/baseline/gov/states/va/tax/income/deductions/va_reduced_itemized_deductions.yaml b/policyengine_us/tests/policy/baseline/gov/states/va/tax/income/deductions/va_reduced_itemized_deductions.yaml index 80257f26b5c..2b573082eef 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/va/tax/income/deductions/va_reduced_itemized_deductions.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/va/tax/income/deductions/va_reduced_itemized_deductions.yaml @@ -40,3 +40,37 @@ state_code: VA output: va_reduced_itemized_deductions: 35_282 + +- name: The federal claim of right repayment deduction stays in the limited itemized deduction total + # Va. Code 58.1-322.03(1)(a) adopts federally allowable itemized + # deductions; IRC 68(c) does not exempt section 1341 repayments. + period: 2025 + absolute_error_margin: 0.01 + input: + filing_status: SINGLE + adjusted_gross_income: 500_000 # > $332,700 + charitable_deduction: 20_000 + claim_of_right_deduction: 10_000 + state_and_local_sales_or_income_tax: 0 + state_code: VA + output: + # Line 1: 30,000. Line 9: min(80% x 30,000, 3% x (500,000 - 332,700)) + # = 5,019. Line 12a: 30,000 - 5,019. + va_reduced_itemized_deductions: 24_981 + +- name: The 2017 limited total includes miscellaneous deductions after the federal AGI floor + period: 2017 + absolute_error_margin: 0.01 + input: + filing_status: SINGLE + adjusted_gross_income: 350_000 + charitable_deduction: 20_000 + total_misc_deductions: 8_000 + claim_of_right_deduction: 0 + state_and_local_sales_or_income_tax: 0 + state_code: VA + output: + # 8,000 - 2% x 350,000 = 1,000 enters before the section 68 reduction. + misc_deduction: 1_000 + # 21,000 - min(80% x 21,000, 3% x (350,000 - 261,500)). + va_reduced_itemized_deductions: 18_345 diff --git a/policyengine_us/tests/policy/baseline/gov/states/wi/tax/income/wi_itemized_deduction_credit.yaml b/policyengine_us/tests/policy/baseline/gov/states/wi/tax/income/wi_itemized_deduction_credit.yaml index f49e4bdeb3b..e26cda776f8 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/wi/tax/income/wi_itemized_deduction_credit.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/wi/tax/income/wi_itemized_deduction_credit.yaml @@ -26,6 +26,21 @@ output: wi_itemized_deduction_credit_potential: 0 +- name: WI itemized deduction credit includes repayments unused for its separate credit + # Wis. Stat. 71.07(5)(a)6 excludes repayments only when used for the + # separate state credit. IRC 67(b)(9) excludes section 1341 deductions + # from miscellaneous deductions, so paragraph 7 does not remove them. + absolute_error_margin: 0.01 + period: 2025 + input: + wi_standard_deduction: 10_000 + charitable_deduction: 3_000 + interest_deduction: 12_000 + claim_of_right_deduction: 20_000 + state_code: WI + output: + wi_itemized_deduction_credit_potential: 1_250 # = (3K + 12K + 20K - 10K) * 5% + # 2020 Form 1 instructions, PDF p. 17 (printed p. 15), line 11: # https://www.revenue.wi.gov/TaxForms2020/2020-Form1-inst.pdf#page=17 # Schedule 1, PDF p. 5, lines 3 and 8-9: diff --git a/policyengine_us/tests/policy/baseline/household/income/household/household_refundable_state_tax_credits.yaml b/policyengine_us/tests/policy/baseline/household/income/household/household_refundable_state_tax_credits.yaml index e1f251326e3..57eac4c3c85 100644 --- a/policyengine_us/tests/policy/baseline/household/income/household/household_refundable_state_tax_credits.yaml +++ b/policyengine_us/tests/policy/baseline/household/income/household/household_refundable_state_tax_credits.yaml @@ -72,3 +72,37 @@ wi_retirement_income_exclusion_elected: true household_state_tax_before_refundable_credits: 3_000 household_refundable_state_tax_credits: 300 + +- name: North Carolina refundable payment reaches a household with two tax units + # Structural case under G.S. 105-266.2: tax units owe -430 and 800. + # Household tax before refundable credits includes 30 of use tax: + # (70 + 800 + 30) - 500 = (-430 + 800) + 30 = 400. + period: 2025 + input: + people: + parent: + age: 50 + adult_child: + age: 25 + tax_units: + parent_return: + members: [parent] + nc_income_tax_before_credits: 100 + nc_non_refundable_credits: 30 + nc_claim_of_right_payment: 500 + state_use_tax: 20 + child_return: + members: [adult_child] + nc_income_tax_before_credits: 1000 + nc_non_refundable_credits: 200 + nc_claim_of_right_payment: 0 + state_use_tax: 10 + households: + household: + members: [parent, adult_child] + state_code: NC + output: + nc_income_tax: [-430, 800] + state_income_tax: [-430, 800] + household_state_tax_before_refundable_credits: 900 + household_refundable_state_tax_credits: 500 diff --git a/policyengine_us/tests/policy/baseline/household/income/household/household_state_tax_before_refundable_credits.yaml b/policyengine_us/tests/policy/baseline/household/income/household/household_state_tax_before_refundable_credits.yaml index 03a80e94c46..56ac46b5848 100644 --- a/policyengine_us/tests/policy/baseline/household/income/household/household_state_tax_before_refundable_credits.yaml +++ b/policyengine_us/tests/policy/baseline/household/income/household/household_state_tax_before_refundable_credits.yaml @@ -241,3 +241,21 @@ output: household_state_tax_before_refundable_credits: 4_500 household_refundable_state_tax_credits: 100 + +- name: North Carolina household tax before refundable credits excludes the claim of right payment + # Structural case: G.S. 105-266.2 makes the payment refundable, including + # the amount above the current year's tax. It belongs in the credit total. + period: 2025 + input: + state_code: NC + nc_income_tax_before_credits: 100 + nc_non_refundable_credits: 30 + nc_claim_of_right_payment: 500 + state_use_tax: 20 + output: + nc_income_tax_before_refundable_credits: 70 + nc_refundable_credits: 500 + nc_income_tax: -430 + state_income_tax: -430 + household_state_tax_before_refundable_credits: 90 + household_refundable_state_tax_credits: 500 diff --git a/policyengine_us/tests/policy/contrib/federal/abolish_payroll_tax.yaml b/policyengine_us/tests/policy/contrib/federal/abolish_payroll_tax.yaml index 96a8db88953..bee6ad3084c 100644 --- a/policyengine_us/tests/policy/contrib/federal/abolish_payroll_tax.yaml +++ b/policyengine_us/tests/policy/contrib/federal/abolish_payroll_tax.yaml @@ -55,7 +55,7 @@ state_code: NC employment_income: 60_000 income_tax_before_refundable_credits: 0 - nc_income_tax: 1_000 + nc_income_tax_before_refundable_credits: 1_000 nc_use_tax: 20 output: employee_payroll_tax: 0 diff --git a/policyengine_us/tests/policy/contrib/states/nc/cdcc/nc_cdcc.yaml b/policyengine_us/tests/policy/contrib/states/nc/cdcc/nc_cdcc.yaml index 9dab37908b0..8a0ab67fdcb 100644 --- a/policyengine_us/tests/policy/contrib/states/nc/cdcc/nc_cdcc.yaml +++ b/policyengine_us/tests/policy/contrib/states/nc/cdcc/nc_cdcc.yaml @@ -81,3 +81,63 @@ cdcc_potential: 1_000 output: nc_cdcc: 0 + +- name: NC CDCC reform keeps the baseline claim of right payment + # Regression test for #8775: the reform adds its CDCC to North Carolina's + # baseline refundable credits instead of replacing them. + period: 2026 + reforms: policyengine_us.reforms.states.nc.cdcc.nc_cdcc + input: + gov.contrib.states.nc.cdcc.in_effect: true + state_code: NC + cdcc_potential: 1_000 + nc_claim_of_right_payment: 250 + nc_income_tax_before_credits: 600 + nc_use_tax: 0 + nc_non_refundable_credits: 0 + output: + nc_cdcc: 300 + nc_refundable_credits: 550 + nc_income_tax: 50 + +- name: NC CDCC reform does not add use tax to income tax + # Use tax is counted at the household level through state_use_tax (#8775). + period: 2026 + reforms: policyengine_us.reforms.states.nc.cdcc.nc_cdcc + input: + gov.contrib.states.nc.cdcc.in_effect: true + state_code: NC + cdcc_potential: 1_000 + nc_income_tax_before_credits: 600 + nc_use_tax: 100 + nc_non_refundable_credits: 0 + output: + nc_cdcc: 300 + # 600 - 300 = 300; it would be 400 if use tax were added. + nc_income_tax: 300 + +- name: Both NC contrib credits stack on the claim of right payment, and use tax stays out of income tax + # Review r2 of PolicyEngine/policyengine-us#10038. Refundable credits: + # 250 payment + 100 EITC (10% of 1,000) + 300 CDCC (30% of 1,000) = 650. + period: 2026 + reforms: + - policyengine_us.reforms.states.nc.eitc.nc_eitc + - policyengine_us.reforms.states.nc.cdcc.nc_cdcc + input: + gov.contrib.states.nc.eitc.match: 0.1 + gov.contrib.states.nc.cdcc.in_effect: true + state_code: NC + eitc: 1_000 + cdcc_potential: 1_000 + nc_claim_of_right_payment: 250 + nc_income_tax_before_credits: 600 + nc_use_tax: 100 + nc_non_refundable_credits: 0 + output: + nc_refundable_credits: 650 + # 600 - 650; the 100 of use tax is counted once, through state_use_tax. + nc_income_tax: -50 + state_income_tax: -50 + state_use_tax: 100 + household_state_tax_before_refundable_credits: 700 + household_refundable_state_tax_credits: 650 diff --git a/policyengine_us/tests/policy/contrib/states/nc/eitc/nc_eitc.yaml b/policyengine_us/tests/policy/contrib/states/nc/eitc/nc_eitc.yaml index ed383cb202b..09145e7375a 100644 --- a/policyengine_us/tests/policy/contrib/states/nc/eitc/nc_eitc.yaml +++ b/policyengine_us/tests/policy/contrib/states/nc/eitc/nc_eitc.yaml @@ -49,3 +49,21 @@ nc_eitc: 3_000 nc_refundable_credits: 3_000 nc_income_tax: -2_500 + +- name: NC EITC reform keeps the baseline claim of right payment + # Regression test for #8775: the reform adds its EITC to North Carolina's + # baseline refundable credits instead of replacing them. + period: 2026 + reforms: policyengine_us.reforms.states.nc.eitc.nc_eitc + input: + gov.contrib.states.nc.eitc.match: 0.1 + state_code: NC + eitc: 1_000 + nc_claim_of_right_payment: 250 + nc_income_tax_before_credits: 600 + nc_use_tax: 0 + nc_non_refundable_credits: 0 + output: + nc_eitc: 100 + nc_refundable_credits: 350 + nc_income_tax: 250 diff --git a/policyengine_us/tests/policy/contrib/states/nc/eitc/nc_eitc_excludes_use_tax.yaml b/policyengine_us/tests/policy/contrib/states/nc/eitc/nc_eitc_excludes_use_tax.yaml index bf877dda502..4abc4d48e43 100644 --- a/policyengine_us/tests/policy/contrib/states/nc/eitc/nc_eitc_excludes_use_tax.yaml +++ b/policyengine_us/tests/policy/contrib/states/nc/eitc/nc_eitc_excludes_use_tax.yaml @@ -1,5 +1,5 @@ -# Regression test for #8775: the NC EITC reform's nc_income_tax override must -# mirror baseline (nc_income_tax_before_credits minus credits) and must NOT add +# Regression test for #8775: under the NC EITC reform, nc_income_tax must +# match baseline (nc_income_tax_before_credits minus credits) and must NOT add # nc_use_tax. Use tax is already counted at the household level via # state_use_tax; adding it here would raise tax for every NC filer (even with # no EITC) and double-count it. diff --git a/policyengine_us/tests/unit/test_claim_of_right_section_1341_properties.py b/policyengine_us/tests/unit/test_claim_of_right_section_1341_properties.py new file mode 100644 index 00000000000..022de486265 --- /dev/null +++ b/policyengine_us/tests/unit/test_claim_of_right_section_1341_properties.py @@ -0,0 +1,524 @@ +"""Branch isolation and cross-case properties of the section 1341 computation. + +26 U.S.C. 1341(a): when a filer repays more than $3,000 of income included in +an earlier year under a claim of right, federal tax is the lesser of (4) the +tax with a deduction for the repayment and (5) the tax without it minus the +decrease in the earlier year's tax from excluding the income. Ties use (4) +(26 CFR 1.1341-1(b)(3)); any excess of the decrease over the tax is refunded +(1341(b)(1)). North Carolina allows no claim of right deduction under +1341(a)(5) (G.S. 105-153.5(a)(2)d) and instead treats the increase in the +earlier year's North Carolina tax as a payment (G.S. 105-266.2). + +The policy cases are in YAML (``gov/irs/credits/claim_of_right``). These tests +cover what a YAML case cannot. The model picks the method by calculating +federal tax in two override branches, so the tests build separate simulations +and compare them: + +- each branch equals a simulation that fixes the method as an input before + anything is calculated, and income tax equals the smaller of the two + (ties to the deduction), where the credit side comes from a simulation with + no repayment at all less the prior-year decrease; +- results do not depend on which variable is calculated first, including + when a tax liability under one itemizing choice is calculated before the + method is known, under both settings of + ``gov.simulation.branch_to_determine_itemization``; the itemizing branches + keep the simulation's method, including the 2026 branch that + ``tax_unit_itemizes`` opens for the section 68 limitation; +- a later year calculated on the same simulation equals a simulation of that + year alone, and an itemizing branch of a simulation whose itemizing input + changed after its tax was calculated does not reuse that tax; +- the grid runs in 2025 and 2026, and in 2020, where the itemization choice + compares branches with different AGI; +- relations between cases over a grid: tax never rises with the repayment + (also across the $3,000 threshold) or with the prior-year decrease, and a + repayment of $3,000 or less changes nothing (section 67(h), formerly 67(g)). + +They also check, at every grid point, that the deduction is the whole +repayment or nothing, the credit is the whole decrease or nothing, and never +both; that North Carolina's deduction is zero whenever the credit method +applies and otherwise is what it is with the deduction method fixed; and that +its payment is the prior-year increase when the credit method applies and zero +otherwise. + +Last, one itemizing household per state: the credit method reduces the federal +tax deductible in Alabama, Missouri and Oregon, so their state taxes can rise. +Other states' taxes stay unchanged for this household (no state input is +supplied). The deduction method leaves Arizona's and Kansas's taxes unchanged. +""" + +import gc +import itertools + +import numpy as np +import pytest +from policyengine_core.periods import instant +from policyengine_core.reforms import Reform + +from policyengine_us import CountryTaxBenefitSystem, Simulation +from policyengine_us.variables.household.demographic.geographic.state_code import ( + StateCode, +) + +REPAYMENTS = [0, 2_999, 3_000, 3_001, 5_000, 20_000, 150_000] +DECREASES = [0, 400, 2_500, 12_000, 60_000] +WAGES = [0, 30_000, 80_000, 400_000, 1_500_000] +CHARITY = [0, 20_000] +AXES = [REPAYMENTS, DECREASES, WAGES, CHARITY] +GRID = list(itertools.product(*AXES)) +SHAPE = tuple(len(axis) for axis in AXES) +REPAYMENT, DECREASE, WAGE, CHARITABLE = ( + np.array([point[i] for point in GRID], dtype=float) for i in range(len(AXES)) +) +# An illustrative North Carolina prior-year tax increase on the repaid income. +NC_INCREASE = 0.05 * REPAYMENT +ZEROS = np.zeros_like(REPAYMENT) +THRESHOLD = 3_000 +# 2020 exercises the itemization choice between two branches with different +# AGI (the 2020 above-the-line charitable deduction). It comes last so the +# tests that use YEARS[0] and YEARS[1] keep 2025 and 2026. +YEARS = [2025, 2026, 2020] +ITEMIZATION_AGI_YEAR = 2020 +TOLERANCE = 0.01 +# The 50 states and the District of Columbia. +STATES = [ + state.name + for state in StateCode + if state.name not in {"AA", "AE", "AP", "AS", "GU", "MP", "PR", "PW", "VI"} +] +# States whose own rules leave out the federal claim of right repayment +# deduction: A.R.S. 43-1021(9) and K.S.A. 79-32,120(a). +# California carries the federal deduction in Schedule CA column A. +STATES_WITHOUT_THE_DEDUCTION = ["AZ", "KS"] +BRANCHES = [ + "income_tax_if_claiming_claim_of_right_deduction", + "income_tax_if_claiming_claim_of_right_credit", +] +VARIABLES = [ + "income_tax", + "tax_unit_itemizes", + "tax_liability_if_itemizing", + "tax_liability_if_not_itemizing", + "claim_of_right_section_1341_eligible", + "claim_of_right_credit_applies", + "claim_of_right_deduction", + "claim_of_right_credit", + "nc_claim_of_right_deduction", + "nc_claim_of_right_payment", + "nc_income_tax_before_refundable_credits", + "nc_income_tax", +] + BRANCHES + + +def grid_simulation( + years, repayment=REPAYMENT, decrease=DECREASE, nc_increase=NC_INCREASE, method=None +): + """One single-person North Carolina tax unit per grid point.""" + + def yearly(value): + return {year: value for year in years} + + situation = {"people": {}, "tax_units": {}, "households": {}} + for i in range(len(GRID)): + person = f"p{i}" + situation["people"][person] = { + "age": yearly(40), + "employment_income": yearly(WAGE[i]), + "charitable_cash_donations": yearly(CHARITABLE[i]), + "claim_of_right_repayment": yearly(float(repayment[i])), + } + tax_unit = { + "members": [person], + "claim_of_right_prior_year_tax_decrease": yearly(float(decrease[i])), + "nc_claim_of_right_prior_year_tax_increase": yearly(float(nc_increase[i])), + } + if method is not None: + tax_unit["claim_of_right_credit_applies"] = yearly(method) + situation["tax_units"][f"t{i}"] = tax_unit + situation["households"][f"h{i}"] = { + "members": [person], + "state_code": yearly("NC"), + } + return Simulation(situation=situation) + + +def calculate(simulation, year, variables): + return {v: np.asarray(simulation.calculate(v, year)) for v in variables} + + +@pytest.fixture(scope="module") +def results(): + out = {} + for year in YEARS: + out[year] = calculate(grid_simulation([year]), year, VARIABLES) + # Independent references: no repayment at all, and each method fixed + # as an input rather than chosen in a branch. + none = grid_simulation([year], ZEROS, ZEROS, ZEROS) + out[year]["tax_without_repayment"] = np.asarray( + none.calculate("income_tax", year) + ) + deduction = grid_simulation([year], method=False) + out[year]["tax_with_deduction"] = np.asarray( + deduction.calculate("income_tax", year) + ) + out[year]["nc_deduction_if_deduction"] = np.asarray( + deduction.calculate("nc_claim_of_right_deduction", year) + ) + credit = grid_simulation([year], method=True) + out[year]["nc_deduction_if_credit"] = np.asarray( + credit.calculate("nc_claim_of_right_deduction", year) + ) + return out + + +def eligible(): + return REPAYMENT > THRESHOLD + + +@pytest.mark.parametrize("year", YEARS) +def test_tax_is_the_lesser_of_the_two_methods(results, year): + r = results[year] + tax_with_deduction = r["tax_with_deduction"] + tax_with_credit = r["tax_without_repayment"] - DECREASE + # Compared to the cent; equal amounts keep the deduction. + credit = eligible() & ( + np.round(tax_with_credit, 2) < np.round(tax_with_deduction, 2) + ) + assert credit.any() and (eligible() & ~credit).any(), "both methods occur" + np.testing.assert_array_equal(r["claim_of_right_credit_applies"], credit) + expected = np.where( + eligible(), + np.where(credit, tax_with_credit, tax_with_deduction), + r["tax_without_repayment"], + ) + np.testing.assert_allclose(r["income_tax"], expected, atol=TOLERANCE) + + +@pytest.mark.parametrize("year", YEARS) +def test_branches_match_independent_simulations(results, year): + r = results[year] + np.testing.assert_allclose( + r["income_tax_if_claiming_claim_of_right_deduction"], + r["tax_with_deduction"], + atol=TOLERANCE, + ) + tax_with_credit = r["tax_without_repayment"] - DECREASE + np.testing.assert_allclose( + r["income_tax_if_claiming_claim_of_right_credit"][eligible()], + tax_with_credit[eligible()], + atol=TOLERANCE, + ) + + +@pytest.mark.parametrize("year", [YEARS[0], ITEMIZATION_AGI_YEAR]) +@pytest.mark.parametrize( + "first", ["tax_liability_if_itemizing", "tax_liability_if_not_itemizing"] + BRANCHES +) +def test_results_do_not_depend_on_calculation_order(results, first, year): + # A tax liability under one itemizing choice is calculated in a branch. + # Asked for before the method is known, it must not leave a value behind + # that a later method branch reuses. + simulation = grid_simulation([year]) + simulation.calculate(first, year) + for variable in VARIABLES: + np.testing.assert_allclose( + np.asarray(simulation.calculate(variable, year)), + results[year][variable], + atol=TOLERANCE, + err_msg=f"{variable} changes when {first} is calculated first", + ) + + +def test_a_later_year_matches_a_simulation_of_that_year_alone(results): + simulation = grid_simulation(YEARS) + simulation.calculate("income_tax", YEARS[0]) + for variable in VARIABLES: + np.testing.assert_allclose( + np.asarray(simulation.calculate(variable, YEARS[1])), + results[YEARS[1]][variable], + atol=TOLERANCE, + err_msg=f"{variable} differs after an earlier year was calculated", + ) + + +@pytest.mark.parametrize("year", YEARS) +def test_deduction_and_credit_are_all_or_nothing_and_exclusive(results, year): + r = results[year] + credit_applies = r["claim_of_right_credit_applies"] + deduction = r["claim_of_right_deduction"] + credit = r["claim_of_right_credit"] + np.testing.assert_array_equal(r["claim_of_right_section_1341_eligible"], eligible()) + np.testing.assert_allclose( + deduction, np.where(eligible() & ~credit_applies, REPAYMENT, 0) + ) + np.testing.assert_allclose(credit, np.where(credit_applies, DECREASE, 0)) + assert not np.any((deduction > 0) & (credit > 0)) + + +@pytest.mark.parametrize("year", YEARS) +def test_a_repayment_of_3000_or_less_changes_nothing(results, year): + r = results[year] + small = ~eligible() + assert not r["claim_of_right_credit_applies"][small].any() + np.testing.assert_allclose( + r["income_tax"][small], r["tax_without_repayment"][small], atol=TOLERANCE + ) + + +@pytest.mark.parametrize("year", YEARS) +def test_tax_never_rises(results, year): + r = results[year] + assert np.all(r["income_tax"] <= r["tax_without_repayment"] + TOLERANCE) + table = r["income_tax"].reshape(SHAPE) + assert np.all(np.diff(table, axis=0) <= TOLERANCE), "rises with the repayment" + assert np.all(np.diff(table, axis=1) <= TOLERANCE), "rises with the decrease" + + +@pytest.mark.parametrize("year", YEARS) +def test_a_decrease_above_the_tax_is_refunded(results, year): + r = results[year] + credit_applies = r["claim_of_right_credit_applies"] + refunded = credit_applies & (DECREASE > r["tax_without_repayment"]) + assert refunded.any(), "the grid should include refunds" + assert np.all(r["income_tax"][refunded] < 0) + + +@pytest.mark.parametrize("year", YEARS) +def test_north_carolina_follows_the_federal_method(results, year): + r = results[year] + credit_applies = r["claim_of_right_credit_applies"] + np.testing.assert_allclose( + r["nc_claim_of_right_deduction"], + np.where(credit_applies, 0, r["nc_deduction_if_deduction"]), + ) + np.testing.assert_allclose( + r["nc_deduction_if_credit"], + np.where(eligible(), 0, r["nc_deduction_if_deduction"]), + ) + np.testing.assert_allclose( + r["nc_claim_of_right_payment"], np.where(credit_applies, NC_INCREASE, 0) + ) + np.testing.assert_allclose( + r["nc_income_tax"], + r["nc_income_tax_before_refundable_credits"] - r["nc_claim_of_right_payment"], + atol=TOLERANCE, + ) + + +def state_income_tax(year, repayment, method=None): + """State income tax of an itemizing single filer in each state.""" + situation = {"people": {}, "tax_units": {}, "households": {}} + for i, state in enumerate(STATES): + situation["people"][f"p{i}"] = { + "age": {year: 40}, + "employment_income": {year: 60_000}, + "charitable_cash_donations": {year: 25_000}, + "claim_of_right_repayment": {year: repayment}, + } + situation["tax_units"][f"t{i}"] = { + "members": [f"p{i}"], + "claim_of_right_prior_year_tax_decrease": {year: 2_500}, + } + if method is not None: + situation["tax_units"][f"t{i}"]["claim_of_right_credit_applies"] = { + year: method + } + situation["households"][f"h{i}"] = { + "members": [f"p{i}"], + "state_code": {year: state}, + } + simulation = Simulation(situation=situation) + return np.asarray(simulation.calculate("state_income_tax", year)) + + +def test_states_under_each_federal_method(): + # One year: each of these three simulations computes every state's tax. + year = YEARS[0] + without_repayment = state_income_tax(year, 0) + with_credit = state_income_tax(year, 10_000, method=True) + federal_tax_deduction_states = np.isin(STATES, ["AL", "MO", "OR"]) + np.testing.assert_allclose( + with_credit[~federal_tax_deduction_states], + without_repayment[~federal_tax_deduction_states], + atol=TOLERANCE, + ) + assert np.all( + with_credit[federal_tax_deduction_states] + >= without_repayment[federal_tax_deduction_states] - TOLERANCE + ) + assert np.any( + with_credit[federal_tax_deduction_states] + > without_repayment[federal_tax_deduction_states] + TOLERANCE + ) + with_deduction = state_income_tax(year, 10_000, method=False) + assert np.any(np.abs(with_deduction - without_repayment) > 1), ( + "the deduction should reach the states that follow federal itemized deductions" + ) + excluded = np.isin(STATES, STATES_WITHOUT_THE_DEDUCTION) + np.testing.assert_allclose( + with_deduction[excluded], without_repayment[excluded], atol=TOLERANCE + ) + + +# The household from reviews r1 and r2 of PolicyEngine/policyengine-us#10038. +# With the deduction, $20,000 of itemized deductions leave $40,000 of taxable +# income: $1,192.50 + 12% x $28,075 = $4,561.50. Without it, the $15,750 +# standard deduction leaves $44,250: $5,071.50, less the $100 decrease is +# $4,971.50. So the deduction applies, and tax without itemizing under that +# method is $5,071.50. +TEXAS_YEAR = 2025 +# From 2026 tax_unit_itemizes takes the itemized deductions from the branch +# that itemizes (the P.L. 119-21 section 68 limitation). A household for which +# that branch, choosing a method for itself, would pick the deduction while +# the simulation picks the credit. Standard deduction $16,100 plus the $1,000 +# section 170(p) charitable deduction: taxable income $42,900, tax $1,240 + +# 12% x $30,500 = $4,900, less the $800 decrease is $4,100. With the deduction: +# gifts of $10,000 less the 0.5% floor ($300) plus the $10,000 repayment are +# $19,700 of itemized deductions, taxable income $40,300, tax $4,588. Itemizing +# under the credit method: $9,700 of deductions, taxable income $50,300, tax +# $5,788 less $800 is $4,988. +ITEMIZING_BRANCH_YEAR = 2026 +ITEMIZING_BRANCH_EXPECTED = { + "income_tax": 4_100, + "claim_of_right_credit_applies": True, + "tax_unit_itemizes": False, + "tax_liability_if_itemizing": 4_988, + "tax_liability_if_not_itemizing": 4_100, + "income_tax_if_claiming_claim_of_right_deduction": 4_588, + "income_tax_if_claiming_claim_of_right_credit": 4_100, +} +TEXAS_EXPECTED = { + "income_tax": 4_561.5, + "claim_of_right_credit_applies": False, + "tax_liability_if_itemizing": 4_561.5, + "tax_liability_if_not_itemizing": 5_071.5, + "income_tax_if_claiming_claim_of_right_deduction": 4_561.5, + "income_tax_if_claiming_claim_of_right_credit": 4_971.5, +} + + +class no_itemization_branching(Reform): + def apply(self): + def modify(parameters): + parameters.gov.simulation.branch_to_determine_itemization.update( + start=instant(f"{TEXAS_YEAR}-01-01"), + stop=instant(f"{ITEMIZING_BRANCH_YEAR}-12-31"), + value=False, + ) + return parameters + + self.modify_parameters(modify) + + +@pytest.fixture(scope="module") +def systems(): + systems = { + True: None, + False: CountryTaxBenefitSystem(reform=(no_itemization_branching,)), + } + yield systems + # Release the reformed system before the rest of the test process runs. + systems.clear() + gc.collect() + + +def texas_simulation(system, year=TEXAS_YEAR, decrease=100, **tax_unit_inputs): + situation = { + "people": { + "p": { + "age": {year: 40}, + "employment_income": {year: 60_000}, + "charitable_cash_donations": {year: 10_000}, + "claim_of_right_repayment": {year: 10_000}, + } + }, + "tax_units": { + "t": { + "members": ["p"], + "claim_of_right_prior_year_tax_decrease": {year: decrease}, + "state_sales_tax": {year: 0}, + "local_sales_tax": {year: 0}, + **{name: {year: value} for name, value in tax_unit_inputs.items()}, + } + }, + "households": {"h": {"members": ["p"], "state_code": {year: "TX"}}}, + } + if system is None: + return Simulation(situation=situation) + return Simulation(tax_benefit_system=system, situation=situation) + + +@pytest.mark.parametrize("branching", [True, False]) +@pytest.mark.parametrize("first", list(TEXAS_EXPECTED)) +def test_texas_household_does_not_depend_on_calculation_order( + systems, branching, first +): + simulation = texas_simulation(systems[branching]) + simulation.calculate(first, TEXAS_YEAR) + for variable, expected in TEXAS_EXPECTED.items(): + np.testing.assert_allclose( + np.asarray(simulation.calculate(variable, TEXAS_YEAR)), + [expected], + atol=TOLERANCE, + err_msg=f"{variable} when {first} is calculated first", + ) + + +@pytest.mark.parametrize("branching", [True, False]) +@pytest.mark.parametrize("first", list(ITEMIZING_BRANCH_EXPECTED)) +def test_the_itemizing_branch_keeps_the_simulation_method(systems, branching, first): + # From policyengine-core 3.33, set_input on a branch drops the values + # stored after the overridden variable was first stored anywhere in the + # simulation. A branch fixing only itemization then lost the inherited + # method and chose its own, and with itemization branching off its + # itemized deductions alone decided whether to itemize: $4,988 here. + year = ITEMIZING_BRANCH_YEAR + forced = texas_simulation(systems[branching], year, 800, tax_unit_itemizes=True) + assert not forced.calculate("claim_of_right_credit_applies", year)[0], ( + "a filer who must itemize would choose the deduction" + ) + simulation = texas_simulation(systems[branching], year, 800) + simulation.calculate(first, year) + for variable, expected in ITEMIZING_BRANCH_EXPECTED.items(): + np.testing.assert_allclose( + np.asarray(simulation.calculate(variable, year)), + [expected], + atol=TOLERANCE, + err_msg=f"{variable} when {first} is calculated first", + ) + + +def test_a_branch_does_not_reuse_tax_calculated_before_an_input_changed(): + # Review r3 of PolicyEngine/policyengine-us#10038. No repayment, $20,000 of + # charitable gifts: $5,071.50 with the $15,750 standard deduction (taxable + # income $44,250), $4,561.50 itemizing (taxable income $40,000). + year = TEXAS_YEAR + simulation = Simulation( + situation={ + "people": { + "p": { + "age": {year: 40}, + "employment_income": {year: 60_000}, + "charitable_cash_donations": {year: 20_000}, + } + }, + "tax_units": { + "t": { + "members": ["p"], + "tax_unit_itemizes": {year: False}, + "state_sales_tax": {year: 0}, + "local_sales_tax": {year: 0}, + } + }, + "households": {"h": {"members": ["p"], "state_code": {year: "TX"}}}, + } + ) + np.testing.assert_allclose( + simulation.calculate("income_tax", year), [5_071.5], atol=TOLERANCE + ) + # A plain branch whose itemizing input now equals the itemizing branch's + # override still holds the tax calculated without itemizing. + branch = simulation.get_branch("itemizes_after_the_fact") + branch.set_input("tax_unit_itemizes", year, np.array([True])) + np.testing.assert_allclose( + branch.calculate("tax_liability_if_itemizing", year), [4_561.5], atol=TOLERANCE + ) diff --git a/policyengine_us/tests/unit/test_mt_taxable_income_properties.py b/policyengine_us/tests/unit/test_mt_taxable_income_properties.py new file mode 100644 index 00000000000..04ea4a7abdc --- /dev/null +++ b/policyengine_us/tests/unit/test_mt_taxable_income_properties.py @@ -0,0 +1,131 @@ +"""In 2024 Montana's capped state-tax adjustment precedes the taxable-income floor. + +MCA 15-30-2101(7) incorporates the subtraction-based federal definition of +taxable income. The 2024 Form 2 Worksheet A reduces the deduction by the +capped state-income-tax adjustment before taxable income is floored at zero: +https://mca.legmt.gov/bills/mca/title_0150/chapter_0300/part_0210/section_0010/0150-0300-0210-0010.html +https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2024_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=15 + +From 2025 the addback is a Schedule I addition after the floor; YAML cases in +mt_claim_of_right_deduction.yaml cover 2025 and 2026, so this file checks +2024 only. + +Generated batches exercise both federal deduction elections and excess +deductions. They check the ordering against an independent reference and the +former floor-then-add upper bound. Each batch also includes the review's +floor-binding witness and its higher-income twin, where changing the order +has no effect. Other Montana adjustments and QBI are held at zero to isolate +the state-tax adjustment. +""" + +import numpy as np +import pytest +from hypothesis import given, settings, strategies as st + +from policyengine_us import Simulation +from policyengine_us.system import system + +YEARS = (2024,) + + +@pytest.fixture(scope="module") +def reference_system(): + # Reuse only the read-only policy source. Each generated batch gets its + # own simulation, entities and calculation holders. + return system + + +@st.composite +def deduction_case(draw): + agi = draw(st.integers(min_value=-20_000, max_value=200_000)) + itemized = draw(st.integers(min_value=0, max_value=100_000)) + standard = draw(st.integers(min_value=0, max_value=40_000)) + # All of the generated state tax fits within the allowed itemized total. + state_tax = draw(st.integers(min_value=0, max_value=min(itemized, 40_000))) + itemizes = draw(st.booleans()) + return agi, itemized, standard, state_tax, itemizes + + +def _situation(points): + people, tax_units, households = {}, {}, {} + + def all_years(value): + return {year: value for year in YEARS} + + for index, (agi, itemized, standard, state_tax, itemizes) in enumerate(points): + name = f"person_{index}" + people[name] = { + "age": all_years(40), + "is_tax_unit_head": all_years(True), + "real_estate_taxes": all_years(0), + "mt_additions": all_years(0), + "mt_subtractions": all_years(0), + "mt_federal_obbba_subtraction": all_years(0), + } + tax_units[name] = { + "members": [name], + "adjusted_gross_income": all_years(agi), + "exemptions": all_years(0), + "tax_unit_itemizes": all_years(itemizes), + "itemized_taxable_income_deductions": all_years(itemized), + "standard_deduction": all_years(standard), + "state_withheld_income_tax": all_years(state_tax), + "local_income_tax": all_years(0), + "state_sales_tax": all_years(0), + "local_sales_tax": all_years(0), + "salt_deduction": all_years(state_tax), + "mt_federal_itemized_personal_property_taxes": all_years(0), + "wagering_losses_deduction": all_years(0), + "qualified_business_income_deduction": all_years(0), + "charitable_deduction_for_non_itemizers": all_years(0), + "tip_income_deduction": all_years(0), + "overtime_income_deduction": all_years(0), + "additional_senior_deduction": all_years(0), + "auto_loan_interest_deduction": all_years(0), + } + households[name] = { + "members": [name], + "state_code": all_years("MT"), + } + return {"people": people, "tax_units": tax_units, "households": households} + + +@settings(max_examples=6, deadline=None, derandomize=True) +@given(points=st.lists(deduction_case(), min_size=1, max_size=4)) +def test_state_tax_adjustment_precedes_taxable_income_floor(reference_system, points): + witnesses = [ + (10_000, 20_000, 14_600, 6_000, True), + (50_000, 20_000, 14_600, 6_000, True), + ] + points = points + witnesses + simulation = Simulation( + tax_benefit_system=reference_system, + situation=_situation(points), + ) + agi, itemized, standard, state_tax, itemizes = ( + np.asarray(values) for values in zip(*points) + ) + adjustment = np.where( + itemizes, np.minimum(state_tax, np.maximum(itemized - standard, 0)), 0 + ) + elected_deduction = np.where(itemizes, itemized, standard) + + for year in YEARS: + federal_deductions = elected_deduction + federal_pre_floor_base = agi - federal_deductions + expected = np.maximum(federal_pre_floor_base + adjustment, 0) + old_floor_then_add = np.maximum(federal_pre_floor_base, 0) + adjustment + + np.testing.assert_array_equal( + simulation.calculate("taxable_income_deductions", year), federal_deductions + ) + np.testing.assert_array_equal( + simulation.calculate("mt_state_income_tax_itemized_add_back", year), + adjustment, + ) + actual = simulation.calculate("mt_taxable_income_joint", year) + np.testing.assert_array_equal(actual, expected) + assert np.all(actual <= old_floor_then_add) + # Keep a binding floor and a nonbinding floor in every generated batch. + assert actual[-2] == 0 < old_floor_then_add[-2] + assert actual[-1] == old_floor_then_add[-1] == 35_400 diff --git a/policyengine_us/tests/unit/test_nc_claim_of_right_properties.py b/policyengine_us/tests/unit/test_nc_claim_of_right_properties.py index 7ff5a694e8d..d86fc79c5d5 100644 --- a/policyengine_us/tests/unit/test_nc_claim_of_right_properties.py +++ b/policyengine_us/tests/unit/test_nc_claim_of_right_properties.py @@ -65,6 +65,12 @@ def grid_simulation(year, people, tax_units): } situation["tax_units"][f"t{i}"] = { "members": [person], + # These tests check the deduction's arithmetic, which applies + # when federal tax is computed with the deduction (section + # 1341(a)(4)). Fixing that method here skips the two extra + # federal tax computations that choose it; + # test_claim_of_right_section_1341_properties.py covers the choice. + "claim_of_right_credit_applies": {year: False}, **{name: {year: float(values[i])} for name, values in tax_units.items()}, } situation["households"][f"h{i}"] = { diff --git a/policyengine_us/tools/general.py b/policyengine_us/tools/general.py index 7afc7860fd7..831784336cc 100644 --- a/policyengine_us/tools/general.py +++ b/policyengine_us/tools/general.py @@ -218,15 +218,25 @@ def get_itemization_branch(tax_unit, period, itemizes: bool): """ The branch of ``tax_unit``'s simulation that fixes ``tax_unit_itemizes``. - It is named ``itemizing`` or ``not_itemizing``. Every caller asks for the - same inputs, so they share one branch: the choice itself and the tax - liabilities it compares. + It is named ``itemizing`` or ``not_itemizing``. When some tax unit repays + more than $3,000 of claim of right income (26 U.S.C. 1341), the branch + also takes this simulation's method, ``claim_of_right_credit_applies``, as + an input, so it never chooses one for itself: with itemizing fixed, a + branch would choose the method best for that choice, not the method this + simulation uses. Every caller asks for the same inputs, so they share one + branch. With no qualifying repayment the method is false everywhere and is + left out, which keeps the branch sharing this simulation's cache. """ + overrides = {"tax_unit_itemizes": np.full(tax_unit.count, itemizes, dtype=bool)} + if tax_unit("claim_of_right_section_1341_eligible", period).any(): + overrides["claim_of_right_credit_applies"] = tax_unit( + "claim_of_right_credit_applies", period + ) return get_override_branch( tax_unit.simulation, "itemizing" if itemizes else "not_itemizing", period, - {"tax_unit_itemizes": np.full(tax_unit.count, itemizes, dtype=bool)}, + overrides, ) diff --git a/policyengine_us/tools/period_branch.py b/policyengine_us/tools/period_branch.py index f81448ca771..2d2033c540b 100644 --- a/policyengine_us/tools/period_branch.py +++ b/policyengine_us/tools/period_branch.py @@ -1,11 +1,15 @@ """Formula branches that calculate one period, under overridden inputs. A policyengine-core branch starts from every array its parent has cached when -the branch is created and never sees the parent's later calculations, and -``set_input`` on the branch stores the new value without clearing anything -that was calculated from the old one. A branch therefore answers any variable -its parent had already calculated with the parent's value, whatever the -branch's inputs say. A branch kept from another period also answers this +the branch is created and never sees the parent's later calculations. Before +policyengine-core 3.33, ``set_input`` on the branch stored the new value +without clearing anything that was calculated from the old one, so a branch +answered any variable its parent had already calculated with the parent's +value, whatever the branch's inputs said. From 3.33 it drops the values stored +after the overridden variable was first stored anywhere in the simulation, +which can include a choice the caller wants the branch to keep; pass such a +choice as an input (as ``get_itemization_branch`` does for the claim of right +method). A branch kept from another period also answers this period from a copy taken before any of this period was calculated, unlike the branch a simulation calculating only this period would create, so a later year came out differently when an earlier year had been calculated first. @@ -23,8 +27,15 @@ formula branches while its parent is still calculating the variable the branch overrides. Otherwise the branch drops every array it copied except inputs, each for the periods it was set for, and calculates the rest - itself. + itself. A parent value equal to the override is not enough: the parent's + cache can predate a later change to another input. - A branch reused within its period with different inputs is created again. +- A caller can ask the branch never to keep the parent's calculated values + (``inherit_calculated=False``). The parent can hold a value that depends on + the overridden variable although it has no value for that variable yet: + one it calculated in another branch, which chose the overridden variable + for itself. The branches that fix the claim of right method (26 U.S.C. + 1341) start from inputs for that reason. ``get_branch_for_period`` is the same with no inputs, for branches that change the tax-benefit system rather than inputs: the caller swaps the system @@ -199,11 +210,14 @@ def get_override_branch( name: str, period: Period, inputs: Dict[str, Override], + inherit_calculated: bool = True, ) -> Simulation: """Return ``simulation``'s branch ``name`` for ``period``, with ``inputs`` set. ``inputs`` maps each overridden variable to its value for ``period``, or - to a ``(period, value)`` pair for another period (e.g. a month). + to a ``(period, value)`` pair for another period (e.g. a month). With + ``inherit_calculated=False`` a new branch keeps only inputs, whether or + not the parent has calculated an overridden variable. """ period = to_period(period) overrides = list(_overrides(period, inputs)) @@ -227,7 +241,7 @@ def get_override_branch( ) branch = simulation.get_branch(name) branch.branch_period = period - if parent_knows_override: + if parent_knows_override or not inherit_calculated: drop_inherited_values(branch) for variable, input_period, value in overrides: branch.set_input(variable, input_period, value) diff --git a/policyengine_us/variables/gov/aca/ptc/net_premium_tax_credit.py b/policyengine_us/variables/gov/aca/ptc/net_premium_tax_credit.py new file mode 100644 index 00000000000..7710be3e8ee --- /dev/null +++ b/policyengine_us/variables/gov/aca/ptc/net_premium_tax_credit.py @@ -0,0 +1,17 @@ +from policyengine_us.model_api import * + + +class net_premium_tax_credit(Variable): + value_type = float + entity = TaxUnit + label = "Net premium tax credit reported on the federal return" + unit = USD + definition_period = YEAR + default_value = 0 + documentation = ( + "Actual net premium tax credit after advance-payment reconciliation: " + "max(Form 8962 line 24 minus line 25, 0), reported on line 26. This " + "return-amount input is distinct from assigned_aca_ptc, which does not " + "reconcile advance payments." + ) + reference = "https://www.irs.gov/pub/irs-prior/f8962--2025.pdf#page=1" diff --git a/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_credit.py b/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_credit.py new file mode 100644 index 00000000000..494a6cb24e7 --- /dev/null +++ b/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_credit.py @@ -0,0 +1,29 @@ +from policyengine_us.model_api import * + + +class claim_of_right_credit(Variable): + value_type = float + entity = TaxUnit + label = "Section 1341 credit for repayment of amounts included in income from earlier years" + unit = USD + documentation = ( + "When tax is computed under section 1341(a)(5), the decrease in " + "prior-year tax from excluding the repaid income. It is reported as " + "a payment (Schedule 3, line 13b), so any excess over the year's tax " + "is refunded (section 1341(b)(1))." + ) + definition_period = YEAR + reference = ( + "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapQ-partV-sec1341.htm", + "https://www.irs.gov/pub/irs-prior/f1040s3--2025.pdf", + # 2025 Form 1040 instructions, Schedule 3 line 13b + "https://www.irs.gov/pub/irs-prior/i1040gi--2025.pdf#page=117", + # Publication 525 (2025), Repayments, method 2 + "https://www.irs.gov/pub/irs-prior/p525--2025.pdf#page=36", + ) + + def formula(tax_unit, period, parameters): + eligible = tax_unit("claim_of_right_section_1341_eligible", period) + credit_applies = tax_unit("claim_of_right_credit_applies", period) + decrease = tax_unit("claim_of_right_prior_year_tax_decrease", period) + return where(eligible & credit_applies, decrease, 0) diff --git a/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_credit_applies.py b/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_credit_applies.py new file mode 100644 index 00000000000..7c46719ad72 --- /dev/null +++ b/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_credit_applies.py @@ -0,0 +1,40 @@ +from policyengine_us.model_api import * + + +class claim_of_right_credit_applies(Variable): + value_type = bool + entity = TaxUnit + label = "Tax is computed under section 1341(a)(5)" + documentation = ( + "Whether federal income tax for the year of repayment is computed " + "under 26 U.S.C. 1341(a)(5): the tax without a deduction for the " + "repayment, minus the decrease in prior-year tax from excluding the " + "repaid income (the credit method). Section 1341 makes the tax the " + "lesser of this and the tax computed with the deduction under " + "1341(a)(4), so the method is computed, not elected. When the two " + "are equal, the tax is computed under 1341(a)(4). The comparison is " + "of federal income tax after credits; the parts of it outside " + "chapter 1 do not depend on the repayment." + ) + definition_period = YEAR + reference = ( + "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapQ-partV-sec1341.htm", + # 26 CFR 1.1341-1(b)(1) and (b)(3) + "https://www.ecfr.gov/current/title-26/chapter-I/subchapter-A/part-1/subject-group-ECFR4c74bc8cf7c11fb/section-1.1341-1", + # Publication 525 (2025), Repayments, methods 1 and 2 + "https://www.irs.gov/pub/irs-prior/p525--2025.pdf#page=36", + ) + + def formula(tax_unit, period, parameters): + eligible = tax_unit("claim_of_right_section_1341_eligible", period) + if not eligible.any(): + # Comparing the two methods takes two more tax computations; + # skip them when no tax unit repays more than the threshold. + return np.zeros(tax_unit.count, dtype=bool) + tax_if_credit = tax_unit("income_tax_if_claiming_claim_of_right_credit", period) + tax_if_deduction = tax_unit( + "income_tax_if_claiming_claim_of_right_deduction", period + ) + # Ties go to the deduction (26 CFR 1.1341-1(b)(3)). Comparing to the + # cent keeps floating-point noise from deciding a tie. + return eligible & (np.round(tax_if_credit, 2) < np.round(tax_if_deduction, 2)) diff --git a/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_prior_year_tax_decrease.py b/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_prior_year_tax_decrease.py new file mode 100644 index 00000000000..01d92fdfa29 --- /dev/null +++ b/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_prior_year_tax_decrease.py @@ -0,0 +1,28 @@ +from policyengine_us.model_api import * + + +class claim_of_right_prior_year_tax_decrease(Variable): + value_type = float + entity = TaxUnit + label = ( + "Federal prior-year tax decrease from excluding repaid claim of right income" + ) + unit = USD + documentation = ( + "Decrease in the filers' federal income tax under chapter 1 of the " + "Internal Revenue Code for the earlier year or years that would " + "result solely from excluding from gross income all the income they " + "repaid this year (claim_of_right_repayment): the chapter 1 tax " + "previously determined, after credits and including the alternative " + "minimum tax, less that tax refigured without the repaid income. It " + "leaves out the net investment income tax, self-employment tax and " + "payroll taxes." + ) + definition_period = YEAR + reference = ( + "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapQ-partV-sec1341.htm", + # 26 CFR 1.1341-1(b)(1)(ii) and (d)(4) + "https://www.ecfr.gov/current/title-26/chapter-I/subchapter-A/part-1/subject-group-ECFR4c74bc8cf7c11fb/section-1.1341-1", + # Publication 525 (2025), Repayments, method 2, steps 2 and 3 + "https://www.irs.gov/pub/irs-prior/p525--2025.pdf#page=36", + ) diff --git a/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_section_1341_eligible.py b/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_section_1341_eligible.py new file mode 100644 index 00000000000..e9d9143cd1a --- /dev/null +++ b/policyengine_us/variables/gov/irs/credits/claim_of_right/claim_of_right_section_1341_eligible.py @@ -0,0 +1,28 @@ +from policyengine_us.model_api import * + + +class claim_of_right_section_1341_eligible(Variable): + value_type = bool + entity = TaxUnit + label = "Claim of right repayment qualifies for section 1341" + documentation = ( + "Whether the repayment of claim of right income on the return " + "exceeds the section 1341(a)(3) threshold, so that tax is the " + "lesser of the tax with a deduction for the repayment and the tax " + "without it less the prior-year tax decrease. The threshold applies " + "to repayments of income of the same class under 26 CFR " + "1.1341-1(a)(3), not to each repayment separately. The model sums " + "the head's and spouse's repayments without distinguishing income " + "classes; same-class aggregation is not modeled." + ) + definition_period = YEAR + reference = ( + "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapQ-partV-sec1341.htm", + "https://www.ecfr.gov/current/title-26/chapter-I/subchapter-A/part-1/subject-group-ECFR4c74bc8cf7c11fb/section-1.1341-1", + "https://www.irs.gov/pub/irs-prior/p525--2025.pdf#page=36", + ) + + def formula(tax_unit, period, parameters): + p = parameters(period).gov.irs.deductions.itemized.claim_of_right + repayment = tax_unit("tax_unit_claim_of_right_repayment", period) + return repayment > p.threshold diff --git a/policyengine_us/variables/gov/irs/credits/claim_of_right/income_tax_if_claiming_claim_of_right_credit.py b/policyengine_us/variables/gov/irs/credits/claim_of_right/income_tax_if_claiming_claim_of_right_credit.py new file mode 100644 index 00000000000..91095a583d8 --- /dev/null +++ b/policyengine_us/variables/gov/irs/credits/claim_of_right/income_tax_if_claiming_claim_of_right_credit.py @@ -0,0 +1,27 @@ +from policyengine_us.model_api import * + + +class income_tax_if_claiming_claim_of_right_credit(Variable): + value_type = float + entity = TaxUnit + label = "Federal income tax under section 1341(a)(5)" + unit = USD + documentation = ( + "Federal income tax computed without a deduction for the repayment of " + "claim of right income, less the decrease in prior-year tax from " + "excluding the repaid income (section 1341(a)(5))." + ) + definition_period = YEAR + reference = "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapQ-partV-sec1341.htm" + + def formula(tax_unit, period, parameters): + branch = get_override_branch( + tax_unit.simulation, + "claim_of_right_credit", + period, + {"claim_of_right_credit_applies": np.ones(tax_unit.count, dtype=bool)}, + # A value the parent calculated in another branch reflects the + # method that branch chose, so start from inputs only. + inherit_calculated=False, + ) + return branch.calculate("income_tax", period) diff --git a/policyengine_us/variables/gov/irs/credits/claim_of_right/income_tax_if_claiming_claim_of_right_deduction.py b/policyengine_us/variables/gov/irs/credits/claim_of_right/income_tax_if_claiming_claim_of_right_deduction.py new file mode 100644 index 00000000000..1e5372ca046 --- /dev/null +++ b/policyengine_us/variables/gov/irs/credits/claim_of_right/income_tax_if_claiming_claim_of_right_deduction.py @@ -0,0 +1,26 @@ +from policyengine_us.model_api import * + + +class income_tax_if_claiming_claim_of_right_deduction(Variable): + value_type = float + entity = TaxUnit + label = "Federal income tax under section 1341(a)(4)" + unit = USD + documentation = ( + "Federal income tax computed with a deduction for the repayment of " + "claim of right income (section 1341(a)(4))." + ) + definition_period = YEAR + reference = "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapQ-partV-sec1341.htm" + + def formula(tax_unit, period, parameters): + branch = get_override_branch( + tax_unit.simulation, + "claim_of_right_deduction", + period, + {"claim_of_right_credit_applies": np.zeros(tax_unit.count, dtype=bool)}, + # A value the parent calculated in another branch reflects the + # method that branch chose, so start from inputs only. + inherit_calculated=False, + ) + return branch.calculate("income_tax", period) diff --git a/policyengine_us/variables/gov/irs/credits/claim_of_right/tax_unit_claim_of_right_repayment.py b/policyengine_us/variables/gov/irs/credits/claim_of_right/tax_unit_claim_of_right_repayment.py new file mode 100644 index 00000000000..be284128fc5 --- /dev/null +++ b/policyengine_us/variables/gov/irs/credits/claim_of_right/tax_unit_claim_of_right_repayment.py @@ -0,0 +1,27 @@ +from policyengine_us.model_api import * + + +class tax_unit_claim_of_right_repayment(Variable): + value_type = float + entity = TaxUnit + label = "Repayment of claim of right income on the return" + unit = USD + documentation = ( + "Total repaid this year by the head and spouse of income included in " + "an earlier year under a claim of right, excluding repayments " + "deducted in arriving at adjusted gross income. Dependents' " + "repayments belong on their own returns." + ) + definition_period = YEAR + reference = ( + "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapQ-partV-sec1341.htm", + # Publication 525 (2025), Repayments: consider the total amount + # repaid on the return + "https://www.irs.gov/pub/irs-prior/p525--2025.pdf#page=36", + ) + + def formula(tax_unit, period, parameters): + person = tax_unit.members + repayment = person("claim_of_right_repayment", period) + head_or_spouse = person("is_tax_unit_head_or_spouse", period) + return tax_unit.sum(repayment * head_or_spouse) diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/claim_of_right_deduction.py b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/claim_of_right_deduction.py new file mode 100644 index 00000000000..bb8b52793c1 --- /dev/null +++ b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/claim_of_right_deduction.py @@ -0,0 +1,36 @@ +from policyengine_us.model_api import * + + +class claim_of_right_deduction(Variable): + value_type = float + entity = TaxUnit + label = "Claim of right repayment deduction" + unit = USD + documentation = ( + "Itemized deduction for repaying more than the section 1341 threshold " + "of income included in an earlier year under a claim of right " + "(Schedule A, line 16), when tax is computed with the deduction " + "under section 1341(a)(4). It is not a miscellaneous itemized " + "deduction (section 67(b)(9)), so neither the two percent floor nor " + "the suspension of those deductions from 2018 applies. Under " + "section 1341(a)(5) the repayment is not deducted (section " + "1341(b)(3)). Not modeled: before 2018 a repayment of the threshold " + "amount or less was a miscellaneous itemized deduction subject to " + "the two percent floor; from 2018 it is disallowed (section 67(g), " + "redesignated 67(h) by P.L. 119-21)." + ) + definition_period = YEAR + reference = ( + "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapQ-partV-sec1341.htm", + "https://www.law.cornell.edu/uscode/text/26/67#b_9", + # 2025 Schedule A instructions, line 16, PDF pages 11-12 + "https://www.irs.gov/pub/irs-prior/i1040sca--2025.pdf#page=11", + # 2017 Schedule A instructions, line 28 + "https://www.irs.gov/pub/irs-prior/i1040sca--2017.pdf#page=13", + ) + + def formula(tax_unit, period, parameters): + eligible = tax_unit("claim_of_right_section_1341_eligible", period) + credit_applies = tax_unit("claim_of_right_credit_applies", period) + repayment = tax_unit("tax_unit_claim_of_right_repayment", period) + return where(eligible & ~credit_applies, repayment, 0) diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/tax_unit_itemizes.py b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/tax_unit_itemizes.py index 30e413249e2..ad55ecc92d7 100644 --- a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/tax_unit_itemizes.py +++ b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/tax_unit_itemizes.py @@ -51,7 +51,8 @@ def formula(tax_unit, period, parameters): # qualified business income deduction, which depends on the # itemization choice, so they come from the branch that itemizes # (the one that also gives tax_liability_if_itemizing). - # Calculated before branching, so the branch inherits it. + # Calculated before branching, so the branch inherits it when no + # one repays claim of right income above $3,000. tax_unit("total_itemized_taxable_income_deductions", period) itemized_deductions = get_itemization_branch( tax_unit, period, itemizes=True diff --git a/policyengine_us/variables/gov/states/al/tax/income/deductions/federal_income_tax/al_federal_income_tax_deduction.py b/policyengine_us/variables/gov/states/al/tax/income/deductions/federal_income_tax/al_federal_income_tax_deduction.py index d7c710f9c51..7b6533a392a 100644 --- a/policyengine_us/variables/gov/states/al/tax/income/deductions/federal_income_tax/al_federal_income_tax_deduction.py +++ b/policyengine_us/variables/gov/states/al/tax/income/deductions/federal_income_tax/al_federal_income_tax_deduction.py @@ -14,6 +14,8 @@ class al_federal_income_tax_deduction(Variable): unit = USD definition_period = YEAR reference = ( + # Alabama Administrative Code r. 810-3-15-.20(1)(d)2. + "https://www.revenue.alabama.gov/wp-content/uploads/2021/12/810-3-15-.20.pdf#page=2", # 2021 Alabama Form 40 booklet, Federal Income Tax Deduction Worksheet "https://www.revenue.alabama.gov/wp-content/uploads/2022/06/21f40abk.pdf#page=20", # Act 2022-37 (HB 231), section 1. @@ -30,8 +32,11 @@ def formula(tax_unit, period, parameters): # tax) of the worksheet. federal_tax = tax_unit("income_tax_before_refundable_credits", period) - # Part I (worksheet lines 1-6): subtract the actual refundable federal - # credits (EITC, refundable CTC/ACTC, American Opportunity Credit). + # The regulation subtracts all federal payment credits, including net + # PTC and section 1341 relief. Non-refundable credits already reduced + # federal_tax, so the AOC entry includes only its refundable portion. + # The regulation's current text (amended 2010) governs every modeled + # year, so the same list applies from 2015. part_i = max_(federal_tax - add(tax_unit, period, p.credits), 0) # Part II (Act 2022-37) applies only to tax year 2021, the one year the @@ -82,12 +87,17 @@ def formula(tax_unit, period, parameters): recomputed_cdcc = branch.tax_unit("cdcc", period) recomputed_eitc = branch.tax_unit("eitc", period) - # Worksheet line 11 (2021 Form 1040 line 29) is the REFUNDABLE portion of - # the American Opportunity Credit (Form 8863 line 8). The non-refundable - # portion already reduced `federal_tax`, so subtracting the total would - # double-count it. - refundable_american_opportunity_credit = tax_unit( - "refundable_american_opportunity_credit", period + # Only EITC and refundable CTC are replaced with 2020-rule amounts. + # All other payment credits, including refundable AOC, remain actual + # current-year amounts in both alternatives. + other_payment_credits = add( + tax_unit, + period, + [ + credit + for credit in p.credits + if credit not in ("eitc", "refundable_ctc") + ], ) # `federal_tax` (Part I line 3) includes the net investment income tax, @@ -114,7 +124,7 @@ def formula(tax_unit, period, parameters): + niit - recomputed_eitc - recomputed_refundable_ctc - - refundable_american_opportunity_credit, + - other_payment_credits, 0, ) diff --git a/policyengine_us/variables/gov/states/al/tax/income/deductions/federal_income_tax/al_other_federal_payment_credits.py b/policyengine_us/variables/gov/states/al/tax/income/deductions/federal_income_tax/al_other_federal_payment_credits.py new file mode 100644 index 00000000000..4ebfaae2b77 --- /dev/null +++ b/policyengine_us/variables/gov/states/al/tax/income/deductions/federal_income_tax/al_other_federal_payment_credits.py @@ -0,0 +1,22 @@ +from policyengine_us.model_api import * + + +class al_other_federal_payment_credits(Variable): + value_type = float + entity = TaxUnit + label = "Other federal payment credits reducing Alabama's federal tax deduction" + unit = USD + definition_period = YEAR + default_value = 0 + defined_for = StateCode.AL + documentation = ( + "Actual federal payment credits not already included by the named " + "Alabama federal-tax-deduction credit variables. Excludes withholding, " + "estimated tax payments, extension payments, and amounts excluded by " + "Act 2021-1, section 2(b), including recovery rebate credits." + ) + reference = ( + "https://www.revenue.alabama.gov/wp-content/uploads/2021/12/810-3-15-.20.pdf#page=2", + # Act 2021-1 (HB 170), section 2(b). + "https://alison.legislature.state.al.us/files/pdf/SearchableInstruments/2021RS/PrintFiles/HB170-Enr.pdf#page=3", + ) diff --git a/policyengine_us/variables/gov/states/az/tax/income/deductions/itemized/az_itemized_deductions.py b/policyengine_us/variables/gov/states/az/tax/income/deductions/itemized/az_itemized_deductions.py index 30916228f82..f5d3a3e073f 100644 --- a/policyengine_us/variables/gov/states/az/tax/income/deductions/itemized/az_itemized_deductions.py +++ b/policyengine_us/variables/gov/states/az/tax/income/deductions/itemized/az_itemized_deductions.py @@ -12,6 +12,8 @@ class az_itemized_deductions(Variable): reference = ( "https://law.justia.com/codes/arizona/2022/title-43/section-43-1042/", "https://www.azleg.gov/ars/43/01042.htm", + "https://www.azleg.gov/ars/43/01021.htm", + "https://www.azleg.gov/ars/43/01029.htm", "https://azdor.gov/forms/individual/itemized-deduction-adjustments-form", "https://azdor.gov/forms/individual/form-140-resident-personal-income-tax-form-calculating", ) @@ -23,6 +25,12 @@ def formula(tax_unit, period, parameters): az_itemized = parameters(period).gov.states.az.tax.income.deductions.itemized # Medical and charitable are handled separately below; the state and # local tax deduction is also handled separately so Arizona can cap it. + # Arizona adds the federal claim of right repayment deduction back to + # Arizona gross income (A.R.S. 43-1021(9)) and computes its tax + # without it (A.R.S. 43-1029), so it gives no net Arizona deduction. + # Leaving it out here gives the same taxable income for an Arizona + # itemizer, but Arizona AGI is not raised by the addition, and the + # Arizona claim of right credit is not modeled. deductions = [ deduction for deduction in p.itemized_deductions @@ -31,6 +39,7 @@ def formula(tax_unit, period, parameters): "medical_expense_deduction", "charitable_deduction", "salt_deduction", + "claim_of_right_deduction", ] ] federal_deductions = add(tax_unit, period, deductions) diff --git a/policyengine_us/variables/gov/states/ca/tax/income/deductions/itemized/ca_itemized_deductions_pre_limitation.py b/policyengine_us/variables/gov/states/ca/tax/income/deductions/itemized/ca_itemized_deductions_pre_limitation.py index cad0de42a80..9e7a5fc77b5 100644 --- a/policyengine_us/variables/gov/states/ca/tax/income/deductions/itemized/ca_itemized_deductions_pre_limitation.py +++ b/policyengine_us/variables/gov/states/ca/tax/income/deductions/itemized/ca_itemized_deductions_pre_limitation.py @@ -10,6 +10,7 @@ class ca_itemized_deductions_pre_limitation(Variable): reference = ( "https://www.ftb.ca.gov/forms/2021/2021-540-ca-instructions.html", "https://www.ftb.ca.gov/forms/2022/2022-540-ca-instructions.html", + # Schedule CA (540) Part II line 16, claim of right "https://www.ftb.ca.gov/forms/2025/2025-540-ca-instructions.html", "https://www.ftb.ca.gov/about-ftb/data-reports-plans/summary-of-federal-income-tax-changes/index.html", # 2024 Schedule CA (540) instructions, line 15 @@ -23,6 +24,11 @@ def formula(tax_unit, period, parameters): # errors. Schedule CA line 15 replaces the federal casualty loss, # which is limited to declared disasters from 2018, with California's # own. + # Schedule CA Part II line 16, column A, carries the federal claim + # of right deduction by default. Not modeled: California's own credit + # and column B removal (Form 540 line 78, "IRC 1341"), the column C + # deduction when federal tax used the credit, and the bar for income + # California did not tax, including Social Security repayments. federal_components = parameters(period).gov.irs.deductions.itemized_deductions deductions = [ variable diff --git a/policyengine_us/variables/gov/states/ks/tax/income/deductions/ks_itemized_deductions.py b/policyengine_us/variables/gov/states/ks/tax/income/deductions/ks_itemized_deductions.py index fd0b8dee13f..fa987b8ec7c 100644 --- a/policyengine_us/variables/gov/states/ks/tax/income/deductions/ks_itemized_deductions.py +++ b/policyengine_us/variables/gov/states/ks/tax/income/deductions/ks_itemized_deductions.py @@ -10,6 +10,7 @@ class ks_itemized_deductions(Variable): reference = ( "https://www.ksrevenue.gov/pdf/ip21.pdf", "https://www.ksrevenue.gov/pdf/ip22.pdf", + "https://www.ksrevisor.gov/statutes/chapters/ch79/079_032_0120.html", ) defined_for = StateCode.KS @@ -25,4 +26,9 @@ def formula(tax_unit, period, parameters): # compute itemized deduction maximum itm_deds_less_salt = tax_unit("itemized_deductions_less_salt", period) uncapped_property_taxes = add(tax_unit, period, ["real_estate_taxes"]) - return itm_deds_less_salt + uncapped_property_taxes + # K.S.A. 79-32,120(a) limits Kansas itemized deductions to charitable + # contributions, medical care, qualified residence interest and + # property taxes, so the federal claim of right repayment deduction + # is not one of them. + claim_of_right_deduction = tax_unit("claim_of_right_deduction", period) + return itm_deds_less_salt - claim_of_right_deduction + uncapped_property_taxes diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/federal_itemization/mt_itemized_deductions_for_federal_itemization_indiv.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/federal_itemization/mt_itemized_deductions_for_federal_itemization_indiv.py index d946cd9d98e..1c1a049fbba 100644 --- a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/federal_itemization/mt_itemized_deductions_for_federal_itemization_indiv.py +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/federal_itemization/mt_itemized_deductions_for_federal_itemization_indiv.py @@ -48,6 +48,7 @@ def formula(person, period, parameters): period, [ "mt_misc_deductions", + "mt_misc_deductions_subject_to_floor_indiv", "mt_child_dependent_care_expense_deduction", "mt_medical_expense_deduction_indiv", "mt_salt_deduction", diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/federal_itemization/mt_itemized_deductions_for_federal_itemization_joint.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/federal_itemization/mt_itemized_deductions_for_federal_itemization_joint.py index 1ed4e6fd3e0..17125439820 100644 --- a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/federal_itemization/mt_itemized_deductions_for_federal_itemization_joint.py +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/federal_itemization/mt_itemized_deductions_for_federal_itemization_joint.py @@ -48,6 +48,7 @@ def formula(person, period, parameters): period, [ "mt_misc_deductions", + "mt_misc_deductions_subject_to_floor_joint", "mt_child_dependent_care_expense_deduction_joint", "mt_medical_expense_deduction_joint", "mt_salt_deduction", diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_claim_of_right_deduction.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_claim_of_right_deduction.py new file mode 100644 index 00000000000..b36a031cb70 --- /dev/null +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_claim_of_right_deduction.py @@ -0,0 +1,37 @@ +from policyengine_us.model_api import * + + +class mt_claim_of_right_deduction(Variable): + value_type = float + entity = Person + label = "Montana claim of right repayment deduction" + unit = USD + documentation = ( + "The person's part of the federal claim of right repayment deduction " + "(Schedule A, line 16), which Montana allows as an itemized " + "deduction: through 2023 on Form 2 itemized deductions line 18, and " + "from 2024 within the federal itemized deductions on Form 2 line 2." + ) + definition_period = YEAR + reference = ( + "https://mca.legmt.gov/bills/mca/title_0150/chapter_0300/part_0210/section_0200/0150-0300-0210-0200.html", + "https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2023_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=39", + # 2024 Form 2 instructions, line 2, Worksheet A line 1: "Enter your + # total federal itemized deductions from Form 1040, line 12". + "https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2024_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=15", + ) + defined_for = StateCode.MT + + def formula(person, period, parameters): + deducted = person.tax_unit("claim_of_right_deduction", period) + head_or_spouse = person("is_tax_unit_head_or_spouse", period) + repayment = max_(0, person("claim_of_right_repayment", period)) * head_or_spouse + # Historical small-class repayments belong only in the floor-subject + # pool, even when the federal aggregate model combines distinct classes. + small_repayment = person("mt_misc_claim_of_right_repayment", period) + nonfloor_repayment = max_(0, repayment - small_repayment) + total = person.tax_unit.sum(nonfloor_repayment) + # Allocate the allowed federal amount to its head/spouse payers once, + # without exceeding their eligible nonfloor repayments. + share = nonfloor_repayment / where(total > 0, total, 1) + return min_(deducted, total) * share diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_claim_of_right_repayment_income_class.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_claim_of_right_repayment_income_class.py new file mode 100644 index 00000000000..6d1d4ee0af6 --- /dev/null +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_claim_of_right_repayment_income_class.py @@ -0,0 +1,21 @@ +from policyengine_us.model_api import * + + +class mt_claim_of_right_repayment_income_class(Variable): + value_type = int + entity = Person + label = "Income class of the Montana claim of right repayment" + documentation = ( + "User-assigned class identifier for the person's claim of right " + "repayment. Use the same identifier for head and spouse repayments " + "of the same federal income class, and different identifiers for " + "different classes. The default represents one common income class. " + "Each person's repayment input represents the aggregate for that class. " + "Used only to classify the historical Montana miscellaneous deduction; " + "the federal section 1341 calculation retains its aggregate model." + ) + definition_period = YEAR + reference = ( + "https://www.ecfr.gov/current/title-26/section-1.1341-1#p-1.1341-1(a)(3)" + ) + defined_for = StateCode.MT diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_itemized_deductions_indiv.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_itemized_deductions_indiv.py index b690c0195d8..ddbd1ad57e3 100644 --- a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_itemized_deductions_indiv.py +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_itemized_deductions_indiv.py @@ -48,6 +48,7 @@ def formula(person, period, parameters): period, [ "mt_misc_deductions", + "mt_misc_deductions_subject_to_floor_indiv", "mt_child_dependent_care_expense_deduction", "mt_medical_expense_deduction_indiv", "mt_salt_deduction", diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_itemized_deductions_joint.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_itemized_deductions_joint.py index 120ddac9db1..526246e927a 100644 --- a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_itemized_deductions_joint.py +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_itemized_deductions_joint.py @@ -48,6 +48,7 @@ def formula(person, period, parameters): period, [ "mt_misc_deductions", + "mt_misc_deductions_subject_to_floor_joint", "mt_child_dependent_care_expense_deduction_joint", "mt_medical_expense_deduction_joint", "mt_salt_deduction", diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_misc_claim_of_right_repayment.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_misc_claim_of_right_repayment.py new file mode 100644 index 00000000000..0b8aefdbbec --- /dev/null +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_misc_claim_of_right_repayment.py @@ -0,0 +1,34 @@ +from policyengine_us.model_api import * + + +class mt_misc_claim_of_right_repayment(Variable): + value_type = float + entity = Person + label = "Montana claim of right repayment subject to the miscellaneous floor" + unit = USD + definition_period = YEAR + reference = ( + "https://www.ecfr.gov/current/title-26/section-1.1341-1#p-1.1341-1(a)(3)", + "https://web.archive.org/web/20240107204047/https://mtrevenue.gov/wp-content/uploads/2018/02/2017-Form2-with-Legal-References.pdf#page=6", + ) + defined_for = StateCode.MT + + def formula(person, period, parameters): + p = parameters(period).gov.states.mt.tax.income.deductions.itemized + if not p.misc_floor_applies: + return 0 + on_return = person("is_tax_unit_head_or_spouse", period) + repayment = max_(0, person("claim_of_right_repayment", period)) * on_return + income_class = person("mt_claim_of_right_repayment_income_class", period) + head = person("is_tax_unit_head", period) + spouse = person("is_tax_unit_spouse", period) + head_class = person.tax_unit.sum(income_class * head) + spouse_class = person.tax_unit.sum(income_class * spouse) + same_class = head_class == spouse_class + # The $3,000 test applies to each income class on the federal return, + # including both spouses, rather than to individual repayments. + class_total = where(same_class, person.tax_unit.sum(repayment), repayment) + threshold = parameters( + period + ).gov.irs.deductions.itemized.claim_of_right.threshold + return repayment * (class_total <= threshold) diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_misc_deductions_subject_to_floor_indiv.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_misc_deductions_subject_to_floor_indiv.py new file mode 100644 index 00000000000..4aff660675e --- /dev/null +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_misc_deductions_subject_to_floor_indiv.py @@ -0,0 +1,28 @@ +from policyengine_us.model_api import * + + +class mt_misc_deductions_subject_to_floor_indiv(Variable): + value_type = float + entity = Person + label = "Montana miscellaneous deductions after the separate return AGI floor" + unit = USD + definition_period = YEAR + reference = "https://web.archive.org/web/20240107204047/https://mtrevenue.gov/wp-content/uploads/2018/02/2017-Form2-with-Legal-References.pdf#page=6" + defined_for = "mt_married_filing_separately_on_same_return_eligible" + + def formula(person, period, parameters): + p = parameters(period).gov.states.mt.tax.income.deductions.itemized + if not p.misc_floor_applies: + return 0 + pool = add( + person, + period, + [ + "mt_misc_claim_of_right_repayment", + "unreimbursed_business_employee_expenses", + "tax_preparation_fees", + ], + ) + agi = person("mt_agi_indiv", period) + on_return = person("is_tax_unit_head_or_spouse", period) + return on_return * max_(0, pool - p.misc_floor * agi) diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_misc_deductions_subject_to_floor_joint.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_misc_deductions_subject_to_floor_joint.py new file mode 100644 index 00000000000..eda9797fe89 --- /dev/null +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/general/mt_misc_deductions_subject_to_floor_joint.py @@ -0,0 +1,32 @@ +from policyengine_us.model_api import * + + +class mt_misc_deductions_subject_to_floor_joint(Variable): + value_type = float + entity = TaxUnit + label = "Montana miscellaneous deductions after the joint return AGI floor" + unit = USD + definition_period = YEAR + reference = "https://web.archive.org/web/20240107204047/https://mtrevenue.gov/wp-content/uploads/2018/02/2017-Form2-with-Legal-References.pdf#page=6" + defined_for = StateCode.MT + + def formula(tax_unit, period, parameters): + p = parameters(period).gov.states.mt.tax.income.deductions.itemized + if not p.misc_floor_applies: + return 0 + person = tax_unit.members + on_return = person("is_tax_unit_head_or_spouse", period) + # Use raw expenses: the federal misc_deduction already subtracts a + # floor based on federal AGI, which can differ from Montana AGI. + pool = add( + person, + period, + [ + "mt_misc_claim_of_right_repayment", + "unreimbursed_business_employee_expenses", + "tax_preparation_fees", + ], + ) + expenses = tax_unit.sum(pool * on_return) + agi = tax_unit("mt_agi_joint", period) + return max_(0, expenses - p.misc_floor * agi) diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/mt_federal_deductions.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/mt_federal_deductions.py new file mode 100644 index 00000000000..6b71edc7bbf --- /dev/null +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/mt_federal_deductions.py @@ -0,0 +1,52 @@ +from policyengine_us.model_api import * + + +class mt_federal_deductions(Variable): + value_type = float + entity = TaxUnit + label = "Federal standard or itemized deduction for Montana" + documentation = ( + "For display only: the federal standard or itemized deduction as " + "Montana's return reports it. mt_taxable_income_joint does not read " + "this variable. It computes its own deduction term from " + "taxable_income_deductions, which also keeps the qualified business " + "income deduction (added back) and the Schedule 1-A deductions in the " + "federal base." + ) + unit = USD + definition_period = YEAR + reference = ( + "https://mca.legmt.gov/bills/mca/title_0150/chapter_0300/part_0210/section_0200/0150-0300-0210-0200.html", + "https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2024_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=15", + # PDF pages 5, 13 + "https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2025_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=5", + ) + defined_for = StateCode.MT + + def formula_2024(tax_unit, period, parameters): + itemizes = tax_unit("tax_unit_itemizes", period) + # Use the full allowed federal amount after federal limitations, + # including any claim of right deduction, and the federal election. + # The federal model adds wagering losses separately from its general + # itemized aggregate; they are also part of the allowed itemized amount. + itemized = add( + tax_unit, + period, + ["itemized_taxable_income_deductions", "wagering_losses_deduction"], + ) + standard = tax_unit("standard_deduction", period) + non_itemizer_charity = tax_unit( + "charitable_deduction_for_non_itemizers", period + ) + # This display isolates standard/itemized deductions. The taxable- + # income formula reads the actual federal base, adds QBI back, and + # keeps Schedule 1-A deductions in that base without deducting them twice. + federal_deduction = where(itemizes, itemized, standard + non_itemizer_charity) + # In 2024 Worksheet A reduces the line 2 deduction by the addback. + # From 2025 line 2 takes the federal deduction unreduced, and the + # addback is a Schedule I addition after the line 3 floor. + p = parameters(period).gov.states.mt.tax.income.deductions.itemized + add_back = tax_unit("mt_state_income_tax_itemized_add_back", period) + return max_( + 0, federal_deduction - add_back * p.state_income_tax_add_back_before_floor + ) diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/mt_federal_itemized_personal_property_taxes.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/mt_federal_itemized_personal_property_taxes.py new file mode 100644 index 00000000000..7bf9d6f3c80 --- /dev/null +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/mt_federal_itemized_personal_property_taxes.py @@ -0,0 +1,18 @@ +from policyengine_us.model_api import * + + +class mt_federal_itemized_personal_property_taxes(Variable): + value_type = float + entity = TaxUnit + label = "Personal property taxes included in the federal SALT deduction for Montana" + unit = USD + documentation = ( + "Actual personal property tax component reported on federal Schedule A " + "line 5c, used to isolate the state income tax component of the capped " + "Schedule A line 5e amount. Default zero because the federal model " + "does not separately model personal property taxes. This input does " + "not itself increase the federal SALT deduction." + ) + definition_period = YEAR + reference = "https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2025_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=22" + defined_for = StateCode.MT diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/mt_state_income_tax_itemized_add_back.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/mt_state_income_tax_itemized_add_back.py new file mode 100644 index 00000000000..7a279981547 --- /dev/null +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/mt_state_income_tax_itemized_add_back.py @@ -0,0 +1,43 @@ +from policyengine_us.model_api import * + + +class mt_state_income_tax_itemized_add_back(Variable): + value_type = float + entity = TaxUnit + label = ( + "Montana addback of state income tax deducted in federal itemized deductions" + ) + unit = USD + definition_period = YEAR + reference = ( + "https://mca.legmt.gov/bills/mca/title_0150/chapter_0300/part_0210/section_0200/0150-0300-0210-0200.html", + "https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2024_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=15", + "https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2025_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=22", + ) + defined_for = StateCode.MT + + def formula_2024(tax_unit, period, parameters): + itemizes = tax_unit("tax_unit_itemizes", period) + # The federal model adds wagering losses separately from its general + # itemized aggregate; they are also part of the allowed itemized amount. + itemized = add( + tax_unit, + period, + ["itemized_taxable_income_deductions", "wagering_losses_deduction"], + ) + standard = tax_unit("standard_deduction", period) + salt = tax_unit("salt_deduction", period) + state_income_tax = add(tax_unit, period, ["state_withheld_income_tax"]) + local_income_tax = add(tax_unit, period, ["local_income_tax"]) + sales_tax = add(tax_unit, period, ["state_sales_tax", "local_sales_tax"]) + income_tax_deducted = state_income_tax + local_income_tax >= sales_tax + other_taxes = local_income_tax + add( + tax_unit, + period, + ["real_estate_taxes", "mt_federal_itemized_personal_property_taxes"], + ) + # Worksheet B isolates state income tax after the federal SALT cap. + # Business-level state tax additions are separate from this ceiling. + deducted_state_income_tax = min_(state_income_tax, max_(0, salt - other_taxes)) + ceiling = max_(0, itemized - standard) + return itemizes * income_tax_deducted * min_(deducted_state_income_tax, ceiling) diff --git a/policyengine_us/variables/gov/states/mt/tax/income/tax_calculation/mt_taxable_income_joint.py b/policyengine_us/variables/gov/states/mt/tax/income/tax_calculation/mt_taxable_income_joint.py index 11cc56bc887..e8093542f6f 100644 --- a/policyengine_us/variables/gov/states/mt/tax/income/tax_calculation/mt_taxable_income_joint.py +++ b/policyengine_us/variables/gov/states/mt/tax/income/tax_calculation/mt_taxable_income_joint.py @@ -11,6 +11,13 @@ class mt_taxable_income_joint(Variable): reference = ( "https://revenuefiles.mt.gov/files/Forms/Montana-Individual-Income-Tax-Return-Form-2/2022_Montana_Individual_Income_Tax_Return_Form_2.pdf#page=1", "https://revenuefiles.mt.gov/files/Forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2022_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=16", + # MCA 15-30-2120(1), (2)(i)-(j): federal taxable income base and addbacks. + "https://mca.legmt.gov/bills/mca/title_0150/chapter_0300/part_0210/section_0200/0150-0300-0210-0200.html", + "https://mca.legmt.gov/bills/mca/title_0150/chapter_0300/part_0210/section_0010/0150-0300-0210-0010.html", + "https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2024_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=15", + # PDF pages 5, 13, 22 + "https://revenue.mt.gov/files/forms/Montana-Individual-Income-Tax-Return-Form-2-Instructions/2025_Montana_Individual_Income_Tax_Return_Form_2_Instructions.pdf#page=5", + "https://revenuefiles.mt.gov/files/Forms/Montana-Individual-Income-Tax-Return-Form-2/2025_Montana_Individual_Income_Tax_Return_Form_2.pdf#page=1", ) def formula(person, period, parameters): @@ -36,3 +43,41 @@ def formula(person, period, parameters): ) return is_head * max_(0, total_agi - deductions - exemptions) + + def formula_2024(person, period, parameters): + # MCA 15-30-2101(7) incorporates the subtraction-based IRC 63 base. + # In 2024, Worksheet A adjusts the deduction before Form 2 line 3's + # zero floor, so deductions exceeding AGI can absorb the + # state-income-tax addback. From 2025 the addback is a Schedule I + # addition after the floor (2026 follows the 2025 form by convention). + tax_unit = person.tax_unit + federal_base = ( + tax_unit("adjusted_gross_income", period) + - tax_unit("exemptions", period) + - tax_unit("taxable_income_deductions", period) + ) + qbi_add_back = tax_unit("qualified_business_income_deduction", period) + state_tax_add_back = tax_unit("mt_state_income_tax_itemized_add_back", period) + before_floor = parameters( + period + ).gov.states.mt.tax.income.deductions.itemized.state_income_tax_add_back_before_floor + federal_base = max_( + 0, federal_base + qbi_add_back + state_tax_add_back * before_floor + ) + # Form 2 applies Montana additions and subtractions after line 3. + on_return = person("is_tax_unit_head_or_spouse", period) + additions = tax_unit.sum(person("mt_additions", period) * on_return) + additions = additions + state_tax_add_back * (not before_floor) + subtractions = tax_unit.sum(person("mt_subtractions", period) * on_return) + p = parameters(period).gov.states.mt.tax.income.subtractions + if "mt_federal_obbba_subtraction" in p.subtractions: + # Schedule 1-A deductions are already in federal taxable income. + # The legacy AGI-based subtraction must not deduct them again. + subtractions = subtractions - tax_unit.sum( + person("mt_federal_obbba_subtraction", period) * on_return + ) + is_head = person("is_tax_unit_head", period) + return is_head * max_( + 0, + federal_base + additions - subtractions, + ) diff --git a/policyengine_us/variables/gov/states/nc/tax/income/credits/claim_of_right/nc_claim_of_right_payment.py b/policyengine_us/variables/gov/states/nc/tax/income/credits/claim_of_right/nc_claim_of_right_payment.py new file mode 100644 index 00000000000..cd275c9378c --- /dev/null +++ b/policyengine_us/variables/gov/states/nc/tax/income/credits/claim_of_right/nc_claim_of_right_payment.py @@ -0,0 +1,37 @@ +from policyengine_us.model_api import * + + +class nc_claim_of_right_payment(Variable): + value_type = float + entity = TaxUnit + label = "North Carolina tax payment for restored claim of right income" + unit = USD + documentation = ( + "A filer whose federal tax is computed under 26 U.S.C. 1341(a)(5) is " + "considered to have paid North Carolina tax equal to the increase in " + "the earlier year's North Carolina tax from including the restored " + "income, minus the decrease in this year's North Carolina tax because " + "the item was deductible. An overpayment it creates is refunded. " + "Modeled for current North Carolina residents only: a filer who " + "paid the earlier North Carolina tax and has since moved away is " + "not covered, because the model computes a state's tax for its " + "residents." + ) + definition_period = YEAR + reference = ( + "https://www.ncleg.gov/EnactedLegislation/Statutes/HTML/BySection/Chapter_105/GS_105-266.2.html", + "https://www.ncleg.gov/EnactedLegislation/SessionLaws/HTML/1997-1998/SL1997-213.html", + ) + defined_for = StateCode.NC + + def formula(tax_unit, period, parameters): + eligible = tax_unit("claim_of_right_section_1341_eligible", period) + credit_applies = tax_unit("claim_of_right_credit_applies", period) + prior_year_tax_increase = tax_unit( + "nc_claim_of_right_prior_year_tax_increase", period + ) + # Term (ii), the decrease in this year's North Carolina tax because + # the item was deductible, is zero: under section 1341(a)(5) the + # repayment is not deducted federally (section 1341(b)(3)), and + # G.S. 105-153.5(a)(2)d allows no North Carolina deduction for it. + return where(eligible & credit_applies, prior_year_tax_increase, 0) diff --git a/policyengine_us/variables/gov/states/nc/tax/income/credits/claim_of_right/nc_claim_of_right_prior_year_tax_increase.py b/policyengine_us/variables/gov/states/nc/tax/income/credits/claim_of_right/nc_claim_of_right_prior_year_tax_increase.py new file mode 100644 index 00000000000..814b4df7615 --- /dev/null +++ b/policyengine_us/variables/gov/states/nc/tax/income/credits/claim_of_right/nc_claim_of_right_prior_year_tax_increase.py @@ -0,0 +1,18 @@ +from policyengine_us.model_api import * + + +class nc_claim_of_right_prior_year_tax_increase(Variable): + value_type = float + entity = TaxUnit + label = "North Carolina prior-year tax increase from restored claim of right income" + unit = USD + documentation = ( + "Amount by which the filers' North Carolina individual income tax " + "(Article 4 of Chapter 105) for the earlier year or years was " + "increased because the income they repaid this year " + "(claim_of_right_repayment) was included in gross income for that " + "year." + ) + definition_period = YEAR + reference = "https://www.ncleg.gov/EnactedLegislation/Statutes/HTML/BySection/Chapter_105/GS_105-266.2.html" + defined_for = StateCode.NC diff --git a/policyengine_us/variables/gov/states/nc/tax/income/deductions/itemized/nc_claim_of_right_deduction.py b/policyengine_us/variables/gov/states/nc/tax/income/deductions/itemized/nc_claim_of_right_deduction.py index dbcbe3397ee..73420914c70 100644 --- a/policyengine_us/variables/gov/states/nc/tax/income/deductions/itemized/nc_claim_of_right_deduction.py +++ b/policyengine_us/variables/gov/states/nc/tax/income/deductions/itemized/nc_claim_of_right_deduction.py @@ -12,10 +12,11 @@ class nc_claim_of_right_deduction(Variable): "2026, only income North Carolina taxed that year. Repayments above " "the threshold are deductible in full. Smaller repayments are reduced " "by two percent of federal adjusted gross income less the filers' " - "other miscellaneous itemized deductions. Not modeled: the bar on the " - "deduction when federal tax for the year of repayment is computed " - "under 26 U.S.C. 1341(a)(5), and from 2026, repayments of amounts North " - "Carolina added to adjusted gross income that federal law excluded." + "other miscellaneous itemized deductions. No deduction is allowed " + "when federal tax for the year of repayment is computed under 26 " + "U.S.C. 1341(a)(5). Not modeled: from 2026, repayments of amounts " + "North Carolina added to adjusted gross income that federal law " + "excluded." ) definition_period = YEAR reference = ( @@ -59,8 +60,14 @@ def formula(tax_unit, period, parameters): other_misc_deductions = 0 remaining_floor = max_(floor - other_misc_deductions, 0) small_repayment_deduction = max_(repayment - remaining_floor, 0) - return where( + deduction = where( repayment > p.claim_of_right.threshold, repayment, small_repayment_deduction, ) + # No deduction when federal tax for the year of repayment is + # computed under section 1341(a)(5); G.S. 105-266.2 instead treats + # the prior-year North Carolina tax on the item as a payment. + eligible = tax_unit("claim_of_right_section_1341_eligible", period) + credit_applies = tax_unit("claim_of_right_credit_applies", period) + return where(eligible & credit_applies, 0, deduction) diff --git a/policyengine_us/variables/gov/states/nc/tax/income/nc_income_tax.py b/policyengine_us/variables/gov/states/nc/tax/income/nc_income_tax.py index 83a4c333d99..f42b325f956 100644 --- a/policyengine_us/variables/gov/states/nc/tax/income/nc_income_tax.py +++ b/policyengine_us/variables/gov/states/nc/tax/income/nc_income_tax.py @@ -8,9 +8,5 @@ class nc_income_tax(Variable): unit = USD definition_period = YEAR defined_for = StateCode.NC - - def formula(tax_unit, period, parameters): - tax_before_credits = tax_unit("nc_income_tax_before_credits", period) - # North Carolina provides no refundable income tax credits - credits = tax_unit("nc_non_refundable_credits", period) - return max_(0, tax_before_credits - credits) + adds = ["nc_income_tax_before_refundable_credits"] + subtracts = ["nc_refundable_credits"] diff --git a/policyengine_us/variables/gov/states/nc/tax/income/nc_income_tax_before_refundable_credits.py b/policyengine_us/variables/gov/states/nc/tax/income/nc_income_tax_before_refundable_credits.py new file mode 100644 index 00000000000..92cabeac3b5 --- /dev/null +++ b/policyengine_us/variables/gov/states/nc/tax/income/nc_income_tax_before_refundable_credits.py @@ -0,0 +1,15 @@ +from policyengine_us.model_api import * + + +class nc_income_tax_before_refundable_credits(Variable): + value_type = float + entity = TaxUnit + label = "North Carolina income tax before refundable credits" + unit = USD + definition_period = YEAR + defined_for = StateCode.NC + + def formula(tax_unit, period, parameters): + tax_before_credits = tax_unit("nc_income_tax_before_credits", period) + credits = tax_unit("nc_non_refundable_credits", period) + return max_(0, tax_before_credits - credits) diff --git a/policyengine_us/variables/gov/states/nc/tax/income/nc_refundable_credits.py b/policyengine_us/variables/gov/states/nc/tax/income/nc_refundable_credits.py new file mode 100644 index 00000000000..8f6815920db --- /dev/null +++ b/policyengine_us/variables/gov/states/nc/tax/income/nc_refundable_credits.py @@ -0,0 +1,11 @@ +from policyengine_us.model_api import * + + +class nc_refundable_credits(Variable): + value_type = float + entity = TaxUnit + label = "North Carolina refundable credits" + unit = USD + definition_period = YEAR + defined_for = StateCode.NC + adds = "gov.states.nc.tax.income.credits.refundable" diff --git a/policyengine_us/variables/gov/states/or/tax/income/subtractions/or_federal_tax_liability_subtraction.py b/policyengine_us/variables/gov/states/or/tax/income/subtractions/or_federal_tax_liability_subtraction.py index 43168c0596f..a6ddc91d824 100644 --- a/policyengine_us/variables/gov/states/or/tax/income/subtractions/or_federal_tax_liability_subtraction.py +++ b/policyengine_us/variables/gov/states/or/tax/income/subtractions/or_federal_tax_liability_subtraction.py @@ -9,7 +9,9 @@ class or_federal_tax_liability_subtraction(Variable): definition_period = YEAR reference = ( "https://www.oregon.gov/dor/forms/FormsPubs/publication-or-17_101-431_2021.pdf#page=71", - "https://www.oregonlegislature.gov/bills_laws/ors/ors316.html", # Subsection 316.800 + "https://www.oregonlegislature.gov/bills_laws/ors/ors316.html", # ORS 316.680 and 316.685 + # ORS 316.680(1)(b) and 316.685(1), PDF pages 52, 54 + "https://www.oregonlegislature.gov/bills_laws/Archive/2023ors316.pdf#page=52", ) defined_for = StateCode.OR @@ -17,6 +19,8 @@ def formula(tax_unit, period, parameters): # calculate Oregon concept of federal income tax federal_itax = tax_unit("income_tax", period) federal_eitc = tax_unit("eitc", period) + # ORS 316.685(1)(b) disregards EITC when computing federal taxes + # accrued. Section 1341 relief continues to reduce those taxes. or_federal_income_tax = max_(0, federal_itax + federal_eitc) # limit subtraction based on caps scaled to federal AGI filing_status = tax_unit("filing_status", period) diff --git a/policyengine_us/variables/gov/states/wi/tax/income/credits/itemized_deduction/wi_itemized_deduction_credit_potential.py b/policyengine_us/variables/gov/states/wi/tax/income/credits/itemized_deduction/wi_itemized_deduction_credit_potential.py index 20d76bf3e70..4673dd7141b 100644 --- a/policyengine_us/variables/gov/states/wi/tax/income/credits/itemized_deduction/wi_itemized_deduction_credit_potential.py +++ b/policyengine_us/variables/gov/states/wi/tax/income/credits/itemized_deduction/wi_itemized_deduction_credit_potential.py @@ -14,6 +14,9 @@ class wi_itemized_deduction_credit_potential(Variable): "https://www.revenue.wi.gov/TaxForms2021/2021-Form1NPR-Inst.pdf#page=34", "https://www.revenue.wi.gov/TaxForms2022/2022-Form1.pdf#page=4", "https://docs.legis.wisconsin.gov/misc/lfb/informational_papers/january_2023/0002_individual_income_tax_informational_paper_2.pdf#page=19", + # Wis. Stat. 71.07(5)(a) + "https://docs.legis.wisconsin.gov/statutes/statutes/71.pdf#page=39", + "https://www.revenue.wi.gov/TaxForms2025/2025-Form1.pdf#page=4", ) defined_for = StateCode.WI @@ -21,6 +24,10 @@ def formula(tax_unit, period, parameters): # Schedule 1 uses actual or hypothetical Schedule A components, # excluding SALT, miscellaneous deductions, and the federal # charitable allowance for non-itemizers. + # Wis. Stat. 71.07(5)(a)6 excludes repayments only when used for the + # separate Wisconsin claim of right credit, which is not modeled. + # Section 1341 deductions are not miscellaneous deductions under + # IRC 67(b)(9), so paragraph 7 does not exclude them either. wi_itmded = add( tax_unit, period, @@ -29,6 +36,7 @@ def formula(tax_unit, period, parameters): "interest_deduction", "wi_itemized_deduction_credit_charitable_deduction", "casualty_loss_deduction", + "claim_of_right_deduction", ], ) # Exclude mortgage insurance premiums included in federal interest. diff --git a/source_conflicts/candidates.yaml b/source_conflicts/candidates.yaml index c9e9ddc6db9..fbd780acf24 100644 --- a/source_conflicts/candidates.yaml +++ b/source_conflicts/candidates.yaml @@ -324,15 +324,17 @@ candidates: net premium tax and section 1341 credits, with a zero floor. other: Subtract only the enumerated refundable credits, omitting net premium tax and section 1341 credits. pe_us: - follows: conflicting-source + follows: statute code: - policyengine_us/parameters/gov/states/al/tax/income/deductions/federal_tax/credits.yaml - policyengine_us/variables/gov/states/al/tax/income/deductions/federal_income_tax/al_federal_income_tax_deduction.py prs: - https://github.com/PolicyEngine/policyengine-us/pull/10038 - state: open - note: A decision was requested; the statute-first rule requires correcting the worksheet-based model where it - conflicts with the statutory reading, after checking each year's list. + state: ruled + note: Under the statute-first rule the code applies the regulation's list, subtracting all federal payment credits + (refundable AOC only, net premium tax credit, section 1341 credit and a residual input), from 2015, the first year + the parameter covers, because the regulation's current text dates from a 2010 amendment. The item starts in 2018, + the first year whose worksheet PolicyEngine compared; worksheets before 2018 were not checked. - id: us-al:irrevocable-trust-loss-deduction program: income-tax years: @@ -5546,15 +5548,16 @@ candidates: statute: Subtract the credit unless it falls within the statutory overpayment-credit exception. other: The chart omits Schedule 3 line 13b, leaving deductible federal tax unchanged. pe_us: - follows: conflicting-source + follows: statute code: - policyengine_us/parameters/gov/states/mo/tax/income/deductions/federal_income_tax/ignored_credits.yaml - policyengine_us/variables/gov/states/mo/tax/income/deductions/mo_federal_income_tax_deduction.py prs: - https://github.com/PolicyEngine/policyengine-us/pull/10038 state: ruled - note: 'Ruled in October 2026 to follow worksheets; the later statute-first rule requires a model change if this - credit is outside the statutory exception. Code not yet on main: mo_federal_income_tax_deduction.' + note: An October 2026 ruling followed the chart; under the later statute-first rule the code follows RSMo + 143.171(2)(1). The section 1341 credit is outside the statutory exceptions and is not added back, so it reduces + the deduction. - id: us-mo:liheap-110-percent-poverty-floor program: liheap years: @@ -8518,8 +8521,8 @@ candidates: remain excluded from the worksheet's reductions? sources: - kind: statute - citation: ORS 316.680(1)(b) - url: https://www.oregonlegislature.gov/bills_laws/ors/ors316.html + citation: ORS 316.680(1)(b) and 316.685(1)(b) + url: https://www.oregonlegislature.gov/bills_laws/Archive/2023ors316.pdf#page=52 - kind: guidance citation: 2025 Publication OR-17, PDF p.71 url: https://www.oregon.gov/dor/forms/FormsPubs/publication-or-17_101-431_2025.pdf#page=71 @@ -8527,18 +8530,19 @@ candidates: citation: 2025 OR-17 federal tax subtraction worksheet, PDF pp.71-72 (also 2017, 2018 and 2021) url: https://www.oregon.gov/dor/forms/FormsPubs/publication-or-17_101-431_2025.pdf#page=71 readings: - statute: The statute refers to federal income taxes accrued; how it treats the section 1341 credit is unresolved. + statute: The subtraction is for federal income taxes accrued, and ORS 316.685(1)(b) disregards only the earned + income credit in computing them, so the section 1341 credit reduces the subtraction. other: The prose says credits except EITC reduce the subtraction, but the worksheet does not subtract the section 1341 credit. pe_us: - follows: unknown + follows: statute code: - policyengine_us/variables/gov/states/or/tax/income/subtractions/or_federal_tax_liability_subtraction.py prs: - https://github.com/PolicyEngine/policyengine-us/pull/10038 state: ruled - note: 'Ruled in October 2026 to follow the worksheet; establish the statutory treatment before determining whether - a model change is required. Code not yet on main: or_federal_tax_liability_subtraction.' + note: An October 2026 ruling followed the worksheet; under the later statute-first rule the code follows ORS + 316.685(1)(b), starting from federal income tax after all credits and adding back only the earned income credit. - id: us-or:liheap-final-payment-band-bound program: liheap years: @@ -11284,14 +11288,15 @@ candidates: repayment exclusion applies when Wisconsin's own credit is used. other: The form includes only medical expenses, interest, charitable gifts and casualty losses. pe_us: - follows: conflicting-source + follows: statute code: - policyengine_us/variables/gov/states/wi/tax/income/credits/itemized_deduction/wi_itemized_deduction_credit_potential.py prs: - https://github.com/PolicyEngine/policyengine-us/pull/10038 state: ruled - note: An October 2026 ruling followed the worksheet; the statute-first rule requires including the repayment deduction - if the statutory reading is confirmed. + note: An October 2026 ruling followed the worksheet; under the later statute-first rule the code includes the + federal claim of right deduction in the credit base with the Schedule 1 components. The separate Wisconsin + repayment credit that would trigger the 71.07(5)(a)6 exclusion is not modeled. - id: us-wi:liheap-categorical-benefit-income program: liheap years: