Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/claimable-filer-nm.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Apply New Mexico's rules for a filer who can be claimed as a dependent: no child income tax credit when every filer can be claimed (NMSA 7-2-18.34), no childless EITC, child care credit child or certain-dependents deduction on a return with a claimable filer, and the medical care credit, property tax rebate and centenarian exemption only for a filer who meets the age test and cannot be claimed; the medical expense credit and exemption and the childless EITC now test filers' ages, not a dependent's, and the EITC's child route also counts older qualifying children under IRC 32(c)(3) (a dependent aged 18, a student under 24 or a permanently disabled child).
95 changes: 95 additions & 0 deletions policyengine_us/tests/core/test_claimable_filer_nm_invariants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
"""New Mexico rules for a filer who can be claimed as a dependent.

Several credits and exemptions bar "a dependent of another individual", and
dependent-based amounts need dependents that a return with a claimable filer
cannot have (IRC 152(b)(1)).

For couples with either, both or neither spouse claimed:

1. Swap invariance: each output is the same under either head/spouse
labelling (Hypothesis batches, the seeded population and the crafted
centenarian cases).
2. Monotonicity: marking another filer as claimed never raises an output
(seeded population and crafted cases only).

The crafted cases add spouses aged 100 or older, whom the generated population
(ages 18 to 90) never has.
"""

import pytest
from hypothesis import HealthCheck, given, settings
from hypothesis import strategies as st

from policyengine_us.tests.core.test_claimable_filer_federal_invariants import (
check_monotone,
check_swap,
)
from policyengine_us.tests.core.test_dependent_elsewhere_head_spouse_swap_invariance import (
CLAIM_PATTERNS,
_crafted_cases,
_seeded_couples,
adults,
dependents,
)

STATES = ["NM"]
YEARS = [2023, 2025, 2026]
OUTPUTS = [
"nm_ctc",
"nm_medical_expense_credit",
"nm_medical_expense_exemption",
"nm_eitc",
"nm_deduction_for_certain_dependents",
"nm_property_tax_rebate",
"nm_cdcc_max_amount",
"nm_hundred_year_exemption",
]


def _centenarian_cases():
# One or both spouses aged 100 or older, with income to exempt.
centenarian = {"age": 101, "taxable_pension_income": 20_000.0}
older = {"age": 103, "taxable_interest_income": 5_000.0}
younger = {"age": 70, "social_security_retirement": 12_000.0}
return [
{
"state": "NM",
"adults": couple,
"dependents": [],
"claimed": claimed,
}
for couple in ([centenarian, younger], [centenarian, older])
for claimed in [(True, False), (False, True), (True, True)]
]


@st.composite
def couples(draw):
return {
"state": draw(st.sampled_from(STATES)),
"adults": [draw(adults()), draw(adults())],
"dependents": draw(st.lists(dependents(), max_size=2)),
"claimed": draw(st.sampled_from(CLAIM_PATTERNS)),
}


@settings(
max_examples=2,
deadline=None,
derandomize=True,
suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large],
)
@given(st.sampled_from(YEARS), st.lists(couples(), min_size=6, max_size=12))
def test_nm_claimable_filer_rules_are_label_free(year, units):
check_swap(units, year, OUTPUTS)


@pytest.mark.parametrize("year", YEARS)
def test_nm_claimable_filer_rules_seeded_population(year):
units = (
_seeded_couples(STATES, per_state=3)
+ _crafted_cases(STATES)
+ _centenarian_cases()
)
check_swap(units, year, OUTPUTS)
check_monotone(units, year, OUTPUTS)
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,140 @@
is_tax_unit_dependent: true
output:
nm_cdcc_eligible_child: true

- name: 2025 joint return with one claimable spouse has no eligible child (the claimable spouse is the head)
period: 2025
input:
people:
person_a:
age: 30
claimed_as_dependent_on_another_return: true
is_tax_unit_head: true
is_tax_unit_spouse: false
person_b:
age: 30
is_tax_unit_head: false
is_tax_unit_spouse: true
child:
age: 5
tax_units:
tax_unit:
members: [person_a, person_b, child]
filing_status: JOINT
households:
household:
members: [person_a, person_b, child]
state_code: NM
output:
# NMSA 7-2-18.1 counts IRC 152 dependents; IRC 152(b)(1) leaves such a
# return none.
nm_cdcc_eligible_child: [false, false, false]

- name: 2025 joint return with one claimable spouse has no eligible child (the claimable spouse is the spouse)
period: 2025
input:
people:
person_b:
age: 30
is_tax_unit_head: true
is_tax_unit_spouse: false
person_a:
age: 30
claimed_as_dependent_on_another_return: true
is_tax_unit_head: false
is_tax_unit_spouse: true
child:
age: 5
tax_units:
tax_unit:
members: [person_b, person_a, child]
filing_status: JOINT
households:
household:
members: [person_b, person_a, child]
state_code: NM
output:
# NMSA 7-2-18.1 counts IRC 152 dependents; IRC 152(b)(1) leaves such a
# return none.
nm_cdcc_eligible_child: [false, false, false]

- name: 2025 joint return with neither spouse claimable has an eligible child
period: 2025
input:
people:
person_a:
age: 30
person_b:
age: 30
child:
age: 5
tax_units:
tax_unit:
members: [person_a, person_b, child]
filing_status: JOINT
households:
household:
members: [person_a, person_b, child]
state_code: NM
output:
nm_cdcc_eligible_child: [false, false, true]

# Publication 501, Dependent Taxpayer Test: a filer whose would-be claimant is not
# required to file and files no return or only for a refund can claim dependents.
- name: 2025 joint return whose claimable spouse is within the filing exception has an eligible child (the claimable spouse is the head)
period: 2025
input:
people:
person_a:
age: 30
claimable_as_dependent_on_another_return: true
dependent_claimant_filing_exception: true
is_tax_unit_head: true
is_tax_unit_spouse: false
person_b:
age: 30
is_tax_unit_head: false
is_tax_unit_spouse: true
child:
age: 5
is_tax_unit_head: false
is_tax_unit_spouse: false
tax_units:
tax_unit:
members: [person_a, person_b, child]
filing_status: JOINT
households:
household:
members: [person_a, person_b, child]
state_code: NM
output:
nm_cdcc_eligible_child: [false, false, true]

- name: 2025 joint return whose claimable spouse is within the filing exception has an eligible child (the claimable spouse is the spouse)
period: 2025
input:
people:
person_b:
age: 30
is_tax_unit_head: true
is_tax_unit_spouse: false
person_a:
age: 30
claimable_as_dependent_on_another_return: true
dependent_claimant_filing_exception: true
is_tax_unit_head: false
is_tax_unit_spouse: true
child:
age: 5
is_tax_unit_head: false
is_tax_unit_spouse: false
tax_units:
tax_unit:
members: [person_b, person_a, child]
filing_status: JOINT
households:
household:
members: [person_b, person_a, child]
state_code: NM
output:
nm_cdcc_eligible_child: [false, false, true]
Loading