From 609a5645dfde918aef3dca2d984b7e721f10bc8b Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 19 Oct 2026 08:44:51 -0400 Subject: [PATCH 1/7] Use W-2 box 1 wages in the dependent standard deduction worksheet and Medicaid filing test The Form 1040 Standard Deduction Worksheet for Dependents starts earned income from line 1z, and line 1a is W-2 box 1, which leaves out elective deferrals. The model used wages before deferrals, so a claimed dependent with $10,000 of wages, a $6,000 401(k) deferral and $600 of interest got a $10,450 deduction and no filing requirement instead of $4,450 and a required return. Add standard_deduction_worksheet_earned_income, built from the existing gov.irs.income.filing_requirement.dependent.earned_income_sources list (W-2 box 1 wages, Schedule 1 lines 3 and 6) minus Schedule 1 line 15, and use it in the federal, Oregon and Hawaii dependent worksheets. The Medicaid dependent filing test reads the same source list for both its earned income and its unearned income split. Farm income (Schedule 1 line 6), which the worksheet counts, is now earned income in all four. Co-Authored-By: Claude Opus 5.5 --- .../dependent-worksheet-w2-wages.fixed.md | 1 + .../dependent/earned_income_sources.yaml | 25 +-- .../medicaid_person_is_required_to_file.yaml | 71 ++++++++ .../standard/basic_standard_deduction.yaml | 128 ++++++++++++++ ...ard_deduction_worksheet_earned_income.yaml | 159 ++++++++++++++++++ .../tax/income/deductions/hi_deductions.yaml | 65 +++++-- .../standard/or_standard_deduction.yaml | 54 +++++- .../medicaid_person_is_required_to_file.py | 28 +-- .../basic_standard_deduction.py | 10 +- ...ndard_deduction_worksheet_earned_income.py | 38 +++++ .../hi/tax/income/deductions/hi_deductions.py | 10 +- .../deductions/or_standard_deduction.py | 13 +- 12 files changed, 545 insertions(+), 57 deletions(-) create mode 100644 changelog.d/dependent-worksheet-w2-wages.fixed.md create mode 100644 policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income.yaml create mode 100644 policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income.py diff --git a/changelog.d/dependent-worksheet-w2-wages.fixed.md b/changelog.d/dependent-worksheet-w2-wages.fixed.md new file mode 100644 index 00000000000..413163791d9 --- /dev/null +++ b/changelog.d/dependent-worksheet-w2-wages.fixed.md @@ -0,0 +1 @@ +Use Form W-2 box 1 wages, which leave out elective deferrals, and farm income as earned income in the federal, Oregon and Hawaii standard deduction worksheets for dependents and in the Medicaid dependent filing test. diff --git a/policyengine_us/parameters/gov/irs/income/filing_requirement/dependent/earned_income_sources.yaml b/policyengine_us/parameters/gov/irs/income/filing_requirement/dependent/earned_income_sources.yaml index 22410a45918..e57a506d02c 100644 --- a/policyengine_us/parameters/gov/irs/income/filing_requirement/dependent/earned_income_sources.yaml +++ b/policyengine_us/parameters/gov/irs/income/filing_requirement/dependent/earned_income_sources.yaml @@ -1,7 +1,8 @@ -description: The Internal Revenue Service counts these gross income sources as earned income when it tests the unearned income of a filer who can be claimed as a dependent; every other gross income source is unearned income. +description: The Internal Revenue Service counts these gross income sources as earned income of a filer who can be claimed as a dependent, both for the standard deduction worksheet for dependents and for the unearned income filing test; every other gross income source is unearned income. values: 2010-01-01: - # Form 1040 line 1z (wages). + # Form 1040 line 1z (wages). Line 1a is the total of Form(s) W-2, box 1, + # which leaves out elective deferrals. - irs_employment_income # Schedule 1 line 3 (business income, Schedule C). - self_employment_income @@ -11,14 +12,18 @@ values: metadata: unit: list period: year - label: IRS earned income sources for the dependent unearned income filing test + label: IRS earned income sources for filers who can be claimed as dependents reference: - title: 26 U.S. Code § 6012(a)(1)(C)(i)(I) and (f)(2)(D) - income other than earned income href: https://www.law.cornell.edu/uscode/text/26/6012 - # "Generally, your earned income is the total of the amount(s) you - # reported on Form 1040 or 1040-SR, line 1z, and Schedule 1, lines 3, 6, - # 8r, 8t, and 8u minus the amount, if any, on Schedule 1, line 15." - # Schedule 1 line 5 (rents, royalties, partnerships, S corporations and - # trusts) is not on the list. - - title: 2025 Form 1040 instructions, Standard Deduction Worksheet for Dependents - href: https://www.irs.gov/pub/irs-prior/i1040gi--2025.pdf#page=35 + - title: 26 U.S. Code § 63(c)(5) - limitation on basic standard deduction in the case of certain dependents + href: https://www.law.cornell.edu/uscode/text/26/63#c_5 + # Line 1a is the total of Form(s) W-2, box 1 (page 23); an elective + # deferral "isn't included as income in box 1 of your Form W-2" (page + # 25). Worksheet footnote (page 35): "Generally, your earned income is + # the total of the amount(s) you reported on Form 1040 or 1040-SR, line + # 1z, and Schedule 1, lines 3, 6, 8r, 8t, and 8u minus the amount, if + # any, on Schedule 1, line 15." Schedule 1 line 5 (rents, royalties, + # partnerships, S corporations and trusts) is not on the list. + - title: "2025 Form 1040 instructions, line 1a and Standard Deduction Worksheet for Dependents #page 23,25,35" + href: https://www.irs.gov/pub/irs-prior/i1040gi--2025.pdf#page=23 diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.yaml index 94f2f9c5ef7..940309a7e4a 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.yaml @@ -145,3 +145,74 @@ members: [person1] output: medicaid_person_is_required_to_file: true + +- name: Case 9, a dependent's earned income is W-2 box 1 wages, after a 401(k) deferral. + # Form 1040 instructions (2025): line 1a is W-2 box 1, which leaves out + # the $6,000 elective deferral. Earned income is $4,000, so the Pub. 501 + # (2025), Table 2 limit is the larger of $1,350 or $4,000 + $450 = $4,450. + # Gross income, $4,000 of wages and $600 of interest, is more than $4,450, + # so the dependent must file. + period: 2025 + input: + people: + person1: + age: 17 + employment_income: 10_000 + traditional_401k_contributions: 6_000 + taxable_interest_income: 600 + tax_units: + tax_unit: + members: [person1] + output: + medicaid_person_is_required_to_file: true + +- name: Case 10, the same box 1 wages without a deferral give the same answer. + # Control for Case 9: $4,000 of wages and $600 of interest; $4,600 is more + # than $4,000 + $450 = $4,450. + period: 2025 + input: + people: + person1: + age: 17 + employment_income: 4_000 + taxable_interest_income: 600 + tax_units: + tax_unit: + members: [person1] + output: + medicaid_person_is_required_to_file: true + +- name: Case 11, wages over the regular amount before a deferral but not after it do not require a return. + # Box 1 wages are $17,000 - $3,000 = $14,000, not more than the $15,750 + # single amount (Table 2, test 2), and gross income of $14,000 is not more + # than $14,000 + $450 = $14,450 (test 3). + period: 2025 + input: + people: + person1: + age: 17 + employment_income: 17_000 + traditional_401k_contributions: 3_000 + tax_units: + tax_unit: + members: [person1] + output: + medicaid_person_is_required_to_file: false + +- name: Case 12, farm income is earned income, not unearned income. + # The Form 1040 dependent worksheet counts Schedule 1 line 6 (farm income) + # as earned income. $2,000 of farm income is not unearned income over + # $1,350, and gross income of $2,000 is not more than $2,000 + $450. The + # section 6017 self-employment tax filing rule is not part of the section + # 6012(a)(1) test that 42 CFR 435.603(d)(2) uses. + period: 2025 + input: + people: + person1: + age: 17 + farm_operations_income: 2_000 + tax_units: + tax_unit: + members: [person1] + output: + medicaid_person_is_required_to_file: false diff --git a/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/basic_standard_deduction.yaml b/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/basic_standard_deduction.yaml index 4099214070c..a3a4d3e62bd 100644 --- a/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/basic_standard_deduction.yaml +++ b/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/basic_standard_deduction.yaml @@ -285,3 +285,131 @@ # Worksheet earned income subtracts Schedule 1 line 15: # $3,000 - $3,000 x 0.9235 x 15.3% / 2 = $2,788.06; plus $450 = $3,238.06. basic_standard_deduction: 3238.06 + +- name: 2025 dependent filer with a 401(k) deferral uses W-2 box 1 wages on the worksheet + # Form 1040 instructions (2025): worksheet earned income starts from line + # 1z, and line 1a is W-2 box 1, which leaves out the $6,000 elective + # deferral. Earned income is $10,000 - $6,000 = $4,000; $4,000 + $450 = + # $4,450. Gross income, $4,000 of wages and $600 of interest, is more than + # $4,450, so a return is required (Pub. 501 (2025), Table 2). + period: 2025 + input: + people: + head: + age: 20 + employment_income: 10_000 + traditional_401k_contributions: 6_000 + taxable_interest_income: 600 + claimed_as_dependent_on_another_return: true + tax_units: + tax_unit: + members: [head] + filing_status: SINGLE + households: + household: + members: [head] + state_code: CA + output: + basic_standard_deduction: 4_450 + tax_unit_is_required_to_file: true + +- name: 2025 dependent filer with the same W-2 box 1 wages and no deferral gets the same deduction + # Control for the case above: $4,000 of wages with no deferral gives + # $4,000 + $450 = $4,450, and gross income of $4,600 requires a return. + period: 2025 + input: + people: + head: + age: 20 + employment_income: 4_000 + taxable_interest_income: 600 + claimed_as_dependent_on_another_return: true + tax_units: + tax_unit: + members: [head] + filing_status: SINGLE + households: + household: + members: [head] + state_code: CA + output: + basic_standard_deduction: 4_450 + tax_unit_is_required_to_file: true + +- name: 2025 dependent filer whose wages before deferral exceed the regular amount but whose W-2 box 1 wages do not + # $17,000 of wages less a $3,000 deferral is $14,000 of box 1 wages; + # $14,000 + $450 = $14,450, below the $15,750 single amount. Gross income, + # $14,000, does not exceed $14,450, so no return is required. + period: 2025 + input: + people: + head: + age: 20 + employment_income: 17_000 + traditional_401k_contributions: 3_000 + claimed_as_dependent_on_another_return: true + tax_units: + tax_unit: + members: [head] + filing_status: SINGLE + households: + household: + members: [head] + state_code: CA + output: + basic_standard_deduction: 14_450 + tax_unit_is_required_to_file: false + +- name: 2025 dependent filer with farm income counts it as earned income on the worksheet + # Schedule 1 line 6 (farm income) is in worksheet earned income, net of + # the deductible part of self-employment tax (line 15): + # $3,000 - $3,000 x 0.9235 x 15.3% / 2 = $2,788.06; plus $450 = $3,238.06. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 20 + farm_operations_income: 3_000 + claimed_as_dependent_on_another_return: true + tax_units: + tax_unit: + members: [head] + filing_status: SINGLE + households: + household: + members: [head] + state_code: CA + output: + basic_standard_deduction: 3238.06 + +- name: 2025 joint return with a claimable spouse sums both spouses' W-2 box 1 wages + # Box 1 wages are $8,000 - $3,000 = $5,000 and $8,000, so joint earned + # income is $13,000; $13,000 + $450 = $13,450, below the $31,500 joint + # amount. + period: 2025 + input: + people: + person_a: + age: 20 + employment_income: 8_000 + traditional_401k_contributions: 3_000 + claimed_as_dependent_on_another_return: true + is_tax_unit_head: true + is_tax_unit_spouse: false + person_b: + age: 20 + employment_income: 8_000 + claimed_as_dependent_on_another_return: false + is_tax_unit_head: false + is_tax_unit_spouse: true + tax_units: + tax_unit: + members: [person_a, person_b] + filing_status: JOINT + households: + household: + members: [person_a, person_b] + state_code: CA + output: + basic_standard_deduction: 13_450 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income.yaml b/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income.yaml new file mode 100644 index 00000000000..2f2ec8cd9f5 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income.yaml @@ -0,0 +1,159 @@ +- name: Wages count as reported in W-2 box 1, after a 401(k) deferral + # Form 1040 instructions (2025): line 1a is W-2 box 1, and an elective + # deferral is not included in box 1. $10,000 - $6,000 = $4,000. + period: 2025 + input: + people: + head: + age: 20 + employment_income: 10_000 + traditional_401k_contributions: 6_000 + tax_units: + tax_unit: + members: [head] + households: + household: + members: [head] + output: + standard_deduction_worksheet_earned_income: 4_000 + +- name: Pretax health premiums and HSA payroll contributions are also left out of box 1 wages + # $10,000 - $1,000 - $500 = $8,500. + period: 2025 + input: + people: + head: + age: 20 + employment_income: 10_000 + pre_tax_health_insurance_premiums: 1_000 + health_savings_account_payroll_contributions: 500 + tax_units: + tax_unit: + members: [head] + households: + household: + members: [head] + output: + standard_deduction_worksheet_earned_income: 8_500 + +- name: Designated Roth 401(k) contributions stay in box 1 wages + # 2025 Form 1040 instructions, IRA deduction worksheet, note 3: "Except for + # designated Roth contributions, these amounts aren't included as income + # in box 1 of your Form W-2." + period: 2025 + input: + people: + head: + age: 20 + employment_income: 10_000 + roth_401k_contributions: 2_000 + tax_units: + tax_unit: + members: [head] + households: + household: + members: [head] + output: + standard_deduction_worksheet_earned_income: 10_000 + +- name: Self-employment income is net of the deductible part of self-employment tax + # $3,000 - $3,000 x 0.9235 x 15.3% / 2 = $2,788.06. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 20 + self_employment_income: 3_000 + tax_units: + tax_unit: + members: [head] + households: + household: + members: [head] + output: + standard_deduction_worksheet_earned_income: 2788.06 + +- name: Farm income (Schedule 1 line 6) counts, net of the deductible part of self-employment tax + # $3,000 - $3,000 x 0.9235 x 15.3% / 2 = $2,788.06. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 20 + farm_operations_income: 3_000 + tax_units: + tax_unit: + members: [head] + households: + household: + members: [head] + output: + standard_deduction_worksheet_earned_income: 2788.06 + +- name: A farm loss reduces earned income + # $5,000 of wages less a $2,000 farm loss is $3,000; a loss owes no + # self-employment tax. + period: 2025 + input: + people: + head: + age: 20 + employment_income: 5_000 + farm_operations_income: -2_000 + tax_units: + tax_unit: + members: [head] + households: + household: + members: [head] + output: + standard_deduction_worksheet_earned_income: 3_000 + +- name: Earned income is not negative + # $1,000 of wages less a $5,000 business loss is floored at $0. + period: 2025 + input: + people: + head: + age: 20 + employment_income: 1_000 + self_employment_income: -5_000 + tax_units: + tax_unit: + members: [head] + households: + household: + members: [head] + output: + standard_deduction_worksheet_earned_income: 0 + +- name: A joint return sums both spouses' box 1 wages and leaves out a dependent's wages + # Head $8,000 - $3,000 = $5,000; spouse $8,000; the dependent child's + # $2,000 belongs on the child's own return. $5,000 + $8,000 = $13,000. + period: 2025 + input: + people: + head: + age: 30 + employment_income: 8_000 + traditional_401k_contributions: 3_000 + is_tax_unit_head: true + spouse: + age: 30 + employment_income: 8_000 + is_tax_unit_spouse: true + child: + age: 10 + employment_income: 2_000 + is_tax_unit_dependent: true + tax_units: + tax_unit: + members: [head, spouse, child] + filing_status: JOINT + households: + household: + members: [head, spouse, child] + output: + standard_deduction_worksheet_earned_income: 13_000 diff --git a/policyengine_us/tests/policy/baseline/gov/states/hi/tax/income/deductions/hi_deductions.yaml b/policyengine_us/tests/policy/baseline/gov/states/hi/tax/income/deductions/hi_deductions.yaml index 56eb95f2a84..61691fd2025 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/hi/tax/income/deductions/hi_deductions.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/hi/tax/income/deductions/hi_deductions.yaml @@ -3,7 +3,7 @@ input: state_code: HI filing_status: JOINT - tax_unit_earned_income: 1_000 + standard_deduction_worksheet_earned_income: 1_000 hi_agi: 1_000 hi_total_itemized_deductions: 5_000 hi_reduced_itemized_deductions: 1_000 @@ -16,7 +16,7 @@ input: state_code: HI filing_status: JOINT - tax_unit_earned_income: 1_000_000 + standard_deduction_worksheet_earned_income: 1_000_000 hi_agi: 1_000_000 hi_total_itemized_deductions: 5_000 hi_reduced_itemized_deductions: 1_000 @@ -29,7 +29,7 @@ input: state_code: HI filing_status: JOINT - tax_unit_earned_income: 1_000 + standard_deduction_worksheet_earned_income: 1_000 hi_agi: 1_000 hi_total_itemized_deductions: 1_000 hi_reduced_itemized_deductions: 1_000 @@ -42,7 +42,7 @@ input: state_code: HI filing_status: SEPARATE - tax_unit_earned_income: 1_000_000 + standard_deduction_worksheet_earned_income: 1_000_000 hi_agi: 1_000_000 hi_total_itemized_deductions: 5_000 hi_reduced_itemized_deductions: 1_000 @@ -55,7 +55,7 @@ input: state_code: HI filing_status: JOINT - tax_unit_earned_income: 1_000_000 + standard_deduction_worksheet_earned_income: 1_000_000 hi_agi: 1_000_000 hi_total_itemized_deductions: 5_000 hi_reduced_itemized_deductions: 4_500 @@ -90,7 +90,7 @@ tax_unit: members: [person_a, person_b] filing_status: JOINT - tax_unit_earned_income: 3_000 + standard_deduction_worksheet_earned_income: 3_000 hi_itemized_deductions: 0 households: household: @@ -118,7 +118,7 @@ tax_unit: members: [person_b, person_a] filing_status: JOINT - tax_unit_earned_income: 3_000 + standard_deduction_worksheet_earned_income: 3_000 hi_itemized_deductions: 0 households: household: @@ -146,7 +146,7 @@ tax_unit: members: [person_a, person_b] filing_status: JOINT - tax_unit_earned_income: 3_000 + standard_deduction_worksheet_earned_income: 3_000 hi_itemized_deductions: 4_000 households: household: @@ -174,7 +174,7 @@ tax_unit: members: [person_b, person_a] filing_status: JOINT - tax_unit_earned_income: 3_000 + standard_deduction_worksheet_earned_income: 3_000 hi_itemized_deductions: 4_000 households: household: @@ -190,7 +190,7 @@ state_code: HI filing_status: SINGLE claimed_as_dependent_on_another_return: true - tax_unit_earned_income: 300 + standard_deduction_worksheet_earned_income: 300 hi_itemized_deductions: 0 output: # HRS 235-2.4(a)(3): greater of $500 or earned income ($300). @@ -276,3 +276,48 @@ output: # $3,000 - $3,000 x 0.9235 x 15.3% / 2 = $2,788.06, below the $8,800 joint amount. hi_deductions: 2788.06 + +- name: 2025 single dependent filer with a 401(k) deferral uses W-2 box 1 wages + # N-11 instructions (2025), PDF page 20: earned income is federal Form 1040 + # line 1 wages, which are W-2 box 1 and leave out the $2,000 elective + # deferral. Greater of $500 or $3,000 - $2,000 = $1,000. + period: 2025 + input: + people: + head: + age: 20 + employment_income: 3_000 + traditional_401k_contributions: 2_000 + claimed_as_dependent_on_another_return: true + tax_units: + tax_unit: + members: [head] + filing_status: SINGLE + hi_itemized_deductions: 0 + households: + household: + members: [head] + state_code: HI + output: + hi_deductions: 1_000 + +- name: 2025 single dependent filer with the same box 1 wages and no deferral gets the same deduction + # Control for the case above: greater of $500 or $1,000 of wages. + period: 2025 + input: + people: + head: + age: 20 + employment_income: 1_000 + claimed_as_dependent_on_another_return: true + tax_units: + tax_unit: + members: [head] + filing_status: SINGLE + hi_itemized_deductions: 0 + households: + household: + members: [head] + state_code: HI + output: + hi_deductions: 1_000 diff --git a/policyengine_us/tests/policy/baseline/gov/states/or/tax/income/deductions/standard/or_standard_deduction.yaml b/policyengine_us/tests/policy/baseline/gov/states/or/tax/income/deductions/standard/or_standard_deduction.yaml index c040dee6619..8c539d076fa 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/or/tax/income/deductions/standard/or_standard_deduction.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/or/tax/income/deductions/standard/or_standard_deduction.yaml @@ -69,7 +69,7 @@ filing_status: JOINT age_head: 35 claimed_as_dependent_on_another_return: true - tax_unit_earned_income: 600 + standard_deduction_worksheet_earned_income: 600 output: # $1100 base or_standard_deduction: 1_100 @@ -81,7 +81,7 @@ filing_status: SINGLE age_head: 35 claimed_as_dependent_on_another_return: true - tax_unit_earned_income: 1_000 + standard_deduction_worksheet_earned_income: 1_000 output: # $1000 income + $350 addition, below the $2,350 normal standard deduction cap. or_standard_deduction: 1_350 @@ -93,7 +93,7 @@ filing_status: SINGLE age: 35 claimed_as_dependent_on_another_return: true - tax_unit_earned_income: 1_000 + standard_deduction_worksheet_earned_income: 1_000 blind_head: true output: # $1000 income + $350 addition + $1200 blind @@ -156,7 +156,7 @@ tax_unit: members: [person_a, person_b] filing_status: JOINT - tax_unit_earned_income: 3_000 + standard_deduction_worksheet_earned_income: 3_000 households: household: members: [person_a, person_b] @@ -183,7 +183,7 @@ tax_unit: members: [person_b, person_a] filing_status: JOINT - tax_unit_earned_income: 3_000 + standard_deduction_worksheet_earned_income: 3_000 households: household: members: [person_b, person_a] @@ -213,3 +213,47 @@ # $1,500 - $1,500 x 0.9235 x 15.3% / 2 = $1,394.03; plus $450 = $1,844.03, # above the $1,350 minimum and below the $2,835 single amount. or_standard_deduction: 1844.03 + +- name: 2025 dependent filer with a 401(k) deferral uses W-2 box 1 wages + # Earned income is figured as in the federal worksheet, from W-2 box 1, + # which leaves out the $2,000 elective deferral: $3,000 - $2,000 = $1,000; + # $1,000 + $450 = $1,450, above the $1,350 minimum and below the $2,835 + # single amount. + period: 2025 + input: + people: + head: + age: 20 + employment_income: 3_000 + traditional_401k_contributions: 2_000 + claimed_as_dependent_on_another_return: true + tax_units: + tax_unit: + members: [head] + filing_status: SINGLE + households: + household: + members: [head] + state_code: OR + output: + or_standard_deduction: 1_450 + +- name: 2025 dependent filer with the same box 1 wages and no deferral gets the same deduction + # Control for the case above: $1,000 + $450 = $1,450. + period: 2025 + input: + people: + head: + age: 20 + employment_income: 1_000 + claimed_as_dependent_on_another_return: true + tax_units: + tax_unit: + members: [head] + filing_status: SINGLE + households: + household: + members: [head] + state_code: OR + output: + or_standard_deduction: 1_450 diff --git a/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.py b/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.py index c5fec3109ad..f22a25df229 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.py +++ b/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.py @@ -3,13 +3,6 @@ FilingStatus, ) -# The wage and self-employment sources in gov.irs.gross_income.sources. -EARNED_GROSS_INCOME_SOURCES = [ - "irs_employment_income", - "self_employment_income", - "sstb_self_employment_income", -] - class medicaid_person_is_required_to_file(Variable): value_type = bool @@ -20,19 +13,28 @@ class medicaid_person_is_required_to_file(Variable): "https://www.law.cornell.edu/cfr/text/42/435.603#d_2", "https://www.irs.gov/publications/p501", "https://www.irs.gov/pub/irs-prior/p501--2025.pdf#page=4", + # Form 1040 instructions: line 1a is Form(s) W-2, box 1 (PDF page 23), + # which leaves out elective deferrals (page 25). + # PDF pages 23, 25 + "https://www.irs.gov/pub/irs-prior/i1040gi--2025.pdf#page=23", ) def formula(person, period, parameters): standard = parameters(period).gov.irs.deductions.standard filing_requirement = parameters(period).gov.irs.income.filing_requirement gross_income = person("medicaid_irs_gross_income", period) - earned_income = person("earned_income", period) - # Unearned income is gross income other than wages and self-employment - # earnings (IRS Pub. 501, Table 2). Gross income counts each source's - # positive amount, so subtract those sources' positive amounts: a - # business loss does not turn other income into unearned income. + # Earned income is wages as reported in Form W-2 box 1, which leave + # out elective deferrals, plus business and farm income: the gross + # income sources the IRS dependent worksheet counts as earned. A + # business or farm loss reduces it. + earned_income_sources = filing_requirement.dependent.earned_income_sources + earned_income = add(person, period, earned_income_sources) + # Unearned income is gross income other than earned income (IRS Pub. + # 501, Table 2). Gross income counts each source's positive amount, so + # subtract those sources' positive amounts: a business loss does not + # turn other income into unearned income. earned_gross_income = 0 - for source in EARNED_GROSS_INCOME_SOURCES: + for source in earned_income_sources: earned_gross_income += max_(0, person(source, period)) unearned_income = max_(0, gross_income - earned_gross_income) diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/basic_standard_deduction.py b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/basic_standard_deduction.py index 952da61a05f..d895e9ee929 100644 --- a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/basic_standard_deduction.py +++ b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/basic_standard_deduction.py @@ -25,12 +25,10 @@ def formula(tax_unit, period, parameters): # can be claimed. dependent_elsewhere = tax_unit("head_or_spouse_is_dependent_elsewhere", period) standard_deduction = p.amount[filing_status] - # Worksheet earned income: wages and self-employment income minus the - # deductible part of self-employment tax (Schedule 1, line 15). - worksheet_earned_income = max_( - tax_unit("tax_unit_earned_income", period) - - tax_unit("self_employment_tax_ald", period), - 0, + # Worksheet earned income: W-2 box 1 wages, business and farm income, + # minus the deductible part of self-employment tax. + worksheet_earned_income = tax_unit( + "standard_deduction_worksheet_earned_income", period ) standard_deduction_if_dependent = min_( standard_deduction, diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income.py b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income.py new file mode 100644 index 00000000000..a63f9b9a89e --- /dev/null +++ b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income.py @@ -0,0 +1,38 @@ +from policyengine_us.model_api import * + + +class standard_deduction_worksheet_earned_income(Variable): + value_type = float + entity = TaxUnit + label = "Earned income for the standard deduction worksheet for dependents" + unit = USD + documentation = ( + "Earned income of the head and spouse on the Standard Deduction " + "Worksheet for Dependents: wages from Form W-2 box 1, which leave out " + "elective deferrals, plus business and farm income, minus the " + "deductible part of self-employment tax." + ) + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/63#c_5", + # Form 1040 instructions. Line 1a is the total of Form(s) W-2, box 1 + # (PDF page 23). An elective deferral "isn't included as income in + # box 1 of your Form W-2" (page 25). Worksheet footnote: "Generally, + # your earned income is the total of the amount(s) you reported on + # Form 1040 or 1040-SR, line 1z, and Schedule 1, lines 3, 6, 8r, 8t, + # and 8u minus the amount, if any, on Schedule 1, line 15" (page 34 + # in 2024, page 35 in 2025). + # PDF pages 23, 25, 34 + "https://www.irs.gov/pub/irs-prior/i1040gi--2024.pdf#page=23", + # PDF pages 23, 25, 35 + "https://www.irs.gov/pub/irs-prior/i1040gi--2025.pdf#page=23", + ) + + def formula(tax_unit, period, parameters): + p = parameters(period).gov.irs.income.filing_requirement.dependent + # Form 1040 line 1z wages (irs_employment_income, after elective + # deferrals and other pretax payroll deductions) and Schedule 1 lines + # 3 and 6. A business or farm loss reduces the total. + earned_income = tax_unit_non_dep_add(tax_unit, period, p.earned_income_sources) + # Schedule 1, line 15: the deductible part of self-employment tax. + return max_(earned_income - tax_unit("self_employment_tax_ald", period), 0) diff --git a/policyengine_us/variables/gov/states/hi/tax/income/deductions/hi_deductions.py b/policyengine_us/variables/gov/states/hi/tax/income/deductions/hi_deductions.py index fe50a345a3c..38e5e40180f 100644 --- a/policyengine_us/variables/gov/states/hi/tax/income/deductions/hi_deductions.py +++ b/policyengine_us/variables/gov/states/hi/tax/income/deductions/hi_deductions.py @@ -21,7 +21,6 @@ def formula(tax_unit, period, parameters): standard_deduction = tax_unit("hi_standard_deduction", period) total_itemized_deduction = tax_unit("hi_itemized_deductions", period) - tax_unit_earned_income = tax_unit("tax_unit_earned_income", period) filing_status = tax_unit("filing_status", period) # check itemized deduction eligibility @@ -35,10 +34,11 @@ def formula(tax_unit, period, parameters): is_dependent_on_another_return = tax_unit( "head_or_spouse_is_dependent_elsewhere", period ) - # Worksheet earned income: wages and self-employment income minus the - # deductible part of self-employment tax (Schedule 1, line 15). - worksheet_earned_income = max_( - tax_unit_earned_income - tax_unit("self_employment_tax_ald", period), 0 + # Worksheet earned income: federal Form 1040 line 1 wages and Schedule + # 1 lines 3 (business) and 6 (farming), minus line 15 (N-11 + # instructions, PDF page 20). + worksheet_earned_income = tax_unit( + "standard_deduction_worksheet_earned_income", period ) dependent_standard_deduction = min_( max_(p.threshold.dependent, worksheet_earned_income), standard_deduction diff --git a/policyengine_us/variables/gov/states/or/tax/income/deductions/or_standard_deduction.py b/policyengine_us/variables/gov/states/or/tax/income/deductions/or_standard_deduction.py index 54d2dc18fbc..dd9293000a1 100644 --- a/policyengine_us/variables/gov/states/or/tax/income/deductions/or_standard_deduction.py +++ b/policyengine_us/variables/gov/states/or/tax/income/deductions/or_standard_deduction.py @@ -11,7 +11,8 @@ class or_standard_deduction(Variable): reference = ( "https://www.oregon.gov/dor/forms/FormsPubs/form-or-40-inst_101-040-1_2021.pdf#page=18", "https://www.oregonlegislature.gov/bills_laws/ors/ors316.html", # ORS 316.695(7)-(8) - "https://www.oregon.gov/dor/forms/FormsPubs/publication-or-17_101-431_2025.pdf#page=96", + # Earned income definition and dependent worksheets, PDF pages 95-96 + "https://www.oregon.gov/dor/forms/FormsPubs/publication-or-17_101-431_2025.pdf#page=95", ) defined_for = StateCode.OR @@ -21,13 +22,9 @@ def formula(tax_unit, period, parameters): filing_status = tax_unit("filing_status", period) initial_core_deduction = p.amount[filing_status] # Replace if claimable as a dependent. Earned income is figured as in - # the federal worksheet, net of the deductible part of self-employment - # tax (Schedule 1, line 15). - earned_income = max_( - tax_unit("tax_unit_earned_income", period) - - tax_unit("self_employment_tax_ald", period), - 0, - ) + # the federal worksheet: W-2 box 1 wages, business and farm income, + # net of the deductible part of self-employment tax. + earned_income = tax_unit("standard_deduction_worksheet_earned_income", period) claimable_dep_floor = p.claimable_as_dependent.min claimable_dep_earned_amount = ( earned_income + p.claimable_as_dependent.earned_income_addition From 59dc4330d76eb7d97588e8dfbfb9be61c3b54077 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 19 Oct 2026 08:58:40 -0400 Subject: [PATCH 2/7] Add property tests for dependent worksheet earned income Hypothesis draws single and joint tax units in Oregon, Hawaii and Texas and checks, for 2025 and 2026: deferral invariance (only W-2 box 1 wages matter), the 63(c)(5) bounds, monotonicity in box 1 wages and in the deferral, a hand reference for wage-only units, and Publication 501 Table 2 on box 1 wages for both the federal and Medicaid filing tests. Co-Authored-By: Claude Opus 5.5 --- ...dent_worksheet_earned_income_invariants.py | 317 ++++++++++++++++++ 1 file changed, 317 insertions(+) create mode 100644 policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py diff --git a/policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py b/policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py new file mode 100644 index 00000000000..da5cc5a14d2 --- /dev/null +++ b/policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py @@ -0,0 +1,317 @@ +"""Invariants for earned income on the standard deduction worksheet for dependents. + +The Form 1040 Standard Deduction Worksheet for Dependents starts earned income +from line 1z, and line 1a is the total of Form(s) W-2, box 1, which leaves out +elective deferrals (2025 Form 1040 instructions, PDF pages 23, 25 and 35). +`standard_deduction_worksheet_earned_income` is that amount for the head and +spouse; `basic_standard_deduction` (26 USC 63(c)(5)), `or_standard_deduction` +and `hi_deductions` use it for a filer who can be claimed as a dependent, and +`medicaid_person_is_required_to_file` reads the same earned income sources. +YAML cases pin single households; these tests check what must hold for every +input. + +`test_worksheet_properties` draws batches of single and joint tax units with +Hypothesis (any mix of claimability, wages, 401(k) deferrals, self-employment +and farm income or loss, and interest, in Oregon, Hawaii or Texas) and runs +each batch, with four variants of every unit, as one simulation for 2025 and +2026. Three fixed units, the review's case (a claimed single filer with +$10,000 of wages, a $6,000 deferral and $600 of interest) in each state, +start every batch so that each property has rows to check: + +1. Deferral invariance: a unit whose wages are W with a deferral D gets the + same worksheet earned income, deductions, federal filing requirement and + Medicaid filing requirement as a twin with wages max(W - D, 0) and no + deferral. Only W-2 box 1 wages matter. +2. Bounds: the basic standard deduction of a unit whose head or spouse can be + claimed is at least the section 63(c)(5)(A) amount and never more than the + regular basic standard deduction for its filing status; for any other unit + it is the regular amount. Hawaii's limited deduction never exceeds Hawaii's + regular standard deduction. +3. Monotonicity: $1,000 more wages with the same deferral never lowers + worksheet earned income or any of the three deductions, and a deferral + $1,000 larger out of the same wages never raises them. +4. Reference: for units with wages and deferrals only, worksheet earned income + equals the sum of max(W - D, 0) over the head and spouse, and the basic + standard deduction of a claimable unit equals min(regular amount, + max(63(c)(5)(A) amount, worksheet earned income + 63(c)(5)(B) amount)). +5. Table 2 (2025): for single claimable filers under 65 and not blind with + only wages, deferrals and interest, both `tax_unit_is_required_to_file` and + `medicaid_person_is_required_to_file` equal Publication 501 (2025), Table + 2, computed with W-2 box 1 wages as earned income. +""" + +import numpy as np +from hypothesis import HealthCheck, given, settings +from hypothesis import strategies as st + +from policyengine_us import Simulation +from policyengine_us.system import system as SYSTEM + +YEARS = (2025, 2026) +STATES = ("OR", "HI", "TX") +VARIANTS = ("base", "twin", "raised", "deferred") +RAISE = 1_000 + +# Publication 501 (2025), Table 2, single dependents not 65 or older or blind: +# https://www.irs.gov/pub/irs-prior/p501--2025.pdf#page=4 +TABLE_2_FLOOR = 1_350 +TABLE_2_EARNED_INCOME_ADDITION = 450 +TABLE_2_EARNED_INCOME_LIMIT = 15_750 + + +def simulate(units): + """One simulation of independent tax units, each in its own household.""" + people, tax_units, households = {}, {}, {} + groups = {"marital_units": {}, "spm_units": {}, "families": {}} + for index, unit in enumerate(units): + members = [f"adult_{index}_{n}" for n in range(len(unit["adults"]))] + for name, inputs in zip(members, unit["adults"]): + people[name] = { + variable: {year: value for year in YEARS} + for variable, value in inputs.items() + } + tax_units[f"tax_unit_{index}"] = { + "members": members, + "filing_status": {year: unit["filing_status"] for year in YEARS}, + # Keep Hawaii's comparison on the standard deduction. + "hi_itemized_deductions": {year: 0 for year in YEARS}, + } + households[f"household_{index}"] = { + "members": members, + "state_code": {year: unit["state"] for year in YEARS}, + } + for name in ("spm_units", "families"): + groups[name][f"{name}_{index}"] = {"members": members} + groups["marital_units"][f"marital_unit_{index}"] = {"members": members} + return Simulation( + situation={ + "people": people, + "tax_units": tax_units, + "households": households, + **groups, + } + ) + + +def adult(claimed, wages, deferral, self_employment, farm, interest): + return { + "age": 30, + "is_blind": False, + "claimed_as_dependent_on_another_return": claimed, + "employment_income": wages, + "traditional_401k_contributions": deferral, + "self_employment_income": self_employment, + "farm_operations_income": farm, + "taxable_interest_income": interest, + } + + +def variant(unit, kind): + """The unit, its no-deferral twin, or the unit with more wages or a larger + deferral out of the same wages.""" + adults = [] + for person in unit["adults"]: + person = dict(person) + if kind == "twin": + person["employment_income"] = max( + person["employment_income"] - person["traditional_401k_contributions"], + 0, + ) + person["traditional_401k_contributions"] = 0 + elif kind == "raised": + person["employment_income"] += RAISE + elif kind == "deferred": + person["traditional_401k_contributions"] = min( + person["traditional_401k_contributions"] + RAISE, + person["employment_income"], + ) + adults.append(person) + return {**unit, "adults": adults} + + +money = st.integers(min_value=0, max_value=40_000) +loss_or_profit = st.one_of(st.just(0), st.integers(min_value=-10_000, max_value=10_000)) + + +@st.composite +def adults(draw): + wages = draw(money) + deferral = draw(st.integers(min_value=0, max_value=wages)) + return adult( + claimed=draw(st.booleans()), + wages=wages, + deferral=deferral, + self_employment=draw(loss_or_profit), + farm=draw(loss_or_profit), + interest=draw(st.integers(min_value=0, max_value=5_000)), + ) + + +@st.composite +def units(draw): + joint = draw(st.booleans()) + members = [draw(adults()) for _ in range(2 if joint else 1)] + return { + "filing_status": "JOINT" if joint else "SINGLE", + "state": draw(st.sampled_from(STATES)), + "adults": members, + } + + +# Fixed units so every property has rows: the reviewer's case and its twin. +FIXED_UNITS = [ + { + "filing_status": "SINGLE", + "state": state, + "adults": [adult(True, 10_000, 6_000, 0, 0, 600)], + } + for state in STATES +] + + +def head_values(simulation, units, variable, year): + values = np.asarray(simulation.calculate(variable, year)) + first = np.cumsum([0] + [len(unit["adults"]) for unit in units]) + return values[first[:-1]] + + +@settings( + max_examples=40, + deadline=None, + suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large], +) +@given(st.lists(units(), min_size=1, max_size=12)) +def test_worksheet_properties(drawn): + base = FIXED_UNITS + drawn + batch = [variant(unit, kind) for kind in VARIANTS for unit in base] + simulation = simulate(batch) + n = len(base) + rows = {kind: slice(i * n, (i + 1) * n) for i, kind in enumerate(VARIANTS)} + claimable = np.array( + [ + any(a["claimed_as_dependent_on_another_return"] for a in unit["adults"]) + for unit in base + ] + ) + joint = np.array([unit["filing_status"] == "JOINT" for unit in base]) + wages_only = np.array( + [ + all( + a["self_employment_income"] == 0 and a["farm_operations_income"] == 0 + for a in unit["adults"] + ) + for unit in base + ] + ) + hi = np.array([unit["state"] == "HI" for unit in base]) + assert (claimable & wages_only & ~joint).any() + + for year in YEARS: + p = SYSTEM.parameters(year).gov.irs.deductions.standard + values = { + variable: np.asarray(simulation.calculate(variable, year)) + for variable in ( + "standard_deduction_worksheet_earned_income", + "basic_standard_deduction", + "standard_deduction", + "tax_unit_is_required_to_file", + "or_standard_deduction", + "hi_deductions", + "hi_standard_deduction", + ) + } + values["medicaid_head"] = head_values( + simulation, batch, "medicaid_person_is_required_to_file", year + ) + + # 1. Deferral invariance. + for variable, value in values.items(): + np.testing.assert_array_equal( + value[rows["base"]], + value[rows["twin"]], + err_msg=f"{year}: {variable} depends on the deferral, not box 1", + ) + + # 2. Bounds. + regular = np.where(joint, p.amount["JOINT"], p.amount["SINGLE"]) + basic = values["basic_standard_deduction"][rows["base"]] + assert (basic[claimable] <= regular[claimable] + 1e-6).all(), year + assert (basic[claimable] >= p.dependent.amount - 1e-6).all(), year + np.testing.assert_allclose(basic[~claimable], regular[~claimable]) + hi_limited = values["hi_deductions"][rows["base"]][hi] + hi_regular = values["hi_standard_deduction"][rows["base"]][hi] + assert (hi_limited <= hi_regular + 1e-6).all(), year + + # 3. Monotonicity in box 1 wages, both ways. + for variable in ( + "standard_deduction_worksheet_earned_income", + "basic_standard_deduction", + "or_standard_deduction", + "hi_deductions", + ): + value = values[variable] + assert (value[rows["raised"]] >= value[rows["base"]] - 1e-6).all(), ( + f"{year}: {variable} falls with more box 1 wages" + ) + assert (value[rows["deferred"]] <= value[rows["base"]] + 1e-6).all(), ( + f"{year}: {variable} rises with a larger deferral" + ) + + # 4. Reference, for units with wages and deferrals only. + worksheet = values["standard_deduction_worksheet_earned_income"][rows["base"]] + expected_worksheet = np.array( + [ + sum( + max(a["employment_income"] - a["traditional_401k_contributions"], 0) + for a in unit["adults"] + ) + for unit in base + ] + ) + np.testing.assert_allclose( + worksheet[wages_only], expected_worksheet[wages_only], atol=0.01 + ) + expected_basic = np.minimum( + regular, + np.maximum( + p.dependent.amount, + expected_worksheet + p.dependent.additional_earned_income, + ), + ) + rows_4 = wages_only & claimable + np.testing.assert_allclose(basic[rows_4], expected_basic[rows_4], atol=0.01) + + # 5. Table 2 with box 1 wages as earned income (2025 amounts). + if year == 2025: + single = ~joint & claimable & wages_only + person = [unit["adults"][0] for unit in base] + earned = np.array( + [ + max(a["employment_income"] - a["traditional_401k_contributions"], 0) + for a in person + ] + ) + unearned = np.array([a["taxable_interest_income"] for a in person]) + expected = ( + (unearned > TABLE_2_FLOOR) + | (earned > TABLE_2_EARNED_INCOME_LIMIT) + | ( + earned + unearned + > np.maximum( + TABLE_2_FLOOR, + np.minimum( + earned, + TABLE_2_EARNED_INCOME_LIMIT + - TABLE_2_EARNED_INCOME_ADDITION, + ) + + TABLE_2_EARNED_INCOME_ADDITION, + ) + ) + ) + assert single.any() + for variable in ("tax_unit_is_required_to_file", "medicaid_head"): + np.testing.assert_array_equal( + values[variable][rows["base"]][single], + expected[single], + err_msg=f"2025: {variable} differs from Table 2 on box 1 wages", + ) From f661fc916bab2d1dbcfb94d5c67638e0e98face9 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 19 Oct 2026 09:37:25 -0400 Subject: [PATCH 3/7] Subtract Schedule 1 line 15 in the Medicaid dependent filing test Review of #10272: once farm income counted as earned income, the Medicaid test, which never subtracted the deductible part of self-employment tax, told a dependent with $15,000 of farm profit that no return was required. The worksheet's earned income is $13,940.28, so the limit is $14,390.28 and a return is required, as the federal test finds. The same gap applied to Schedule C income on main. Add Person standard_deduction_worksheet_earned_income_person (W-2 box 1 wages plus Schedule C and F, minus self_employment_tax_ald_person, not floored), sum it for the head and spouse in the tax-unit variable, and use it, floored at zero, in the Medicaid test. Add a property that the Medicaid and federal tests agree for every single claimable filer in 2025, and qualify deferral invariance to an unchanged line 15. Co-Authored-By: Claude Opus 5.5 --- ...dent_worksheet_earned_income_invariants.py | 20 ++++++++- .../medicaid_person_is_required_to_file.yaml | 42 +++++++++++++++++-- ...ard_deduction_worksheet_earned_income.yaml | 23 ++++++++++ ...uction_worksheet_earned_income_person.yaml | 35 ++++++++++++++++ .../medicaid_person_is_required_to_file.py | 22 ++++++---- ...ndard_deduction_worksheet_earned_income.py | 33 +++++++-------- ...eduction_worksheet_earned_income_person.py | 41 ++++++++++++++++++ 7 files changed, 182 insertions(+), 34 deletions(-) create mode 100644 policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income_person.yaml create mode 100644 policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income_person.py diff --git a/policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py b/policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py index da5cc5a14d2..45a8e0cc5fb 100644 --- a/policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py +++ b/policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py @@ -6,7 +6,8 @@ `standard_deduction_worksheet_earned_income` is that amount for the head and spouse; `basic_standard_deduction` (26 USC 63(c)(5)), `or_standard_deduction` and `hi_deductions` use it for a filer who can be claimed as a dependent, and -`medicaid_person_is_required_to_file` reads the same earned income sources. +`medicaid_person_is_required_to_file` uses the same per-person amount +(`standard_deduction_worksheet_earned_income_person`). YAML cases pin single households; these tests check what must hold for every input. @@ -21,7 +22,10 @@ 1. Deferral invariance: a unit whose wages are W with a deferral D gets the same worksheet earned income, deductions, federal filing requirement and Medicaid filing requirement as a twin with wages max(W - D, 0) and no - deferral. Only W-2 box 1 wages matter. + deferral, as long as the Schedule 1 line 15 deduction is the same for + both. Deferrals are still Social Security and Medicare wages, so near the + Social Security wage base they change self-employment tax and line 15; + the drawn wages and self-employment income stay far below it. 2. Bounds: the basic standard deduction of a unit whose head or spouse can be claimed is at least the section 63(c)(5)(A) amount and never more than the regular basic standard deduction for its filing status; for any other unit @@ -38,6 +42,11 @@ only wages, deferrals and interest, both `tax_unit_is_required_to_file` and `medicaid_person_is_required_to_file` equal Publication 501 (2025), Table 2, computed with W-2 box 1 wages as earned income. +6. Federal and Medicaid agree (2025): for every drawn single filer who can + be claimed (under 65, not blind), including self-employment and farm + income or loss, `medicaid_person_is_required_to_file` equals + `tax_unit_is_required_to_file`. Both apply section 6012(a)(1) through the + same limited standard deduction, including its line 15 subtraction. """ import numpy as np @@ -309,6 +318,13 @@ def test_worksheet_properties(drawn): ) ) assert single.any() + # 6. Federal and Medicaid agree for every single claimable filer. + all_single = ~joint & claimable + np.testing.assert_array_equal( + values["medicaid_head"][rows["base"]][all_single], + values["tax_unit_is_required_to_file"][rows["base"]][all_single], + err_msg="2025: Medicaid and federal filing tests differ", + ) for variable in ("tax_unit_is_required_to_file", "medicaid_head"): np.testing.assert_array_equal( values[variable][rows["base"]][single], diff --git a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.yaml b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.yaml index 940309a7e4a..cdb21d0fe03 100644 --- a/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.yaml +++ b/policyengine_us/tests/policy/baseline/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.yaml @@ -201,10 +201,12 @@ - name: Case 12, farm income is earned income, not unearned income. # The Form 1040 dependent worksheet counts Schedule 1 line 6 (farm income) - # as earned income. $2,000 of farm income is not unearned income over - # $1,350, and gross income of $2,000 is not more than $2,000 + $450. The - # section 6017 self-employment tax filing rule is not part of the section - # 6012(a)(1) test that 42 CFR 435.603(d)(2) uses. + # as earned income, net of the deductible part of self-employment tax + # (line 15): $2,000 - $2,000 x 0.9235 x 15.3% / 2 = $1,858.70. $2,000 of + # farm income is not unearned income over $1,350, and gross income of + # $2,000 is not more than $1,858.70 + $450 = $2,308.70. The section 6017 + # self-employment tax filing rule is not part of the section 6012(a)(1) + # test that 42 CFR 435.603(d)(2) uses. period: 2025 input: people: @@ -216,3 +218,35 @@ members: [person1] output: medicaid_person_is_required_to_file: false + +- name: Case 13, farm income counts net of the deductible part of self-employment tax. + # Worksheet earned income is $15,000 - $15,000 x 0.9235 x 15.3% / 2 = + # $13,940.28, so the limit is $13,940.28 + $450 = $14,390.28, below the + # $15,750 single amount. Gross income of $15,000 is more than that, so the + # dependent must file, as the federal test finds for the same filer. + period: 2025 + input: + people: + person1: + age: 17 + farm_operations_income: 15_000 + tax_units: + tax_unit: + members: [person1] + output: + medicaid_person_is_required_to_file: true + +- name: Case 14, self-employment income counts net of the deductible part of self-employment tax. + # Same arithmetic as Case 13 for $15,000 of Schedule C income: the limit + # is $14,390.28 and gross income of $15,000 is more than that. + period: 2025 + input: + people: + person1: + age: 17 + self_employment_income: 15_000 + tax_units: + tax_unit: + members: [person1] + output: + medicaid_person_is_required_to_file: true diff --git a/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income.yaml b/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income.yaml index 2f2ec8cd9f5..2d303c7ebde 100644 --- a/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income.yaml @@ -157,3 +157,26 @@ members: [head, spouse, child] output: standard_deduction_worksheet_earned_income: 13_000 + +- name: On a joint return one spouse's business loss offsets the other spouse's wages before the zero floor + # $5,000 of wages less the spouse's $3,000 loss is $2,000. + period: 2025 + input: + people: + head: + age: 30 + employment_income: 5_000 + is_tax_unit_head: true + spouse: + age: 30 + self_employment_income: -3_000 + is_tax_unit_spouse: true + tax_units: + tax_unit: + members: [head, spouse] + filing_status: JOINT + households: + household: + members: [head, spouse] + output: + standard_deduction_worksheet_earned_income: 2_000 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income_person.yaml b/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income_person.yaml new file mode 100644 index 00000000000..d7b5dc6b38c --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/deductions/standard/standard_deduction_worksheet_earned_income_person.yaml @@ -0,0 +1,35 @@ +- name: A person's wages count as reported in W-2 box 1, after a 401(k) deferral + # $10,000 - $6,000 = $4,000. + period: 2025 + input: + people: + person: + age: 17 + employment_income: 10_000 + traditional_401k_contributions: 6_000 + output: + standard_deduction_worksheet_earned_income_person: 4_000 + +- name: Farm income counts net of the deductible part of self-employment tax + # $15,000 - $15,000 x 0.9235 x 15.3% / 2 = $13,940.28. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + person: + age: 17 + farm_operations_income: 15_000 + output: + standard_deduction_worksheet_earned_income_person: 13_940.28 + +- name: A loss is kept, not floored, so a joint return can net it against the other spouse + # $1,000 of wages less a $5,000 business loss. + period: 2025 + input: + people: + person: + age: 17 + employment_income: 1_000 + self_employment_income: -5_000 + output: + standard_deduction_worksheet_earned_income_person: -4_000 diff --git a/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.py b/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.py index f22a25df229..b422c7a4013 100644 --- a/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.py +++ b/policyengine_us/variables/gov/hhs/medicaid/income/medicaid_person_is_required_to_file.py @@ -14,8 +14,10 @@ class medicaid_person_is_required_to_file(Variable): "https://www.irs.gov/publications/p501", "https://www.irs.gov/pub/irs-prior/p501--2025.pdf#page=4", # Form 1040 instructions: line 1a is Form(s) W-2, box 1 (PDF page 23), - # which leaves out elective deferrals (page 25). - # PDF pages 23, 25 + # which leaves out elective deferrals (page 25); the Standard + # Deduction Worksheet for Dependents' earned income subtracts Schedule + # 1, line 15 (page 35). + # PDF pages 23, 25, 35 "https://www.irs.gov/pub/irs-prior/i1040gi--2025.pdf#page=23", ) @@ -23,18 +25,20 @@ def formula(person, period, parameters): standard = parameters(period).gov.irs.deductions.standard filing_requirement = parameters(period).gov.irs.income.filing_requirement gross_income = person("medicaid_irs_gross_income", period) - # Earned income is wages as reported in Form W-2 box 1, which leave - # out elective deferrals, plus business and farm income: the gross - # income sources the IRS dependent worksheet counts as earned. A - # business or farm loss reduces it. - earned_income_sources = filing_requirement.dependent.earned_income_sources - earned_income = add(person, period, earned_income_sources) + # Earned income is figured as on the IRS dependent worksheet, which + # sets the limited standard deduction the gross income test compares + # against: W-2 box 1 wages (which leave out elective deferrals) plus + # business and farm income, minus the deductible part of + # self-employment tax, and not below zero. + earned_income = max_( + person("standard_deduction_worksheet_earned_income_person", period), 0 + ) # Unearned income is gross income other than earned income (IRS Pub. # 501, Table 2). Gross income counts each source's positive amount, so # subtract those sources' positive amounts: a business loss does not # turn other income into unearned income. earned_gross_income = 0 - for source in earned_income_sources: + for source in filing_requirement.dependent.earned_income_sources: earned_gross_income += max_(0, person(source, period)) unearned_income = max_(0, gross_income - earned_gross_income) diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income.py b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income.py index a63f9b9a89e..7901cba9354 100644 --- a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income.py +++ b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income.py @@ -10,29 +10,24 @@ class standard_deduction_worksheet_earned_income(Variable): "Earned income of the head and spouse on the Standard Deduction " "Worksheet for Dependents: wages from Form W-2 box 1, which leave out " "elective deferrals, plus business and farm income, minus the " - "deductible part of self-employment tax." + "deductible part of self-employment tax, and not below zero." ) definition_period = YEAR reference = ( "https://www.law.cornell.edu/uscode/text/26/63#c_5", - # Form 1040 instructions. Line 1a is the total of Form(s) W-2, box 1 - # (PDF page 23). An elective deferral "isn't included as income in - # box 1 of your Form W-2" (page 25). Worksheet footnote: "Generally, - # your earned income is the total of the amount(s) you reported on - # Form 1040 or 1040-SR, line 1z, and Schedule 1, lines 3, 6, 8r, 8t, - # and 8u minus the amount, if any, on Schedule 1, line 15" (page 34 - # in 2024, page 35 in 2025). - # PDF pages 23, 25, 34 - "https://www.irs.gov/pub/irs-prior/i1040gi--2024.pdf#page=23", - # PDF pages 23, 25, 35 - "https://www.irs.gov/pub/irs-prior/i1040gi--2025.pdf#page=23", + # Standard Deduction Worksheet for Dependents, Form 1040 instructions. + "https://www.irs.gov/pub/irs-prior/i1040gi--2024.pdf#page=34", + "https://www.irs.gov/pub/irs-prior/i1040gi--2025.pdf#page=35", + # Publication 501, Table 8, line 1: "Enter your earned income (defined + # below). If none, enter -0-." + "https://www.irs.gov/pub/irs-prior/p501--2025.pdf#page=26", ) def formula(tax_unit, period, parameters): - p = parameters(period).gov.irs.income.filing_requirement.dependent - # Form 1040 line 1z wages (irs_employment_income, after elective - # deferrals and other pretax payroll deductions) and Schedule 1 lines - # 3 and 6. A business or farm loss reduces the total. - earned_income = tax_unit_non_dep_add(tax_unit, period, p.earned_income_sources) - # Schedule 1, line 15: the deductible part of self-employment tax. - return max_(earned_income - tax_unit("self_employment_tax_ald", period), 0) + # The head's and spouse's amounts: a dependent's earnings belong on + # the dependent's own return. A joint return sums both spouses' + # amounts before the zero floor. + earned_income = tax_unit_non_dep_sum( + "standard_deduction_worksheet_earned_income_person", tax_unit, period + ) + return max_(earned_income, 0) diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income_person.py b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income_person.py new file mode 100644 index 00000000000..779c7bcb4a1 --- /dev/null +++ b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income_person.py @@ -0,0 +1,41 @@ +from policyengine_us.model_api import * + + +class standard_deduction_worksheet_earned_income_person(Variable): + value_type = float + entity = Person + label = ( + "Earned income for the standard deduction worksheet for dependents, by person" + ) + unit = USD + documentation = ( + "A person's earned income on the Standard Deduction Worksheet for " + "Dependents: wages from Form W-2 box 1, which leave out elective " + "deferrals, plus business and farm income, minus the deductible part " + "of their self-employment tax. Not floored at zero, so that on a " + "joint return one spouse's loss offsets the other's earnings." + ) + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/63#c_5", + # Form 1040 instructions. Line 1a is the total of Form(s) W-2, box 1 + # (PDF page 23). An elective deferral "isn't included as income in + # box 1 of your Form W-2" (page 25). Worksheet footnote: "Generally, + # your earned income is the total of the amount(s) you reported on + # Form 1040 or 1040-SR, line 1z, and Schedule 1, lines 3, 6, 8r, 8t, + # and 8u minus the amount, if any, on Schedule 1, line 15" (page 34 + # in 2024, page 35 in 2025). + # PDF pages 23, 25, 34 + "https://www.irs.gov/pub/irs-prior/i1040gi--2024.pdf#page=23", + # PDF pages 23, 25, 35 + "https://www.irs.gov/pub/irs-prior/i1040gi--2025.pdf#page=23", + ) + + def formula(person, period, parameters): + p = parameters(period).gov.irs.income.filing_requirement.dependent + # Form 1040 line 1z wages (irs_employment_income, after elective + # deferrals and other pretax payroll deductions) and Schedule 1 lines + # 3 and 6. A business or farm loss reduces the total. + earned_income = add(person, period, p.earned_income_sources) + # Schedule 1, line 15: the deductible part of self-employment tax. + return earned_income - person("self_employment_tax_ald_person", period) From 8c213d2036ffded32670eb83242f01d351d83661 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 19 Oct 2026 09:42:26 -0400 Subject: [PATCH 4/7] Describe the Medicaid line 15 change in the changelog fragment Co-Authored-By: Claude Opus 5.5 --- changelog.d/dependent-worksheet-w2-wages.fixed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/dependent-worksheet-w2-wages.fixed.md b/changelog.d/dependent-worksheet-w2-wages.fixed.md index 413163791d9..18e7c2a1411 100644 --- a/changelog.d/dependent-worksheet-w2-wages.fixed.md +++ b/changelog.d/dependent-worksheet-w2-wages.fixed.md @@ -1 +1 @@ -Use Form W-2 box 1 wages, which leave out elective deferrals, and farm income as earned income in the federal, Oregon and Hawaii standard deduction worksheets for dependents and in the Medicaid dependent filing test. +Use Form W-2 box 1 wages, which leave out elective deferrals, and farm income as earned income in the federal, Oregon and Hawaii standard deduction worksheets for dependents and in the Medicaid dependent filing test, which now also subtracts the deductible part of self-employment tax as the worksheet does. From 2b1fc7a39f0e1d9ebd78d7e566ed4d994e509b95 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 19 Oct 2026 12:00:25 -0400 Subject: [PATCH 5/7] Pin a fixed unit where line 15 alone decides the filing test Delta review of #10272 (P3): property 6 caught the previous head's Medicaid regression on only some seeds. A claimed single filer with $901 of farm profit and $450 of interest must file only because of the line 15 subtraction, so adding that unit to every batch makes the property fail on the old code for every seed. Co-Authored-By: Claude Opus 5.5 --- ...endent_worksheet_earned_income_invariants.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py b/policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py index 45a8e0cc5fb..da139ea1c6d 100644 --- a/policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py +++ b/policyengine_us/tests/core/test_dependent_worksheet_earned_income_invariants.py @@ -15,9 +15,11 @@ Hypothesis (any mix of claimability, wages, 401(k) deferrals, self-employment and farm income or loss, and interest, in Oregon, Hawaii or Texas) and runs each batch, with four variants of every unit, as one simulation for 2025 and -2026. Three fixed units, the review's case (a claimed single filer with -$10,000 of wages, a $6,000 deferral and $600 of interest) in each state, -start every batch so that each property has rows to check: +2026. Four fixed units start every batch so that each property has rows to +check: the review's case (a claimed single filer with $10,000 of wages, a +$6,000 deferral and $600 of interest) in each state, and a claimed single +filer with $901 of farm profit and $450 of interest, whose filing +requirement turns on the line 15 subtraction alone (property 6): 1. Deferral invariance: a unit whose wages are W with a deferral D gets the same worksheet earned income, deductions, federal filing requirement and @@ -175,6 +177,15 @@ def units(draw): "adults": [adult(True, 10_000, 6_000, 0, 0, 600)], } for state in STATES +] + [ + # Line 15 is $901 x 0.9235 x 15.3% / 2 = $63.65, so the limit is the + # $1,350 floor and gross income of $1,351 requires a return. Without the + # subtraction the limit would be $1,351 and no return would be required. + { + "filing_status": "SINGLE", + "state": "TX", + "adults": [adult(True, 0, 0, 0, 901, 450)], + } ] From 864b917313ff6131dbd422954d3c4be763f07f8c Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Tue, 20 Oct 2026 03:48:59 -0400 Subject: [PATCH 6/7] Keep disability filing property deferrals within annual limits --- .../tests/core/test_disability_filing_invariants.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/policyengine_us/tests/core/test_disability_filing_invariants.py b/policyengine_us/tests/core/test_disability_filing_invariants.py index e961964eb51..cc2617c1442 100644 --- a/policyengine_us/tests/core/test_disability_filing_invariants.py +++ b/policyengine_us/tests/core/test_disability_filing_invariants.py @@ -74,7 +74,8 @@ def filers(draw): is_blind=draw(st.booleans()), claimed_as_dependent_on_another_return=draw(st.booleans()), employment_income=wages, - traditional_401k_contributions=draw(st.integers(0, wages)), + # The 2024 elective-deferral limit is the smallest across YEARS. + traditional_401k_contributions=draw(st.integers(0, min(wages, 23_000))), self_employment_income=draw( st.one_of(st.just(0), st.integers(-10_000, 30_000)) ), From 6d892f14cf5442df49cc62a69167301f25e644cf Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Tue, 20 Oct 2026 12:20:25 -0400 Subject: [PATCH 7/7] Avoid mutating cached dependent worksheet income --- .../standard_deduction_worksheet_earned_income_person.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income_person.py b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income_person.py index 21015272bdb..5a05312d207 100644 --- a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income_person.py +++ b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/standard_deduction/standard_deduction_worksheet_earned_income_person.py @@ -40,6 +40,6 @@ def formula(person, period, parameters): earned_income = add(person, period, p.earned_income_sources) # Form 1040 line 1h disability pensions are part of line 1z, but # are modeled separately from irs_employment_income. - earned_income += person("earned_disability_benefits", period) + earned_income = earned_income + person("earned_disability_benefits", period) # Schedule 1, line 15: the deductible part of self-employment tax. return earned_income - person("self_employment_tax_ald_person", period)