The model deducts more than an Alabama filer's medical and miscellaneous expenses when Alabama AGI falls below zero

Đang mở Phù hợp với người mới
#10,916 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
64/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu với al_medical_expense_deduction.py (dòng 22-23) và al_misc_deduction.py (dòng 36-37), nơi các mức 4% và 2% nhân với al_agi mà không có giới hạn dưới. Bọc al_agi trong max_(..., 0) ở cả hai công thức, giống như bản sửa lỗi casualty loss trong #9912. Hoàn thành khi bảng tái hiện cho thấy các khoản khấu trừ y tế và khác đều bằng 0 đối với người nộp thuế A-C, và các bài kiểm tra với AGI âm của Alabama đều đạt cho từng khoản khấu trừ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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 by al_agi and 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 negative al_agi turns each subtraction into an addition.
  • In al_taxable_income, it floors al_agi less al_deductions at 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.

Ngôn ngữ chính
Python
Star
171
Fork
220
Merge trung bình
4 ngày 13 giờ
Pull request đã merge (30 ngày)
291

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PolicyEngine/policyengine-us

Tất cả issue của PolicyEngine/policyengine-us

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.