Skip to content

Apply ordered aggregate capping to state nonrefundable credits#7984

Merged
MaxGhenis merged 11 commits intomainfrom
audit/state-nonrefundable-credit-order
Apr 14, 2026
Merged

Apply ordered aggregate capping to state nonrefundable credits#7984
MaxGhenis merged 11 commits intomainfrom
audit/state-nonrefundable-credit-order

Conversation

@PavelMakarchuk
Copy link
Copy Markdown
Collaborator

@PavelMakarchuk PavelMakarchuk commented Apr 12, 2026

Summary

  • apply ordered capping to state nonrefundable credit aggregates at the tax-application layer
  • add a shared helper for ordered aggregate state nonrefundable credit application
  • align state nonrefundable credit ordering metadata where the current form order was mismatched
  • fix review issues by limiting New York geothermal credit ordering to 2022+ and moving Ohio onto the ordered aggregate path

Scope

This PR does not implement the full federal-style potential and actual/applied nonrefundable credit pattern for each individual state credit.

Instead, it changes how the aggregate nonrefundable credit bucket is applied against pre-credit tax liability in the states covered here. Raw state credit variables remain their underlying potential amounts.

That means this PR is a tax-application-layer cleanup, not the final per-credit redesign.

Follow-up Needed

A follow-up refactor should add federal-style per-credit applied variables so each state nonrefundable credit can expose:

  • a potential amount
  • an actual taken amount capped by pre-credit tax minus earlier credits on the form

That is the step needed to return true form-order credit values.

Testing

  • uv run ruff check policyengine_us/variables/gov/states/tax/income/non_refundable_credit_cap.py policyengine_us/variables/gov/states/ar/tax/income/ar_non_refundable_credits.py policyengine_us/variables/gov/states/az/tax/income/az_non_refundable_credits.py policyengine_us/variables/gov/states/ct/tax/income/ct_non_refundable_credits.py policyengine_us/variables/gov/states/dc/tax/income/credits/dc_non_refundable_credits.py policyengine_us/variables/gov/states/de/tax/income/de_non_refundable_credits.py policyengine_us/variables/gov/states/ga/tax/income/ga_non_refundable_credits.py policyengine_us/variables/gov/states/hi/tax/income/hi_non_refundable_credits.py policyengine_us/variables/gov/states/id/tax/income/id_non_refundable_credits.py policyengine_us/variables/gov/states/ky/tax/income/credits/ky_non_refundable_credits.py policyengine_us/variables/gov/states/la/tax/income/la_non_refundable_credits.py policyengine_us/variables/gov/states/ma/tax/income/ma_non_refundable_credits.py policyengine_us/variables/gov/states/md/tax/income/credits/md_non_refundable_credits.py policyengine_us/variables/gov/states/me/tax/income/me_non_refundable_credits.py policyengine_us/variables/gov/states/mo/tax/income/credits/mo_non_refundable_credits.py policyengine_us/variables/gov/states/ms/tax/income/ms_non_refundable_credits.py policyengine_us/variables/gov/states/nc/tax/income/nc_non_refundable_credits.py policyengine_us/variables/gov/states/ny/tax/income/ny_non_refundable_credits.py policyengine_us/variables/gov/states/oh/tax/income/oh_non_refundable_credits.py policyengine_us/variables/gov/states/ri/tax/income/ri_non_refundable_credits.py policyengine_us/variables/gov/states/sc/tax/income/sc_non_refundable_credits.py policyengine_us/variables/gov/states/ut/tax/income/credits/ut_non_refundable_credits.py policyengine_us/variables/gov/states/va/tax/income/va_non_refundable_credits.py policyengine_us/variables/gov/states/wi/tax/income/credits/wi_non_refundable_credits.py policyengine_us/variables/gov/states/wv/tax/income/wv_non_refundable_credits.py
  • uv run ruff format --check policyengine_us/variables/gov/states/tax/income/non_refundable_credit_cap.py policyengine_us/variables/gov/states/ar/tax/income/ar_non_refundable_credits.py policyengine_us/variables/gov/states/az/tax/income/az_non_refundable_credits.py policyengine_us/variables/gov/states/ct/tax/income/ct_non_refundable_credits.py policyengine_us/variables/gov/states/dc/tax/income/credits/dc_non_refundable_credits.py policyengine_us/variables/gov/states/de/tax/income/de_non_refundable_credits.py policyengine_us/variables/gov/states/ga/tax/income/ga_non_refundable_credits.py policyengine_us/variables/gov/states/hi/tax/income/hi_non_refundable_credits.py policyengine_us/variables/gov/states/id/tax/income/id_non_refundable_credits.py policyengine_us/variables/gov/states/ky/tax/income/credits/ky_non_refundable_credits.py policyengine_us/variables/gov/states/la/tax/income/la_non_refundable_credits.py policyengine_us/variables/gov/states/ma/tax/income/ma_non_refundable_credits.py policyengine_us/variables/gov/states/md/tax/income/credits/md_non_refundable_credits.py policyengine_us/variables/gov/states/me/tax/income/me_non_refundable_credits.py policyengine_us/variables/gov/states/mo/tax/income/credits/mo_non_refundable_credits.py policyengine_us/variables/gov/states/ms/tax/income/ms_non_refundable_credits.py policyengine_us/variables/gov/states/nc/tax/income/nc_non_refundable_credits.py policyengine_us/variables/gov/states/ny/tax/income/ny_non_refundable_credits.py policyengine_us/variables/gov/states/oh/tax/income/oh_non_refundable_credits.py policyengine_us/variables/gov/states/ri/tax/income/ri_non_refundable_credits.py policyengine_us/variables/gov/states/sc/tax/income/sc_non_refundable_credits.py policyengine_us/variables/gov/states/ut/tax/income/credits/ut_non_refundable_credits.py policyengine_us/variables/gov/states/va/tax/income/va_non_refundable_credits.py policyengine_us/variables/gov/states/wi/tax/income/credits/wi_non_refundable_credits.py policyengine_us/variables/gov/states/wv/tax/income/wv_non_refundable_credits.py
  • python policyengine_us/tests/test_batched.py policyengine_us/tests/policy/baseline/gov/states/az/tax/income --batches 1
  • python policyengine_us/tests/test_batched.py policyengine_us/tests/policy/baseline/gov/states/ct/tax/income --batches 1
  • python policyengine_us/tests/test_batched.py policyengine_us/tests/policy/baseline/gov/states/il/tax/income --batches 1
  • python policyengine_us/tests/test_batched.py policyengine_us/tests/policy/baseline/gov/states/ky/tax/income --batches 1
  • python policyengine_us/tests/test_batched.py policyengine_us/tests/policy/baseline/gov/states/ar/tax/income --batches 1
  • python policyengine_us/tests/test_batched.py policyengine_us/tests/policy/baseline/gov/states/ga/tax/income --batches 1
  • python policyengine_us/tests/test_batched.py policyengine_us/tests/policy/baseline/gov/states/md/tax/income --batches 1
  • python policyengine_us/tests/test_batched.py policyengine_us/tests/policy/baseline/gov/states/ny/tax/income --batches 1
  • python policyengine_us/tests/test_batched.py policyengine_us/tests/policy/baseline/gov/states/oh/tax/income --batches 1
  • python policyengine_us/tests/test_batched.py policyengine_us/tests/policy/baseline/gov/states/wi/tax/income --batches 1
  • python policyengine_us/tests/test_batched.py policyengine_us/tests/policy/baseline/gov/states/wv/tax/income --batches 1

@PavelMakarchuk PavelMakarchuk changed the title Cap state nonrefundable credits in filing order Apply ordered aggregate capping to state nonrefundable credits Apr 12, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 96.48562% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.90%. Comparing base (b70c547) to head (85f4621).
⚠️ Report is 46 commits behind head on main.

Files with missing lines Patch % Lines
...size_credit/ky_family_size_tax_credit_potential.py 66.66% 5 Missing ⚠️
...edits/il_k12_education_expense_credit_potential.py 69.23% 4 Missing ⚠️
.../states/ar/tax/income/ar_non_refundable_credits.py 50.00% 2 Missing ⚠️
.../states/az/tax/income/az_non_refundable_credits.py 50.00% 2 Missing ⚠️
.../states/ct/tax/income/ct_non_refundable_credits.py 50.00% 2 Missing ⚠️
...dc/tax/income/credits/dc_non_refundable_credits.py 50.00% 2 Missing ⚠️
.../states/hi/tax/income/hi_non_refundable_credits.py 50.00% 2 Missing ⚠️
.../states/id/tax/income/id_non_refundable_credits.py 50.00% 2 Missing ⚠️
...ky/tax/income/credits/ky_non_refundable_credits.py 50.00% 2 Missing ⚠️
.../states/la/tax/income/la_non_refundable_credits.py 50.00% 2 Missing ⚠️
... and 10 more
Additional details and impacted files
@@             Coverage Diff             @@
##              main    #7984      +/-   ##
===========================================
- Coverage   100.00%   97.90%   -2.10%     
===========================================
  Files            1      148     +147     
  Lines           13     2096    +2083     
  Branches         0        4       +4     
===========================================
+ Hits            13     2052    +2039     
- Misses           0       44      +44     
Flag Coverage Δ
unittests 97.90% <96.48%> (-2.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PavelMakarchuk PavelMakarchuk marked this pull request as ready for review April 13, 2026 22:40
Copy link
Copy Markdown
Contributor

@MaxGhenis MaxGhenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the Maryland refundable CDCC follow-up. The fix now uses the pre-ordering Part B amount for the refundable computation, and the fixture exercises the integrated path from federal CDCC through Maryland tax liability.

@MaxGhenis MaxGhenis merged commit 0d7045b into main Apr 14, 2026
7 checks passed
@MaxGhenis MaxGhenis deleted the audit/state-nonrefundable-credit-order branch April 14, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants