Repository navigation
Count Form 4797 gains and losses on Massachusetts Schedule D - #9991
Conversation
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>
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>
# Conflicts: # policyengine_us/variables/gov/states/ma/tax/income/adjusted_gross_income/ma_part_a_agi.py # policyengine_us/variables/gov/states/ma/tax/income/gross_income/ma_part_b_gross_income.py # policyengine_us/variables/gov/states/ma/tax/income/gross_income/ma_part_c_gross_income.py
hua7450
left a comment
There was a problem hiding this comment.
Approving. Read all six files at 7c54f35 against main (which now carries 9954), plus other_net_gain, other_net_gain_gross_income, irs_gross_income with gov/irs/gross_income/sources.yaml, loss_ald and the rest of the MA gross income and AGI chain, against the 2023 Schedule D, Schedule B, the Form 1 instructions (page 27) and c. 62 s. 2(b) and (c).
Schedule D line 7 is "Massachusetts long-term capital gains and losses from U.S. Form 4797, Part II", and the instructions say to enter the Part II amounts "treated as capital gains or losses for Massachusetts purposes"; Part I section 1231 gains already reach Schedule D through line 4 (federal Schedule D line 11). other_net_gain is the model's Form 4797 line 18b / Schedule 1 line 4 amount, so ma_long_term_capital_gains summing it with long_term_capital_gains and the line 6 distributions is the right reading, and the holding-period caveat (property held one year or less belongs on Schedule B lines 12 and 17 at the short-term rate) is a documented limitation with no input to fix it. Part B subtracts other_net_gain_gross_income exactly as irs_gross_income adds it (same filer allocation and floor), so a Form 4797 gain leaves Part B and a loss never reduces it, and the loss ordering through the new variable (long-term gains, then Schedule B line 25, then up to 2,000 of dividends at line 32) matches s. 2(c)(2) and (c)(4).
All six cases recompute from the 2023 forms: base tax 5% x (60,000 - 4,400 - 2,000) = 2,680, then 2,930 / 2,830 / 2,780 (Part C 5,000 / 3,000 / 2,000) and 2,850 (Part A 2,000 at 8.5%); the dividend case gives Part A and Part C of 0 and, on the form, 2,680, which the model reaches once PR 9906 taxes the dividends left after line 32.
CI: three of the four red checks never started ("failed to be acquired (5 attempts)"), and states-shard-3 is the Mississippi HSA test that PR 9992 fixed on main after this branch's merge of main. Nothing is caused by this PR.
Merge interaction with PR 9906 (I re-approved it at bae9b4c): whichever lands second should read tax_unit("ma_long_term_capital_gains", period) in ma_part_a_agi.py, in 9906's new ma_part_c_agi.py and in ma_long_term_loss_against_dividends.py; 9906's expected values do not change. For 9894 / 9939 the dependent exclusion would move into ma_long_term_capital_gains as a tax_unit_non_dep_add formula.
Nits, not blocking:
- The
ma_part_a_agicomment says "(line 13)"; the variable is lines 1 to 7 before the line 12 subtraction. - After 9906 merges, assert the 2,680 in the dividend case so the line 32 path is pinned.
- The
documentationstring could say the practical effect of the holding-period limitation in one clause: short-held business property is taxed at 5% here instead of the Schedule B 8.5%.
Resolve ma_part_a_agi with main's #9906 structure (Schedule B loss order variables), and read Schedule D line 13 from ma_long_term_capital_gains in ma_part_a_agi, ma_part_c_agi and ma_long_term_loss_against_dividends, so Form 4797 Part II amounts reach every line 13 use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged Resolution in The Massachusetts tests pass (690). Since this changes code after your approval, please take another look. |
hua7450
left a comment
There was a problem hiding this comment.
Re-approving at f557b33. Against main the PR is exactly the eight files it should be, and relative to the head I approved the only new code is the conflict resolution onto 9906's structure plus the repointed reads: ma_part_a_agi, ma_part_c_agi and ma_long_term_loss_against_dividends all take Schedule D line 13 from ma_long_term_capital_gains, and a grep of the Massachusetts tree at head finds no remaining two-item or bare long_term_capital_gains read where line 13 is meant, so the Form 4797 amounts reach every use, not only ma_part_c_gross_income. Walked the ordering with a Form 4797 loss under the merged structure (line 20, line 22 / Schedule D line 14, line 25, line 32 with the combined 2,000 cap, line 33, Part C = line 13 minus the remaining short-term loss) against the 2023 Schedules B and D and instructions pages 25 to 28: intact. All six cases in ma_long_term_capital_gains.yaml and all ten in 9906's ma_schedule_b_capital_losses.yaml recompute at head, and cases 3 to 6 each fail on main's reads, so every repointed read is pinned.
CI: 25 of 26 green; the red Contrib (congress) job is "hosted runner lost communication with the server" with the test step never concluded, not this PR.
Nits carried from the first round, still optional: the dividend case now yields the form's 2,680 in the model, so asserting it (and the line 32 intermediates) would pin the path; the "(line 13)" comment in ma_part_a_agi is shorthand for lines 1 to 7; and the documentation string could say the holding-period effect in one clause. Follow-ups for a later PR: ma_part_c_gross_income is now unread after 9954 and 9906, and the dependent exclusion for the new variable belongs with 9894 / 9939.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #9990.
What changes
other_net_gain(Form 4797, line 18b, carried to Schedule 1, line 4) enteredma_gross_incomeonly throughirs_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.ma_long_term_capital_gains: the long-term amount on Massachusetts Schedule D, addinglong_term_capital_gains,non_sch_d_capital_gains(line 6) andother_net_gain(line 7).ma_part_c_gross_incomeandma_part_a_agi(the Schedule D, line 13 amount for Schedule B, line 25) read it instead of their own lists.ma_part_b_gross_incomealso subtractsother_net_gain_gross_income, the positive Form 4797 amount thatirs_gross_incomeadds.part_a_and_c_incomeis nowfiler_dividends_and_gains, and the Part B and Part C variables cite the Schedule D instructions (page 27) inreference.other_net_gainis one tax-unit amount, so gains and losses on business property held one year or less (Schedule B, lines 12 and 17) are also counted as Schedule D, line 7 amounts. Thema_long_term_capital_gainsdocumentation says so. Separating them would need a new input.Tests
New
gross_income/ma_long_term_capital_gains.yaml: one case for the new variable and five 2023 returns, each computed line by line from the 2023 Form 1, Schedule B and Schedule D (single, wages 60,000):¹ The form gives 2,680. This PR gives 2,730 until #9906 (#9905) taxes the dividends left after Schedule B, line 32.
The five returns fail on
main. All 674 tests undergov/states/maand 789 other tests with Massachusetts households orother_net_gainpass. With #9976, and separately with #9908, merged in (both changema_gross_income), all 683 Massachusetts tests pass.Overlap
ma_part_a_agi(one line). Since bae9b4c itsma_part_c_agiandma_long_term_loss_against_dividendsreadlong_term_capital_gainsplusnon_sch_d_capital_gains. Whichever of Apply Massachusetts Schedule B capital losses to dividends before long-term gains #9906 and this PR merges second switches those two reads andma_part_a_agitoma_long_term_capital_gains, so the Form 4797 amounts reach them too. Without that switch, four of this PR's five Form 4797 returns fail; with it, all 684 Massachusetts tests pass on Apply Massachusetts Schedule B capital losses to dividends before long-term gains #9906 plus this PR.ma_part_a_agiandma_part_c_gross_income(one line each). To keep their dependent exclusion,ma_long_term_capital_gainswould sum only the head and spouse (tax_unit_non_dep_add).🤖 Generated with Claude Code