Skip to content

Fix MT v32 (State AGI) returning $0 in TAXSIM output#901

Merged
PavelMakarchuk merged 1 commit into
mainfrom
fix-mt-v32-mapping
May 14, 2026
Merged

Fix MT v32 (State AGI) returning $0 in TAXSIM output#901
PavelMakarchuk merged 1 commit into
mainfrom
fix-mt-v32-mapping

Conversation

@PavelMakarchuk
Copy link
Copy Markdown
Collaborator

Summary

For Montana filers, the v32 (State AGI) output of the TAXSIM emulator returned $0 regardless of filing status, even though MT tax was computed correctly. Root cause: the taxsim_v32_state_agi adapter reads PE-US's unified state_agitaxsim_state_agi → sums gov.states.household.state_agis, which for MT lists mt_agi_indiv — a person-level variable defined_for = "mt_married_filing_separately_on_same_return_eligible" that returns 0 for joint, single, and HoH filers.

The MT tax computation itself runs off mt_agi_joint (tax-unit level) and is unaffected — only the displayed v32 was wrong, which made TAXSIM output look like PE skipped MT AGI.

Fix

Add "taxsim_v32_state_agi": {"MT": ["mt_agi_joint"]} to OUTPUT_ADAPTER_OVERRIDES so MT routes through mt_agi_joint, the tax-unit-level MT AGI that applies to all filing statuses except MFS-on-same-return (which is rare in TAXSIM inputs). Also align the per-state fallback in variable_mappings.yaml (mt_agimt_agi_joint) for consistency.

Test plan

  • New parametrized cases in tests/test_state_output_adapters.py:
    • MT single filer ($80K pwages) — v32 was $0, now $80,000 (federal AGI = MT AGI when no MT-specific subtractions).
    • End-to-end check on issue 862 inputs (MT joint, $129K pwages + $20K spouse, $30K proptax + $20K mortgage): v32 was $0, now $150,481.69.
  • Full tests/test_state_output_adapters.py and tests/test_mappers.py pass (47 tests).

Reported in

policyengine-taxsim#862

🤖 Generated with Claude Code

The taxsim_v32_state_agi adapter reads PE-US's unified state_agi
variable, which sums gov.states.household.state_agis. That list points
to mt_agi_indiv (Person, defined_for mt_married_filing_separately_on_same_return_eligible)
— for joint, single, and HoH MT filers this returns 0, even though MT
tax is computed correctly off mt_agi_joint.

Route MT through an override in OUTPUT_ADAPTER_OVERRIDES so v32 reads
mt_agi_joint (the tax-unit-level MT AGI that applies to all filing
statuses except MFS-on-same-return). Also update variable_mappings.yaml
for consistency with the override path.

Reported in #862.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-taxsim Ready Ready Preview, Comment May 13, 2026 11:48pm

Request Review

@PavelMakarchuk PavelMakarchuk merged commit 3262ec4 into main May 14, 2026
12 checks passed
@PavelMakarchuk PavelMakarchuk deleted the fix-mt-v32-mapping branch May 14, 2026 00:13
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.

1 participant