Repository navigation
Tax Maryland's capital gains surtax on net capital gain as the Internal Revenue Code defines it - #9898
Tax Maryland's capital gains surtax on net capital gain as the Internal Revenue Code defines it#9898MaxGhenis wants to merge 1 commit into
Conversation
Md. Code, Tax-General 10-105(a)(3) taxes an additional 2% of "net capital gain, as defined and determined under the Internal Revenue Code" included in Maryland AGI, less gain from excepted assets; (a)(4) applies it when federal AGI is over $350,000. Technical Bulletin No. 58 gives the IRC 1222(11) definition: net long-term capital gain over net short-term capital loss. The model summed every tax unit member's long- and short-term gains, subtracted the capital loss deduction again, left out capital gain distributions, and tested Maryland AGI against the threshold. - md_net_capital_gain (new, Form 502CG line 1): the head and spouse's max(0, min(Schedule D line 15, line 16)), with distributions reported without Schedule D floored per person. A net short-term gain and qualified dividends are not part of it. - md_capital_gains_surtax_excepted_gain (new input, Form 502CG line 8). - md_capital_gains_surtax: 2% of max(0, line 1 - line 8) (line 9). - md_capital_gains_surtax_applies: federal AGI over the threshold. - Parameter references to the statute, ch. 604 and the 2025 forms. Tests: YAML cases with Schedule D and Form 502CG line comments, including the Technical Bulletin 58 example (line 9 = $168,000); property tests with a differential against the federal net_capital_gain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9898 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 76 58 -18
Branches 2 1 -1
=========================================
- Hits 76 58 -18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
PR Review: Tax Maryland's capital gains surtax on net capital gain as the Internal Revenue Code defines itPR #9898 (author: MaxGhenis, head SummaryThe PR rebuilds Maryland's 2% capital gains surtax (Form 502 line 21b) on the statutory base.
The law and the code agree:
Two documentation-level items need a fix before approval:
Neither changes a result. Critical (must fix)None. Should address1. Two new variable references point to pages that don't show what the title cites.
2. The test file says the deterministic grid "runs without Hypothesis", but without Hypothesis the whole file is skipped.
Suggestions
Verified correct
Axiom line assessmentValid
CI statusAll green: 37/37 checks pass ( Branch status
Verdict: REQUEST_CHANGES |
DTrim99
left a comment
There was a problem hiding this comment.
The surtax base is right: net capital gain under IRC § 1222(11), the treatment of capital gain distributions and qualified dividends, the strict federal AGI threshold, and line 9 (TB-58 gives 3,360) all check out, local tax is untouched, and rulespec-us#1518 is dispatch-ready. Two should items (see the comment above): S1, two reference anchors don't show what their titles cite (booklet line 21b is on #page=22, and the TB-58 example is on p. 3), so use one reference per page and fix the PR body's anchor too; and S2, the invariants file says the grid runs without Hypothesis, but the module-level importorskip skips the whole file, so split the module or correct the comment and the PR body.
What was wrong
Maryland's 2025 capital gains surtax is 2% of "net capital gain, as defined and determined under the Internal Revenue Code" included in Maryland AGI, less gain from excepted assets, for filers with federal AGI over $350,000.
md_capital_gains_surtaxinstead tookmax(short_term_capital_gains + long_term_capital_gains − limited_capital_loss, 0)over every tax unit member, andmd_capital_gains_surtax_appliestested Maryland AGI. That left four defects:capital_losseswas supplied as an input.non_sch_d_capital_gains(Form 1099-DIV box 2a reported without Schedule D) are long-term capital gains under 852(b)(3)(B). Dependents' gains were summed in, as Leave dependents' capital income out of state lines on the filers' return #9894 also finds.Every number below is from running main (
b79705b4bd) and this branch (963ae33e10), TY2025:In every row, federal AGI and Maryland AGI are the same on main and the branch, and
md_income_tax_before_creditsmoves by exactly the change in the surtax.Law and forms
I read each of these this session:
surtax_appliesstays true from 2025.md_income_tax_before_creditsis right.Where the form and the statute differ. Form 502CG line 1 points to Form 502 line 1c, which the instructions (p. 13) fill from "Line 7a of the federal Form 1040". That figure counts a net short-term gain; 1222(11) net capital gain does not. This PR follows the statute and TB-58. The YAML comments give the line 7a figure wherever the two differ. A filer who copies line 1c onto Form 502CG line 1 with a net short-term gain would pay more than the model computes.
What changed
md_net_capital_gain(new; Form 502CG line 1). It ismax(0, min(L15, L16))over the head and spouse, where L15 = Σ(long-term gains + max(0, distributions reported without Schedule D)), Schedule D line 15; and L16 = L15 + Σ short-term gains, line 16. That is the smaller of lines 15 and 16, as on the Schedule D Tax Worksheet's line 7.tax_unit_non_dep_addand a per-person filer mask).irs_gross_income.long_term_capital_gains, so they are not added again (YAML cases for both).md_capital_gains_surtax_excepted_gain(new input, TaxUnit, default 0; Form 502CG line 8). Before, the formula listed the six exceptions as unimplemented comments. The model has no data for them, so microsimulation results don't change. Household users can now enter lines 2–7.md_capital_gains_surtax:surtax_rate × max(0, md_net_capital_gain − excepted gain), which is Form 502CG line 9 times 2% (Form 502 line 21b).md_capital_gains_surtax_applies:adjusted_gross_income > surtax_threshold.Invariants
These hold for every input and are tested in
test_md_capital_gains_surtax_invariants.py:md_net_capital_gain = max(0, min(L15, L16)), with L15 and L16 computed in the test from the inputs.md_net_capital_gain = net_capital_gain − qualified dividends. The federalnet_capital_gainimplements 1222(11) separately, asmax(0, LT + D − max(0, −ST)).md_net_capital_gain ≤ max(0, filer_loss_limited_net_capital_gains): it never exceeds the filers' Form 1040 line 7a gain, so all of it is in federal, and hence Maryland, AGI.md_capital_gains_surtax_applies ⇔ adjusted_gross_income > 350,000. The surtax is then0.02 × max(0, NCG − excepted), and 0 otherwise. It always lies in[0, 0.02 × NCG].md_net_capital_gainnor the surtax.md_net_capital_gainby between 0 and x. With a nonnegative short-term total, a further short-term gain adds 0. Raising the excepted gain never raises the surtax.md_capital_gains_surtaxlowersmd_income_tax_before_creditsby exactly the surtax.Tests
md_capital_gains_surtax.yaml(rewritten with Schedule D and Form 502CG line comments), 7 in the newmd_net_capital_gain.yaml, and 5 in the newmd_capital_gains_surtax_applies.yaml, 34 in all.capital_losses: 80_000next to positive gains, an input that contradicts them. It now states the intended net loss as short-term −55,000, giving 0;importorskipmakes the Hypothesis test skip where Hypothesis isn't installed.test_capital_gain_distributions_loss_limit.pytook 64 s of CPU and 2.0 GB peak under similar load.test_parameter_files.pylocally. All pass. CI runs the full suites.Microsimulation
Running: base
b79705b4bdagainst this branch, 2026 and 2025, on the default dataset, withlockrun.shandcompare.pyunder the shared heavy lock. Results will be added here.Relation to other PRs
md_capital_gains_surtax.pylines totax_unit_non_dep_addand adds the same dependent case, which gives 200 here too. This PR covers that change (dependents are left out of every input), so the two conflict inmd_capital_gains_surtax.pyand its YAML. Whichever lands second takes this PR's version of those two files.filer_schedule_d_lines(the filers' Schedule D lines 15 and 16).md_net_capital_gaincomputes the same two lines. Once Use the filers' Schedule D for the tax on net capital gain #9855 merges,md_net_capital_gaincan read the helper; I can open that follow-up.Not in this PR
axiom: TheAxiomFoundation/rulespec-us#1518 queued for Md. Code, Tax-General § 10-105(a)(3)–(4).
us-md/statutes/gtg/10-105.yamlencodes the 2% rate and the $350,000 federal AGI threshold but defersadditional_capital_gain_tax. The issue is dispatch-ready: verbatim law, required outputs, a pasteablereview_finding, and 11 companion tests from the statute, TB-58 and Form 502CG. It is blocked only because the OpenAI-billed signed re-encode needs approval. The base it imports,us:statutes/26/1222#net_capital_gain(§ 1222(11)), is already encoded; capital gain distributions as long-term gain (852(b)(3)(B)) remain TheAxiomFoundation/rulespec-us#1490, queued.🤖 Generated with Claude Code