diff --git a/changelog.d/fix-sehi-employer-plan-exclusion.fixed.md b/changelog.d/fix-sehi-employer-plan-exclusion.fixed.md new file mode 100644 index 00000000000..8382ec25a13 --- /dev/null +++ b/changelog.d/fix-sehi-employer-plan-exclusion.fixed.md @@ -0,0 +1 @@ +Leave out of the self-employed health insurance deduction the premiums of a person who, or whose spouse on a joint return, is eligible for a subsidized employer health plan (26 U.S.C. 162(l)(2)(B), Form 7206 line 1). diff --git a/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/self_employed_health_insurance_employer_plan_eligible.yaml b/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/self_employed_health_insurance_employer_plan_eligible.yaml new file mode 100644 index 00000000000..f6699e1a4c1 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/self_employed_health_insurance_employer_plan_eligible.yaml @@ -0,0 +1,419 @@ +# 26 U.S.C. 162(l)(2)(B) and Form 7206 line 1 leave out premiums for any month +# the taxpayer can join a subsidized plan of an employer of the taxpayer, their +# spouse, a dependent or a child under 27. The model covers the taxpayer's and +# spouse's employers. +# Profit of $50,000 keeps the earned income limit (Form 7206 line 13) above the +# $6,000 of premiums, so the deduction equals the premiums that count. + +- name: No employer plan, so all premiums count. + period: 2025 + input: + is_self_employed: true + self_employment_income: 50_000 + health_insurance_premiums: 6_000 + output: + self_employed_health_insurance_employer_plan_eligible: false + self_employed_health_insurance_premiums: 6_000 + self_employed_health_insurance_ald_person: 6_000 + +- name: Enrolled in employer coverage, so no premiums count. + period: 2025 + input: + is_self_employed: true + self_employment_income: 50_000 + health_insurance_premiums: 6_000 + has_esi: true + output: + self_employed_health_insurance_employer_plan_eligible: true + self_employed_health_insurance_premiums: 0 + self_employed_health_insurance_ald_person: 0 + +- name: Offered employer coverage without enrolling, so no premiums count. + period: 2025 + input: + is_self_employed: true + self_employment_income: 50_000 + health_insurance_premiums: 6_000 + offered_aca_disqualifying_esi: true + output: + self_employed_health_insurance_employer_plan_eligible: true + self_employed_health_insurance_premiums: 0 + self_employed_health_insurance_ald_person: 0 + +- name: An employer pays part of the premiums, so no premiums count. + period: 2025 + input: + is_self_employed: true + self_employment_income: 50_000 + health_insurance_premiums: 6_000 + employer_contribution_to_health_insurance_premiums_category: SOME + output: + self_employed_health_insurance_employer_plan_eligible: true + self_employed_health_insurance_premiums: 0 + self_employed_health_insurance_ald_person: 0 + +- name: The spouse's employer plan bars a joint filer's deduction. + period: 2025 + input: + people: + head: + age: 45 + is_self_employed: true + self_employment_income: 50_000 + health_insurance_premiums: 6_000 + spouse: + age: 45 + employment_income: 40_000 + has_esi: true + tax_units: + tax_unit: + members: [head, spouse] + marital_units: + marital_unit: + members: [head, spouse] + households: + household: + members: [head, spouse] + state_code: TX + output: + self_employed_health_insurance_employer_plan_eligible: [true, true] + self_employed_health_insurance_premiums: [0, 0] + self_employed_health_insurance_ald: 0 + # Half of SE tax: 50,000 x 0.9235 x 0.153 / 2 = 3,532.3875. + # AGI: 50,000 + 40,000 - 3,532.3875 = 86,467.6125. + adjusted_gross_income: 86_467.61 + +- name: The spouse's employer plan also bars the deduction on a joint return without explicit marital units. + period: 2025 + input: + people: + head: + age: 45 + is_self_employed: true + self_employment_income: 50_000 + health_insurance_premiums: 6_000 + spouse: + age: 45 + employment_income: 40_000 + has_esi: true + tax_units: + tax_unit: + members: [head, spouse] + households: + household: + members: [head, spouse] + state_code: TX + output: + self_employed_health_insurance_premiums: [0, 0] + self_employed_health_insurance_ald: 0 + +- name: A housemate's employer plan does not bar a single filer's deduction. + period: 2025 + input: + people: + filer: + age: 45 + is_self_employed: true + self_employment_income: 50_000 + health_insurance_premiums: 6_000 + housemate: + age: 45 + employment_income: 40_000 + has_esi: true + tax_units: + filer_unit: + members: [filer] + housemate_unit: + members: [housemate] + households: + household: + members: [filer, housemate] + state_code: TX + output: + self_employed_health_insurance_employer_plan_eligible: [false, true] + self_employed_health_insurance_premiums: [6_000, 0] + self_employed_health_insurance_ald: [6_000, 0] + +- name: A dependent's ESI flag leaves the parents' employer-plan eligibility clear. + period: 2025 + input: + people: + head: + age: 50 + is_self_employed: true + self_employment_income: 50_000 + health_insurance_premiums: 6_000 + spouse: + age: 50 + child: + age: 20 + is_tax_unit_dependent: true + is_full_time_student: true + employment_income: 5_000 + has_esi: true + tax_units: + tax_unit: + members: [head, spouse, child] + marital_units: + marital_unit: + members: [head, spouse] + child_marital_unit: + members: [child] + households: + household: + members: [head, spouse, child] + state_code: TX + output: + # A dependent's ESI flag can describe a parent's employer plan, so it + # does not establish access through the dependent's own employer. + self_employed_health_insurance_employer_plan_eligible: [false, false, false] + self_employed_health_insurance_premiums: [6_000, 0, 0] + self_employed_health_insurance_ald: 6_000 + +- name: A parent's employer plan does not bar a self-employed dependent's own deduction. + period: 2025 + input: + people: + head: + age: 50 + employment_income: 80_000 + has_esi: true + child: + age: 22 + is_tax_unit_dependent: true + is_full_time_student: true + is_self_employed: true + self_employment_income: 3_000 + health_insurance_premiums: 1_000 + tax_units: + tax_unit: + members: [head, child] + households: + household: + members: [head, child] + state_code: TX + output: + self_employed_health_insurance_employer_plan_eligible: [true, false] + self_employed_health_insurance_premiums: [0, 1_000] + # Half of the child's SE tax: 3,000 x 0.9235 x 0.153 / 2 = 211.94325. + # The earned income limit is 3,000 - 211.94325 = 2,788.05675. + # The child deducts min(1,000, 2,788.05675) = 1,000. + self_employed_health_insurance_ald_person: [0, 1_000] + +- name: A dependent's employer offer flag leaves premiums for their own policy deductible. + period: 2025 + input: + people: + head: + age: 50 + employment_income: 80_000 + has_esi: true + child: + age: 22 + is_tax_unit_dependent: true + is_full_time_student: true + is_self_employed: true + self_employment_income: 3_000 + health_insurance_premiums: 1_000 + offered_aca_disqualifying_esi: true + tax_units: + tax_unit: + members: [head, child] + households: + household: + members: [head, child] + state_code: TX + output: + # The parent's ESI flag counts; the dependent's offer or enrollment + # flag does not. The parent has no self-employed premiums: base = 0. + # Half of the child's SE tax: 3,000 x 0.9235 x 0.153 / 2 = 211.94325. + # Earned income limit: 3,000 - 211.94325 = 2,788.05675. + # The child's base is 1,000; min(1,000, 2,788.05675) = 1,000. + self_employed_health_insurance_employer_plan_eligible: [true, false] + self_employed_health_insurance_premiums: [0, 1_000] + self_employed_health_insurance_ald_person: [0, 1_000] + +- name: A dependent's ESI flag leaves premiums for their own policy deductible. + period: 2025 + input: + people: + head: + age: 50 + employment_income: 80_000 + has_esi: true + child: + age: 22 + is_tax_unit_dependent: true + is_full_time_student: true + is_self_employed: true + self_employment_income: 3_000 + health_insurance_premiums: 1_000 + has_esi: true + tax_units: + tax_unit: + members: [head, child] + households: + household: + members: [head, child] + state_code: TX + output: + # The parent's ESI flag counts; the dependent's offer or enrollment + # flag does not. The parent has no self-employed premiums: base = 0. + # Half of the child's SE tax: 3,000 x 0.9235 x 0.153 / 2 = 211.94325. + # Earned income limit: 3,000 - 211.94325 = 2,788.05675. + # The child's base is 1,000; min(1,000, 2,788.05675) = 1,000. + self_employed_health_insurance_employer_plan_eligible: [true, false] + self_employed_health_insurance_premiums: [0, 1_000] + self_employed_health_insurance_ald_person: [0, 1_000] + +- name: A dependent's own employer contribution bars their deduction without barring the parent. + period: 2025 + input: + people: + head: + age: 50 + employment_income: 80_000 + child: + age: 22 + is_tax_unit_dependent: true + is_full_time_student: true + is_self_employed: true + self_employment_income: 3_000 + health_insurance_premiums: 1_000 + employer_contribution_to_health_insurance_premiums_category: SOME + tax_units: + tax_unit: + members: [head, child] + households: + household: + members: [head, child] + state_code: TX + output: + # The parent has no coverage flags and no self-employed premiums. + # SOME establishes the dependent's own employer contribution, so + # their 1,000 of premiums yield a base of 0 and a deduction of 0. + # Half of SE tax: 3,000 x 0.9235 x 0.153 / 2 = 211.94325. + # The earned income limit, 3,000 - 211.94325 = 2,788.05675, + # exceeds the base; min(0, 2,788.05675) = 0. + self_employed_health_insurance_employer_plan_eligible: [false, true] + self_employed_health_insurance_premiums: [0, 0] + self_employed_health_insurance_ald_person: [0, 0] + +- name: An employer pays all premiums for a plan, so the filer's own-policy premiums do not count. + period: 2025 + input: + is_self_employed: true + self_employment_income: 50_000 + health_insurance_premiums: 6_000 + employer_contribution_to_health_insurance_premiums_category: ALL + output: + # ALL establishes employer support, so the filer excludes all 6,000. + # Half of SE tax: 50,000 x 0.9235 x 0.153 / 2 = 3,532.3875. + # The limit, 50,000 - 3,532.3875 = 46,467.6125, exceeds the base. + # The filer deducts min(0, 46,467.6125) = 0. + self_employed_health_insurance_employer_plan_eligible: true + self_employed_health_insurance_premiums: 0 + self_employed_health_insurance_ald_person: 0 + +- name: The spouse's medical plan bars medical premiums while long-term care premiums remain deductible. + period: 2025 + input: + people: + head: + age: 45 + is_self_employed: true + self_employment_income: 50_000 + health_insurance_premiums: 6_000 + long_term_health_insurance_premiums: 500 + spouse: + age: 43 + employment_income: 40_000 + has_esi: true + tax_units: + tax_unit: + members: [head, spouse] + marital_units: + marital_unit: + members: [head, spouse] + households: + household: + members: [head, spouse] + state_code: TX + output: + # The spouse's ESI bars both filers' medical premiums: line 1 = 0. + self_employed_health_insurance_employer_plan_eligible: [true, true] + self_employed_health_insurance_premiums: [0, 0] + # At age 45, the head's 2025 long-term care limit exceeds 500. + # Line 2 = 500; half of SE tax = 50,000 x 0.9235 x 0.153 / 2 + # = 3,532.3875; earned income limit = 46,467.6125. + # The head deducts min(0 + 500, 46,467.6125) = 500. + self_employed_health_insurance_ald_person: [500, 0] + self_employed_health_insurance_ald: 500 + # The head deducts 500 - min(0, 500) = 500 of long-term care premiums. + self_employed_health_insurance_ald_long_term_care_part: [500, 0] + # AGI = 50,000 + 40,000 - 3,532.3875 - 500 = 85,967.6125. + adjusted_gross_income: 85_967.61 + # Schedule A retains 6,000 + 500 - 500 = 6,000 before its floor. + itemized_medical_expenses: 6_000 + +# Notice 2008-1, examples 2-4, and Form 7206 lines 1, 11 and 14: +# a more-than-2% shareholder can deduct premiums paid by their S corporation. +# The 66,000 of box 1 wages include 6,000 of premiums; box 5 excludes them. +- name: A shareholder deducts own-business premiums when coverage flags are clear. + period: 2025 + input: + is_self_employed: true + employment_income: 66_000 + s_corp_shareholder_medicare_wages: 60_000 + self_employed_health_insurance_plan_business: S_CORPORATION + health_insurance_premiums: 6_000 + employer_contribution_to_health_insurance_premiums_category: NONE + has_esi: false + offered_aca_disqualifying_esi: false + output: + self_employed_health_insurance_employer_plan_eligible: false + self_employed_health_insurance_premiums: 6_000 + self_employed_health_insurance_earned_income_limit: 60_000 + # Line 14 = min(6,000, 60,000) = 6,000; no self-employment tax. + self_employed_health_insurance_ald_person: 6_000 + # AGI = box 1 wages 66,000 - deduction 6,000 = 60,000. + adjusted_gross_income: 60_000 + +- name: An unrelated employer's contribution bars a shareholder's own-business premiums. + period: 2025 + input: + is_self_employed: true + employment_income: 66_000 + s_corp_shareholder_medicare_wages: 60_000 + self_employed_health_insurance_plan_business: S_CORPORATION + health_insurance_premiums: 6_000 + employer_contribution_to_health_insurance_premiums_category: ALL + output: + # ALL describes another employer's subsidized plan, not the corporation's + # own payment. Congress bars line 1 under section 162(l)(2)(B); + # min(0, 60,000) = 0. + self_employed_health_insurance_employer_plan_eligible: true + self_employed_health_insurance_premiums: 0 + self_employed_health_insurance_earned_income_limit: 60_000 + self_employed_health_insurance_ald_person: 0 + adjusted_gross_income: 66_000 + +- name: The model bars a shareholder who sets ESI for their own S corporation's plan. + period: 2025 + input: + is_self_employed: true + employment_income: 66_000 + s_corp_shareholder_medicare_wages: 60_000 + self_employed_health_insurance_plan_business: S_CORPORATION + health_insurance_premiums: 6_000 + employer_contribution_to_health_insurance_premiums_category: NONE + has_esi: true + output: + # Known input limitation: has_esi does not identify whose plan covers the + # filer. The model bars line 1 even for the qualifying own-business plan, + # which the IRS permits in Notice 2008-1: base = 0; min(0, 60,000) = 0. + self_employed_health_insurance_employer_plan_eligible: true + self_employed_health_insurance_premiums: 0 + self_employed_health_insurance_earned_income_limit: 60_000 + self_employed_health_insurance_ald_person: 0 + adjusted_gross_income: 66_000 diff --git a/policyengine_us/tests/unit/test_self_employed_health_insurance_employer_plan_properties.py b/policyengine_us/tests/unit/test_self_employed_health_insurance_employer_plan_properties.py new file mode 100644 index 00000000000..32a1ea786a3 --- /dev/null +++ b/policyengine_us/tests/unit/test_self_employed_health_insurance_employer_plan_properties.py @@ -0,0 +1,284 @@ +"""Properties of the employer-plan bar on the self-employed health insurance deduction. + +26 U.S.C. 162(l)(2)(B) and Form 7206 line 1 leave out premiums for any month +the taxpayer can join a subsidized plan of an employer of the taxpayer, their +spouse, a dependent or a child under 27. The model covers the taxpayer's and +spouse's employers and treats annual eligibility as full-year eligibility. For +the head and spouse, ESI, an offer or an employer contribution of SOME or ALL +counts as access through their own or their spouse's employer. Either filer's +flags bar both filers on a joint return. For tax unit dependents, only an +employer contribution of SOME or ALL counts; ESI and offer flags can describe +a parent's employer plan. + +Each batch places every drawn tax unit twice, once as drawn and once with every +coverage flag cleared, and runs as one vectorized baseline simulation. For +every tax unit and year: + +1. Reference: each person's premium base follows the flag interpretation + above: their premiums if they are self-employed and neither their own + eligibility nor a spouse's eligibility bars them, and 0 otherwise. Only + the head and spouse can pass eligibility to each other. +2. Bounds: 0 <= deduction <= premium base <= premiums. +3. Monotone: clearing the coverage flags never lowers a person's premium base + or deduction. +4. Differential: the generated units have wages and self-employment income + only, so the twins' AGI difference equals the difference in the head's + and spouse's deductions. This identity does not hold in general. With + Social Security income, taxable benefits can also change when the + deduction changes, so AGI can move by a different amount. + +The deterministic grid combines every head and spouse flag setting with a +dependent's ESI flag both clear and set, for a couple with a self-employed head. +Sources: https://www.law.cornell.edu/uscode/text/26/162#l_2_B and +https://www.irs.gov/pub/irs-prior/f7206--2025.pdf#page=1 (line 1). +""" + +import itertools + +import numpy as np +import pytest +from hypothesis import HealthCheck, given, settings +from hypothesis import strategies as st + +from policyengine_us import Simulation + +YEARS = [2024, 2025, 2026] +TOLERANCE = 0.01 +CONTRIBUTIONS = ["NONE", "SOME", "ALL", "NA"] +EMPLOYER_PAYS = {"SOME", "ALL"} +NO_FLAGS = {"has_esi": False, "offered": False, "contribution": "NONE"} + + +def every_year(value): + return {year: value for year in YEARS} + + +def own_eligible(flags, filer=True): + return flags["contribution"] in EMPLOYER_PAYS or ( + filer and (flags["has_esi"] or flags["offered"]) + ) + + +def person_inputs(age, member, flags, dependent=False): + inputs = { + "age": every_year(age), + "is_self_employed": every_year(member["self_employed"]), + "self_employment_income": every_year(member["profit"]), + "employment_income": every_year(member["wages"]), + "health_insurance_premiums": every_year(member["premiums"]), + "has_esi": every_year(flags["has_esi"]), + "offered_aca_disqualifying_esi": every_year(flags["offered"]), + "employer_contribution_to_health_insurance_premiums_category": every_year( + flags["contribution"] + ), + } + if dependent: + inputs["is_tax_unit_dependent"] = every_year(True) + return inputs + + +def build_situation(units): + """Each unit twice: as drawn, then with every coverage flag cleared.""" + people, tax_units, households = {}, {}, {} + rows = [] # per person: (premiums, self-employed, expected base, unit, twin) + unit_index = 0 + for twin in (False, True): + for i, unit in enumerate(units): + name = f"u{i}_{'twin' if twin else 'drawn'}" + members = unit["members"] + flags = [NO_FLAGS if twin else m["flags"] for m in members] + filers = [True, unit["joint"]][: min(2, len(members))] + filers += [False] * (len(members) - len(filers)) + names = [] + for j, (member, member_flags) in enumerate(zip(members, flags)): + person = f"{name}_p{j}" + names.append(person) + is_dependent = not filers[j] + people[person] = person_inputs( + member["age"], member, member_flags, dependent=is_dependent + ) + for j, member in enumerate(members): + own = own_eligible(flags[j], filers[j]) + other_filer = any( + own_eligible(flags[k]) + for k in range(len(members)) + if k != j and filers[k] + ) + eligible = own or (filers[j] and other_filer) + base = ( + member["premiums"] + if member["self_employed"] and not eligible + else 0.0 + ) + rows.append( + ( + member["premiums"], + member["self_employed"], + base, + unit_index, + twin, + ) + ) + tax_units[name] = {"members": names} + households[name] = {"members": names, "state_code": every_year("TX")} + unit_index += 1 + situation = {"people": people, "tax_units": tax_units, "households": households} + premiums, self_employed, base, unit, twin = (np.array(c) for c in zip(*rows)) + return situation, premiums.astype(float), base.astype(float), unit, twin + + +def check_batch(units): + situation, premiums, expected_base, unit, twin = build_situation(units) + sim = Simulation(situation=situation) + n = len(units) + for year in YEARS: + base = sim.calculate("self_employed_health_insurance_premiums", year) + deduction = sim.calculate("self_employed_health_insurance_ald_person", year) + # 1. Reference. + np.testing.assert_allclose(base, expected_base, atol=TOLERANCE) + # 2. Bounds. + assert np.all(deduction >= -TOLERANCE) + assert np.all(deduction <= base + TOLERANCE) + assert np.all(base <= premiums + TOLERANCE) + # 3. Monotone: the twin (no flags) of each person has at least as much. + drawn, cleared = ~twin, twin + assert np.all(base[cleared] >= base[drawn] - TOLERANCE) + assert np.all(deduction[cleared] >= deduction[drawn] - TOLERANCE) + # 4. Differential: with wages and self-employment income only, + # AGI moves through the head's and spouse's deductions, which + # `self_employed_health_insurance_ald` sums. + agi = sim.calculate("adjusted_gross_income", year) + filer_deduction = sim.calculate("self_employed_health_insurance_ald", year) + np.testing.assert_allclose( + agi[:n] - agi[n:], + filer_deduction[n:] - filer_deduction[:n], + atol=TOLERANCE, + ) + + +flags_strategy = st.fixed_dictionaries( + { + "has_esi": st.booleans(), + "offered": st.booleans(), + "contribution": st.sampled_from(CONTRIBUTIONS), + } +) +money = st.one_of(st.sampled_from([0, 1, 6_000]), st.integers(0, 40_000)).map(float) +profit = st.one_of( + st.sampled_from([-5_000, 0, 433, 434, 50_000]), st.integers(-20_000, 250_000) +).map(float) + + +def member_strategy(age): + return st.fixed_dictionaries( + { + "age": st.just(age), + "self_employed": st.booleans(), + "profit": profit, + "wages": st.one_of(st.just(0.0), money), + "premiums": money, + "flags": flags_strategy, + } + ) + + +unit_strategy = st.builds( + lambda joint, head, spouse, dependents: { + "joint": joint, + "members": [head] + ([spouse] if joint else []) + dependents, + }, + st.booleans(), + member_strategy(45), + member_strategy(43), + st.lists(member_strategy(19), max_size=2), +) +SETTINGS = dict( + max_examples=15, + deadline=None, + derandomize=True, + suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large], +) + + +@settings(**SETTINGS) +@given(st.lists(unit_strategy, min_size=4, max_size=12)) +def test_premium_base_matches_the_form_7206_reference(units): + check_batch(units) + + +ALL_FLAGS = [ + {"has_esi": has_esi, "offered": offered, "contribution": contribution} + for has_esi, offered, contribution in itertools.product( + [False, True], [False, True], CONTRIBUTIONS + ) +] + + +def grid_units(): + def member(age, self_employed, flags, premiums): + return { + "age": age, + "self_employed": self_employed, + "profit": 50_000.0 if self_employed else 0.0, + "wages": 0.0 if self_employed else 30_000.0, + "premiums": premiums, + "flags": flags, + } + + return [ + { + "joint": True, + "members": [ + member(45, True, head, 6_000.0), + member(43, False, spouse, 0.0), + # Half of SE tax: 50,000 x 0.9235 x 0.153 / 2 = 3,532.3875. + # Earned income limit: 50,000 - 3,532.3875 = 46,467.6125. + # A dependent's ESI flag leaves the 1,000 of premiums + # deductible: min(1,000, 46,467.6125) = 1,000. + member(19, True, dependent, 1_000.0), + ], + } + for head, spouse, dependent in itertools.product( + ALL_FLAGS, ALL_FLAGS, [NO_FLAGS, {**NO_FLAGS, "has_esi": True}] + ) + ] + + +@pytest.fixture(scope="module") +def grid(): + units = grid_units() + situation, premiums, expected_base, unit, twin = build_situation(units) + return Simulation(situation=situation), units, expected_base, twin + + +@pytest.mark.parametrize("year", YEARS) +def test_grid_bars_on_head_or_spouse_coverage_only(grid, year): + sim, units, expected_base, twin = grid + base = sim.calculate("self_employed_health_insurance_premiums", year) + np.testing.assert_allclose(base, expected_base, atol=TOLERANCE) + head_base = base[~twin].reshape(len(units), 3)[:, 0] + barred = np.array( + [ + own_eligible(u["members"][0]["flags"]) + or own_eligible(u["members"][1]["flags"]) + for u in units + ] + ) + # The head's premiums count exactly when neither filer is eligible; the + # dependent's coverage never matters. + np.testing.assert_allclose(head_base, np.where(barred, 0, 6_000), atol=TOLERANCE) + # Guard against a vacuous pass. + assert barred.any() and (~barred).any() + + +@pytest.mark.parametrize("year", YEARS) +def test_grid_deduction_moves_agi_one_for_one(grid, year): + sim, units, _, twin = grid + n = len(units) + agi = sim.calculate("adjusted_gross_income", year) + deduction = sim.calculate("self_employed_health_insurance_ald", year) + np.testing.assert_allclose( + agi[:n] - agi[n:], deduction[n:] - deduction[:n], atol=TOLERANCE + ) + # The twins all deduct the full $6,000; the earned income limit is higher. + np.testing.assert_allclose(deduction[n:], 6_000, atol=TOLERANCE) diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/self_employed_health_insurance_employer_plan_eligible.py b/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/self_employed_health_insurance_employer_plan_eligible.py new file mode 100644 index 00000000000..fd7aebe9ab9 --- /dev/null +++ b/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/self_employed_health_insurance_employer_plan_eligible.py @@ -0,0 +1,94 @@ +from policyengine_us.model_api import * + + +class self_employed_health_insurance_employer_plan_eligible(Variable): + value_type = bool + entity = Person + label = "Eligible for a subsidized employer health plan (self-employed health insurance deduction)" + documentation = ( + "The model identifies people whose employer-plan eligibility bars " + "their Form 7206 line 1 deduction under 26 U.S.C. 162(l)(2)(B). For " + "the head and spouse, the model counts has_esi, " + "offered_aca_disqualifying_esi, or employer contributions of SOME or " + "ALL as access through their own or their spouse's employer. The " + "model bars both joint filers if either meets that test. For tax unit " + "dependents, the model counts only their own employer contributions " + "of SOME or ALL. It ignores their enrollment and offer flags because " + "those inputs can describe a parent's plan. Treasury includes related " + "individuals in employer offers under 26 CFR 1.36B-2(c)(3)(i)(A); " + "Congress does not list a parent's employer for the dependent's " + "deduction. The model misses a dependent's own subsidized employer " + "enrollment or offer without contributions of SOME or ALL. Entering " + "a parent's family-plan contribution on the dependent instead bars " + "the dependent, because the model reads it as their own employer's " + "contribution. A qualifying plan established by the person's own " + "partnership, or S corporation in which they own more than 2%, does " + "not trigger the statutory employer-plan bar (sections 162(l)(5) and " + "1372(a) and Notice 2008-1 for S corporations; the Form 7206 " + "instructions for partners). Enter that business's eligible premium " + "payments or reimbursements in health_insurance_premiums, without " + "recording those payments as employer contributions of SOME or ALL. " + "Setting has_esi or offered_aca_disqualifying_esi for that plan still " + "bars a filer's deduction in the model, because the inputs cannot " + "distinguish it from another employer's plan. Retain flags for " + "subsidized coverage through an unrelated employer. Keep coverage " + "flags accurate for ACA calculations; the current inputs cannot " + "represent every own-business plan for both calculations. " + "The model assumes a subsidy when a filer has ESI or an " + "ACA-disqualifying offer, and assumes that each joint filer can join " + "the other's plan. The inputs identify neither the employer " + "maintaining a plan nor its subsidy or family eligibility. The model " + "cannot distinguish an unsubsidized plan, a spouse's plan the " + "taxpayer cannot join, or a parent's plan for a nondependent filer, " + "such as a 25-year-old. It misses unaffordable subsidized offers " + "because offered_aca_disqualifying_esi covers only affordable, " + "minimum-value offers. No input records a QSEHRA; the model counts " + "one only through the contribution category. Congress bars premiums " + "month by month; the model applies annual eligibility to the whole " + "year. The model cannot see a separately filing spouse in another tax " + "unit or establish the taxpayer's access to a dependent's or under-27 " + "child's employer plan. The model would create a cycle if it read " + "filing status here, because that status depends on dependents' " + "incomes and this deduction. Congress applies separate eligibility " + "tests to medical and long-term care plans under section " + "162(l)(2)(B)(i)-(ii). The model bars only line 1 premiums because no " + "input records employer long-term care plan eligibility; eligible " + "long-term care premiums still enter the deduction on line 2." + ) + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/162#l_2_B", + "https://www.irs.gov/pub/irs-prior/f7206--2025.pdf#page=1", # Line 1, first bullet + # Plans established under a partnership or an S corporation + "https://www.irs.gov/pub/irs-prior/i7206--2025.pdf#page=1", + "https://www.irs.gov/pub/irs-prior/i7206--2025.pdf#page=2", # Other coverage + "https://www.irs.gov/pub/irs-prior/i1040gi--2022.pdf#page=88", # Line 17, before Form 7206 + "https://www.ecfr.gov/current/title-26/section-1.36B-2#p-1.36B-2(c)(3)(i)(A)", + # PDF pages 3-4: own-business plans and the other-coverage condition + "https://www.irs.gov/pub/irs-drop/n-08-01.pdf#page=3", + ) + + def formula(person, period, parameters): + contribution = person( + "employer_contribution_to_health_insurance_premiums_category", + period, + ) + contribution_status = contribution.possible_values + employer_pays = (contribution == contribution_status.SOME) | ( + contribution == contribution_status.ALL + ) + filer = person("is_tax_unit_head_or_spouse", period) + # Read filers' enrollment and offer flags as access through their own + # or spouse's employer. A dependent's flags can describe a parent's + # plan, so require their own employer's contribution instead. + own = employer_pays | ( + filer + & ( + person("has_esi", period) + | person("offered_aca_disqualifying_esi", period) + ) + ) + # Either joint filer's eligibility bars both filers. A dependent's + # employer contribution does not establish a parent's access. + filer_own = own & filer + return own | (filer & person.tax_unit.any(filer_own)) diff --git a/policyengine_us/variables/household/expense/health/employer_contribution_to_health_insurance_premiums_category.py b/policyengine_us/variables/household/expense/health/employer_contribution_to_health_insurance_premiums_category.py index 6ca48d23a44..d7daa46f69f 100644 --- a/policyengine_us/variables/household/expense/health/employer_contribution_to_health_insurance_premiums_category.py +++ b/policyengine_us/variables/household/expense/health/employer_contribution_to_health_insurance_premiums_category.py @@ -15,3 +15,19 @@ class employer_contribution_to_health_insurance_premiums_category(Variable): definition_period = YEAR possible_values = EmployerPremiumContribution default_value = EmployerPremiumContribution.NONE + documentation = ( + "The share of health insurance premiums paid by the person's employer. " + "For the self-employed health insurance deduction, enter a qualifying " + "plan's payments or reimbursements from the person's own partnership " + "or S corporation in health_insurance_premiums, without recording " + "those payments as employer contributions of SOME or ALL. This S " + "corporation treatment applies to shareholders who own more than 2%. " + "Retain contributions from an unrelated employer. See " + "self_employed_health_insurance_employer_plan_eligible for the " + "remaining coverage-flag limitations." + ) + reference = ( + "https://www.irs.gov/pub/irs-prior/i7206--2025.pdf#page=1", + # PDF pages 3-4 + "https://www.irs.gov/pub/irs-drop/n-08-01.pdf#page=3", + ) diff --git a/policyengine_us/variables/household/expense/health/health_insurance_premiums.py b/policyengine_us/variables/household/expense/health/health_insurance_premiums.py index 2dd3643c801..96b74e2e394 100644 --- a/policyengine_us/variables/household/expense/health/health_insurance_premiums.py +++ b/policyengine_us/variables/household/expense/health/health_insurance_premiums.py @@ -13,10 +13,20 @@ class health_insurance_premiums(Variable): uprating = "calibration.gov.hhs.cms.direct_purchase_premium_per_enrollee" documentation = ( "Annual person-paid health insurance premiums supplied directly as an " - "input, excluding premiums paid through pretax payroll deductions and " - "employer-paid premiums. Pretax payroll payments belong only in " + "input. Include eligible premium payments or reimbursements from " + "the person's own partnership or S corporation in which they own " + "more than 2%, as described in " + "self_employed_health_insurance_plan_business. The model treats " + "those payments as the person's own premiums. Exclude other " + "employer-paid premiums and pretax payroll deductions. Pretax " + "payroll payments belong only in " "pre_tax_health_insurance_premiums; the two sets are disjoint and total " "person-paid premiums equal their sum. This direct non-pretax amount is " "an alternative to the applicable decomposed non-pretax inputs, not an " "additional expense." ) + reference = ( + "https://www.irs.gov/pub/irs-prior/i7206--2025.pdf#page=1", + # PDF pages 3-4 + "https://www.irs.gov/pub/irs-drop/n-08-01.pdf#page=3", + ) diff --git a/policyengine_us/variables/household/expense/health/self_employed_health_insurance_plan_business.py b/policyengine_us/variables/household/expense/health/self_employed_health_insurance_plan_business.py index ce86f4cde10..21317654907 100644 --- a/policyengine_us/variables/household/expense/health/self_employed_health_insurance_plan_business.py +++ b/policyengine_us/variables/household/expense/health/self_employed_health_insurance_plan_business.py @@ -35,7 +35,16 @@ class self_employed_health_insurance_plan_business(Variable): "counts as established under the partnership or S corporation only " "when that business pays or reimburses the premiums and reports them " "as guaranteed payments or wages; enter those premiums in " - "health_insurance_premiums. A partner also includes those guaranteed " + "health_insurance_premiums. Do not record that business's payment " + "as an employer contribution of SOME or ALL for the self-employed " + "health insurance deduction. Setting has_esi or " + "offered_aca_disqualifying_esi for that plan still bars a filer's " + "deduction in the model; the inputs cannot distinguish it from " + "another employer's plan. Retain eligibility flags and contributions " + "for an unrelated employer's subsidized plan. Keep coverage flags " + "accurate for ACA calculations; the current inputs cannot represent " + "every own-business plan for both calculations. A partner also " + "includes those guaranteed " "payments in partnership_income, and in " "partnership_self_employment_net_earnings when the partnership " "reports them in K-1 box 14 code A; a shareholder includes the wages " diff --git a/policyengine_us/variables/household/expense/health/self_employed_health_insurance_premiums.py b/policyengine_us/variables/household/expense/health/self_employed_health_insurance_premiums.py index b548d91392b..e9194938bc5 100644 --- a/policyengine_us/variables/household/expense/health/self_employed_health_insurance_premiums.py +++ b/policyengine_us/variables/household/expense/health/self_employed_health_insurance_premiums.py @@ -7,13 +7,39 @@ class self_employed_health_insurance_premiums(Variable): label = "Self-employed health insurance premiums" unit = USD documentation = ( - "Annual person-paid health insurance premiums for plans covering " - "individuals not covered by employer-sponsored health insurance. Excludes " - "pretax payroll deductions and employer-paid premiums; pretax payroll " - "payments belong only in pre_tax_health_insurance_premiums. The pretax " - "and non-pretax sets are disjoint. Defaults to the direct non-pretax " - "health_insurance_premiums input for self-employed people." + "The model takes Form 7206 line 1 premiums from the non-pretax " + "health_insurance_premiums input. It excludes pretax payroll " + "deductions and employer-paid premiums, except eligible payments or " + "reimbursements from the person's own partnership or S corporation " + "in which they own more than 2% (Notice 2008-1 for S corporations; " + "the Form 7206 instructions for partners). Enter those " + "payments in health_insurance_premiums, without recording them as " + "employer contributions of SOME or ALL. Pretax payroll payments " + "belong only in pre_tax_health_insurance_premiums; the pretax and " + "non-pretax sets remain disjoint. The model excludes premiums when " + "self_employed_health_insurance_employer_plan_eligible holds. That " + "variable documents the annual coverage assumptions and the " + "own-business coverage flags that still trigger the model's bar. " + "Congress disallows a deduction for the part of Marketplace " + "premiums the premium tax credit pays under 26 U.S.C. 280C(g). " + "The model takes premiums as supplied and does not net the credit " + "it calculates out of them. Calculating the credit depends on AGI " + "and this deduction (policyengine-us #10124)." ) definition_period = YEAR defined_for = "is_self_employed" - adds = ["health_insurance_premiums"] + reference = ( + "https://www.law.cornell.edu/uscode/text/26/162#l", + "https://www.irs.gov/pub/irs-prior/f7206--2025.pdf#page=1", # Line 1 + # Plans established under a partnership or an S corporation + "https://www.irs.gov/pub/irs-prior/i7206--2025.pdf#page=1", + # PDF pages 3-4 + "https://www.irs.gov/pub/irs-drop/n-08-01.pdf#page=3", + ) + + def formula(person, period, parameters): + premiums = person("health_insurance_premiums", period) + employer_plan_eligible = person( + "self_employed_health_insurance_employer_plan_eligible", period + ) + return where(employer_plan_eligible, 0, premiums)