Skip to content

Comments

Fix DC SE loss addition to cap at federally-deducted amount#7437

Open
PavelMakarchuk wants to merge 3 commits intomainfrom
fix/dc-se-loss-addition-cap
Open

Fix DC SE loss addition to cap at federally-deducted amount#7437
PavelMakarchuk wants to merge 3 commits intomainfrom
fix/dc-se-loss-addition-cap

Conversation

@PavelMakarchuk
Copy link
Collaborator

Summary

  • Caps dc_self_employment_loss_addition at the SE loss actually deducted in federal AGI via loss_ald, instead of using the raw self_employment_income
  • When combined with the federal §461(l) excess business loss limitation (which caps deductible losses at $305K single / $610K MFJ in 2024), the old code created absurdly large positive DC AGI on taxpayers with large negative SE income

Example (from policyengine-taxsim#684)

Single filer, DC, self-employment income = -$25,000,000:

Metric Before (bug) After (fix)
Federal AGI -$305,000 -$305,000
DC SE loss addition $24,988,000 $293,000
DC AGI $24,683,000 -$12,000
DC income tax $2,635,878 $0

Root cause

dc_self_employment_loss_addition used raw self_employment_income to compute the addition. But federal AGI (DC's starting point) only contains the §461(l)-capped amount of SE loss. The addition should only add back what was actually subtracted.

Fix

Isolate the SE portion of loss_ald (which also includes capital losses) and cap the DC addition at that amount:

loss_ald = person.tax_unit("loss_ald", period)
limited_capital_loss = person.tax_unit("limited_capital_loss", period)
se_loss_in_ald = max_(0, loss_ald - limited_capital_loss)
effective_loss = min_(loss_taxunit, se_loss_in_ald)

Fixes #7408

Test plan

  • All 5 YAML tests pass (2 existing + 3 new)
  • Case 3: Large SE loss (-$25M) correctly capped at $293K addition (not $24.988M)
  • Case 4: SE loss below federal cap but above DC threshold ($50K → $38K addition)
  • Case 5: SE loss below DC threshold ($10K → $0 addition)
  • Existing tests unchanged (losses below §461(l) cap are unaffected)

🤖 Generated with Claude Code

PavelMakarchuk and others added 3 commits February 19, 2026 14:44
The DC SE loss addition was using raw self_employment_income instead of the
amount actually deducted in federal AGI via loss_ald. When combined with the
federal §461(l) excess business loss limitation, this created absurdly large
positive DC AGI on taxpayers with large negative SE income.

Fixes #7408

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Case 6: Verifies SE isolation from loss_ald when capital losses are present
($305K loss_ald - $3K capital = $302K SE portion, addition = $290K).
Case 7: Boundary test at exactly $12K DC threshold (addition = $0).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@PavelMakarchuk PavelMakarchuk marked this pull request as ready for review February 19, 2026 20:05
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7437   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         1    -3     
  Lines           76        27   -49     
  Branches         1         0    -1     
=========================================
- Hits            76        27   -49     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

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.

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.

DC self-employment loss addition uses raw SE loss instead of federally-deducted amount, causing massive positive DC AGI on negative income

3 participants