Skip to content

Keep capital gains and losses out of Massachusetts Part B income - #9954

Merged
PavelMakarchuk merged 2 commits into
mainfrom
ma-part-b-capital-loss
Oct 7, 2026
Merged

PavelMakarchuk merged 2 commits into
mainfrom
ma-part-b-capital-loss

Conversation

@PavelMakarchuk

@PavelMakarchuk PavelMakarchuk commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #9953. Fixes #9957.

What changes

Capital gain netting (#9953). ma_part_b_gross_income now subtracts from ma_gross_income the amounts that irs_gross_income added for dividends and capital gains: each head's and spouse's max(0, dividend_income), max(0, capital_gains) and max(0, non_sch_d_capital_gains). Before, it subtracted ma_part_a_gross_income and ma_part_c_gross_income, which net capital losses the Schedule B and D way, so the difference stayed in Part B:

  • A long-term loss against a short-term gain reduced Part B, although ma_part_a_agi already applies it on Schedule B, line 25.
  • One spouse's short-term loss against the other spouse's long-term gain added phantom Part B income.

M.G.L. c. 62 § 2(b) puts all capital gain income in Part A or Part C, and § 2(d)(1)(M) disallows the IRC § 62(a)(3) loss deduction against Part B.

Capital gain distributions (#9957). non_sch_d_capital_gains (Form 1040 line 7 without a federal Schedule D) was in neither Part A nor Part C, so it stayed in Part B. Massachusetts reports it on Schedule D, line 6. ma_part_c_gross_income and ma_part_a_agi (the Schedule D, line 13 amount for line 25) now add it to long_term_capital_gains. The two changes are in one PR because each is wrong without the other: Part B must stop subtracting Part C at the same time as Part C starts to include the distributions.

Tests

gross_income/ma_part_b_gross_income.yaml has eight 2023 returns, each computed line by line from the 2023 Form 1, Schedule B and Schedule D (wages 60,000; single unless noted):

Return Part B gross: main → PR Tax before credits: main → PR
Dividends 1,000, short-term gain 3,000, long-term loss 1,000 59,000 → 60,000 2,850 → 2,900
Short-term gain 3,000, long-term loss 1,000 59,000 → 60,000 2,800 → 2,850
Dividends 1,000, short-term gain 1,000, long-term loss 3,000 59,000 → 60,000 not asserted¹
Joint: long-term gain 5,000; spouse short-term loss 2,000 62,000 → 60,000 2,710 → 2,610
Distributions 5,000 65,000 → 60,000 2,930 → 2,930
Distributions 5,000, short-term loss 2,000 65,000 → 60,000 2,930 → 2,830
Distributions 5,000, long-term loss 3,000 65,000 → 60,000 2,930 → 2,780
Distributions 5,000, short-term gain 3,000, long-term loss 1,000 64,000 → 60,000 3,050 → 3,135

¹ The form gives 2,680. Main gives 2,680 only because this error offsets #9905; this PR alone gives 2,730, and this PR with #9906 gives 2,680.

All eight tests fail on main. The NBER TAXSIM-35 staxbc equals the form in rows 2 and 3. In row 1 it gives 2,815 (PolicyEngine/policyengine-taxsim#1399).

All 661 tests under gov/states/ma and 746 other tests with Massachusetts households pass.

Overlap

🤖 Generated with Claude Code

ma_part_b_gross_income subtracted Part A and Part C gross income from
ma_gross_income. Those net capital losses the Schedule B and D way, but
irs_gross_income adds each filer's net capital gain floored at zero, so
the difference stayed in Part B: a long-term loss against a short-term
gain reduced Part B, and one spouse's short-term loss against the other
spouse's long-term gain added phantom Part B income. Subtract the same
dividend and capital gain amounts irs_gross_income adds instead
(M.G.L. c. 62 s. 2(b), s. 2(d)(1)(M)).

Fixes #9953.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
non_sch_d_capital_gains (Form 1040 line 7 distributions without a
federal Schedule D) entered ma_gross_income through irs_gross_income but
neither Part A nor Part C, so it stayed in Part B. Massachusetts reports
them on Schedule D, line 6: add them to the long-term amount in
ma_part_c_gross_income and ma_part_a_agi, and take them out of
ma_part_b_gross_income.

Fixes #9957.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@hua7450 hua7450 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving. Read the three formulas at 01b1873 and on main, plus ma_gross_income, ma_part_a_gross_income, irs_gross_income with gov/irs/gross_income/sources.yaml, and the capital_gains aggregate, against M.G.L. c. 62 s. 2(b) and the 2023 Form 1 instructions (Schedule D line 6 for capital gain distributions, page 27).

The new Part B formula subtracts exactly what irs_gross_income adds for the filers (each person's dividends, max_(0, capital_gains) and max_(0, non_sch_d_capital_gains), dependents excluded), so Part B is Form 1 line 10 with no capital component in any sign case and a net loss can never reduce it. The main formula subtracted ma_part_a_gross_income + ma_part_c_gross_income, whose unit-level netting differs from the per-person floor: with short-term 3,000 and long-term -1,000, gross income carries 2,000 but main removed 3,000 and understated Part B by 1,000; head gives 60,000 on 60,000 of wages, as the new case expects. Interest is unaffected because ma_part_a_gross_income never held it. Counting capital gain distributions in ma_part_c_gross_income and in the Schedule D line 13 amount inside ma_part_a_agi matches Schedule D line 6, and the three edits are consistent with each other, so the Parts still partition ma_gross_income with nothing dropped or double counted.

All eight new cases recompute by hand at head, and each differs on main. No +=, vectorized, changelog describes both changes.

Merge order with PR 9906: both rewrite ma_part_a_agi.py (textual conflict), and 9906's new ma_part_c_agi and ma_long_term_loss_against_dividends read long_term_capital_gains only. If 9906 lands after this PR without adding non_sch_d_capital_gains to those two reads, distributions drop out of the Part C base and cases 5 to 8 here fail. This PR does not move any value in 9906's tests, so merging this one first and having 9906 pick up the distributions in its rebase is the clean path.

Nits, not blocking:

  1. part_a_and_c_income is a misleading name, since the comment says it is deliberately not Part A plus Part C gross income; filer_dividends_and_gains or similar would read better.
  2. ma_part_b_gross_income and ma_part_c_gross_income could cite the Form 1 instructions page for Schedule D line 6 in their reference.

Pre-existing, for a follow-up: Form 4797 gains (other_net_gain) stay in Part B although Massachusetts routes them to Schedules B and D (instructions pages 25 and 27).

@PavelMakarchuk
PavelMakarchuk merged commit 19c240d into main Oct 7, 2026
35 checks passed
@PavelMakarchuk
PavelMakarchuk deleted the ma-part-b-capital-loss branch October 7, 2026 16:11
PavelMakarchuk added a commit that referenced this pull request Oct 7, 2026
After #9954, Massachusetts Schedule D, line 13 includes capital gain
distributions reported without a federal Schedule D (line 6). Read them
in ma_part_c_agi and ma_long_term_loss_against_dividends too, so
distributions stay in Part C and a long-term loss they cover is not
applied against dividends on Schedule B, line 32.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PavelMakarchuk added a commit that referenced this pull request Oct 8, 2026
…g-term gains (#9906)

* Apply Massachusetts Schedule B capital losses to dividends before long-term gains

Schedule B line 20 applies a short-term loss first against up to $2,000 of
dividends, and line 22 applies only the rest against long-term gains. Part A
then taxes the dividends left (line 33). Part A taxable income used the gross
dividends, and Part C subtracted the full short-term loss.

Fixes #9905

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Apply only the remaining Massachusetts short-term loss to Part C gains

Part C AGI added the short-term loss applied against dividends back to
a Part C gross income that was already floored at zero, so a short-term
loss larger than the long-term gain left too much Part C income.
Schedule B, line 22 and Schedule D, lines 14 and 15 apply only the line
21 remainder against the long-term gain.

Add cases with a long-term gain below the short-term loss, a combined
$2,000 cap, and a 2023 case at the 8.5% rate. Label the new loss
variables as applied against dividends and cite c.62 s.2(c)(2) and (4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Count capital gain distributions in the Schedule B loss order

After #9954, Massachusetts Schedule D, line 13 includes capital gain
distributions reported without a federal Schedule D (line 6). Read them
in ma_part_c_agi and ma_long_term_loss_against_dividends too, so
distributions stay in Part C and a long-term loss they cover is not
applied against dividends on Schedule B, line 32.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
PavelMakarchuk added a commit that referenced this pull request Oct 12, 2026
* Keep capital gains and losses out of Massachusetts Part B income

ma_part_b_gross_income subtracted Part A and Part C gross income from
ma_gross_income. Those net capital losses the Schedule B and D way, but
irs_gross_income adds each filer's net capital gain floored at zero, so
the difference stayed in Part B: a long-term loss against a short-term
gain reduced Part B, and one spouse's short-term loss against the other
spouse's long-term gain added phantom Part B income. Subtract the same
dividend and capital gain amounts irs_gross_income adds instead
(M.G.L. c. 62 s. 2(b), s. 2(d)(1)(M)).

Fixes #9953.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Count capital gain distributions on Massachusetts Schedule D

non_sch_d_capital_gains (Form 1040 line 7 distributions without a
federal Schedule D) entered ma_gross_income through irs_gross_income but
neither Part A nor Part C, so it stayed in Part B. Massachusetts reports
them on Schedule D, line 6: add them to the long-term amount in
ma_part_c_gross_income and ma_part_a_agi, and take them out of
ma_part_b_gross_income.

Fixes #9957.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Count Form 4797 gains and losses on Massachusetts Schedule D

other_net_gain (Form 4797 line 18b, Schedule 1 line 4) entered
ma_gross_income only through irs_gross_income, so a gain stayed in Part
B and a loss was dropped. Massachusetts reports Form 4797, Part II
amounts on Schedule D, line 7. Add ma_long_term_capital_gains for the
long-term Schedule D amount (long-term gains, line 6 distributions and
line 7 Form 4797 amounts), use it in ma_part_c_gross_income and
ma_part_a_agi, and take other_net_gain_gross_income out of
ma_part_b_gross_income.

Also renames part_a_and_c_income to filer_dividends_and_gains and cites
the Schedule D instructions in the Part B and Part C references, from
the #9954 review.

Fixes #9990.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: PavelMakarchuk <pavel@axiom.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants