Skip to content

Conversation

@MaxGhenis
Copy link
Contributor

Closes #7017

Summary

NJ gross income now correctly applies the 'same category rule' per N.J.S. 54A:5-1 - net losses in any income category are disregarded (capped at $0) before summing. Previously, negative values from capital losses, S-corp losses, etc. would incorrectly reduce NJ gross income.

Changes

  • Modified nj_gross_income to calculate each NJ income category separately
  • Applied max_(0, category_total) to categories that can have losses:
    • Category (b): Business income (self-employment + farm)
    • Category (c): Capital gains (short-term + long-term)
    • Category (d): Rental income
    • Categories (k)/(p): Partnership and S-corp income
  • Added 5 test cases for the same category rule

Example

Input (from issue):

  • Wages: $136,639
  • Dividends: $1,661
  • Interest: $343
  • Capital losses: -$240,126
  • S-corp losses: -$29,134

Before (incorrect): NJ gross income = -$133,628 (losses subtracted)
After (correct): NJ gross income = $138,643 (losses disregarded per same category rule)

Test plan

  • All 5 new NJ same category rule tests pass
  • All 208 existing NJ tests pass
  • make format applied

References


Generated with Claude Code

NJ gross income now correctly applies the 'same category rule' per N.J.S. 54A:5-1 - net losses in any income category are disregarded (capped at $0) before summing.

Changes:
- Modified nj_gross_income to calculate each NJ income category separately
- Applied max_(0, category_total) to categories that can have losses:
  - Category (b): Business income (self-employment + farm)
  - Category (c): Capital gains (short-term + long-term)
  - Category (d): Rental income
  - Categories (k)/(p): Partnership and S-corp income
- Added test cases for the same category rule

Closes #7017

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 (4226fa5) to head (b397630).
⚠️ Report is 1152 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7296   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines            9        22   +13     
=========================================
+ Hits             9        22   +13     
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.

MaxGhenis and others added 2 commits January 31, 2026 08:04
The CI uses Black 26.1.0 which has different f-string formatting
preferences than Black 25.11.0 used locally.

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

PR Review: NJ Same Category Rule

✅ APPROVED

This PR correctly implements New Jersey's "same category rule" per N.J.S.A. 54A:5-1.


Verification Summary

Legal Basis Confirmed

Per NJ Division of Taxation: "Losses which occur within one category of gross income may be applied against other sources of gross income within the same category... However, a net loss in one category of gross income may not be applied against gross income in another category."

Categories with max_(0, ...) Applied (Can Have Losses)

Category Implementation Correct
(b) Business self_employment_income + farm_income
(c) Capital Gains short_term + long_term
(d) Rental rental_income
(k)/(p) Partnership/S-corp partnership_s_corp_income

Categories Without Capping (Always Positive or Handled Elsewhere)

Category Implementation Notes
(a) Wages employment_income Always positive ✅
(e) Interest taxable_interest_income Always positive ✅
(f) Dividends dividend_income Always positive ✅
(g) Gambling gambling_winnings Net winnings ✅
(j) Pensions/IRA taxable_pension_income + taxable_ira_distributions Always positive ✅
(n) Alimony alimony_income Always positive ✅

Test Calculations Verified

Test 1 (from issue #7017):

  • Wages: $136,639.06
  • Interest: $171.53 × 2 = $343.06
  • Dividends: $830.69 × 2 = $1,661.38
  • Capital losses: -$240,125.70 → $0 (disregarded) ✅
  • S-corp losses: -$29,133.92 → $0 (disregarded) ✅
  • Before fix: -$133,628 (incorrect - losses subtracted)
  • After fix: $138,643.44 (correct per same category rule)

All Income Sources Preserved

The formula includes all 12 income sources from the original gross_income_sources parameter:

  • ✅ employment_income, taxable_interest_income, dividend_income
  • ✅ self_employment_income, farm_income
  • ✅ long_term_capital_gains, short_term_capital_gains
  • ✅ taxable_pension_income, taxable_ira_distributions
  • ✅ partnership_s_corp_income, rental_income
  • ✅ gambling_winnings, alimony_income, miscellaneous_income

Validation Checklist

Check Result
Same category rule per N.J.S.A. 54A:5-1 ✅ Correct
max_(0, ...) on loss-possible categories ✅ Applied
All income sources included ✅ Complete
Test coverage ✅ 5 scenarios
CI passing ✅ All green
Changelog entry ✅ Present

Minor Note

The parameter file gross_income_sources.yaml is no longer used by the variable but remains as useful documentation of NJ income categories. This is acceptable.

Recommendation: Ready to merge.

@PavelMakarchuk PavelMakarchuk merged commit e902c05 into main Feb 2, 2026
9 checks passed
@PavelMakarchuk PavelMakarchuk deleted the nj-same-category branch February 2, 2026 01:03
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.

NJ gross income incorrectly includes net losses from income categories; missing 'same category rule'

3 participants