The model deducts more than an Alabama filer's medical and miscellaneous expenses when Alabama AGI falls below zero
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 64/100
Research direction
Start with al_medical_expense_deduction.py (lines 22-23) and al_misc_deduction.py (lines 36-37), where the 4% and 2% rates multiply al_agi without a floor. Wrap al_agi in max_(..., 0) in both formulas, as the casualty loss fix in #9912 does. Done when the reproduction table shows medical and misc deductions of 0 for filers A-C, and tests at negative Alabama AGI pass for each deduction.
Written by the indexing model from the issue text.
Description
When a tax unit's Alabama adjusted gross income (AGI) falls below zero, the model adds 4% of the loss to the Alabama medical expense deduction and 2% of the loss to the miscellaneous deduction. For example, a single filer who reports a $10,000 business loss as their only 2025 income, and who has no expenses, gets a $400 medical deduction and a $200 miscellaneous deduction. With $1,000 of medical expenses and $500 of unreimbursed employee expenses, the same filer gets $1,400 and $700.
Alabama income tax does not change, since the model floors Alabama taxable income at zero and these filers already start below zero. The extra amounts show up in al_medical_expense_deduction, al_misc_deduction, al_itemized_deductions and state_itemized_deductions. They reach al_deductions whenever the itemized total, with them, exceeds the standard deduction. For example, the model gives the second filer $3,100 of itemized deductions, $1,000 of it from a casualty loss deduction it builds the same way. Without the extra $600, the total falls to $2,500, under the $3,000 standard deduction.
What Alabama allows
The Legislature limits the medical and dental expense deduction to "the excess of those expenses over 4.0 percent of adjusted gross income" (Ala. Code § 40-18-15(a)(13), reprinted on PDF pages 5 and 6 of HB527 of 2026, as enrolled). In Rule 810-3-15-.16, the Department of Revenue allows the deduction "for expenses paid during the taxable year". In its 2025 Form 40 instructions, the Department tells filers to deduct only the part of their medical and dental expenses above 4% of Form 40 line 10.
The Legislature groups unreimbursed employee business expenses with the section 212 deduction for the costs of producing income and of figuring a tax. It allows them "only to the extent that the aggregate of the deductions exceeds 2 percent of adjusted gross income" (§ 40-18-15(a)(23), PDF pages 7 and 8).
We read both provisions to cap each deduction at the expenses, so a filer with negative AGI deducts those expenses in full and no more. For the medical deduction, the Legislature allows the expenses "as determined in accordance with 26 U.S.C. § 213", with 4% in place of 7.5%. In section 213(a), Congress allows the expenses paid "to the extent that such expenses exceed" a share of AGI. For the miscellaneous deduction, the Legislature allows the expenses themselves "only to the extent" that their total exceeds 2% of AGI.
On Schedule A, the Department has filers multiply Form 40 line 10 by 4% and by 2% and subtract each product from the expenses. A filer who follows those steps with a negative line 10 gets the model's figures. The Department does not say, on the form or in its instructions, how to fill in lines 3 and 23 when line 10 falls below zero.
Where the model does this
- In
al_medical_expense_deduction, the model multiplies the 4% rate byal_agiand subtracts the product from the expenses. - In
al_misc_deduction, it does the same with the 2% rate. - In
al_agi, it returns gross income less deductions with no lower bound, so a negativeal_agiturns each subtraction into an addition. - In
al_taxable_income, it floorsal_agilessal_deductionsat zero, which keeps the tax at 0.
For the federal medical_expense_deduction and misc_deduction, the model multiplies the rates by AGI floored at zero, positive_agi. In al_casualty_loss_deduction, the model subtracts 10% of al_agi the same way and gives the first filer $1,000; in the open pull request #9912, we floor al_agi at zero there.
Reproduction
At main (f9266153215817169964d8a31ec6d2464d8c2b45):
from policyengine_us import Simulation
YEAR = 2025
def single_alabama_filer(person=None, tax_unit=None):
return {
"people": {"filer": {"age": {YEAR: 40}, **(person or {})}},
"tax_units": {"tax_unit": {"members": ["filer"], **(tax_unit or {})}},
"households": {
"household": {"members": ["filer"], "state_code": {YEAR: "AL"}}
},
}
CASES = {
"A": single_alabama_filer({"self_employment_income": {YEAR: -10_000}}),
"B": single_alabama_filer(
{
"self_employment_income": {YEAR: -10_000},
"other_medical_expenses": {YEAR: 1_000},
"unreimbursed_business_employee_expenses": {YEAR: 500},
}
),
"C": single_alabama_filer({"self_employment_income": {YEAR: -100_000}}),
"D": single_alabama_filer(
{
"employment_income": {YEAR: 50_000},
"other_medical_expenses": {YEAR: 3_000},
"unreimbursed_business_employee_expenses": {YEAR: 1_500},
}
),
}
VARIABLES = [
"al_agi",
"al_medical_expense_deduction",
"al_misc_deduction",
"al_casualty_loss_deduction",
"al_itemized_deductions",
"al_standard_deduction",
"al_deductions",
"al_taxable_income",
"al_income_tax",
]
sims = {name: Simulation(situation=situation) for name, situation in CASES.items()}
print(f"{'':30s}" + "".join(f"{name:>10s}" for name in CASES))
for variable in VARIABLES:
values = [float(sim.calculate(variable, YEAR)[0]) for sim in sims.values()]
print(f"{variable:30s}" + "".join(f"{value:>10,.0f}" for value in values))
A B C D
al_agi -10,000 -10,000 -100,000 50,000
al_medical_expense_deduction 400 1,400 4,000 1,000
al_misc_deduction 200 700 2,000 500
al_casualty_loss_deduction 1,000 1,000 10,000 0
al_itemized_deductions 1,600 3,100 16,000 5,325
al_standard_deduction 3,000 3,000 3,000 2,500
al_deductions 4,500 4,600 17,500 10,696
al_taxable_income 0 0 0 39,304
al_income_tax 0 0 0 1,925
Filer A has a $10,000 business loss and no expenses. Filer B has the same loss, $1,000 of medical expenses and $500 of unreimbursed employee expenses. Filer C has a $100,000 loss and no expenses. Filer D earns $50,000 in wages, has $3,000 of medical expenses and $1,500 of employee expenses, and deducts $1,000 and $500 after the 4% and 2% floors.
Fix
Floor al_agi at zero in both formulas with max_(tax_unit("al_agi", period), 0), as we do for the casualty loss deduction in #9912, and add a test at negative Alabama AGI for each deduction.
- Dominant language
- Python
- Stars
- 171
- Forks
- 220
- Avg merge
- 4d 13h
- Merged PRs (30d)
- 291
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PolicyEngine/policyengine-us
-
PolicyEngine backdates South Carolina’s EITC into 2015–2017Possibly taken @MaxGhenis claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PolicyEngine/policyengine-us#10944 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
PolicyEngine/policyengine-us#10915 ·
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
PolicyEngine/policyengine-us#10911 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
PolicyEngine/policyengine-us#10894 ·
Maintainers usually reply within 2 days
-
The model denies Medicaid to expansion-group adults in Virginia, Maine, Idaho and Utah in 2019 or 2020, when those states covered themPossibly taken @MaxGhenis claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
PolicyEngine/policyengine-us#10791 ·
Maintainers usually reply within 2 days
All issues in PolicyEngine/policyengine-us
Similar issues
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
JheysonJhordyHuarauyaRiquelme/sprocguard#18 ·
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
dlq/synthpopcan#59 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mdn/translated-content#40220 ·
Maintainers usually reply within 4 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
ETSInitiative/PETSIRD#243 ·
Maintainers usually reply within 1 day
-
deferred p2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
cuadrao-ai/argus#2160 ·
Maintainers usually reply within 1 day