diff --git a/changelog.d/fix-dependent-deducted-health-premiums.fixed.md b/changelog.d/fix-dependent-deducted-health-premiums.fixed.md new file mode 100644 index 00000000000..4d18486fdaa --- /dev/null +++ b/changelog.d/fix-dependent-deducted-health-premiums.fixed.md @@ -0,0 +1 @@ +Removed premiums deducted by dependents as self-employed health insurance from their parents' Schedule A medical expenses. diff --git a/policyengine_us/tests/core/test_long_term_care_premium_properties.py b/policyengine_us/tests/core/test_long_term_care_premium_properties.py index a5359cd45d2..71b23db5478 100644 --- a/policyengine_us/tests/core/test_long_term_care_premium_properties.py +++ b/policyengine_us/tests/core/test_long_term_care_premium_properties.py @@ -22,12 +22,13 @@ medical part = min(filers' medical premiums, deduction); long-term care part = min(filers' eligible premiums, deduction - medical part); together they equal min(filers' medical + eligible premiums, deduction), and the - applied exclusion of a computed subtotal is their sum. + computed subtotal's applied exclusion also includes the medical parts of + dependents' own deductions. 3. Accounting: the subtotal is members' medical premiums - medical part + members' eligible premiums - long-term care part - dependents' own - long-term care parts + other expenses. A person's own long-term care part - is what that person's deduction leaves after their medical premiums, - limited to their eligible premiums. The long-term care premiums + medical and long-term care parts + other expenses. A person's own + long-term care part is what that person's deduction leaves after their + medical premiums, limited to their eligible premiums. The long-term care premiums inside it lie between what the dependents' own deductions left of their eligible premiums and all members' eligible premiums. 4. Conservation (derived deduction): every eligible premium is deducted once, @@ -294,6 +295,10 @@ def unit_sum(values): eligible * self_employed, person_deduction - np.minimum(health * self_employed, person_deduction), ) + dependent = ~filer.astype(bool) + dependent_medical_part = unit_sum( + np.minimum(health, person_deduction - own_long_term_care_part) * dependent + ) np.testing.assert_allclose( run["itemized_medical_expenses_excluded_premiums"], medical_part, @@ -311,15 +316,14 @@ def unit_sum(values): ) np.testing.assert_allclose( run["itemized_medical_expenses_applied_exclusion"], - medical_part + long_term_care_part, + medical_part + long_term_care_part + dependent_medical_part, atol=TOLERANCE, ) - # 3. Accounting identity for the subtotal, from the raw inputs. Each - # dependent's own deduction took that dependent's long-term care part. + # 3. Each dependent excludes the medical and long-term care premiums + # they deducted on their own return from the parents' subtotal. inside = run["itemized_medical_expenses_long_term_care_premiums"] all_eligible = unit_sum(eligible) - dependent = ~filer.astype(bool) dependents_part = unit_sum(own_long_term_care_part * dependent) np.testing.assert_allclose( inside, @@ -333,7 +337,11 @@ def unit_sum(values): subtotal = run["itemized_medical_expenses"] np.testing.assert_allclose( subtotal, - unit_sum(health) - medical_part + inside + unit_sum(other), + unit_sum(health) + - medical_part + - dependent_medical_part + + inside + + unit_sum(other), atol=TOLERANCE, ) @@ -344,7 +352,7 @@ def unit_sum(values): subtotal - unit_sum(other) + run["self_employed_health_insurance_ald"] - + dependents_part, + + unit_sum(person_deduction * dependent), unit_sum(health) + all_eligible, atol=TOLERANCE, ) diff --git a/policyengine_us/tests/core/test_medical_expense_premium_conservation.py b/policyengine_us/tests/core/test_medical_expense_premium_conservation.py index 387f788e431..a6fd0ea99b6 100644 --- a/policyengine_us/tests/core/test_medical_expense_premium_conservation.py +++ b/policyengine_us/tests/core/test_medical_expense_premium_conservation.py @@ -6,11 +6,15 @@ tax units. Premium inputs use payer attribution: a person's inputs include all premiums that person paid, including family coverage regardless of who is covered. -The federal conservation properties generate deductions within the filers' -paid premiums; beneficiary-assigned inputs cannot establish that invariant. +The federal conservation properties generate each deduction within the +deducting person's paid premiums, including eligible long-term care premiums. +Supplied filer deductions stay within the head's and spouse's paid pool. The independent accounting invariant is that Schedule A's premium base plus -the self-employed health insurance deduction never exceeds premiums paid. +every self-employed health insurance deduction never exceeds premiums paid. Non-premium medical expenses must remain available in full before the floor. +This accounting identity retains the existing inclusion of undeducted +dependent-paid premiums. Section 213(a) allows parents only expenses they paid; +the broader payer-attribution correction needs separate coverage. Examples use small vectorized simulations and a shared read-only reference system. Supplied and computed subtotal scenarios use separate simulations to @@ -38,17 +42,19 @@ def reference_system(): @st.composite def person_expenses(draw): - premiums = draw(st.integers(0, 25_000)) + premiums = draw(st.integers(0, 500_000)) / 100 direct = draw(st.booleans()) self_employed = draw(st.booleans()) - covered = draw(st.integers(0, premiums)) if self_employed else 0 + covered = draw(st.integers(0, round(premiums * 100))) / 100 if self_employed else 0 # A direct premium can also exercise the default derivation of the SE # premium input. Decomposed premiums need the covered subset explicitly. if direct and draw(st.booleans()): covered = None return { "premiums": premiums, - "other": draw(st.integers(0, 10_000)), + "long_term_care": draw(st.integers(0, 800_000)) / 100, + "age": draw(st.sampled_from([17, 40, 41, 50, 51, 60, 61, 70, 71])), + "other": draw(st.integers(0, 200_000)) / 100, "earnings": draw(st.integers(-25_000, 50_000)) if self_employed else 0, "self_employed": self_employed, "direct": direct, @@ -57,12 +63,20 @@ def person_expenses(draw): units = st.lists( - st.lists(person_expenses(), min_size=1, max_size=3), + st.lists(person_expenses(), min_size=1, max_size=5), min_size=2, max_size=4, ) +def _eligible_long_term_care(person): + limit = system.parameters( + f"{PERIOD}-01-01" + ).gov.irs.deductions.itemized.medical.long_term_care_premium_limit + age_limit = limit.calc(np.array([person.get("age", 40)]), right=True)[0] + return min(person.get("long_term_care", 0), age_limit) + + @st.composite def units_with_deduction(draw): members = draw(units) @@ -70,7 +84,19 @@ def units_with_deduction(draw): # Payer attribution puts parent-paid family premiums on that parent. # The head's and spouse's deduction covers their paid premium pool. A # dependent's own SE deduction belongs on their separate return. - draw(st.integers(0, sum(person["premiums"] for person in unit[:2]))) + draw( + st.integers( + 0, + round( + sum( + person["premiums"] + _eligible_long_term_care(person) + for person in unit[:2] + ) + * 100 + ), + ) + ) + / 100 for unit in members ] return members, deductions @@ -89,14 +115,15 @@ def _simulation(members, reference_system, deductions=None): else "health_insurance_premiums_without_medicare_part_b" ) values = { - "age": 12 if person_index == 2 else 40, + "age": person.get("age", 12 if person_index >= 2 else 40), "is_tax_unit_head": person_index == 0, "is_tax_unit_spouse": person_index == 1, - "is_tax_unit_dependent": person_index == 2, + "is_tax_unit_dependent": person_index >= 2, "is_self_employed": person["self_employed"], "self_employment_income": person["earnings"], "medicare_enrolled": False, premium_variable: person["premiums"], + "long_term_health_insurance_premiums": person.get("long_term_care", 0), "other_medical_expenses": person["other"], } if person["covered"] is not None: @@ -115,8 +142,10 @@ def _simulation(members, reference_system, deductions=None): "state_code": {PERIOD: "TX"}, } marital_units[f"marital_unit_{unit_index}"] = {"members": names[:2]} - for name in names[2:]: - marital_units[f"dependent_marital_unit_{unit_index}"] = {"members": [name]} + for person_index, name in enumerate(names[2:], start=2): + marital_units[f"dependent_marital_unit_{unit_index}_{person_index}"] = { + "members": [name] + } return Simulation( tax_benefit_system=reference_system, situation={ @@ -129,26 +158,78 @@ def _simulation(members, reference_system, deductions=None): def _assert_conservation(members, simulation): - paid = np.array([sum(person["premiums"] for person in unit) for unit in members]) + paid = np.array( + [ + sum(person["premiums"] + person.get("long_term_care", 0) for person in unit) + for unit in members + ] + ) + eligible_paid = np.array( + [ + sum( + person["premiums"] + _eligible_long_term_care(person) for person in unit + ) + for unit in members + ] + ) other = np.array([sum(person["other"] for person in unit) for unit in members]) - dependent_premiums = np.array( - [sum(person["premiums"] for person in unit[2:]) for unit in members] + medical_base = simulation.calculate("itemized_medical_expenses", PERIOD).astype( + np.float64 ) - medical_base = simulation.calculate("itemized_medical_expenses", PERIOD) - se_deduction = simulation.calculate("self_employed_health_insurance_ald", PERIOD) + se_deduction = simulation.calculate( + "self_employed_health_insurance_ald", PERIOD + ).astype(np.float64) + dependent_deductions = simulation.calculate( + "dependents_self_employed_health_insurance_ald", PERIOD + ).astype(np.float64) + all_deductions = se_deduction + dependent_deductions schedule_a_premium_use = medical_base - other - # Neither the SE deduction nor a different filing unit can consume the - # non-premium expenses. Check the bound separately from conservation. - assert (schedule_a_premium_use >= 0).all() - assert (schedule_a_premium_use >= dependent_premiums).all() - # The Form 7206 earnings limit leaves cents in the derived deduction, so - # the sums carry float32 rounding: allow a cent. - assert (schedule_a_premium_use + se_deduction <= paid + 0.01).all() - # All premiums here are otherwise eligible: unused premiums remain in - # Schedule A's base, even when earnings cap the SE deduction. + flat_people = [person for unit in members for person in unit] + medical_premiums = np.array([person["premiums"] for person in flat_people]) + eligible_care = np.array( + [_eligible_long_term_care(person) for person in flat_people] + ) + medical_exclusion_bound = simulation.calculate( + "self_employed_health_insurance_ald_excluded_premiums", PERIOD + ).astype(np.float64) + care_excluded = simulation.calculate( + "self_employed_health_insurance_ald_long_term_care_part", PERIOD + ).astype(np.float64) + person_deductions = simulation.calculate( + "self_employed_health_insurance_ald_person", PERIOD + ).astype(np.float64) + medical_excluded = np.minimum( + medical_exclusion_bound, np.maximum(0, person_deductions) - care_excluded + ) + unit_ends = np.cumsum([len(unit) for unit in members]) + unit_starts = np.concatenate(([0], unit_ends[:-1])) + expected_dependent_deductions = np.array( + [ + person_deductions[start + 2 : end].sum() + for start, end in zip(unit_starts, unit_ends) + ] + ) + np.testing.assert_allclose( + dependent_deductions, expected_dependent_deductions, rtol=0, atol=0.01 + ) + + # Each person can consume only their own premiums, across medical and + # long-term care coverage. A dependent cannot consume a sibling's costs. + assert (medical_excluded >= 0).all() + assert (medical_excluded <= medical_premiums + 0.01).all() + assert (care_excluded >= 0).all() + assert (care_excluded <= eligible_care + 0.01).all() + np.testing.assert_allclose( + medical_excluded + care_excluded, person_deductions, rtol=0, atol=0.01 + ) + # Preserve every non-premium expense and every eligible premium nobody + # deducts, including premiums above a dependent's earned income limit. + # Model arrays use float32, so compare the combined uses within one cent. + assert (medical_base >= other - 0.01).all() + assert (schedule_a_premium_use + all_deductions <= paid + 0.01).all() np.testing.assert_allclose( - schedule_a_premium_use + se_deduction, paid, rtol=0, atol=0.01 + schedule_a_premium_use + all_deductions, eligible_paid, rtol=0, atol=0.01 ) @@ -156,6 +237,8 @@ def _assert_conservation(members, simulation): [ dict( premiums=6_000, + long_term_care=600, + age=40, other=500, earnings=1_000, self_employed=True, @@ -164,6 +247,8 @@ def _assert_conservation(members, simulation): ), dict( premiums=2_000, + long_term_care=1_500, + age=51, other=300, earnings=5_000, self_employed=True, @@ -172,12 +257,34 @@ def _assert_conservation(members, simulation): ), dict( premiums=12_000, + long_term_care=700, + age=17, other=200, earnings=15_000, self_employed=True, direct=True, covered=None, ), + dict( + premiums=3_000.01, + long_term_care=480, + age=40, + other=200.01, + earnings=1_000, + self_employed=True, + direct=False, + covered=2_000, + ), + dict( + premiums=0, + long_term_care=600, + age=71, + other=100, + earnings=0, + self_employed=False, + direct=True, + covered=0, + ), ], [ dict( @@ -203,6 +310,7 @@ def test_premiums_are_not_duplicated_with_derived_se_deduction( @settings(max_examples=12, deadline=None, derandomize=True) @example(case=(EXAMPLE_UNITS, [8_000, 0])) +@example(case=(EXAMPLE_UNITS, [9_500, 0])) @given(case=units_with_deduction()) def test_premiums_are_not_duplicated_with_tax_unit_se_deduction(reference_system, case): members, deductions = case diff --git a/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses_excluded_dependent_premiums.yaml b/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses_excluded_dependent_premiums.yaml new file mode 100644 index 00000000000..85a5576d653 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses_excluded_dependent_premiums.yaml @@ -0,0 +1,834 @@ +- name: Parents exclude the medical and long-term care premiums their dependent deducts. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 45 + employment_income: 50_000 + other_medical_expenses: 50_000 + is_tax_unit_head: true + spouse: + age: 45 + employment_income: 50_000 + is_tax_unit_spouse: true + dependent: + age: 20 + is_tax_unit_dependent: true + is_self_employed: true + self_employment_income: 10_000 + health_insurance_premiums: 3_000 + long_term_health_insurance_premiums: 500 + tax_units: + parents: + members: [head, spouse, dependent] + marital_units: + parents: + members: [head, spouse] + dependent: + members: [dependent] + households: + household: + members: [head, spouse, dependent] + state_code: TX + output: + # The age-20 limit admits 480 of the 500 long-term care premiums. + eligible_long_term_care_premiums: [0, 0, 480] + # 10,000 - (10,000 x 0.9235 x 0.153 / 2) exceeds 3,000 + 480. + self_employed_health_insurance_ald_person: [0, 0, 3_480] + self_employed_health_insurance_ald: 0 + dependents_self_employed_health_insurance_ald: 3_480 + itemized_medical_expenses_long_term_care_premiums: 0 + # 50,000 + 3,000 + 480 - 3,480 = 50,000. + itemized_medical_expenses: 50_000 + # The parents' AGI excludes the dependent's income and deduction. + adjusted_gross_income: 100_000 + medical_expense_deduction: 42_500 # 50,000 - 7.5% x 100,000. + tax_unit_itemizes: true + +- name: A filer excludes each premium payment once alongside a dependent deduction. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 45 + is_tax_unit_head: true + is_self_employed: true + self_employment_income: 20_000 + health_insurance_premiums: 5_000 + other_medical_expenses: 50_000 + dependent: + age: 20 + is_tax_unit_dependent: true + is_self_employed: true + self_employment_income: 10_000 + health_insurance_premiums: 3_000 + long_term_health_insurance_premiums: 500 + tax_units: + family: + members: [head, dependent] + marital_units: + head: + members: [head] + dependent: + members: [dependent] + households: + household: + members: [head, dependent] + state_code: TX + output: + eligible_long_term_care_premiums: [0, 480] + # 20,000 - (20,000 x 0.9235 x 0.153 / 2) = 18,587.045 > 5,000. + # 10,000 - (10,000 x 0.9235 x 0.153 / 2) = 9,293.5225 > 3,480. + self_employed_health_insurance_ald_person: [5_000, 3_480] + self_employed_health_insurance_ald: 5_000 + dependents_self_employed_health_insurance_ald: 3_480 + itemized_medical_expenses_excluded_premiums: 5_000 + itemized_medical_expenses_excluded_dependent_premiums: 3_000 + itemized_medical_expenses_long_term_care_premiums: 0 + # 5,000 + 3,000 + 480 - 5,000 - 3,000 - 480 + 50,000 = 50,000. + itemized_medical_expenses: 50_000 + +- name: Parents exclude premiums their dependent deducts against partnership earnings. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 45 + employment_income: 50_000 + other_medical_expenses: 50_000 + is_tax_unit_head: true + spouse: + age: 45 + employment_income: 50_000 + is_tax_unit_spouse: true + dependent: + age: 20 + is_tax_unit_dependent: true + is_self_employed: true + partnership_self_employment_net_earnings: 10_000 + health_insurance_premiums: 3_000 + long_term_health_insurance_premiums: 500 + tax_units: + parents: + members: [head, spouse, dependent] + marital_units: + parents: + members: [head, spouse] + dependent: + members: [dependent] + households: + household: + members: [head, spouse, dependent] + state_code: TX + output: + # The age-20 limit admits 480 of the 500 long-term care premiums. + eligible_long_term_care_premiums: [0, 0, 480] + # 10,000 - (10,000 x 0.9235 x 0.153 / 2) exceeds 3,000 + 480. + self_employed_health_insurance_ald_person: [0, 0, 3_480] + self_employed_health_insurance_ald: 0 + dependents_self_employed_health_insurance_ald: 3_480 + itemized_medical_expenses_long_term_care_premiums: 0 + # 50,000 + 3,000 + 480 - 3,480 = 50,000. + itemized_medical_expenses: 50_000 + # The parents' AGI excludes the dependent's income and deduction. + adjusted_gross_income: 100_000 + medical_expense_deduction: 42_500 # 50,000 - 7.5% x 100,000. + tax_unit_itemizes: true + +- name: Parents retain premiums above their dependent's earnings limit. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 45 + employment_income: 50_000 + other_medical_expenses: 50_000 + is_tax_unit_head: true + spouse: + age: 45 + employment_income: 50_000 + is_tax_unit_spouse: true + dependent: + age: 20 + is_tax_unit_dependent: true + is_self_employed: true + self_employment_income: 1_000 + health_insurance_premiums: 3_000 + long_term_health_insurance_premiums: 500 + tax_units: + parents: + members: [head, spouse, dependent] + marital_units: + parents: + members: [head, spouse] + dependent: + members: [dependent] + households: + household: + members: [head, spouse, dependent] + state_code: TX + output: + # 1,000 - (1,000 x 0.9235 x 0.153 / 2) = 929.35225. + self_employed_health_insurance_ald_person: [0, 0, 929.35225] + self_employed_health_insurance_ald: 0 + dependents_self_employed_health_insurance_ald: 929.35225 + # The deduction consumes medical premiums first, leaving all 480 LTC. + itemized_medical_expenses_long_term_care_premiums: 480 + # 50,000 + (3,000 - 929.35225) + 480 = 52,550.64775. + itemized_medical_expenses: 52_550.64775 + adjusted_gross_income: 100_000 + medical_expense_deduction: 45_050.64775 # 52,550.64775 - 7,500. + tax_unit_itemizes: true + +- name: Parents retain long-term care premiums above their dependent's earnings limit. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 45 + employment_income: 50_000 + other_medical_expenses: 50_000 + is_tax_unit_head: true + spouse: + age: 45 + employment_income: 50_000 + is_tax_unit_spouse: true + dependent: + age: 20 + is_tax_unit_dependent: true + is_self_employed: true + self_employment_income: 3_500 + health_insurance_premiums: 3_000 + long_term_health_insurance_premiums: 500 + tax_units: + parents: + members: [head, spouse, dependent] + marital_units: + parents: + members: [head, spouse] + dependent: + members: [dependent] + households: + household: + members: [head, spouse, dependent] + state_code: TX + output: + # 3,500 - (3,500 x 0.9235 x 0.153 / 2) = 3,252.732875. + self_employed_health_insurance_ald_person: [0, 0, 3_252.732875] + self_employed_health_insurance_ald: 0 + # Medical premiums consume 3,000; LTC consumes 252.732875 of 480. + itemized_medical_expenses_long_term_care_premiums: 227.267125 + itemized_medical_expenses: 50_227.267125 + medical_expense_deduction: 42_727.267125 + tax_unit_itemizes: true + +- name: A supplied dependent deduction of -1 excludes only its own premium parts. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + health_insurance_premiums: 500 + other_medical_expenses: 100 + dependent: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + health_insurance_premiums: 1_000 + long_term_health_insurance_premiums: 500 + self_employed_health_insurance_ald_person: -1 + sibling: + age: 15 + is_tax_unit_dependent: true + health_insurance_premiums: 1_000 + tax_units: + parents: + members: [parent, dependent, sibling] + output: + # min(1,000, max(0, -1) - 0) = 0. + itemized_medical_expenses_excluded_dependent_premiums: 0 + # Parent and sibling premiums (1,500) and other costs (100) stay intact. + # LTC remaining: 480 - 0. + itemized_medical_expenses_long_term_care_premiums: 480 + itemized_medical_expenses: 3080 + +- name: A supplied dependent deduction of 0 excludes only its own premium parts. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + health_insurance_premiums: 500 + other_medical_expenses: 100 + dependent: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + health_insurance_premiums: 1_000 + long_term_health_insurance_premiums: 500 + self_employed_health_insurance_ald_person: 0 + sibling: + age: 15 + is_tax_unit_dependent: true + health_insurance_premiums: 1_000 + tax_units: + parents: + members: [parent, dependent, sibling] + output: + # min(1,000, max(0, 0) - 0) = 0. + itemized_medical_expenses_excluded_dependent_premiums: 0 + # Parent and sibling premiums (1,500) and other costs (100) stay intact. + # LTC remaining: 480 - 0. + itemized_medical_expenses_long_term_care_premiums: 480 + itemized_medical_expenses: 3080 + +- name: A supplied dependent deduction of 0.01 excludes only its own premium parts. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + health_insurance_premiums: 500 + other_medical_expenses: 100 + dependent: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + health_insurance_premiums: 1_000 + long_term_health_insurance_premiums: 500 + self_employed_health_insurance_ald_person: 0.01 + sibling: + age: 15 + is_tax_unit_dependent: true + health_insurance_premiums: 1_000 + tax_units: + parents: + members: [parent, dependent, sibling] + output: + # min(1,000, max(0, 0.01) - 0) = 0.01. + itemized_medical_expenses_excluded_dependent_premiums: 0.01 + # Parent and sibling premiums (1,500) and other costs (100) stay intact. + # LTC remaining: 480 - 0. + itemized_medical_expenses_long_term_care_premiums: 480 + itemized_medical_expenses: 3079.99 + +- name: A supplied dependent deduction of 999.99 excludes only its own premium parts. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + health_insurance_premiums: 500 + other_medical_expenses: 100 + dependent: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + health_insurance_premiums: 1_000 + long_term_health_insurance_premiums: 500 + self_employed_health_insurance_ald_person: 999.99 + sibling: + age: 15 + is_tax_unit_dependent: true + health_insurance_premiums: 1_000 + tax_units: + parents: + members: [parent, dependent, sibling] + output: + # min(1,000, max(0, 999.99) - 0) = 999.99. + itemized_medical_expenses_excluded_dependent_premiums: 999.99 + # Parent and sibling premiums (1,500) and other costs (100) stay intact. + # LTC remaining: 480 - 0. + itemized_medical_expenses_long_term_care_premiums: 480 + itemized_medical_expenses: 2080.01 + +- name: A supplied dependent deduction of 1000 excludes only its own premium parts. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + health_insurance_premiums: 500 + other_medical_expenses: 100 + dependent: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + health_insurance_premiums: 1_000 + long_term_health_insurance_premiums: 500 + self_employed_health_insurance_ald_person: 1000 + sibling: + age: 15 + is_tax_unit_dependent: true + health_insurance_premiums: 1_000 + tax_units: + parents: + members: [parent, dependent, sibling] + output: + # min(1,000, max(0, 1000) - 0) = 1000. + itemized_medical_expenses_excluded_dependent_premiums: 1000 + # Parent and sibling premiums (1,500) and other costs (100) stay intact. + # LTC remaining: 480 - 0. + itemized_medical_expenses_long_term_care_premiums: 480 + itemized_medical_expenses: 2080 + +- name: A supplied dependent deduction of 1000.01 excludes only its own premium parts. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + health_insurance_premiums: 500 + other_medical_expenses: 100 + dependent: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + health_insurance_premiums: 1_000 + long_term_health_insurance_premiums: 500 + self_employed_health_insurance_ald_person: 1000.01 + sibling: + age: 15 + is_tax_unit_dependent: true + health_insurance_premiums: 1_000 + tax_units: + parents: + members: [parent, dependent, sibling] + output: + # min(1,000, max(0, 1000.01) - 0.01) = 1000. + itemized_medical_expenses_excluded_dependent_premiums: 1000 + # Parent and sibling premiums (1,500) and other costs (100) stay intact. + # LTC remaining: 480 - 0.01. + itemized_medical_expenses_long_term_care_premiums: 479.99 + itemized_medical_expenses: 2079.99 + +- name: A supplied dependent deduction of 1480 excludes only its own premium parts. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + health_insurance_premiums: 500 + other_medical_expenses: 100 + dependent: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + health_insurance_premiums: 1_000 + long_term_health_insurance_premiums: 500 + self_employed_health_insurance_ald_person: 1480 + sibling: + age: 15 + is_tax_unit_dependent: true + health_insurance_premiums: 1_000 + tax_units: + parents: + members: [parent, dependent, sibling] + output: + # min(1,000, max(0, 1480) - 480) = 1000. + itemized_medical_expenses_excluded_dependent_premiums: 1000 + # Parent and sibling premiums (1,500) and other costs (100) stay intact. + # LTC remaining: 480 - 480. + itemized_medical_expenses_long_term_care_premiums: 0 + itemized_medical_expenses: 1600 + +- name: A supplied dependent deduction of 2000 excludes only its own premium parts. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + health_insurance_premiums: 500 + other_medical_expenses: 100 + dependent: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + health_insurance_premiums: 1_000 + long_term_health_insurance_premiums: 500 + self_employed_health_insurance_ald_person: 2000 + sibling: + age: 15 + is_tax_unit_dependent: true + health_insurance_premiums: 1_000 + tax_units: + parents: + members: [parent, dependent, sibling] + output: + # min(1,000, max(0, 2000) - 480) = 1000. + itemized_medical_expenses_excluded_dependent_premiums: 1000 + # Parent and sibling premiums (1,500) and other costs (100) stay intact. + # LTC remaining: 480 - 480. + itemized_medical_expenses_long_term_care_premiums: 0 + itemized_medical_expenses: 1600 + +- name: North Dakota retains its medical cost base after a dependent deducts premiums. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + employment_income_before_lsr: 40_000 # TANF formulas read wages here, so the family gets no TANF. + other_medical_expenses: 2_000 + dependent: + age: 17 + is_tax_unit_dependent: true + health_insurance_premiums: 3_000 + self_employed_health_insurance_ald_person: 1_000 + tax_units: + parents: + members: [parent, dependent] + households: + household: + members: [parent, dependent] + state_code: ND + output: + itemized_medical_expenses: 4_000 # 2,000 + 3,000 - 1,000. + itemized_medical_expenses_applied_exclusion: 1_000 + nd_renters_refund_income: 35_000 # 40,000 - (4,000 + 1,000). + +- name: North Dakota restores a dependent's exclusion beside a supplied zero filer exclusion. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + employment_income_before_lsr: 40_000 # TANF formulas read wages here, so the family gets no TANF. + other_medical_expenses: 2_000 + dependent: + age: 17 + is_tax_unit_dependent: true + health_insurance_premiums: 3_000 + self_employed_health_insurance_ald_person: 1_000 + tax_units: + parents: + members: [parent, dependent] + itemized_medical_expenses_applied_exclusion: 0 + households: + household: + members: [parent, dependent] + state_code: ND + output: + itemized_medical_expenses: 4_000 # 2,000 + 3,000 - 1,000. + # The supplied zero covers the filers' exclusion only. + itemized_medical_expenses_applied_exclusion: 0 + itemized_medical_expenses_excluded_dependent_premiums: 1_000 + # NDCC 57-02-08.1(5)(c) counts costs the applicant's dependent paid: + # 40,000 - (4,000 + 0 + 1,000) = 35,000. + nd_renters_refund_income: 35_000 + +- name: New Mexico retains its senior medical credit at the paid cost boundary. + period: 2025 + input: + people: + parent: + age: 65 + medicare_enrolled: false + dependent: + age: 17 + is_tax_unit_dependent: true + health_insurance_premiums: 28_000 + self_employed_health_insurance_ald_person: 1_000 + tax_units: + parents: + members: [parent, dependent] + households: + household: + members: [parent, dependent] + state_code: NM + output: + itemized_medical_expenses: 27_000 # 28,000 - 1,000. + itemized_medical_expenses_applied_exclusion: 1_000 + nm_medical_expense_credit: 2_800 # The paid cost base stays 28,000. + nm_medical_expense_exemption: 0 # The exemption requires more than 28,000. + +- name: New Mexico restores a dependent's exclusion beside a supplied zero filer exclusion. + period: 2025 + input: + people: + parent: + age: 65 + medicare_enrolled: false + dependent: + age: 17 + is_tax_unit_dependent: true + health_insurance_premiums: 28_001 + self_employed_health_insurance_ald_person: 1_000 + tax_units: + parents: + members: [parent, dependent] + itemized_medical_expenses_applied_exclusion: 0 + households: + household: + members: [parent, dependent] + state_code: NM + output: + itemized_medical_expenses: 27_001 # 28,001 - 1,000. + # The supplied zero covers the filers' exclusion only. + itemized_medical_expenses_applied_exclusion: 0 + itemized_medical_expenses_excluded_dependent_premiums: 1_000 + # 27,001 + 0 + 1,000 = 28,001: at least 28,000 for the credit and more + # than 28,000 for the exemption. + nm_medical_expense_credit: 2_800 + nm_medical_expense_exemption: 3_000 + +- name: Montana retains non-premium expenses after a dependent deducts medical premiums. + period: 2023 + input: + people: + parent: + age: 40 + employment_income: 100_000 + other_medical_expenses: 8_000 + dependent: + age: 17 + is_tax_unit_dependent: true + health_insurance_premiums: 3_000 + self_employed_health_insurance_ald_person: 1_000 + tax_units: + parents: + members: [parent, dependent] + households: + household: + members: [parent, dependent] + state_code: MT + output: + itemized_medical_expenses: 10_000 # 8,000 + (3,000 - 1,000). + # Remove the remaining premiums (2,000); 8,000 - 7.5% x 100,000 = 500. + # The parent paid no premiums for Montana's separate deduction. + mt_medical_expense_deduction_joint: [500, 0] + +- name: A dependent deducting only long-term care leaves medical premiums available. + period: 2025 + input: + people: + parent: + age: 40 + other_medical_expenses: 100 + dependent: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + self_employment_income: 10_000 + health_insurance_premiums: 1_000 + self_employed_health_insurance_premiums: 0 + long_term_health_insurance_premiums: 480 + tax_units: + parents: + members: [parent, dependent] + output: + self_employed_health_insurance_ald_person: [0, 480] + self_employed_health_insurance_ald_long_term_care_part: [0, 480] + itemized_medical_expenses_excluded_dependent_premiums: 0 + itemized_medical_expenses_long_term_care_premiums: 0 + itemized_medical_expenses: 1_100 # 100 + 1,000; the 480 was deducted. + +- name: Montana preserves a supplied exclusion with a computed subtotal. + period: 2023 + input: + people: + parent: + age: 40 + employment_income: 100_000 + health_insurance_premiums: 1_000 + other_medical_expenses: 8_000 + dependent: + age: 17 + is_tax_unit_dependent: true + health_insurance_premiums: 3_000 + self_employed_health_insurance_ald_person: 1_000 + tax_units: + parents: + members: [parent, dependent] + itemized_medical_expenses_applied_exclusion: 500 + households: + household: + members: [parent, dependent] + state_code: MT + output: + itemized_medical_expenses: 11_000 # 1,000 + 3,000 - 1,000 + 8,000. + itemized_medical_expenses_applied_exclusion: 500 + # Main: 12,000 - (4,000 - 500) = 8,500, then a 7,500 floor. + # The computed subtotal removes 1,000 more premiums; Montana restores + # that amount when separating premiums from the other expenses. + # The parent's 1,000 premium deduction adds to the 1,000 floored amount. + mt_medical_expense_deduction_joint: [2_000, 0] + +- name: Montana preserves a supplied exclusion without a dependent deduction. + period: 2023 + input: + age: 40 + employment_income: 100_000 + health_insurance_premiums: 1_000 + other_medical_expenses: 8_000 + itemized_medical_expenses_applied_exclusion: 500 + state_code: MT + output: + itemized_medical_expenses: 9_000 + # (9,000 - (1,000 - 500) - 7,500) + 1,000 premiums = 2,000. + mt_medical_expense_deduction_joint: 2_000 + +- name: Montana keeps other expenses on line 1 when a supplied subtotal leaves out a dependent's deducted premiums. + period: 2023 + input: + people: + parent: + age: 40 + employment_income: 100_000 + other_medical_expenses: 8_000 + dependent: + age: 17 + is_tax_unit_dependent: true + health_insurance_premiums: 3_000 + self_employed_health_insurance_ald_person: 1_000 + tax_units: + parents: + members: [parent, dependent] + # The subtotal and exclusion the formulas compute for these people. + itemized_medical_expenses: 10_000 # 8,000 + (3,000 - 1,000). + itemized_medical_expenses_applied_exclusion: 1_000 + households: + household: + members: [parent, dependent] + state_code: MT + output: + itemized_medical_expenses_excluded_dependent_premiums: 1_000 + # The filers excluded nothing, so the 1,000 exclusion holds the + # dependent's deducted premiums: min(1,000, 1,000 - 0) = 1,000. + # Premiums left in the subtotal: 3,000 - 1,000 = 2,000. + # Line 1: (10,000 - 2,000) - 7.5% x 100,000 = 500, as computed. + mt_medical_expense_deduction_joint: [500, 0] + +- name: Montana takes a supplied exclusion from the premiums a dependent deducted and leaves the rest in the subtotal. + period: 2022 + absolute_error_margin: 0.01 + input: + people: + parent: + is_tax_unit_head: true + age: 30 + health_insurance_premiums: 6_000 + long_term_health_insurance_premiums: 400 + self_employed_health_insurance_ald_person: 6_400 + dependent: + is_tax_unit_dependent: true + age: 10 + health_insurance_premiums: 1_000 + self_employed_health_insurance_ald_person: 600 + tax_units: + parents: + members: [parent, dependent] + # Schedule A line 1: 10,000 of other expenses + the 400 of premiums + # the dependent did not deduct. The exclusion holds the parent's + # 6,000 of medical and 400 of long-term care premiums and the + # dependent's 600. + itemized_medical_expenses: 10_400 + itemized_medical_expenses_applied_exclusion: 7_000 + mt_agi_joint: 40_000 + households: + household: + members: [parent, dependent] + state_code: MT + output: + itemized_medical_expenses_excluded_dependent_premiums: 600 + # The filers' own exclusion: 6,000 + 400 = 6,400. The other + # 7,000 - 6,400 = 600 of the supplied exclusion holds the dependent's + # deducted premiums. Medical premiums the subtotal leaves out: + # min(6,000, 7,000 - 600) + 600 = 6,600; premiums left in it: + # 7,000 - 6,600 = 400. + # Line 1: (10,400 - 400) - 7.5% x 40,000 = 7,000. + # Lines 2 and 3: 6,000 + 400 - 6,400 = 0. + mt_premium_deduction_joint: 0 + mt_medical_expense_deduction_joint: [7_000, 0] + +- name: Montana leaves a dependent's deducted premiums in a supplied subtotal when its exclusion covers the filers only. + period: 2022 + absolute_error_margin: 0.01 + input: + people: + parent: + is_tax_unit_head: true + age: 30 + health_insurance_premiums: 6_000 + long_term_health_insurance_premiums: 400 + self_employed_health_insurance_ald_person: 6_400 + dependent: + is_tax_unit_dependent: true + age: 10 + health_insurance_premiums: 1_000 + self_employed_health_insurance_ald_person: 600 + tax_units: + parents: + members: [parent, dependent] + # This subtotal holds 10,000 of other expenses and all 1,000 of the + # dependent's premiums. Its exclusion holds only the parent's 6,000 + # of medical and 400 of long-term care premiums. + itemized_medical_expenses: 11_000 + itemized_medical_expenses_applied_exclusion: 6_400 + mt_agi_joint: 40_000 + households: + household: + members: [parent, dependent] + state_code: MT + output: + itemized_medical_expenses_excluded_dependent_premiums: 600 + # The supplied exclusion equals the filers' own 6,400, so none of it + # holds the dependent's premiums: min(600, 6,400 - 6,400) = 0. + # Medical premiums the subtotal leaves out: min(6,000, 6,400) = 6,000; + # premiums left in it: 7,000 - 6,000 = 1,000. + # Line 1: (11,000 - 1,000) - 7.5% x 40,000 = 7,000. + mt_premium_deduction_joint: 0 + mt_medical_expense_deduction_joint: [7_000, 0] + +- name: Montana reads no more of a supplied exclusion as a dependent's premiums than the dependent deducted. + period: 2022 + absolute_error_margin: 0.01 + input: + people: + parent: + is_tax_unit_head: true + age: 30 + health_insurance_premiums: 6_000 + long_term_health_insurance_premiums: 400 + self_employed_health_insurance_ald_person: 6_400 + dependent: + is_tax_unit_dependent: true + age: 10 + health_insurance_premiums: 1_000 + self_employed_health_insurance_ald_person: 600 + tax_units: + parents: + members: [parent, dependent] + # The subtotal holds 10,000 of other expenses + the 400 of premiums + # the dependent did not deduct. The exclusion exceeds the 7,000 these + # people deducted by 500. + itemized_medical_expenses: 10_400 + itemized_medical_expenses_applied_exclusion: 7_500 + mt_agi_joint: 40_000 + households: + household: + members: [parent, dependent] + state_code: MT + output: + # 7,500 - 6,400 = 1,100 of the exclusion sits above the filers' own; + # min(600, 1,100) = 600 of it holds the dependent's deducted premiums. + # Medical premiums the subtotal leaves out: + # min(6,000, 7,500 - 600) + 600 = 6,600; premiums left in it: 400. + # Line 1: (10,400 - 400) - 7.5% x 40,000 = 7,000. + mt_premium_deduction_joint: 0 + mt_medical_expense_deduction_joint: [7_000, 0] diff --git a/policyengine_us/tests/policy/baseline/gov/states/nj/tax/income/deductions/nj_medical_expense_deduction.yaml b/policyengine_us/tests/policy/baseline/gov/states/nj/tax/income/deductions/nj_medical_expense_deduction.yaml index 56b037f6c2c..50b27d66b16 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nj/tax/income/deductions/nj_medical_expense_deduction.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nj/tax/income/deductions/nj_medical_expense_deduction.yaml @@ -176,8 +176,234 @@ dependents_self_employed_health_insurance_ald: 1_000 # The child deducts the 1,000 of premiums on their own return. Only the # 500 of other expenses remains, under the 600 floor (2% of 30,000). + itemized_medical_expenses: 500 nj_medical_expense_deduction: 0 +- name: New Jersey excludes a dependent's deducted premiums once with a computed federal subtotal + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_tax_unit_head: true + employment_income: 30_000 + medicare_enrolled: false + other_medical_expenses: 10_000 + child: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + self_employment_income: 10_000 + medicare_enrolled: false + health_insurance_premiums: 3_000 + long_term_health_insurance_premiums: 480 + tax_units: + tax_unit: + members: [parent, child] + marital_units: + parent_unit: + members: [parent] + child_unit: + members: [child] + households: + household: + members: [parent, child] + state_code: NJ + output: + # The child deducts 3,000 medical + min(480, 480) long-term care = 3,480. + # The earnings limit, 10,000 - 10,000 x 0.9235 x 0.153 / 2 = 9,293.52, + # exceeds those premiums. + dependents_self_employed_health_insurance_ald: 3_480 + itemized_medical_expenses_excluded_dependent_premiums: 3_000 + itemized_medical_expenses_long_term_care_premiums: 0 + # Federal medical expenses: 3,000 - 3,000 + 480 - 480 + 10,000 = 10,000. + itemized_medical_expenses: 10_000 + itemized_medical_expenses_applied_exclusion: 3_000 + nj_agi: 30_000 + # New Jersey deducts 10,000 - 0.02 x 30,000 = 9,400. The parent takes + # no separate self-employed deduction or second dependent exclusion. + nj_medical_expense_deduction: 9_400 + +- name: New Jersey retains its dependent premium exclusion for a supplied federal subtotal + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_tax_unit_head: true + employment_income: 30_000 + medicare_enrolled: false + other_medical_expenses: 10_000 + child: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + self_employment_income: 10_000 + medicare_enrolled: false + health_insurance_premiums: 3_000 + long_term_health_insurance_premiums: 480 + tax_units: + tax_unit: + members: [parent, child] + # This subtotal includes 3,000 medical premiums and 10,000 other + # expenses, after leaving out the child's deducted 480 LTC premiums. + itemized_medical_expenses: 13_000 + marital_units: + parent_unit: + members: [parent] + child_unit: + members: [child] + households: + household: + members: [parent, child] + state_code: NJ + output: + # The child deducts 3,480, below the 9,293.52 earned income limit. + dependents_self_employed_health_insurance_ald: 3_480 + itemized_medical_expenses_excluded_dependent_premiums: 3_000 + itemized_medical_expenses_long_term_care_premiums: 0 + itemized_medical_expenses: 13_000 + itemized_medical_expenses_applied_exclusion: 0 + nj_agi: 30_000 + # New Jersey removes the 3,000 medical premiums from the supplied + # subtotal: 13,000 - 3,000 - 0.02 x 30,000 = 9,400. + nj_medical_expense_deduction: 9_400 + +- name: New Jersey takes nothing more out of a supplied subtotal that already leaves out a dependent's deducted premiums + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_tax_unit_head: true + employment_income: 30_000 + medicare_enrolled: false + other_medical_expenses: 10_000 + child: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + self_employment_income: 10_000 + medicare_enrolled: false + health_insurance_premiums: 3_000 + long_term_health_insurance_premiums: 480 + tax_units: + tax_unit: + members: [parent, child] + # The subtotal and exclusion the formulas compute for these people: + # 10,000 of other expenses, with the child's 3,000 of deducted + # medical premiums in the exclusion. + itemized_medical_expenses: 10_000 + itemized_medical_expenses_applied_exclusion: 3_000 + marital_units: + parent_unit: + members: [parent] + child_unit: + members: [child] + households: + household: + members: [parent, child] + state_code: NJ + output: + dependents_self_employed_health_insurance_ald: 3_480 + itemized_medical_expenses_excluded_dependent_premiums: 3_000 + nj_agi: 30_000 + # The parent excluded nothing, so the 3,000 exclusion holds the child's + # deducted premiums: min(3,000, 3,000 - 0) = 3,000, and none remain to + # take out. New Jersey deducts 10,000 - 0.02 x 30,000 = 9,400, as + # computed. + nj_medical_expense_deduction: 9_400 + +- name: New Jersey reads no more of a supplied exclusion as a dependent's premiums than the dependent deducted + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_tax_unit_head: true + employment_income: 30_000 + medicare_enrolled: false + other_medical_expenses: 10_000 + child: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + self_employment_income: 10_000 + medicare_enrolled: false + health_insurance_premiums: 3_000 + long_term_health_insurance_premiums: 480 + tax_units: + tax_unit: + members: [parent, child] + itemized_medical_expenses: 10_000 + itemized_medical_expenses_applied_exclusion: 5_000 + marital_units: + parent_unit: + members: [parent] + child_unit: + members: [child] + households: + household: + members: [parent, child] + state_code: NJ + output: + itemized_medical_expenses_excluded_dependent_premiums: 3_000 + nj_agi: 30_000 + # min(3,000, 5,000 - 0) = 3,000 of the exclusion holds the child's + # deducted premiums, so none remain to take out: + # 10,000 - 0.02 x 30,000 = 9,400. + nj_medical_expense_deduction: 9_400 + +- name: New Jersey takes a dependent's deducted premiums out of a supplied subtotal when its exclusion covers the filers only + period: 2025 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + is_tax_unit_head: true + medicare_enrolled: false + health_insurance_premiums: 6_000 + other_medical_expenses: 10_000 + child: + age: 17 + is_tax_unit_dependent: true + is_self_employed: true + self_employment_income: 10_000 + medicare_enrolled: false + health_insurance_premiums: 3_000 + tax_units: + tax_unit: + members: [parent, child] + self_employed_health_insurance_ald: 1_000 + # This subtotal holds 10,000 of other expenses, the parent's 5,000 + # of premiums not deducted and all 3,000 of the child's premiums. + # Its exclusion holds only the parent's 1,000 of deducted premiums. + itemized_medical_expenses: 18_000 + itemized_medical_expenses_applied_exclusion: 1_000 + nj_agi: 30_000 + marital_units: + parent_unit: + members: [parent] + child_unit: + members: [child] + households: + household: + members: [parent, child] + state_code: NJ + output: + itemized_medical_expenses_excluded_premiums: 1_000 + itemized_medical_expenses_excluded_dependent_premiums: 3_000 + # The supplied exclusion equals the filers' own 1,000, so none of it + # holds the child's premiums: min(3,000, 1,000 - 1,000) = 0. New Jersey + # takes all 3,000 out: (18,000 - 3,000 - 0.02 x 30,000) + the parent's + # 1,000 deduction = 15,400. + nj_medical_expense_deduction: 15_400 + - name: New Jersey cannot subtract one dependent's deduction from another dependent's premiums period: 2025 input: diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses.py b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses.py index c046795c4f2..bba6046bad7 100644 --- a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses.py +++ b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses.py @@ -8,8 +8,9 @@ class itemized_medical_expenses(Variable): unit = USD definition_period = YEAR reference = [ - "https://www.law.cornell.edu/uscode/text/26/213", - "https://www.law.cornell.edu/uscode/text/26/162#l_3", + "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapB-partVII-sec213.htm", + "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapB-partVI-sec162.htm", + "https://www.ecfr.gov/current/title-26/section-1.213-1#p-1.213-1(a)(1)", "https://www.irs.gov/instructions/i1040sca", "https://www.irs.gov/pub/irs-prior/i1040sca--2022.pdf#page=2", ] @@ -24,13 +25,16 @@ class itemized_medical_expenses(Variable): "age. Current modeling uses health insurance premiums, those eligible " "long-term care premiums (recorded on the insured person) and other " "medical expenses, excluding general over-the-counter health " - "expenses. Premiums deducted through the " - "filer's self-employed health insurance deduction are excluded under " - "IRC Section 162(l)(3) before the medical expense floor is applied. " + "expenses. Section 162(l)(3) excludes premiums the filers deduct " + "through their self-employed health insurance deduction. Section " + "213(a) and Treasury regulation 1.213-1(a)(1) allow only expenses " + "the filers paid, so premiums a dependent deducts on their own " + "return also leave the subtotal before the medical expense floor. " "Premium inputs use payer attribution: each person reports premiums " "that person paid, including the full cost of family coverage regardless " "of whom it covers. A parent-paid dependent policy belongs on the parent. " - "The exclusion is bounded to filer-paid premiums; beneficiary-attributed " + "The filer exclusion is bounded to the head's and spouse's premium pool; " + "each dependent exclusion is bounded to their own premiums. Beneficiary-attributed " "inputs with an ALD exceeding that pool are inconsistent with this contract " "and cannot establish conservation of the supplied ALD. A supplied value " "bypasses this formula and is used as given. By default it is taken as " @@ -48,11 +52,15 @@ class itemized_medical_expenses(Variable): def formula(tax_unit, period, parameters): premiums = add(tax_unit, period, ["medical_expense_health_insurance_premiums"]) - # The federal ALD covers the head and spouse; dependents take their - # own SE deductions on their own returns. Bound the exclusion to the - # corresponding filer premiums, leaving other medical costs intact. - excluded_premiums = tax_unit( - "itemized_medical_expenses_excluded_premiums", period + # Filers and dependents deduct their own premiums on their own + # returns. Exclude each deducted payment once, within its paid pool. + excluded_premiums = add( + tax_unit, + period, + [ + "itemized_medical_expenses_excluded_premiums", + "itemized_medical_expenses_excluded_dependent_premiums", + ], ) # Eligible long-term care premiums less the part the same deduction # took. diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses_applied_exclusion.py b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses_applied_exclusion.py index a2b0efd8469..625f011366b 100644 --- a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses_applied_exclusion.py +++ b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses_applied_exclusion.py @@ -8,23 +8,38 @@ class itemized_medical_expenses_applied_exclusion(Variable): unit = USD definition_period = YEAR reference = [ - "https://www.law.cornell.edu/uscode/text/26/162#l_3", + "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapB-partVI-sec162.htm", "https://www.irs.gov/instructions/i1040sca", ] documentation = ( - "Premiums actually excluded by the federal medical expense formula. " - "A caller-supplied subtotal bypasses that formula, so no exclusion " - "was applied, unless the caller also supplies this amount: all the " - "premiums, medical and long-term care, that a supplied Schedule A " - "subtotal already leaves out because they were taken as the " - "self-employed health insurance deduction, taken from the head's and " - "spouse's medical insurance premiums first. In a simulation with " + "Filer premiums and dependent medical premiums excluded by the " + "federal medical expense formula. Dependent long-term care premiums " + "remain outside this state addback, as under the existing state bases. " + "A caller-supplied subtotal bypasses that formula. Supply this amount " + "when that subtotal already leaves out premiums taken as the " + "self-employed health insurance deduction. Include medical and " + "long-term care premiums. Allocate the exclusion to the head's and " + "spouse's medical premiums first. In a simulation with " "several tax units, supply it for each of them, since a formula " "variable supplied for some units is 0 for the rest. States retaining " "gross paid medical costs restore this amount; Montana's 2021-2023 " "schedule uses it to take only the medical premiums still inside the " "subtotal out of line 1. Premium inputs use payer attribution, " - "including family coverage paid by a filer. The required " + "including family coverage paid by a filer. " + "For a computed subtotal, a supplied exclusion replaces only the " + "filers' exclusion and excludes dependents' medical premiums. " + "Montana, North Dakota and New Mexico each restore the computed " + "dependent amount separately. A supplied exclusion for a " + "supplied subtotal includes all premiums that subtotal leaves out, " + "including dependents' medical premiums, for North Dakota and New " + "Mexico's addbacks. Beside a supplied subtotal, Montana and New " + "Jersey read the part of a supplied exclusion above the filers' own " + "computed exclusion as the dependents' deducted medical premiums, up " + "to the dependents' computed exclusion. Montana takes the rest from " + "the filers' medical premiums first, and New Jersey takes only the " + "dependents' other deducted premiums out of the subtotal. A subtotal " + "and exclusion supplied at their computed values then give the " + "computed deductions. The required " "policyengine-core>=3.32.27 clears input provenance on deletion, so " "recalculating a deleted subtotal also restores its applied exclusion." ) @@ -42,5 +57,6 @@ def formula(tax_unit, period, parameters): [ "itemized_medical_expenses_excluded_premiums", "itemized_medical_expenses_excluded_long_term_care_premiums", + "itemized_medical_expenses_excluded_dependent_premiums", ], ) diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses_excluded_dependent_premiums.py b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses_excluded_dependent_premiums.py new file mode 100644 index 00000000000..aefc4a80117 --- /dev/null +++ b/policyengine_us/variables/gov/irs/income/taxable_income/deductions/itemizing/itemized_medical_expenses_excluded_dependent_premiums.py @@ -0,0 +1,34 @@ +from policyengine_us.model_api import * + + +class itemized_medical_expenses_excluded_dependent_premiums(Variable): + value_type = float + entity = TaxUnit + label = "Dependents' deducted medical insurance premiums excluded from Schedule A" + unit = USD + definition_period = YEAR + reference = ( + "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapB-partVI-sec162.htm", + "https://www.govinfo.gov/content/pkg/USCODE-2024-title26/html/USCODE-2024-title26-subtitleA-chap1-subchapB-partVII-sec213.htm", + "https://www.ecfr.gov/current/title-26/section-1.213-1#p-1.213-1(a)(1)", + ) + documentation = ( + "Medical insurance premiums each dependent deducts through their own " + "self-employed health insurance deduction. Each exclusion is limited " + "to that person's paid medical premiums and the deduction left after " + "its long-term care part. Premium inputs identify one payment per " + "person without a separate payer. Under section 213(a) and Treasury " + "regulation 1.213-1(a)(1), parents may count only medical expenses " + "they paid. A dependent who deducts their own premiums paid those " + "premiums, so this amount leaves the parents' Schedule A. The formula " + "retains the existing treatment of undeducted dependent premiums." + ) + + def formula(tax_unit, period, parameters): + person = tax_unit.members + medical_part = min_( + person("self_employed_health_insurance_ald_excluded_premiums", period), + max_(0, person("self_employed_health_insurance_ald_person", period)) + - person("self_employed_health_insurance_ald_long_term_care_part", period), + ) + return tax_unit.sum(medical_part * person("is_tax_unit_dependent", period)) diff --git a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/medical/mt_medical_expense_deduction_joint.py b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/medical/mt_medical_expense_deduction_joint.py index 8bf845b16ac..9f57153f0ae 100644 --- a/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/medical/mt_medical_expense_deduction_joint.py +++ b/policyengine_us/variables/gov/states/mt/tax/income/deductions/itemized/medical/mt_medical_expense_deduction_joint.py @@ -27,9 +27,7 @@ def formula(person, period, parameters): # insurance premiums deducted in full on lines 2 and 3. Start # from the federal subtotal and take out the premiums still in # it: the members' medical insurance premiums less the part of - # the self-employed exclusion applied to them, which is bounded by - # the head's and spouse's medical premiums (any excess covered - # long-term care premiums, which are not in the subtotal), and the + # the self-employed exclusion applied to them, and the # long-term care premiums the subtotal includes. For a computed # subtotal this leaves the members' other medical expenses. premiums = add( @@ -38,8 +36,59 @@ def formula(person, period, parameters): filer_premiums = tax_unit_non_dep_sum( "medical_expense_health_insurance_premiums", tax_unit, period ) - excluded = tax_unit("itemized_medical_expenses_applied_exclusion", period) - premiums_in_subtotal = premiums - min_(filer_premiums, max_(0, excluded)) + supplied_subtotal = has_input_for_period( + tax_unit.simulation, "itemized_medical_expenses", period + ) + if supplied_subtotal or has_input_for_period( + tax_unit.simulation, + "itemized_medical_expenses_applied_exclusion", + period, + ): + # Supplied amounts use the pooled filer-first split. + excluded = max_( + 0, + tax_unit("itemized_medical_expenses_applied_exclusion", period), + ) + dependent_exclusion = tax_unit( + "itemized_medical_expenses_excluded_dependent_premiums", period + ) + if supplied_subtotal: + # The exclusion supplied with a subtotal holds every + # premium that subtotal leaves out. Read the part above + # the filers' own exclusion as the medical premiums the + # dependents deducted, up to their computed exclusion. + # Take the rest from the filers' medical premiums first; + # what remains covered long-term care premiums. + filer_exclusion = add( + tax_unit, + period, + [ + "itemized_medical_expenses_excluded_premiums", + "itemized_medical_expenses_excluded_long_term_care_premiums", + ], + ) + dependent_part = min_( + dependent_exclusion, max_(0, excluded - filer_exclusion) + ) + medical_exclusion = ( + min_(filer_premiums, excluded - dependent_part) + dependent_part + ) + else: + # Beside a computed subtotal, a supplied exclusion covers + # the filers only, so add the dependents' exclusion. + medical_exclusion = ( + min_(filer_premiums, excluded) + dependent_exclusion + ) + else: + medical_exclusion = add( + tax_unit, + period, + [ + "itemized_medical_expenses_excluded_premiums", + "itemized_medical_expenses_excluded_dependent_premiums", + ], + ) + premiums_in_subtotal = premiums - medical_exclusion expense = max_( 0, tax_unit("itemized_medical_expenses", period) diff --git a/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.py b/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.py index 686edf58952..cd9cb5e5327 100644 --- a/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.py +++ b/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.py @@ -16,13 +16,13 @@ class nd_renters_refund_income(Variable): documentation = ( "Renter refund income: the listed income sources, less the parts of " "market income that federal law excludes and the unreimbursed medical " - "costs actually paid, and at least zero. The excluded parts are those " - "of each person's market income components " - "(nd_renters_refund_federally_excluded_income) and the federal " - "exclusions the model deducts above the line (excluded_deductions), " - "each of which comes out of the tax unit's income that holds it, or, " - "for income from Puerto Rico and American Samoa, out of market income " - "before losses. Social security counts in full. " + "costs actually paid, and at least zero. The model removes excluded " + "parts of each person's market income components " + "(nd_renters_refund_federally_excluded_income) and federal exclusions " + "deducted above the line (excluded_deductions). It subtracts each " + "exclusion from the tax unit's income that holds it. For Puerto Rico " + "and American Samoa income, it subtracts the exclusion from market " + "income before losses. Social security counts in full. " "The paid-cost base restores the self-employed premiums excluded from " "the federal subtotal: by the federal formula, or as supplied with a " "caller's subtotal in itemized_medical_expenses_applied_exclusion. A " @@ -30,6 +30,9 @@ class nd_renters_refund_income(Variable): "including when components are supplied. Premium inputs use payer " "attribution: each person reports premiums that person paid, including " "family coverage regardless of whom it covers." + " With a computed subtotal, a supplied applied exclusion covers the " + "filers' premiums only, so the model also restores the dependents' " + "computed medical exclusion, as Montana does." ) def formula(tax_unit, period, parameters): @@ -99,6 +102,20 @@ def formula(tax_unit, period, parameters): "itemized_medical_expenses_applied_exclusion", ], ) + # NDCC 57-02-08.1(5)(c) takes out of income the medical expenses "paid + # during the year by the applicant or the applicant's dependent". A + # supplied exclusion beside a computed subtotal covers the filers + # only, so restore the dependents' computed exclusion as well, as + # Montana does. + simulation = tax_unit.simulation + if not has_input_for_period( + simulation, "itemized_medical_expenses", period + ) and has_input_for_period( + simulation, "itemized_medical_expenses_applied_exclusion", period + ): + medical_expenses = medical_expenses + tax_unit( + "itemized_medical_expenses_excluded_dependent_premiums", period + ) return max_( add(tax_unit, period, p.income_sources) - person_exclusions diff --git a/policyengine_us/variables/gov/states/nj/tax/income/deductions/nj_medical_expense_deduction.py b/policyengine_us/variables/gov/states/nj/tax/income/deductions/nj_medical_expense_deduction.py index 81b37a91495..789ab6cd4e7 100644 --- a/policyengine_us/variables/gov/states/nj/tax/income/deductions/nj_medical_expense_deduction.py +++ b/policyengine_us/variables/gov/states/nj/tax/income/deductions/nj_medical_expense_deduction.py @@ -16,7 +16,10 @@ class nj_medical_expense_deduction(Variable): "regardless of who is covered. Each dependent's exclusion is limited " "to that dependent's own medical premiums. A dependent aggregate ALD " "override must identify the corresponding person ALDs for exclusion; " - "the total alone does not establish which person paid the premiums." + "the total alone does not establish which person paid the premiums. " + "A supplied subtotal loses the dependents' deducted premiums once: " + "the formula takes out only those that the applied exclusion supplied " + "with the subtotal does not already cover." ) reference = ( "https://pub.njleg.gov/bills/9899/PL99/222_.HTM", @@ -36,20 +39,33 @@ def formula(tax_unit, period, parameters): # C.54A:3-3 excludes premiums counted by the separate SE deduction # under C.54A:3-5, including a dependent's deduction on their own # return. - # The federal base already excludes the filers' deduction and the - # long-term care part (Form 7206 line 2) of each dependent's own - # deduction. Remove the medical part (line 1) of each dependent's - # deduction (the deduction less its long-term care part), limited to - # that person's own paid medical premiums. - person = tax_unit.members - dependent_medical_part = min_( - person("self_employed_health_insurance_ald_excluded_premiums", period), - max_(0, person("self_employed_health_insurance_ald_person", period)) - - person("self_employed_health_insurance_ald_long_term_care_part", period), - ) - excluded_dependent_premiums = tax_unit.sum( - dependent_medical_part * person("is_tax_unit_dependent", period) - ) + # The computed federal base excludes each dependent's deduction. + # Supplied subtotals retain the separate state medical exclusion, + # less the dependents' premiums that the exclusion supplied with the + # subtotal already covers: the part of that exclusion above the + # filers' own, up to the dependents' computed exclusion. + excluded_dependent_premiums = 0 + if has_input_for_period( + tax_unit.simulation, "itemized_medical_expenses", period + ): + dependent_exclusion = tax_unit( + "itemized_medical_expenses_excluded_dependent_premiums", period + ) + filer_exclusion = add( + tax_unit, + period, + [ + "itemized_medical_expenses_excluded_premiums", + "itemized_medical_expenses_excluded_long_term_care_premiums", + ], + ) + supplied_exclusion = max_( + 0, tax_unit("itemized_medical_expenses_applied_exclusion", period) + ) + already_excluded = min_( + dependent_exclusion, max_(0, supplied_exclusion - filer_exclusion) + ) + excluded_dependent_premiums = dependent_exclusion - already_excluded # New Jersey includes salary-reduction cafeteria-plan premiums in # taxable wages (TB-39(R)), so these employee-paid premiums also # qualify for the medical expense deduction. The separate payroll diff --git a/policyengine_us/variables/gov/states/nm/tax/income/credits/nm_medical_expense_credit.py b/policyengine_us/variables/gov/states/nm/tax/income/credits/nm_medical_expense_credit.py index f7a54906c80..5646461bec5 100644 --- a/policyengine_us/variables/gov/states/nm/tax/income/credits/nm_medical_expense_credit.py +++ b/policyengine_us/variables/gov/states/nm/tax/income/credits/nm_medical_expense_credit.py @@ -23,6 +23,9 @@ class nm_medical_expense_credit(Variable): "This assumes qualifying costs were funded from income included in AGI. " "Premium inputs use payer attribution: each person reports premiums that " "person paid, including family coverage regardless of whom it covers. " + "With a computed subtotal, a supplied applied exclusion covers the " + "filers' premiums only, so the model also restores the dependents' " + "computed medical exclusion, as Montana does." ) def formula(tax_unit, period, parameters): @@ -40,6 +43,19 @@ def formula(tax_unit, period, parameters): "itemized_medical_expenses_applied_exclusion", ], ) + # PIT-RC line 23 counts costs "for the care of any combination of + # you, your spouse, or dependents". A supplied exclusion beside a + # computed subtotal covers the filers only, so restore the + # dependents' computed exclusion as well, as Montana does. + simulation = tax_unit.simulation + if not has_input_for_period( + simulation, "itemized_medical_expenses", period + ) and has_input_for_period( + simulation, "itemized_medical_expenses_applied_exclusion", period + ): + medical_expense = medical_expense + tax_unit( + "itemized_medical_expenses_excluded_dependent_premiums", period + ) expense_eligible = medical_expense >= p.min_expenses # NMSA 7-2-18.13(A) allows the credit to "a taxpayer ... who is # sixty-five years of age or older and who is not a dependent of diff --git a/policyengine_us/variables/gov/states/nm/tax/income/exemptions/nm_medical_expense_exemption.py b/policyengine_us/variables/gov/states/nm/tax/income/exemptions/nm_medical_expense_exemption.py index 7b7d8c53b41..4319c66f2c7 100644 --- a/policyengine_us/variables/gov/states/nm/tax/income/exemptions/nm_medical_expense_exemption.py +++ b/policyengine_us/variables/gov/states/nm/tax/income/exemptions/nm_medical_expense_exemption.py @@ -24,6 +24,9 @@ class nm_medical_expense_exemption(Variable): "included in AGI. Premium inputs use payer attribution: each person " "reports premiums that person paid, including family coverage regardless " "of whom it covers. " + "With a computed subtotal, a supplied applied exclusion covers the " + "filers' premiums only, so the model also restores the dependents' " + "computed medical exclusion, as Montana does." ) def formula(tax_unit, period, parameters): @@ -42,6 +45,19 @@ def formula(tax_unit, period, parameters): "itemized_medical_expenses_applied_exclusion", ], ) + # PIT-ADJ line 18 counts costs "for the care of any combination of + # you, your spouse, or your dependents". A supplied exclusion beside a + # computed subtotal covers the filers only, so restore the + # dependents' computed exclusion as well, as Montana does. + simulation = tax_unit.simulation + if not has_input_for_period( + simulation, "itemized_medical_expenses", period + ) and has_input_for_period( + simulation, "itemized_medical_expenses_applied_exclusion", period + ): + medical_expense = medical_expense + tax_unit( + "itemized_medical_expenses_excluded_dependent_premiums", period + ) # NMSA 7-2-5.9(A) allows the exemption to "any individual sixty-five # years of age or older" for expenses paid "for that individual or # for the individual's spouse or dependent", and PIT-ADJ line 18 asks