Skip to content

Conversation

@MaxGhenis
Copy link
Contributor

Closes #6964

Summary

  • Mississippi income tax now correctly uses loss-limited capital gains (federal $3K limit) instead of unlimited raw capital gains
  • Created new loss_limited_capital_gains Person-level variable that allocates the TaxUnit's loss-limited capital gains proportionally to each person
  • Updated MS income_sources.yaml to use loss_limited_capital_gains instead of capital_gains

Changes

  1. New variable: policyengine_us/variables/household/income/person/capital_gains/loss_limited_capital_gains.py

    • Person-level variable that applies the federal $3K capital loss limit
    • For net gains (positive), returns person's raw capital gains unchanged
    • For net losses, allocates the loss-limited amount proportionally based on each person's share of raw capital gains
  2. Updated parameter: policyengine_us/parameters/gov/states/ms/tax/income/income_sources.yaml

    • Changed capital_gains to loss_limited_capital_gains

Test

  • Added integration test for MS joint filing with large capital losses (from issue)
  • Added unit tests for loss_limited_capital_gains covering:
    • Positive gains (pass-through unchanged)
    • Single filer with losses (applies $3K limit)
    • Joint filers with losses (proportional allocation)
    • Mixed gains/losses at person level with net gain at tax unit level

Closes #6964

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Jan 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (66ccff2) to head (cab7e67).
⚠️ Report is 439 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##             main     #7294       +/-   ##
============================================
+ Coverage   72.72%   100.00%   +27.27%     
============================================
  Files        3757         1     -3756     
  Lines       54115        17    -54098     
  Branches      267         0      -267     
============================================
- Hits        39353        17    -39336     
+ Misses      14742         0    -14742     
+ Partials       20         0       -20     
Flag Coverage Δ
unittests 100.00% <100.00%> (+27.27%) ⬆️

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.

The where() function evaluates both branches, which causes warnings
when dividing by zero even when the zero case would not be selected.
Using np.divide with the where parameter prevents this.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MaxGhenis
Copy link
Contributor Author

Related: PolicyEngine/policyengine-taxsim#627 (MS capital loss issues originally traced here)

MaxGhenis and others added 3 commits January 31, 2026 11:34
The $3K capital loss limit is an IRS rule, so the variable belongs in
gov/irs/ next to the existing loss_limited_net_capital_gains (tax_unit level).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Follows PE naming convention for person-level variables that correspond
to tax_unit-level variables (like self_employment_tax_ald_person).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Consistent with loss_limited_net_capital_gains (tax_unit level).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

MS income tax incorrectly allows unlimited capital losses to offset income

2 participants