From 0ab7df2f575d42050598b2cf141f3fd359f375b0 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 7 Nov 2026 15:11:14 -0500 Subject: [PATCH 01/10] Leave federally excluded income out of North Dakota renter's refund income N.D.C.C. 57-02-08.1(5)(c) counts income from all sources but excludes "any amount excluded from income by federal or state law with the exception of income from social security benefits". nd_renters_refund_income sums market_income, which counts wages before payroll deductions and the tax-exempt parts of interest, pensions and retirement distributions in full, so $5,000 of tax-exempt interest raised the income by $5,000. nd_renters_refund_federally_excluded_income now subtracts each part of market_income that federal gross income leaves out: the pre-tax payroll deductions (401(k) and 403(b) deferrals, payroll health premiums and HSA contributions, dependent care assistance within the IRC 129 limit), tax-exempt interest, the nontaxable parts of pensions and retirement account distributions, disability benefits from a plan the recipient paid for, and alimony under an instrument executed after 2018. It replaces the separate subtractions of pre-tax premiums and excluded disability benefits. Co-Authored-By: Claude Opus 5.5 --- ...renters-refund-federal-exclusions.fixed.md | 1 + ...ters_refund_federally_excluded_income.yaml | 76 ++++++++++++ .../nd_renters_refund_income.yaml | 114 ++++++++++++++++++ ...enters_refund_federally_excluded_income.py | 102 ++++++++++++++++ .../nd_renters_refund_income.py | 28 ++--- 5 files changed, 307 insertions(+), 14 deletions(-) create mode 100644 changelog.d/nd-renters-refund-federal-exclusions.fixed.md create mode 100644 policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.yaml create mode 100644 policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py diff --git a/changelog.d/nd-renters-refund-federal-exclusions.fixed.md b/changelog.d/nd-renters-refund-federal-exclusions.fixed.md new file mode 100644 index 00000000000..45c892d4ef6 --- /dev/null +++ b/changelog.d/nd-renters-refund-federal-exclusions.fixed.md @@ -0,0 +1 @@ +North Dakota renter's refund income leaves out every part of market income that federal law excludes from gross income, as N.D.C.C. 57-02-08.1(5)(c) requires: tax-exempt interest, the nontaxable parts of pensions and retirement distributions, the payroll deductions excluded from wages, and alimony under divorce instruments executed after 2018, besides the disability benefits it already left out. diff --git a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.yaml new file mode 100644 index 00000000000..9faa2a55b46 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.yaml @@ -0,0 +1,76 @@ +- name: Each part of market income that federal law excludes is subtracted once. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + employment_income: 60_000 + traditional_401k_contributions: 4_000 + traditional_403b_contributions: 1_000 + pre_tax_health_insurance_premiums: 3_000 + health_savings_account_payroll_contributions: 2_000 + dependent_care_employer_benefits: 5_000 + taxable_interest_income: 700 + tax_exempt_interest_income: 1_500 + taxable_private_pension_income: 9_000 + tax_exempt_private_pension_income: 2_500 + tax_exempt_401k_distributions: 3_000 + taxable_401k_distributions: 4_000 + disability_benefits: 8_000 + tax_exempt_disability_benefits: 3_500 + alimony_income: 6_000 + divorce_year: 2021 + output: + # Payroll deductions 4,000 + 1,000 + 3,000 + 2,000 + 5,000 = 15,000, + # all within their limits, plus 1,500 + 2,500 + 3,000 + 3,500 + 6,000. + nd_renters_refund_federally_excluded_income: 31_500 + +- name: Taxable amounts are not excluded. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + employment_income: 30_000 + taxable_interest_income: 1_000 + taxable_private_pension_income: 5_000 + taxable_ira_distributions: 2_000 + disability_benefits: 4_000 + alimony_income: 6_000 + divorce_year: 2015 + strike_benefits: 1_000 + military_retirement_pay: 10_000 + output: + nd_renters_refund_federally_excluded_income: 0 + +- name: A tax-exempt amount above the reported total of its source is capped at that total. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + interest_income: 3_000 + tax_exempt_interest_income: 5_000 + output: + market_income: 3_000 + nd_renters_refund_federally_excluded_income: 3_000 + +- name: A source reported only as a total counts in full. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + pension_income: 12_000 + output: + nd_renters_refund_federally_excluded_income: 0 + +- name: The exclusion applies only in North Dakota. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: SD + tax_exempt_interest_income: 5_000 + output: + nd_renters_refund_federally_excluded_income: 0 diff --git a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml index 187e04fe8d3..0341b11abdd 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml @@ -249,3 +249,117 @@ # The 5,000 from a plan the recipient paid for is excluded by IRC # 104(a)(3), and NDCC 57-02-08.1(5)(c) excludes it: 10,000 + 7,000. nd_renters_refund_income: 17_000 + +- name: North Dakota leaves out interest on state and local bonds, which federal law excludes from income. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + employment_income: 20_000 + taxable_interest_income: 1_000 + tax_exempt_interest_income: 5_000 + output: + market_income: 26_000 + # IRC 103(a) excludes the 5,000 of bond interest, and NDCC + # 57-02-08.1(5)(c) excludes any amount federal law excludes: + # 20,000 + 1,000. + nd_renters_refund_income: 21_000 + +- name: North Dakota counts social security in full but leaves out the nontaxable parts of pensions and IRA distributions. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + taxable_private_pension_income: 10_000 + # The investment in the contract (IRC 72(b)(1)). + tax_exempt_private_pension_income: 4_000 + # A qualified Roth IRA distribution (IRC 408A(d)(1)). + tax_exempt_ira_distributions: 6_000 + taxable_ira_distributions: 3_000 + social_security_retirement: 8_000 + output: + # Social security is the one federal exclusion the statute keeps in + # income: 10,000 + 3,000 + 8,000. + nd_renters_refund_income: 21_000 + +- name: North Dakota leaves out the payroll deductions federal law excludes from wages. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + employment_income: 50_000 + # IRC 402(e)(3) and 402(g)(1) elective deferrals, and HSA contributions + # through payroll (IRC 106(d)). + traditional_401k_contributions: 5_000 + health_savings_account_payroll_contributions: 2_000 + output: + irs_employment_income: 43_000 + nd_renters_refund_income: 43_000 + +- name: North Dakota counts dependent care assistance above the IRC 129 limit. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + employment_income: 50_000 + dependent_care_employer_benefits: 9_000 + output: + # IRC 129(a)(2)(A) excludes 7,500 for 2026, and the other 1,500 is + # gross income: 50,000 - 7,500. + taxable_dependent_care_benefits: 1_500 + nd_renters_refund_income: 42_500 + +- name: North Dakota leaves out alimony under a divorce instrument executed after 2018. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + employment_income: 10_000 + alimony_income: 12_000 + divorce_year: 2020 + output: + # The recipient's gross income leaves out alimony under an instrument + # executed after 2018 (IRS Topic 452). + nd_renters_refund_income: 10_000 + +- name: North Dakota counts alimony under a divorce instrument executed before 2019. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + employment_income: 10_000 + alimony_income: 12_000 + divorce_year: 2015 + output: + nd_renters_refund_income: 22_000 + +- name: North Dakota leaves out a dependent's tax-exempt interest and counts the rest of the dependent's income. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + employment_income: 30_000 + child: + age: 15 + is_tax_unit_dependent: true + taxable_interest_income: 500 + tax_exempt_interest_income: 2_000 + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: ND + output: + # NDCC 57-02-08.1(5)(c) counts the dependent's income and excludes what + # federal law excludes: 30,000 + 500. + nd_renters_refund_income: 30_500 diff --git a/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py b/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py new file mode 100644 index 00000000000..c5a79c48096 --- /dev/null +++ b/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py @@ -0,0 +1,102 @@ +from policyengine_us.model_api import * + + +class nd_renters_refund_federally_excluded_income(Variable): + value_type = float + entity = Person + label = "North Dakota Renter's Refund market income excluded by federal law" + unit = USD + definition_period = YEAR + documentation = ( + "The parts of market_income that federal law leaves out of gross " + "income, which N.D.C.C. 57-02-08.1(5)(c) excludes from renter's refund " + "income: the payroll deductions federal law excludes from wages, " + "tax-exempt interest, the nontaxable part of pensions and of " + "retirement account distributions, disability benefits from a plan " + "the recipient paid for, and alimony under a divorce or separation " + "instrument executed after 2018. Each part is at least zero and at " + "most the market_income component it comes from." + ) + reference = ( + # N.D.C.C. 57-02-08.1(5)(c). + "https://ndlegis.gov/cencode/t57c02.pdf#page=16", + # Payroll deductions: elective deferrals (402(e)(3), 402(g)(1)), + # 403(b) contributions, employer health coverage and HSA + # contributions (106(a), 106(d)), cafeteria plans (125(a)) and + # dependent care assistance (129(a)). + "https://www.law.cornell.edu/uscode/text/26/402", + "https://www.law.cornell.edu/uscode/text/26/403#b_1", + "https://www.law.cornell.edu/uscode/text/26/106", + "https://www.law.cornell.edu/uscode/text/26/125#a", + "https://www.law.cornell.edu/uscode/text/26/129#a", + # Interest on state and local bonds. + "https://www.law.cornell.edu/uscode/text/26/103#a", + # Pensions and retirement accounts: the investment in the contract + # (72(b)(1)), rollovers (402(c)(1), 408(d)(3)), and qualified Roth + # distributions (402A(d)(1), 408A(d)(1)). + "https://www.law.cornell.edu/uscode/text/26/72#b_1", + "https://www.law.cornell.edu/uscode/text/26/402A#d_1", + "https://www.law.cornell.edu/uscode/text/26/408#d", + "https://www.law.cornell.edu/uscode/text/26/408A#d_1", + # Disability benefits from a plan the recipient paid for. + "https://www.law.cornell.edu/uscode/text/26/104#a_3", + # Alimony under an instrument executed after 2018. + "https://www.irs.gov/taxtopics/tc452", + ) + defined_for = StateCode.ND + + def formula(person, period, parameters): + def excluded_part(component, excluded): + # Never negative, and never more than the market_income component + # the amount comes from, so an input that reports only the + # component's total keeps all of it as income. + return min_(max_(excluded, 0), max_(component, 0)) + + # Federal gross income counts wages as irs_employment_income, which + # subtracts the pre-tax payroll deductions in pre_tax_contributions + # (traditional 401(k) and 403(b) deferrals, health premiums and HSA + # contributions through payroll, and dependent care assistance), plus + # the dependent care assistance above the IRC 129 limit. Pre-tax + # premiums leave income here, and itemized_medical_expenses leaves + # them out, so no premium is subtracted twice. + wages = person("employment_income", period) + counted_wages = person("irs_employment_income", period) + person( + "taxable_dependent_care_benefits", period + ) + payroll_exclusions = excluded_part(wages, wages - counted_wages) + # Interest on state and local bonds (IRC 103(a)). + interest = excluded_part( + person("interest_income", period), + person("tax_exempt_interest_income", period), + ) + # The investment in the contract, rollovers and qualified distributions + # from designated Roth accounts (IRC 72(b)(1), 402(c)(1), 402A(d)(1)). + pensions = excluded_part( + person("pension_income", period), + person("tax_exempt_pension_income", period), + ) + # Qualified Roth IRA distributions, rollovers and nondeductible + # contributions returned (IRC 408(d), 408A(d)(1)). + retirement_distributions = excluded_part( + person("retirement_distributions", period), + person("tax_exempt_retirement_distributions", period), + ) + # Benefits from a plan the recipient paid for (IRC 104(a)(3)). + disability_benefits = excluded_part( + person("disability_benefits", period), + person("tax_exempt_disability_benefits", period), + ) + # Alimony under an instrument executed after 2018 is not included in + # the recipient's gross income; taxable_alimony_income holds the rest. + alimony = person("alimony_income", period) + excluded_alimony = excluded_part( + alimony, alimony - person("taxable_alimony_income", period) + ) + return ( + payroll_exclusions + + interest + + pensions + + retirement_distributions + + disability_benefits + + excluded_alimony + ) 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 6a85ef76629..dd05606832f 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 @@ -14,7 +14,11 @@ class nd_renters_refund_income(Variable): defined_for = StateCode.ND documentation = ( - "Renter refund income after unreimbursed medical costs actually paid. " + "Renter refund income: the listed income sources, less the parts of " + "market income that federal law excludes " + "(nd_renters_refund_federally_excluded_income) and the unreimbursed " + "medical costs actually paid, and at least zero. 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 " @@ -26,17 +30,14 @@ class nd_renters_refund_income(Variable): def formula(tax_unit, period, parameters): p = parameters(period).gov.states.nd.tax.property.renters_refund - # NDCC 57-02-08.1(5)(c) excludes income excluded by federal or state - # law. market_income includes wages before payroll deductions, so - # subtract the separate pretax premium input once from this base. - # These premiums are disjoint from itemized_medical_expenses, - # whose medical definition follows state income tax law. - excluded_premiums = add(tax_unit, period, ["pre_tax_health_insurance_premiums"]) - # market_income counts disability benefits in full, and federal law - # excludes the part from a plan the recipient paid for (IRC 104(a)(3)). - excluded_disability_benefits = add( - tax_unit, period, ["disability_benefits"] - ) - add(tax_unit, period, ["taxable_disability_benefits"]) + # NDCC 57-02-08.1(5)(c) excludes "any amount excluded from income by + # federal or state law with the exception of income from social + # security benefits". market_income counts wages before payroll + # deductions and the tax-exempt parts of several sources in full, so + # subtract the parts federal law excludes. Social security stays whole. + excluded_income = add( + tax_unit, period, ["nd_renters_refund_federally_excluded_income"] + ) # Restore premiums excluded from the federal subtotal (computed, or # supplied with a caller's subtotal). medical_expenses = add( @@ -49,8 +50,7 @@ def formula(tax_unit, period, parameters): ) return max_( add(tax_unit, period, p.income_sources) - - excluded_premiums - - excluded_disability_benefits + - excluded_income - medical_expenses, 0, ) From 1f54af1e3e257d4747108d7690720bb77d47da4a Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 7 Nov 2026 15:30:11 -0500 Subject: [PATCH 02/10] Test the ND renter's refund exclusions as invariants and log the conflict Property tests check that every market_income component has a stated treatment, that each excluded part lies between zero and its component, that renter's refund income equals irs_gross_income on shared sources, and that a dollar moved to its excluded form leaves income. The candidate entry records the statute against the guideline's item 10 and the application's lines 5 to 7. Co-Authored-By: Claude Opus 5.5 --- ...est_nd_renters_refund_income_exclusions.py | 331 ++++++++++++++++++ source_conflicts/candidates.yaml | 42 +++ 2 files changed, 373 insertions(+) create mode 100644 policyengine_us/tests/test_nd_renters_refund_income_exclusions.py diff --git a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py new file mode 100644 index 00000000000..1f195277ef3 --- /dev/null +++ b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py @@ -0,0 +1,331 @@ +"""Invariants for the federal exclusions in North Dakota's renter's refund income. + +N.D.C.C. 57-02-08.1(5)(c) (https://ndlegis.gov/cencode/t57c02.pdf#page=16) +counts income "from all sources", but excludes "any amount excluded from +income by federal or state law with the exception of income from social +security benefits". nd_renters_refund_income starts from market_income. That +counts wages before payroll deductions, and the tax-exempt parts of interest, +pensions, retirement distributions, disability benefits and alimony, so the +variable subtracts nd_renters_refund_federally_excluded_income. + +Four invariants hold for every input. + +1. Every market_income component has a stated treatment. Either federal gross + income counts it in full, or North Dakota subtracts the part federal law + excludes, or federal gross income leaves it out although federal law does + not exclude it (each named below, with the reason). A new component fails + until it is classified, so a wider market_income cannot bring excluded + income into the refund again, as #10663's wider market_income did. +2. Each excluded part lies between zero and the market_income component it + comes from, so the exclusions never exceed what those components hold. +3. Differential: for a filer whose income comes only from sources that + market_income and federal gross income share, renter's refund income equals + irs_gross_income. The statute's federal exclusions and the federal gross + income model agree on every shared source. +4. Moving a dollar from the taxable form of a source to its excluded form + lowers renter's refund income by that dollar. A dollar of social security + raises it by a dollar, however much of the benefit federal law taxes. + +YAML pins one household per case. These need random amounts over many +households at once, and a list read from market_income's source file. +""" + +import re +from pathlib import Path + +import pytest +import yaml +from hypothesis import example, given, settings +from hypothesis import strategies as st + +from policyengine_us import Simulation + +PACKAGE = Path(__file__).parent.parent +MARKET_INCOME = PACKAGE / "variables/household/income/person/general/market_income.py" +GROSS_INCOME_SOURCES = PACKAGE / "parameters/gov/irs/gross_income/sources.yaml" +YEAR = 2026 +# Amounts are float32 in the model. +TOLERANCE = 0.5 + +# Components federal gross income counts in full, and the gross income source +# that holds each. +COUNTED_IN_FULL = { + "self_employment_income": "self_employment_income", + "sstb_self_employment_income": "sstb_self_employment_income", + "partnership_s_corp_income": "partnership_s_corp_income", + "dividend_income": "dividend_income", + "capital_gains": "capital_gains", + "non_sch_d_capital_gains": "non_sch_d_capital_gains", + "other_net_gain_person": "other_net_gain_gross_income", + "rental_income": "rental_income", + "farm_rent_income": "farm_rent_income", + "estate_income": "estate_income", + "illicit_income": "illicit_income", + "farm_operations_income": "farm_operations_income", + "miscellaneous_income": "miscellaneous_income", + "military_retirement_income": "military_retirement_income", + "ak_permanent_fund_dividend": "ak_permanent_fund_dividend", +} + +# Components with a part federal law excludes: the gross income source that +# holds the rest, and the law that excludes the part. +PARTLY_EXCLUDED = { + "employment_income": ( + "irs_employment_income", + "IRC 402(e)(3), 402(g)(1), 403(b)(1), 106, 125 and 129(a): pre-tax " + "payroll deductions", + ), + "interest_income": ("taxable_interest_income", "IRC 103(a)"), + "pension_income": ("taxable_pension_income", "IRC 72(b)(1), 402(c), 402A(d)"), + "retirement_distributions": ( + "taxable_retirement_distributions", + "IRC 408(d), 408A(d)(1)", + ), + "disability_benefits": ("taxable_disability_benefits", "IRC 104(a)(3)"), + "alimony_income": ( + "taxable_alimony_income", + "Pub. L. 115-97 section 11051: instruments executed after 2018", + ), +} + +# Components that federal gross income leaves out although federal law does +# not exclude them in general. North Dakota counts them. +COUNTED_THOUGH_GROSS_INCOME_OMITS = { + "strike_benefits": "IRS Publication 525 counts strike benefits as income " + "unless the facts show the union meant them as gifts", + "gi_cash_assistance": "a guaranteed income payment is a gift (IRC 102) or " + "public assistance, which the statute counts, depending on the payer, and " + "the input records neither", +} + + +def market_income_components(): + return set(re.findall(r'^\s+"([a-z0-9_]+)",', MARKET_INCOME.read_text(), re.M)) + + +def gross_income_sources(): + raw = yaml.load(GROSS_INCOME_SOURCES.read_text(), Loader=yaml.BaseLoader) + return {name for block in raw["values"].values() for name in block} + + +def test_every_market_income_component_has_a_stated_treatment(): + lists = ( + set(COUNTED_IN_FULL), + set(PARTLY_EXCLUDED), + set(COUNTED_THOUGH_GROSS_INCOME_OMITS), + ) + for index, first in enumerate(lists): + for second in lists[index + 1 :]: + assert not first & second, first & second + classified = set().union(*lists) + components = market_income_components() + assert components - classified == set(), ( + f"market_income components with no North Dakota treatment: " + f"{sorted(components - classified)}. Say whether federal gross income " + "counts each in full, or subtract the part federal law excludes in " + "nd_renters_refund_federally_excluded_income." + ) + assert classified - components == set(), "stale entries above" + + +def test_each_treatment_matches_the_federal_gross_income_list(): + sources = gross_income_sources() + counted = set(COUNTED_IN_FULL.values()) | { + taxable for taxable, _ in PARTLY_EXCLUDED.values() + } + assert counted - sources == set() + # A component that federal gross income starts counting moves to + # COUNTED_IN_FULL. + assert not set(COUNTED_THOUGH_GROSS_INCOME_OMITS) & sources + + +def situation(households): + """Single adults in North Dakota, one per household.""" + people, groups = {}, {} + for index, inputs in enumerate(households): + name = f"person_{index}" + people[name] = {"age": {YEAR: 40}, **{k: {YEAR: v} for k, v in inputs.items()}} + groups[name] = {"members": [name]} + return { + "people": people, + "tax_units": {f"tax_unit_{k}": v for k, v in groups.items()}, + "spm_units": {f"spm_unit_{k}": v for k, v in groups.items()}, + "families": {f"family_{k}": v for k, v in groups.items()}, + "marital_units": {f"marital_unit_{k}": v for k, v in groups.items()}, + "households": { + f"household_{k}": {**v, "state_code": {YEAR: "ND"}} + for k, v in groups.items() + }, + } + + +def calculate(households, *names): + simulation = Simulation(situation=situation(households)) + return [simulation.calculate(name, YEAR).astype(float) for name in names] + + +amount = st.integers(min_value=0, max_value=40_000) + + +@st.composite +def shared_sources(draw): + """Nonnegative income from sources market_income and gross income share.""" + deductions = { + name: draw(st.integers(min_value=0, max_value=8_000)) + for name in ( + "traditional_401k_contributions", + "traditional_403b_contributions", + "pre_tax_health_insurance_premiums", + "health_savings_account_payroll_contributions", + "dependent_care_employer_benefits", + ) + } + disability = draw(amount) + inputs = { + # Wages cover the payroll deductions. + "employment_income": sum(deductions.values()) + + draw(st.integers(min_value=0, max_value=150_000)), + **deductions, + "taxable_interest_income": draw(amount), + "tax_exempt_interest_income": draw(amount), + "taxable_private_pension_income": draw(amount), + "tax_exempt_private_pension_income": draw(amount), + "taxable_public_pension_income": draw(amount), + "tax_exempt_public_pension_income": draw(amount), + "taxable_ira_distributions": draw(amount), + "tax_exempt_ira_distributions": draw(amount), + "taxable_401k_distributions": draw(amount), + "tax_exempt_401k_distributions": draw(amount), + "disability_benefits": disability, + "tax_exempt_disability_benefits": draw( + st.integers(min_value=0, max_value=disability) + ), + "alimony_income": draw(amount), + "divorce_year": draw(st.sampled_from([2010, 2018, 2019, 2024])), + "self_employment_income": draw(amount), + "qualified_dividend_income": draw(amount), + "non_qualified_dividend_income": draw(amount), + "long_term_capital_gains": draw(amount), + "rental_income": draw(amount), + "miscellaneous_income": draw(amount), + "military_retirement_pay": draw(amount), + } + # Leave out a random subset, so zero amounts and missing inputs both occur. + keep = draw(st.sets(st.sampled_from(sorted(inputs)))) + return {k: v for k, v in inputs.items() if k in keep or k == "employment_income"} + + +@settings(max_examples=12, deadline=None) +@given(households=st.lists(shared_sources(), min_size=1, max_size=12)) +@example( + households=[ + { + "employment_income": 50_000, + "traditional_401k_contributions": 5_000, + "tax_exempt_interest_income": 5_000, + "tax_exempt_private_pension_income": 4_000, + "alimony_income": 12_000, + "divorce_year": 2020, + } + ] +) +def test_renters_refund_income_equals_gross_income_on_shared_sources(households): + nd_income, gross_income = calculate( + households, "nd_renters_refund_income", "irs_gross_income" + ) + assert list(nd_income) == pytest.approx(list(gross_income), abs=TOLERANCE) + + +# Inputs for the bounds test: shared sources, plus totals reported without +# their split and tax-exempt parts larger than the totals they belong to. +TOTALS = ("interest_income", "pension_income", "retirement_distributions") + + +@st.composite +def any_sources(draw): + inputs = draw(shared_sources()) + for name in draw(st.sets(st.sampled_from(TOTALS))): + inputs[name] = draw(amount) + if draw(st.booleans()): + inputs["tax_exempt_disability_benefits"] = inputs.get( + "disability_benefits", 0 + ) + draw(amount) + inputs["capital_gains"] = draw(st.integers(min_value=-60_000, max_value=40_000)) + inputs["strike_benefits"] = draw(amount) + return inputs + + +@settings(max_examples=12, deadline=None) +@given(households=st.lists(any_sources(), min_size=1, max_size=12)) +def test_each_excluded_part_lies_within_its_component(households): + names = ["nd_renters_refund_federally_excluded_income", "nd_renters_refund_income"] + names += list(PARTLY_EXCLUDED) + excluded, nd_income, *components = calculate(households, *names) + ceiling = sum(component.clip(min=0) for component in components) + assert (excluded >= -TOLERANCE).all() + assert (excluded <= ceiling + TOLERANCE).all() + assert (nd_income >= 0).all() + + +# Each pair moves a dollar from the taxable form of a source to its excluded +# form. +SHIFTS = [ + ("taxable_interest_income", "tax_exempt_interest_income"), + ("taxable_private_pension_income", "tax_exempt_private_pension_income"), + ("taxable_public_pension_income", "tax_exempt_public_pension_income"), + ("taxable_ira_distributions", "tax_exempt_ira_distributions"), + ("taxable_401k_distributions", "tax_exempt_401k_distributions"), + ("taxable_403b_distributions", "tax_exempt_403b_distributions"), + ("taxable_sep_distributions", "tax_exempt_sep_distributions"), +] + + +@settings(max_examples=12, deadline=None) +@given( + shift=st.sampled_from(SHIFTS), + taxable=st.integers(min_value=1, max_value=60_000), + exempt=st.integers(min_value=0, max_value=60_000), + share=st.floats(min_value=0, max_value=1), + wages=st.integers(min_value=0, max_value=100_000), + social_security=st.integers(min_value=0, max_value=40_000), +) +def test_a_dollar_moved_to_its_excluded_form_leaves_income( + shift, taxable, exempt, share, wages, social_security +): + taxable_name, exempt_name = shift + moved = round(taxable * share) + base = { + "employment_income": wages, + "social_security_retirement": social_security, + taxable_name: taxable, + exempt_name: exempt, + } + shifted = {**base, taxable_name: taxable - moved, exempt_name: exempt + moved} + # A wage dollar deferred into a traditional 401(k), and a disability + # dollar from a plan the recipient paid for, leave the same way. + deferral = round(wages * share) + deferred = {**base, "traditional_401k_contributions": deferral} + disability = {**base, "disability_benefits": exempt + moved} + paid_for = {**disability, "tax_exempt_disability_benefits": moved} + # Social security counts in full however much of it is taxed. + more_social_security = { + **base, + "social_security_retirement": social_security + moved, + } + households = [base, shifted, deferred, disability, paid_for, more_social_security] + (income,) = calculate(households, "nd_renters_refund_income") + assert income[0] - income[1] == pytest.approx(moved, abs=TOLERANCE) + assert income[0] - income[2] == pytest.approx(deferral, abs=TOLERANCE) + assert income[3] - income[4] == pytest.approx(moved, abs=TOLERANCE) + assert income[5] - income[0] == pytest.approx(moved, abs=TOLERANCE) + + +def test_alimony_leaves_income_only_under_a_post_2018_instrument(): + households = [ + {"employment_income": 10_000, "alimony_income": 12_000, "divorce_year": year} + for year in (2015, 2018, 2019, 2024) + ] + (income,) = calculate(households, "nd_renters_refund_income") + assert list(income) == pytest.approx( + [22_000, 22_000, 10_000, 10_000], abs=TOLERANCE + ) diff --git a/source_conflicts/candidates.yaml b/source_conflicts/candidates.yaml index 74cbb1c433c..c2d66efc368 100644 --- a/source_conflicts/candidates.yaml +++ b/source_conflicts/candidates.yaml @@ -6701,6 +6701,48 @@ candidates: and $105,227; 8, $107,574 and $107,565; 9, $109,914 and $109,903; 11, $114,582 and $114,580; 12, $116,922 and $116,919. Size 1 is below the ceiling, size 10 equals it, and from size 13 150% of the guideline exceeds the table. Verify each later fiscal-year table.' +- id: us-nd:renters-refund-federally-excluded-income + program: renter-credit + years: + from: 2025 + type: tax + question: Does the renter's refund count the interest, pensions, IRA distributions, wages and alimony that federal + law leaves out of gross income, when the Tax Commissioner's guideline and the application list those sources as + income with no exception? + sources: + - kind: statute + citation: N.D.C.C. 57-02-08.1(5)(c) + url: https://ndlegis.gov/cencode/t57c02.pdf#page=16 + - kind: guidance + citation: Property Tax Credits for North Dakota Homeowners and Renters, item 10 + url: https://www.tax.nd.gov/sites/www/files/documents/guidelines/homestead-veterans-renters/credits-for-nd-homeowners-renters-guideline.pdf#page=2 + - kind: form + citation: SFN 24777 (10-2025), lines 5 to 7 and the instructions for lines 4 to 9 + url: https://www.tax.nd.gov/sites/www/files/documents/forms/homestead-disabled-renters/renters-refund-application.pdf#page=1 + readings: + statute: Income comes from all sources but leaves out "any amount excluded from income by federal or state law + with the exception of income from social security benefits". Federal law leaves out of gross income the interest + on state and local bonds (IRC 103(a)); the return of a pension's cost, rollovers and qualified Roth distributions + (IRC 72(b)(1), 402(c)(1), 402A(d)(1), 408(d)(3), 408A(d)(1)); the pre-tax payroll deductions of IRC 106, 125, + 129, 402(e)(3) and 403(b)(1); and alimony under a divorce or separation instrument executed after 2018. + other: Item 10 lists pensions "including military pension and I.R.A.", salaries and wages, dividends and interest, + and alimony as income. The application asks for income from salary and wages (line 5) and from interest (line + 6), and its instructions for lines 4 to 9 repeat the list. Neither leaves out the amounts federal law excludes. + example: A renter with $20,000 of wages, $1,000 of taxable interest and $5,000 of interest on municipal bonds has + income of $21,000 under the statute and $26,000 under item 10 and line 6. + pe_us: + follows: statute + code: + - policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py + - policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.py + prs: + - https://github.com/PolicyEngine/policyengine-us/pull/10697 + state: ruled + note: The statute names the exclusion, so it governs over the general lists, as in + us-nd:renters-refund-insurance-proceeds. Social security counts in full by the statute's own exception. North + Dakota's income tax reductions (N.D.C.C. 57-38-30.3(2)), such as military pay, military retirement benefits and 40 + percent of long-term capital gains and qualified dividends, lower taxable income; they do not exclude amounts from + income, and item 10 counts military pensions and net gains, so the refund counts them. - id: us-nd:renters-refund-insurance-proceeds program: renter-credit years: From ac21cd383bf3db064e0706d87a4752bad98d0cfe Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 7 Nov 2026 16:38:24 -0500 Subject: [PATCH 03/10] Subtract the federal exclusions the model deducts above the line The federal model takes four exclusions from gross income as above-the-line deductions, so market_income still holds the income they exclude: savings bond interest spent on higher education (IRC 135), employer adoption assistance (IRC 137), and income from Puerto Rico and the specified possessions (IRC 931, 933). North Dakota's renter's refund income now subtracts them from the tax unit's market income left after the person-level exclusions, never from social security. A new property test classifies every federal above-the-line deduction as a deduction or an exclusion, so a new one fails until someone classifies it. Co-Authored-By: Claude Opus 5.5 --- ...renters-refund-federal-exclusions.fixed.md | 2 +- .../renters_refund/excluded_deductions.yaml | 27 +++ .../nd_renters_refund_income.yaml | 100 +++++++++++ ...est_nd_renters_refund_income_exclusions.py | 159 +++++++++++++++--- ...enters_refund_federally_excluded_income.py | 18 +- .../nd_renters_refund_income.py | 30 +++- source_conflicts/candidates.yaml | 8 +- 7 files changed, 307 insertions(+), 37 deletions(-) create mode 100644 policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml diff --git a/changelog.d/nd-renters-refund-federal-exclusions.fixed.md b/changelog.d/nd-renters-refund-federal-exclusions.fixed.md index 45c892d4ef6..42ede54dde3 100644 --- a/changelog.d/nd-renters-refund-federal-exclusions.fixed.md +++ b/changelog.d/nd-renters-refund-federal-exclusions.fixed.md @@ -1 +1 @@ -North Dakota renter's refund income leaves out every part of market income that federal law excludes from gross income, as N.D.C.C. 57-02-08.1(5)(c) requires: tax-exempt interest, the nontaxable parts of pensions and retirement distributions, the payroll deductions excluded from wages, and alimony under divorce instruments executed after 2018, besides the disability benefits it already left out. +North Dakota renter's refund income leaves out every part of market income that federal law excludes from gross income, as N.D.C.C. 57-02-08.1(5)(c) requires: tax-exempt interest and savings bond interest spent on higher education, the nontaxable parts of pensions and retirement distributions, the payroll deductions and employer adoption assistance excluded from wages, income from Puerto Rico and the U.S. possessions that federal law excludes, and alimony under divorce instruments executed after 2018, besides the disability benefits it already left out. diff --git a/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml b/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml new file mode 100644 index 00000000000..cf7327a3942 --- /dev/null +++ b/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml @@ -0,0 +1,27 @@ +description: North Dakota subtracts these federal exclusions from income under the Renter's Refund program, because the model deducts them above the line and market income still holds the income they exclude. +values: + 2025-01-01: + # Savings bond interest spent on higher education. + - us_bonds_for_higher_ed + # Employer adoption assistance. + - qualified_adoption_assistance_expense + # Income of bona fide residents of Guam, American Samoa or the Northern + # Mariana Islands from sources there. + - specified_possession_income + # Income of bona fide residents of Puerto Rico from sources there. + - puerto_rico_income +metadata: + unit: list + period: year + label: North Dakota Renter's Refund federal exclusions deducted above the line + reference: + - title: N.D.C.C. § 57-02-08.1(5)(c) + href: https://ndlegis.gov/cencode/t57c02.pdf#page=16 + - title: 26 U.S. Code § 135(a) + href: https://www.law.cornell.edu/uscode/text/26/135#a + - title: 26 U.S. Code § 137(a) + href: https://www.law.cornell.edu/uscode/text/26/137#a + - title: 26 U.S. Code § 931(a) + href: https://www.law.cornell.edu/uscode/text/26/931#a + - title: 26 U.S. Code § 933 + href: https://www.law.cornell.edu/uscode/text/26/933 diff --git a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml index 0341b11abdd..9a943f01dde 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml @@ -363,3 +363,103 @@ # NDCC 57-02-08.1(5)(c) counts the dependent's income and excludes what # federal law excludes: 30,000 + 500. nd_renters_refund_income: 30_500 + +- name: North Dakota leaves out savings bond interest spent on higher education, which federal law excludes from income. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + employment_income: 20_000 + taxable_interest_income: 3_000 + # IRC 135(a) excludes it. The model deducts it above the line, so + # interest_income still holds it. + us_bonds_for_higher_ed: 2_000 + output: + market_income: 23_000 + # 20,000 + 3,000 - 2,000. + nd_renters_refund_income: 21_000 + +- name: North Dakota leaves out savings bond interest whose exclusion the household records on the student it paid for. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 45 + employment_income: 30_000 + taxable_interest_income: 4_000 + child: + age: 19 + is_tax_unit_dependent: true + us_bonds_for_higher_ed: 2_500 + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: ND + output: + # 30,000 + 4,000 - 2,500. + nd_renters_refund_income: 31_500 + +- name: North Dakota leaves out employer adoption assistance, which federal law excludes from income. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + employment_income: 45_000 + child: + age: 3 + is_tax_unit_dependent: true + # IRC 137(a) excludes it, and households record it on the adopted + # child. The model deducts it above the line, so the wages include it. + qualified_adoption_assistance_expense: 5_000 + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: ND + output: + # 45,000 - 5,000. + nd_renters_refund_income: 40_000 + +- name: North Dakota leaves out income from Puerto Rico that federal law excludes. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 40 + employment_income: 40_000 + tax_units: + tax_unit: + members: [person] + # IRC 933 excludes it. The model deducts it above the line, so the + # wages include it. + puerto_rico_income: 15_000 + households: + household: + members: [person] + state_code: ND + output: + # 40,000 - 15,000. + nd_renters_refund_income: 25_000 + +- name: North Dakota takes the exclusions the model deducts above the line out of market income only, never out of social security. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + taxable_interest_income: 1_000 + us_bonds_for_higher_ed: 3_000 + social_security_retirement: 8_000 + output: + # Only the 1,000 of market income can leave: 1,000 + 8,000 - 1,000. + nd_renters_refund_income: 8_000 diff --git a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py index 1f195277ef3..a8f40d4474f 100644 --- a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py +++ b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py @@ -6,33 +6,43 @@ security benefits". nd_renters_refund_income starts from market_income. That counts wages before payroll deductions, and the tax-exempt parts of interest, pensions, retirement distributions, disability benefits and alimony, so the -variable subtracts nd_renters_refund_federally_excluded_income. +variable subtracts nd_renters_refund_federally_excluded_income. The federal +model also deducts four exclusions above the line, so market_income holds that +income too, and the variable subtracts them as well (excluded_deductions). Four invariants hold for every input. 1. Every market_income component has a stated treatment. Either federal gross income counts it in full, or North Dakota subtracts the part federal law excludes, or federal gross income leaves it out although federal law does - not exclude it (each named below, with the reason). A new component fails - until it is classified, so a wider market_income cannot bring excluded - income into the refund again, as #10663's wider market_income did. + not exclude it (each named below, with the reason). Every above-the-line + deduction in the federal model is likewise either a deduction, which leaves + the income in, or an exclusion, which North Dakota subtracts. A new + component or deduction fails until it is classified, so a wider + market_income cannot bring excluded income into the refund again, as + #10663's wider market_income did. 2. Each excluded part lies between zero and the market_income component it - comes from, so the exclusions never exceed what those components hold. + comes from, so the exclusions never exceed what those components hold. The + exclusions the model deducts above the line come only out of the market + income left after the others, so social security always counts in full. 3. Differential: for a filer whose income comes only from sources that market_income and federal gross income share, renter's refund income equals - irs_gross_income. The statute's federal exclusions and the federal gross - income model agree on every shared source. + irs_gross_income less the exclusions the federal model deducts above the + line. The statute's federal exclusions and the federal model agree on every + shared source. 4. Moving a dollar from the taxable form of a source to its excluded form lowers renter's refund income by that dollar. A dollar of social security raises it by a dollar, however much of the benefit federal law taxes. YAML pins one household per case. These need random amounts over many -households at once, and a list read from market_income's source file. +households at once, and lists read from market_income's source file and the +federal parameters. """ import re from pathlib import Path +import numpy as np import pytest import yaml from hypothesis import example, given, settings @@ -43,6 +53,11 @@ PACKAGE = Path(__file__).parent.parent MARKET_INCOME = PACKAGE / "variables/household/income/person/general/market_income.py" GROSS_INCOME_SOURCES = PACKAGE / "parameters/gov/irs/gross_income/sources.yaml" +ABOVE_THE_LINE = PACKAGE / "parameters/gov/irs/ald/deductions.yaml" +ND_DEDUCTED_EXCLUSIONS = ( + PACKAGE + / "parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml" +) YEAR = 2026 # Amounts are float32 in the model. TOLERANCE = 0.5 @@ -99,15 +114,55 @@ } +# The federal model's above-the-line deductions. A deduction leaves the income +# it offsets in renter's refund income; the statute excludes only what federal +# law excludes from income. +ABOVE_THE_LINE_DEDUCTIONS = { + "loss_ald": "IRC 62(a)(3) and 1211(b): capital losses", + "self_employment_tax_ald": "IRC 164(f)", + "student_loan_interest_ald": "IRC 221", + "early_withdrawal_penalty": "IRC 62(a)(9)", + "alimony_expense_ald": "IRC 215, for the payer", + "educator_expense_ald": "IRC 62(a)(2)(D)", + "capped_qualified_tuition_expenses_ald": "IRC 222", + "domestic_production_ald": "IRC 199", + "health_savings_account_ald": "IRC 223(a): contributions outside payroll", + "self_employed_health_insurance_ald": "IRC 162(l)", + "self_employed_pension_contribution_ald": "IRC 404", + "traditional_ira_deduction": "IRC 219", + "charitable_contributions_ald": "IRC 62(a)(22)", +} +# Exclusions from gross income that the federal model deducts above the line, +# with market_income holding the income they exclude. North Dakota subtracts +# them. +ABOVE_THE_LINE_EXCLUSIONS = { + "us_bonds_for_higher_ed": "IRC 135(a)", + "qualified_adoption_assistance_expense": "IRC 137(a)", + "specified_possession_income": "IRC 931(a)", + "puerto_rico_income": "IRC 933", +} +# The two a household records on a person; the other two are tax unit inputs, +# which the YAML tests cover. +PERSON_DEDUCTED_EXCLUSIONS = [ + "qualified_adoption_assistance_expense", + "us_bonds_for_higher_ed", +] + + def market_income_components(): return set(re.findall(r'^\s+"([a-z0-9_]+)",', MARKET_INCOME.read_text(), re.M)) -def gross_income_sources(): - raw = yaml.load(GROSS_INCOME_SOURCES.read_text(), Loader=yaml.BaseLoader) +def list_parameter_entries(path): + """Every name a list parameter has held in any period.""" + raw = yaml.load(path.read_text(), Loader=yaml.BaseLoader) return {name for block in raw["values"].values() for name in block} +def gross_income_sources(): + return list_parameter_entries(GROSS_INCOME_SOURCES) + + def test_every_market_income_component_has_a_stated_treatment(): lists = ( set(COUNTED_IN_FULL), @@ -139,6 +194,22 @@ def test_each_treatment_matches_the_federal_gross_income_list(): assert not set(COUNTED_THOUGH_GROSS_INCOME_OMITS) & sources +def test_every_above_the_line_deduction_has_a_stated_treatment(): + assert not set(ABOVE_THE_LINE_DEDUCTIONS) & set(ABOVE_THE_LINE_EXCLUSIONS) + entries = list_parameter_entries(ABOVE_THE_LINE) + classified = set(ABOVE_THE_LINE_DEDUCTIONS) | set(ABOVE_THE_LINE_EXCLUSIONS) + assert entries - classified == set(), ( + f"above-the-line deductions with no North Dakota treatment: " + f"{sorted(entries - classified)}. Say whether each is a deduction, " + "which leaves its income in renter's refund income, or an exclusion " + "from gross income, which excluded_deductions subtracts." + ) + assert classified - entries == set(), "stale entries above" + assert list_parameter_entries(ND_DEDUCTED_EXCLUSIONS) == set( + ABOVE_THE_LINE_EXCLUSIONS + ) + + def situation(households): """Single adults in North Dakota, one per household.""" people, groups = {}, {} @@ -181,12 +252,21 @@ def shared_sources(draw): ) } disability = draw(amount) + other_wages = draw(st.integers(min_value=0, max_value=150_000)) + taxable_interest = draw(amount) inputs = { - # Wages cover the payroll deductions. - "employment_income": sum(deductions.values()) - + draw(st.integers(min_value=0, max_value=150_000)), + # Wages cover the payroll deductions and any adoption assistance. + "employment_income": sum(deductions.values()) + other_wages, **deductions, - "taxable_interest_income": draw(amount), + # Exclusions the federal model deducts above the line, each within the + # income that holds it. + "qualified_adoption_assistance_expense": draw( + st.integers(min_value=0, max_value=other_wages) + ), + "us_bonds_for_higher_ed": draw( + st.integers(min_value=0, max_value=taxable_interest) + ), + "taxable_interest_income": taxable_interest, "tax_exempt_interest_income": draw(amount), "taxable_private_pension_income": draw(amount), "tax_exempt_private_pension_income": draw(amount), @@ -212,7 +292,11 @@ def shared_sources(draw): } # Leave out a random subset, so zero amounts and missing inputs both occur. keep = draw(st.sets(st.sampled_from(sorted(inputs)))) - return {k: v for k, v in inputs.items() if k in keep or k == "employment_income"} + kept = {k: v for k, v in inputs.items() if k in keep or k == "employment_income"} + # Taxable interest holds the savings bond interest. + if "taxable_interest_income" not in kept: + kept.pop("us_bonds_for_higher_ed", None) + return kept @settings(max_examples=12, deadline=None) @@ -226,6 +310,9 @@ def shared_sources(draw): "tax_exempt_private_pension_income": 4_000, "alimony_income": 12_000, "divorce_year": 2020, + "taxable_interest_income": 3_000, + "us_bonds_for_higher_ed": 2_000, + "qualified_adoption_assistance_expense": 4_000, } ] ) @@ -233,7 +320,12 @@ def test_renters_refund_income_equals_gross_income_on_shared_sources(households) nd_income, gross_income = calculate( households, "nd_renters_refund_income", "irs_gross_income" ) - assert list(nd_income) == pytest.approx(list(gross_income), abs=TOLERANCE) + deducted = [ + sum(inputs.get(name, 0) for name in ABOVE_THE_LINE_EXCLUSIONS) + for inputs in households + ] + expected = [gross - out for gross, out in zip(gross_income, deducted)] + assert list(nd_income) == pytest.approx(expected, abs=TOLERANCE) # Inputs for the bounds test: shared sources, plus totals reported without @@ -252,19 +344,34 @@ def any_sources(draw): ) + draw(amount) inputs["capital_gains"] = draw(st.integers(min_value=-60_000, max_value=40_000)) inputs["strike_benefits"] = draw(amount) + inputs["social_security_retirement"] = draw(amount) + # Person-level exclusions larger than the income that should hold them. + for name in draw(st.sets(st.sampled_from(PERSON_DEDUCTED_EXCLUSIONS))): + inputs[name] = draw(st.integers(min_value=0, max_value=400_000)) return inputs @settings(max_examples=12, deadline=None) @given(households=st.lists(any_sources(), min_size=1, max_size=12)) def test_each_excluded_part_lies_within_its_component(households): - names = ["nd_renters_refund_federally_excluded_income", "nd_renters_refund_income"] + names = [ + "nd_renters_refund_federally_excluded_income", + "nd_renters_refund_income", + "market_income", + "social_security", + ] names += list(PARTLY_EXCLUDED) - excluded, nd_income, *components = calculate(households, *names) + excluded, nd_income, market, social_security, *components = calculate( + households, *names + ) ceiling = sum(component.clip(min=0) for component in components) assert (excluded >= -TOLERANCE).all() assert (excluded <= ceiling + TOLERANCE).all() assert (nd_income >= 0).all() + # The exclusions the model deducts above the line come out of the market + # income left after the person-level parts, never out of social security. + floor = np.minimum(social_security, market + social_security - excluded) + assert (nd_income >= floor - TOLERANCE).all() # Each pair moves a dollar from the taxable form of a source to its excluded @@ -312,12 +419,26 @@ def test_a_dollar_moved_to_its_excluded_form_leaves_income( **base, "social_security_retirement": social_security + moved, } - households = [base, shifted, deferred, disability, paid_for, more_social_security] + # A dollar of taxable interest that IRC 135 excludes leaves too, though + # the federal model deducts it above the line. + interest = {**base, "taxable_interest_income": taxable} + bonds = {**interest, "us_bonds_for_higher_ed": moved} + households = [ + base, + shifted, + deferred, + disability, + paid_for, + more_social_security, + interest, + bonds, + ] (income,) = calculate(households, "nd_renters_refund_income") assert income[0] - income[1] == pytest.approx(moved, abs=TOLERANCE) assert income[0] - income[2] == pytest.approx(deferral, abs=TOLERANCE) assert income[3] - income[4] == pytest.approx(moved, abs=TOLERANCE) assert income[5] - income[0] == pytest.approx(moved, abs=TOLERANCE) + assert income[6] - income[7] == pytest.approx(moved, abs=TOLERANCE) def test_alimony_leaves_income_only_under_a_post_2018_instrument(): diff --git a/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py b/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py index c5a79c48096..89ff74f4548 100644 --- a/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py +++ b/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py @@ -8,14 +8,16 @@ class nd_renters_refund_federally_excluded_income(Variable): unit = USD definition_period = YEAR documentation = ( - "The parts of market_income that federal law leaves out of gross " - "income, which N.D.C.C. 57-02-08.1(5)(c) excludes from renter's refund " - "income: the payroll deductions federal law excludes from wages, " - "tax-exempt interest, the nontaxable part of pensions and of " - "retirement account distributions, disability benefits from a plan " - "the recipient paid for, and alimony under a divorce or separation " - "instrument executed after 2018. Each part is at least zero and at " - "most the market_income component it comes from." + "The parts of a person's market_income components that federal law " + "leaves out of gross income, which N.D.C.C. 57-02-08.1(5)(c) excludes " + "from renter's refund income: the payroll deductions federal law " + "excludes from wages, tax-exempt interest, the nontaxable part of " + "pensions and of retirement account distributions, disability " + "benefits from a plan the recipient paid for, and alimony under a " + "divorce or separation instrument executed after 2018. Each part is at " + "least zero and at most the market_income component it comes from. " + "nd_renters_refund_income also subtracts the federal exclusions the " + "model deducts above the line." ) reference = ( # N.D.C.C. 57-02-08.1(5)(c). 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 dd05606832f..d35e5dddce5 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 @@ -15,10 +15,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 " - "(nd_renters_refund_federally_excluded_income) and the unreimbursed " - "medical costs actually paid, and at least zero. Social security " - "counts in full. " + "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), " + "which come out of the market income left after the first. 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 " @@ -35,9 +38,23 @@ def formula(tax_unit, period, parameters): # security benefits". market_income counts wages before payroll # deductions and the tax-exempt parts of several sources in full, so # subtract the parts federal law excludes. Social security stays whole. - excluded_income = add( + person_exclusions = add( tax_unit, period, ["nd_renters_refund_federally_excluded_income"] ) + # The model deducts some federal exclusions above the line, so + # market_income still holds the income they exclude: savings bond + # interest spent on higher education (IRC 135), employer adoption + # assistance (IRC 137) and income from Puerto Rico and the specified + # possessions (IRC 931, 933). A household may record the first two on a + # dependent, so they come out of the tax unit's market income left after + # the person-level exclusions, and never out of social security. + market_income_left = max_( + add(tax_unit, period, ["market_income"]) - person_exclusions, 0 + ) + deducted_exclusions = min_( + max_(add(tax_unit, period, p.excluded_deductions), 0), + market_income_left, + ) # Restore premiums excluded from the federal subtotal (computed, or # supplied with a caller's subtotal). medical_expenses = add( @@ -50,7 +67,8 @@ def formula(tax_unit, period, parameters): ) return max_( add(tax_unit, period, p.income_sources) - - excluded_income + - person_exclusions + - deducted_exclusions - medical_expenses, 0, ) diff --git a/source_conflicts/candidates.yaml b/source_conflicts/candidates.yaml index c2d66efc368..799ead63301 100644 --- a/source_conflicts/candidates.yaml +++ b/source_conflicts/candidates.yaml @@ -6722,9 +6722,10 @@ candidates: readings: statute: Income comes from all sources but leaves out "any amount excluded from income by federal or state law with the exception of income from social security benefits". Federal law leaves out of gross income the interest - on state and local bonds (IRC 103(a)); the return of a pension's cost, rollovers and qualified Roth distributions - (IRC 72(b)(1), 402(c)(1), 402A(d)(1), 408(d)(3), 408A(d)(1)); the pre-tax payroll deductions of IRC 106, 125, - 129, 402(e)(3) and 403(b)(1); and alimony under a divorce or separation instrument executed after 2018. + on state and local bonds (IRC 103(a)) and savings bond interest spent on higher education (IRC 135(a)); the return + of a pension's cost, rollovers and qualified Roth distributions (IRC 72(b)(1), 402(c)(1), 402A(d)(1), 408(d)(3), + 408A(d)(1)); the pre-tax payroll deductions of IRC 106, 125, 129, 402(e)(3) and 403(b)(1) and employer adoption + assistance (IRC 137(a)); and alimony under a divorce or separation instrument executed after 2018. other: Item 10 lists pensions "including military pension and I.R.A.", salaries and wages, dividends and interest, and alimony as income. The application asks for income from salary and wages (line 5) and from interest (line 6), and its instructions for lines 4 to 9 repeat the list. Neither leaves out the amounts federal law excludes. @@ -6735,6 +6736,7 @@ candidates: code: - policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py - policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.py + - policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml prs: - https://github.com/PolicyEngine/policyengine-us/pull/10697 state: ruled From 75e925bac0afd4814c52a258895911278ede3722 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Mon, 9 Nov 2026 06:14:36 -0500 Subject: [PATCH 04/10] Give North Dakota's state-law reductions their own ruling The note on us-nd:renters-refund-federally-excluded-income said the income tax reductions in N.D.C.C. 57-38-30.3(2) lower taxable income without excluding amounts from income. The Legislative Assembly added the statute's exception for social security in House Bill 1174 (2019), the Act that created the social security reduction, so the text doesn't settle the question that flatly. A new entry, us-nd:renters-refund-state-income-tax-reductions, sets out both sides and follows the Tax Commissioner's reading, which counts military pensions and net gains. A YAML case pins the result. Co-Authored-By: Claude Opus 5.5 --- .../nd_renters_refund_income.yaml | 17 +++++ source_conflicts/candidates.yaml | 65 +++++++++++++++++-- 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml index 9a943f01dde..92a0bc58635 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml @@ -463,3 +463,20 @@ output: # Only the 1,000 of market income can leave: 1,000 + 8,000 - 1,000. nd_renters_refund_income: 8_000 + +- name: North Dakota's income tax reductions leave retired military benefits, capital gains and dividends in income. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 45 + state_code: ND + # N.D.C.C. 57-38-30.3(2)(d) and (r) reduce North Dakota taxable income by + # 40 percent of net long-term gains and qualified dividends and by retired + # military benefits. Item 10 of the Tax Commissioner's guideline lists + # military pensions and net gains as income. + military_retirement_income: 30_000 + long_term_capital_gains: 5_000 + qualified_dividend_income: 1_000 + output: + # 30,000 + 5,000 + 1,000, with no state-law subtraction. + nd_renters_refund_income: 36_000 diff --git a/source_conflicts/candidates.yaml b/source_conflicts/candidates.yaml index 799ead63301..aa64b2e1811 100644 --- a/source_conflicts/candidates.yaml +++ b/source_conflicts/candidates.yaml @@ -6741,10 +6741,67 @@ candidates: - https://github.com/PolicyEngine/policyengine-us/pull/10697 state: ruled note: The statute names the exclusion, so it governs over the general lists, as in - us-nd:renters-refund-insurance-proceeds. Social security counts in full by the statute's own exception. North - Dakota's income tax reductions (N.D.C.C. 57-38-30.3(2)), such as military pay, military retirement benefits and 40 - percent of long-term capital gains and qualified dividends, lower taxable income; they do not exclude amounts from - income, and item 10 counts military pensions and net gains, so the refund counts them. + us-nd:renters-refund-insurance-proceeds. Social security counts in full by the statute's own exception. The + state-law half of the clause has its own entry, us-nd:renters-refund-state-income-tax-reductions. +- id: us-nd:renters-refund-state-income-tax-reductions + program: renter-credit + years: + from: 2025 + type: tax + question: Do the amounts North Dakota's income tax reductions subtract, such as military pay, retired military + benefits and 40 percent of net long-term capital gains and qualified dividends, count as "excluded from income by + federal or state law" for the renter's refund? + sources: + - kind: statute + citation: N.D.C.C. 57-02-08.1(5)(c) + url: https://ndlegis.gov/cencode/t57c02.pdf#page=16 + - kind: statute + citation: N.D.C.C. 57-38-30.3(2) + url: https://ndlegis.gov/cencode/t57c38.pdf#page=33 + - kind: statute + citation: House Bill 1174 (2019), enrolled, sections 1 and 3 + url: https://ndlegis.gov/assembly/66-2019/regular/documents/19-0115-05000.pdf#page=1 + - kind: statute + citation: House Bill 1053 (2019), enrolled + url: https://ndlegis.gov/assembly/66-2019/regular/documents/19-0357-02000.pdf#page=1 + - kind: agency-practice + citation: Office of Tax Commissioner, fiscal note on House Bill 1174 (2019), on section 1 + url: https://ndlegis.gov/files/resource/66-2019/library/hb1174.pdf#page=1 + - kind: guidance + citation: Property Tax Credits for North Dakota Homeowners and Renters, item 10 + url: https://www.tax.nd.gov/sites/www/files/documents/guidelines/homestead-veterans-renters/credits-for-nd-homeowners-renters-guideline.pdf#page=2 + - kind: form + citation: SFN 24777 (10-2025), line 7 + url: https://www.tax.nd.gov/sites/www/files/documents/forms/homestead-disabled-renters/renters-refund-application.pdf#page=1 + readings: + statute: Income leaves out "any amount excluded from income by federal or state law with the exception of income + from social security benefits". N.D.C.C. 57-38-30.3(2) defines North Dakota taxable income as federal taxable + income "adjusted as follows", and most adjustments open "Reduced by". The list names military pay, retired + military personnel benefits and 40 percent of net long-term capital gains and qualified dividends, along with + plain deductions such as organ donation expenses. In the same chapter, 57-38-04 says certain compensation "must + be excluded from income". House Bill 1174 (2019) created the social security reduction in section 3 and added the + exception in section 1. In its fiscal note, the Tax Commissioner's office wrote that section 1 keeps the full + benefit in the homestead income test "even though they are excluded from income tax". House Bill 1053 (2019) + created the retired military reduction and added no exception for it. + other: Item 10 of the guideline, in the edition with content revised in July 2025, lists "Pensions, including + military pension and I.R.A." and "Net gains from the sale of property" as income. SFN 24777 line 7 asks for + capital gains. + example: A renter with $30,000 of retired military benefits and no other income has income of $30,000 if the benefits + count and $0 if the reduction excludes them. + pe_us: + follows: gap-fill + code: + - policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.py + prs: + - https://github.com/PolicyEngine/policyengine-us/pull/10697 + state: ruled + note: N.D.C.C. 57-02-08.1(5)(c) doesn't say whether these reductions exclude amounts from income, so PolicyEngine + follows the Tax Commissioner's reading and counts them. The Legislative Assembly wrote the reductions as adjustments + to taxable income. In its fiscal note, the Tax Commissioner's office tied the exception for social security to the + reduction House Bill 1174 created. The exception also keeps in income the part of benefits that IRC 86 leaves out + of gross income, so it has effect even if the reductions exclude nothing. N.D.C.C. 1-02-39 lets a court weigh + legislative history and administrative construction when a statute is ambiguous, and the Commissioner kept military + pensions and net gains in item 10 after both 2019 Acts. - id: us-nd:renters-refund-insurance-proceeds program: renter-credit years: From 4b47634d0295608956abfe3710db7de3c562ec3e Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Wed, 11 Nov 2026 14:40:33 -0500 Subject: [PATCH 05/10] Take each deducted exclusion out of the income that holds it, and answer the 1eef8ca2f0 reviews - nd_renters_refund_income: savings bond interest (IRC 135) now comes out of the tax unit's taxable interest and adoption assistance (IRC 137) out of its wages after payroll deductions, so a loss elsewhere in the unit no longer keeps either in. Puerto Rico and possession income still come out of the market income left. None comes out of social security. - YAML: loss cases for both, a specified possession income case, and the state law case now sets military_retirement_pay, which North Dakota's reduction reads, with the three reductions as outputs. - Property tests: every run moves a nonzero amount of all seven sources, with a business loss; the bounds test checks each part alone, draws losses and the tax unit exclusions, and checks that social security counts in full. - Citations: Roth 401(k) and 403(b) distributions sit in retirement distributions (402A(d)(1), 403(b)(8)); labels for repealed deductions. - Register: the federal entry answers the "other retirement benefits" text and states what "excluded" means; the state-law entry sets out the 2019 record on both sides. Changelog no longer says "every". Co-Authored-By: Claude Opus 5.5 --- ...renters-refund-federal-exclusions.fixed.md | 2 +- ...ters_refund_federally_excluded_income.yaml | 6 +- .../nd_renters_refund_income.yaml | 74 ++++- ...est_nd_renters_refund_income_exclusions.py | 274 +++++++++++++----- ...enters_refund_federally_excluded_income.py | 22 +- .../nd_renters_refund_income.py | 42 ++- source_conflicts/candidates.yaml | 54 +++- 7 files changed, 350 insertions(+), 124 deletions(-) diff --git a/changelog.d/nd-renters-refund-federal-exclusions.fixed.md b/changelog.d/nd-renters-refund-federal-exclusions.fixed.md index 42ede54dde3..4c81177a7f3 100644 --- a/changelog.d/nd-renters-refund-federal-exclusions.fixed.md +++ b/changelog.d/nd-renters-refund-federal-exclusions.fixed.md @@ -1 +1 @@ -North Dakota renter's refund income leaves out every part of market income that federal law excludes from gross income, as N.D.C.C. 57-02-08.1(5)(c) requires: tax-exempt interest and savings bond interest spent on higher education, the nontaxable parts of pensions and retirement distributions, the payroll deductions and employer adoption assistance excluded from wages, income from Puerto Rico and the U.S. possessions that federal law excludes, and alimony under divorce instruments executed after 2018, besides the disability benefits it already left out. +North Dakota renter's refund income leaves out the parts of market income that federal law excludes from gross income, as N.D.C.C. 57-02-08.1(5)(c) requires: tax-exempt interest and savings bond interest spent on higher education, the nontaxable parts of pensions and retirement distributions, the payroll deductions and employer adoption assistance that federal law excludes from wages, income from Puerto Rico, Guam, American Samoa and the Northern Mariana Islands that federal law excludes, and alimony under divorce instruments executed after 2018, besides the disability benefits it already left out. diff --git a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.yaml index 9faa2a55b46..573b5afd1a7 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.yaml @@ -1,4 +1,4 @@ -- name: Each part of market income that federal law excludes is subtracted once. +- name: Each part of market income that federal law excludes leaves once. period: 2026 absolute_error_margin: 0.01 input: @@ -25,7 +25,7 @@ # all within their limits, plus 1,500 + 2,500 + 3,000 + 3,500 + 6,000. nd_renters_refund_federally_excluded_income: 31_500 -- name: Taxable amounts are not excluded. +- name: Taxable amounts stay in income. period: 2026 absolute_error_margin: 0.01 input: @@ -43,7 +43,7 @@ output: nd_renters_refund_federally_excluded_income: 0 -- name: A tax-exempt amount above the reported total of its source is capped at that total. +- name: A tax-exempt amount leaves only up to the reported total of its source. period: 2026 absolute_error_margin: 0.01 input: diff --git a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml index 92a0bc58635..ac220d5c268 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml @@ -451,7 +451,7 @@ # 40,000 - 15,000. nd_renters_refund_income: 25_000 -- name: North Dakota takes the exclusions the model deducts above the line out of market income only, never out of social security. +- name: North Dakota takes savings bond interest out of the interest that holds it, never out of social security. period: 2026 absolute_error_margin: 0.01 input: @@ -461,9 +461,73 @@ us_bonds_for_higher_ed: 3_000 social_security_retirement: 8_000 output: - # Only the 1,000 of market income can leave: 1,000 + 8,000 - 1,000. + # Only the 1,000 of taxable interest can leave: 1,000 + 8,000 - 1,000. nd_renters_refund_income: 8_000 +- name: A business loss doesn't keep savings bond interest spent on higher education in income. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + taxable_interest_income: 3_000 + # IRC 135(a) excludes 2,000 of the interest. + us_bonds_for_higher_ed: 2_000 + self_employment_income: -3_000 + social_security_retirement: 10_000 + output: + market_income: 0 + # 3,000 - 3,000 + 10,000 - 2,000. + nd_renters_refund_income: 8_000 + +- name: A rental loss doesn't keep employer adoption assistance in income. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + employment_income: 40_000 + rental_income: -40_000 + social_security_retirement: 10_000 + child: + age: 3 + is_tax_unit_dependent: true + # IRC 137(a) excludes 5,000 of the wages. + qualified_adoption_assistance_expense: 5_000 + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: ND + output: + # 40,000 - 40,000 + 10,000 - 5,000. + nd_renters_refund_income: 5_000 + +- name: North Dakota leaves out income from Guam, American Samoa or the Northern Mariana Islands that federal law excludes. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 40 + employment_income: 30_000 + tax_units: + tax_unit: + members: [person] + # IRC 931(a) excludes it. The model deducts it above the line, so the + # wages include it. + specified_possession_income: 10_000 + households: + household: + members: [person] + state_code: ND + output: + # 30,000 - 10,000. + nd_renters_refund_income: 20_000 + - name: North Dakota's income tax reductions leave retired military benefits, capital gains and dividends in income. period: 2026 absolute_error_margin: 0.01 @@ -474,9 +538,13 @@ # 40 percent of net long-term gains and qualified dividends and by retired # military benefits. Item 10 of the Tax Commissioner's guideline lists # military pensions and net gains as income. - military_retirement_income: 30_000 + military_retirement_pay: 30_000 long_term_capital_gains: 5_000 qualified_dividend_income: 1_000 output: + # North Dakota's income tax takes each reduction. + nd_military_retirement_subtraction: 30_000 + nd_ltcg_subtraction: 2_000 + nd_qdiv_subtraction: 400 # 30,000 + 5,000 + 1,000, with no state-law subtraction. nd_renters_refund_income: 36_000 diff --git a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py index a8f40d4474f..562c7eb513f 100644 --- a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py +++ b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py @@ -18,21 +18,29 @@ not exclude it (each named below, with the reason). Every above-the-line deduction in the federal model is likewise either a deduction, which leaves the income in, or an exclusion, which North Dakota subtracts. A new - component or deduction fails until it is classified, so a wider + component or deduction fails until someone classifies it, so a wider market_income cannot bring excluded income into the refund again, as #10663's wider market_income did. 2. Each excluded part lies between zero and the market_income component it - comes from, so the exclusions never exceed what those components hold. The - exclusions the model deducts above the line come only out of the market - income left after the others, so social security always counts in full. + comes from, so the exclusions never exceed what those components hold. + Each exclusion the model deducts above the line comes out of the tax unit's + income that holds it: savings bond interest out of taxable interest, + adoption assistance out of wages after payroll deductions, and income from + Puerto Rico and the possessions out of the market income left. None comes + out of social security, so a dollar of social security raises income by a + dollar unless income stays at zero. 3. Differential: for a filer whose income comes only from sources that market_income and federal gross income share, renter's refund income equals irs_gross_income less the exclusions the federal model deducts above the line. The statute's federal exclusions and the federal model agree on every - shared source. + shared source. For interest, pensions, retirement distributions, disability + benefits and the deducted exclusions, the two sides read different inputs. + For wages and alimony both read the same federal variables, so the YAML + cases and invariant 4 test those against the law. 4. Moving a dollar from the taxable form of a source to its excluded form - lowers renter's refund income by that dollar. A dollar of social security - raises it by a dollar, however much of the benefit federal law taxes. + lowers renter's refund income by that dollar, whatever losses the income + holds elsewhere. A dollar of social security raises it by a dollar, however + much of the benefit federal law taxes. YAML pins one household per case. These need random amounts over many households at once, and lists read from market_income's source file and the @@ -91,10 +99,10 @@ "payroll deductions", ), "interest_income": ("taxable_interest_income", "IRC 103(a)"), - "pension_income": ("taxable_pension_income", "IRC 72(b)(1), 402(c), 402A(d)"), + "pension_income": ("taxable_pension_income", "IRC 72(b)(1), 402(c)(1)"), "retirement_distributions": ( "taxable_retirement_distributions", - "IRC 408(d), 408A(d)(1)", + "IRC 402A(d)(1), 402(c)(1), 403(b)(8), 408(d), 408A(d)(1)", ), "disability_benefits": ("taxable_disability_benefits", "IRC 104(a)(3)"), "alimony_income": ( @@ -122,15 +130,17 @@ "self_employment_tax_ald": "IRC 164(f)", "student_loan_interest_ald": "IRC 221", "early_withdrawal_penalty": "IRC 62(a)(9)", - "alimony_expense_ald": "IRC 215, for the payer", + "alimony_expense_ald": "IRC 215, for the payer under an instrument " + "executed before 2019", "educator_expense_ald": "IRC 62(a)(2)(D)", - "capped_qualified_tuition_expenses_ald": "IRC 222", - "domestic_production_ald": "IRC 199", + "capped_qualified_tuition_expenses_ald": "IRC 222, before its repeal for " + "years after 2020", + "domestic_production_ald": "IRC 199, before its repeal for years after 2017", "health_savings_account_ald": "IRC 223(a): contributions outside payroll", "self_employed_health_insurance_ald": "IRC 162(l)", "self_employed_pension_contribution_ald": "IRC 404", "traditional_ira_deduction": "IRC 219", - "charitable_contributions_ald": "IRC 62(a)(22)", + "charitable_contributions_ald": "IRC 62(a)(22), which applied to 2020", } # Exclusions from gross income that the federal model deducts above the line, # with market_income holding the income they exclude. North Dakota subtracts @@ -141,12 +151,50 @@ "specified_possession_income": "IRC 931(a)", "puerto_rico_income": "IRC 933", } -# The two a household records on a person; the other two are tax unit inputs, -# which the YAML tests cover. +# The two a household records on a person; the other two are tax unit inputs. PERSON_DEDUCTED_EXCLUSIONS = [ "qualified_adoption_assistance_expense", "us_bonds_for_higher_ed", ] +TAX_UNIT_DEDUCTED_EXCLUSIONS = ["specified_possession_income", "puerto_rico_income"] + +PAYROLL_DEDUCTIONS = ( + "traditional_401k_contributions", + "traditional_403b_contributions", + "pre_tax_health_insurance_premiums", + "health_savings_account_payroll_contributions", + "dependent_care_employer_benefits", +) +# The inputs that feed each partly excluded component. +SOURCE_INPUTS = { + "employment_income": ("employment_income", *PAYROLL_DEDUCTIONS), + "interest_income": ( + "interest_income", + "taxable_interest_income", + "tax_exempt_interest_income", + ), + "pension_income": ( + "pension_income", + "taxable_private_pension_income", + "tax_exempt_private_pension_income", + "taxable_public_pension_income", + "tax_exempt_public_pension_income", + ), + "retirement_distributions": ( + "retirement_distributions", + "taxable_ira_distributions", + "tax_exempt_ira_distributions", + "taxable_401k_distributions", + "tax_exempt_401k_distributions", + "taxable_403b_distributions", + "tax_exempt_403b_distributions", + "taxable_sep_distributions", + "tax_exempt_sep_distributions", + ), + "disability_benefits": ("disability_benefits", "tax_exempt_disability_benefits"), + "alimony_income": ("alimony_income", "divorce_year"), +} +assert set(SOURCE_INPUTS) == set(PARTLY_EXCLUDED) def market_income_components(): @@ -212,14 +260,29 @@ def test_every_above_the_line_deduction_has_a_stated_treatment(): def situation(households): """Single adults in North Dakota, one per household.""" - people, groups = {}, {} + people, groups, tax_units = {}, {}, {} for index, inputs in enumerate(households): name = f"person_{index}" - people[name] = {"age": {YEAR: 40}, **{k: {YEAR: v} for k, v in inputs.items()}} + people[name] = { + "age": {YEAR: 40}, + **{ + k: {YEAR: v} + for k, v in inputs.items() + if k not in TAX_UNIT_DEDUCTED_EXCLUSIONS + }, + } groups[name] = {"members": [name]} + tax_units[f"tax_unit_{name}"] = { + "members": [name], + **{ + k: {YEAR: v} + for k, v in inputs.items() + if k in TAX_UNIT_DEDUCTED_EXCLUSIONS + }, + } return { "people": people, - "tax_units": {f"tax_unit_{k}": v for k, v in groups.items()}, + "tax_units": tax_units, "spm_units": {f"spm_unit_{k}": v for k, v in groups.items()}, "families": {f"family_{k}": v for k, v in groups.items()}, "marital_units": {f"marital_unit_{k}": v for k, v in groups.items()}, @@ -243,13 +306,7 @@ def shared_sources(draw): """Nonnegative income from sources market_income and gross income share.""" deductions = { name: draw(st.integers(min_value=0, max_value=8_000)) - for name in ( - "traditional_401k_contributions", - "traditional_403b_contributions", - "pre_tax_health_insurance_premiums", - "health_savings_account_payroll_contributions", - "dependent_care_employer_benefits", - ) + for name in PAYROLL_DEDUCTIONS } disability = draw(amount) other_wages = draw(st.integers(min_value=0, max_value=150_000)) @@ -276,6 +333,10 @@ def shared_sources(draw): "tax_exempt_ira_distributions": draw(amount), "taxable_401k_distributions": draw(amount), "tax_exempt_401k_distributions": draw(amount), + "taxable_403b_distributions": draw(amount), + "tax_exempt_403b_distributions": draw(amount), + "taxable_sep_distributions": draw(amount), + "tax_exempt_sep_distributions": draw(amount), "disability_benefits": disability, "tax_exempt_disability_benefits": draw( st.integers(min_value=0, max_value=disability) @@ -329,7 +390,8 @@ def test_renters_refund_income_equals_gross_income_on_shared_sources(households) # Inputs for the bounds test: shared sources, plus totals reported without -# their split and tax-exempt parts larger than the totals they belong to. +# their split, tax-exempt parts larger than the totals they belong to, losses, +# and deducted exclusions larger than the income that should hold them. TOTALS = ("interest_income", "pension_income", "retirement_distributions") @@ -343,35 +405,62 @@ def any_sources(draw): "disability_benefits", 0 ) + draw(amount) inputs["capital_gains"] = draw(st.integers(min_value=-60_000, max_value=40_000)) + inputs["rental_income"] = draw(st.integers(min_value=-60_000, max_value=40_000)) inputs["strike_benefits"] = draw(amount) inputs["social_security_retirement"] = draw(amount) - # Person-level exclusions larger than the income that should hold them. - for name in draw(st.sets(st.sampled_from(PERSON_DEDUCTED_EXCLUSIONS))): + for name in draw( + st.sets( + st.sampled_from(PERSON_DEDUCTED_EXCLUSIONS + TAX_UNIT_DEDUCTED_EXCLUSIONS) + ) + ): inputs[name] = draw(st.integers(min_value=0, max_value=400_000)) return inputs @settings(max_examples=12, deadline=None) -@given(households=st.lists(any_sources(), min_size=1, max_size=12)) +@given(households=st.lists(any_sources(), min_size=1, max_size=6)) def test_each_excluded_part_lies_within_its_component(households): + # Each household as drawn; then each partly excluded source alone, so a + # part above its component can't hide behind another part below its own; + # then each household without its social security. + alone = [ + {k: v for k, v in inputs.items() if k in SOURCE_INPUTS[component]} + for inputs in households + for component in PARTLY_EXCLUDED + ] + without_social_security = [ + {k: v for k, v in inputs.items() if k != "social_security_retirement"} + for inputs in households + ] + count = len(households) names = [ "nd_renters_refund_federally_excluded_income", "nd_renters_refund_income", - "market_income", "social_security", + *PARTLY_EXCLUDED, ] - names += list(PARTLY_EXCLUDED) - excluded, nd_income, market, social_security, *components = calculate( - households, *names + excluded, nd_income, social_security, *components = calculate( + households + alone + without_social_security, *names ) - ceiling = sum(component.clip(min=0) for component in components) assert (excluded >= -TOLERANCE).all() - assert (excluded <= ceiling + TOLERANCE).all() assert (nd_income >= 0).all() - # The exclusions the model deducts above the line come out of the market - # income left after the person-level parts, never out of social security. - floor = np.minimum(social_security, market + social_security - excluded) - assert (nd_income >= floor - TOLERANCE).all() + drawn = slice(0, count) + ceiling = sum(component[drawn].clip(min=0) for component in components) + assert (excluded[drawn] <= ceiling + TOLERANCE).all() + for index in range(len(alone)): + position = count + index + component = components[index % len(PARTLY_EXCLUDED)][position] + assert excluded[position] <= max(component, 0) + TOLERANCE + # Social security counts in full: removing it lowers income by all of it, + # unless income without it stays at zero. + with_it = nd_income[drawn] + without_it = nd_income[-count:] + benefit = social_security[drawn] + positive = without_it > TOLERANCE + assert with_it[positive] - without_it[positive] == pytest.approx( + benefit[positive], abs=TOLERANCE + ) + assert (with_it[~positive] <= benefit[~positive] + TOLERANCE).all() # Each pair moves a dollar from the taxable form of a source to its excluded @@ -389,56 +478,81 @@ def test_each_excluded_part_lies_within_its_component(households): @settings(max_examples=12, deadline=None) @given( - shift=st.sampled_from(SHIFTS), taxable=st.integers(min_value=1, max_value=60_000), exempt=st.integers(min_value=0, max_value=60_000), - share=st.floats(min_value=0, max_value=1), + share=st.floats(min_value=0.01, max_value=1), wages=st.integers(min_value=0, max_value=100_000), social_security=st.integers(min_value=0, max_value=40_000), + loss_share=st.floats(min_value=0, max_value=1), +) +@example( + taxable=3_000, + exempt=0, + share=2 / 3, + wages=0, + social_security=10_000, + loss_share=0.3, ) def test_a_dollar_moved_to_its_excluded_form_leaves_income( - shift, taxable, exempt, share, wages, social_security + taxable, exempt, share, wages, social_security, loss_share ): - taxable_name, exempt_name = shift - moved = round(taxable * share) - base = { - "employment_income": wages, - "social_security_retirement": social_security, - taxable_name: taxable, - exempt_name: exempt, - } - shifted = {**base, taxable_name: taxable - moved, exempt_name: exempt + moved} - # A wage dollar deferred into a traditional 401(k), and a disability - # dollar from a plan the recipient paid for, leave the same way. + # Every run moves at least a dollar of every source. + moved = max(round(taxable * share), 1) deferral = round(wages * share) - deferred = {**base, "traditional_401k_contributions": deferral} - disability = {**base, "disability_benefits": exempt + moved} - paid_for = {**disability, "tax_exempt_disability_benefits": moved} - # Social security counts in full however much of it is taxed. - more_social_security = { - **base, - "social_security_retirement": social_security + moved, - } - # A dollar of taxable interest that IRC 135 excludes leaves too, though - # the federal model deducts it above the line. - interest = {**base, "taxable_interest_income": taxable} - bonds = {**interest, "us_bonds_for_higher_ed": moved} - households = [ - base, - shifted, - deferred, - disability, - paid_for, - more_social_security, - interest, - bonds, - ] + # A business loss no larger than social security, so income stays above + # zero and every dollar shows. + loss = round(social_security * loss_share) + households = [] + for taxable_name, exempt_name in SHIFTS: + base = { + "employment_income": wages, + "self_employment_income": -loss, + "social_security_retirement": social_security, + taxable_name: taxable, + exempt_name: exempt, + } + shifted = {**base, taxable_name: taxable - moved, exempt_name: exempt + moved} + # A wage dollar deferred into a traditional 401(k), and a disability + # dollar from a plan the recipient paid for, leave the same way. + deferred = {**base, "traditional_401k_contributions": deferral} + disability = {**base, "disability_benefits": exempt + moved} + paid_for = {**disability, "tax_exempt_disability_benefits": moved} + # Social security counts in full however much of it federal law taxes. + more_social_security = { + **base, + "social_security_retirement": social_security + moved, + } + # A dollar of taxable interest that IRC 135 excludes leaves too, though + # the federal model deducts it above the line. + interest = {**base, "taxable_interest_income": taxable} + bonds = {**interest, "us_bonds_for_higher_ed": moved} + households += [ + base, + shifted, + deferred, + disability, + paid_for, + more_social_security, + interest, + bonds, + ] (income,) = calculate(households, "nd_renters_refund_income") - assert income[0] - income[1] == pytest.approx(moved, abs=TOLERANCE) - assert income[0] - income[2] == pytest.approx(deferral, abs=TOLERANCE) - assert income[3] - income[4] == pytest.approx(moved, abs=TOLERANCE) - assert income[5] - income[0] == pytest.approx(moved, abs=TOLERANCE) - assert income[6] - income[7] == pytest.approx(moved, abs=TOLERANCE) + for group in range(len(SHIFTS)): + ( + base, + shifted, + deferred, + disability, + paid_for, + more_social_security, + interest, + bonds, + ) = income[8 * group : 8 * group + 8] + assert base - shifted == pytest.approx(moved, abs=TOLERANCE) + assert base - deferred == pytest.approx(deferral, abs=TOLERANCE) + assert disability - paid_for == pytest.approx(moved, abs=TOLERANCE) + assert more_social_security - base == pytest.approx(moved, abs=TOLERANCE) + assert interest - bonds == pytest.approx(moved, abs=TOLERANCE) def test_alimony_leaves_income_only_under_a_post_2018_instrument(): diff --git a/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py b/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py index 89ff74f4548..3ae041d4716 100644 --- a/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py +++ b/policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py @@ -34,9 +34,10 @@ class nd_renters_refund_federally_excluded_income(Variable): # Interest on state and local bonds. "https://www.law.cornell.edu/uscode/text/26/103#a", # Pensions and retirement accounts: the investment in the contract - # (72(b)(1)), rollovers (402(c)(1), 408(d)(3)), and qualified Roth - # distributions (402A(d)(1), 408A(d)(1)). + # (72(b)(1)), rollovers (402(c)(1), 403(b)(8), 408(d)(3)), and + # qualified Roth distributions (402A(d)(1), 408A(d)(1)). "https://www.law.cornell.edu/uscode/text/26/72#b_1", + "https://www.law.cornell.edu/uscode/text/26/403#b_8", "https://www.law.cornell.edu/uscode/text/26/402A#d_1", "https://www.law.cornell.edu/uscode/text/26/408#d", "https://www.law.cornell.edu/uscode/text/26/408A#d_1", @@ -60,7 +61,7 @@ def excluded_part(component, excluded): # contributions through payroll, and dependent care assistance), plus # the dependent care assistance above the IRC 129 limit. Pre-tax # premiums leave income here, and itemized_medical_expenses leaves - # them out, so no premium is subtracted twice. + # them out, so neither subtracts a premium the other has. wages = person("employment_income", period) counted_wages = person("irs_employment_income", period) + person( "taxable_dependent_care_benefits", period @@ -71,14 +72,16 @@ def excluded_part(component, excluded): person("interest_income", period), person("tax_exempt_interest_income", period), ) - # The investment in the contract, rollovers and qualified distributions - # from designated Roth accounts (IRC 72(b)(1), 402(c)(1), 402A(d)(1)). + # The investment in the contract and rollovers from public and private + # employer pensions (IRC 72(b)(1), 402(c)(1)). pensions = excluded_part( person("pension_income", period), person("tax_exempt_pension_income", period), ) - # Qualified Roth IRA distributions, rollovers and nondeductible - # contributions returned (IRC 408(d), 408A(d)(1)). + # Qualified distributions from Roth IRAs and from designated Roth + # accounts in 401(k) and 403(b) plans, rollovers, and nondeductible IRA + # and SEP contributions returned (IRC 402A(d)(1), 402(c)(1), 403(b)(8), + # 408(d), 408A(d)(1)). retirement_distributions = excluded_part( person("retirement_distributions", period), person("tax_exempt_retirement_distributions", period), @@ -88,8 +91,9 @@ def excluded_part(component, excluded): person("disability_benefits", period), person("tax_exempt_disability_benefits", period), ) - # Alimony under an instrument executed after 2018 is not included in - # the recipient's gross income; taxable_alimony_income holds the rest. + # Federal gross income leaves out alimony under an instrument executed + # after 2018 (Pub. L. 115-97 section 11051); taxable_alimony_income + # holds the rest. alimony = person("alimony_income", period) excluded_alimony = excluded_part( alimony, alimony - person("taxable_alimony_income", 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 d35e5dddce5..c4e005f96fe 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 @@ -20,8 +20,8 @@ class nd_renters_refund_income(Variable): "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), " - "which come out of the market income left after the first. Social " - "security counts in full. " + "each of which comes out of the tax unit's income that holds it. " + "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 " @@ -42,18 +42,36 @@ def formula(tax_unit, period, parameters): tax_unit, period, ["nd_renters_refund_federally_excluded_income"] ) # The model deducts some federal exclusions above the line, so - # market_income still holds the income they exclude: savings bond - # interest spent on higher education (IRC 135), employer adoption - # assistance (IRC 137) and income from Puerto Rico and the specified - # possessions (IRC 931, 933). A household may record the first two on a - # dependent, so they come out of the tax unit's market income left after - # the person-level exclusions, and never out of social security. + # market_income still holds the income they exclude. Each comes out of + # the income that holds it, summed over the tax unit, because a + # household may record savings bond interest spent on higher education + # (IRC 135) on the student and employer adoption assistance (IRC 137) + # on the child. Income from Puerto Rico and the specified possessions + # (IRC 931, 933) can sit in any component, so it comes out of the + # market income left after the rest. None of them comes out of social + # security, and a loss elsewhere in the unit keeps neither savings bond + # interest nor adoption assistance in. + holders = { + "us_bonds_for_higher_ed": "taxable_interest_income", + "qualified_adoption_assistance_expense": "irs_employment_income", + } + deducted_exclusions = 0 + without_holder = 0 + for name in p.excluded_deductions: + excluded = max_(add(tax_unit, period, [name]), 0) + if name in holders: + holder = max_(add(tax_unit, period, [holders[name]]), 0) + deducted_exclusions = deducted_exclusions + min_(excluded, holder) + else: + without_holder = without_holder + excluded market_income_left = max_( - add(tax_unit, period, ["market_income"]) - person_exclusions, 0 + add(tax_unit, period, ["market_income"]) + - person_exclusions + - deducted_exclusions, + 0, ) - deducted_exclusions = min_( - max_(add(tax_unit, period, p.excluded_deductions), 0), - market_income_left, + deducted_exclusions = deducted_exclusions + min_( + without_holder, market_income_left ) # Restore premiums excluded from the federal subtotal (computed, or # supplied with a caller's subtotal). diff --git a/source_conflicts/candidates.yaml b/source_conflicts/candidates.yaml index 85b4d047bf1..e94042ecbc2 100644 --- a/source_conflicts/candidates.yaml +++ b/source_conflicts/candidates.yaml @@ -6761,9 +6761,9 @@ candidates: years: from: 2025 type: tax - question: Does the renter's refund count the interest, pensions, IRA distributions, wages and alimony that federal - law leaves out of gross income, when the Tax Commissioner's guideline and the application list those sources as - income with no exception? + question: Does the renter's refund count the interest, pensions, retirement distributions, wages, alimony and other + income that federal law leaves out of gross income, when the Tax Commissioner's guideline and the application list + those sources as income with no exception? sources: - kind: statute citation: N.D.C.C. 57-02-08.1(5)(c) @@ -6775,15 +6775,19 @@ candidates: citation: SFN 24777 (10-2025), lines 5 to 7 and the instructions for lines 4 to 9 url: https://www.tax.nd.gov/sites/www/files/documents/forms/homestead-disabled-renters/renters-refund-application.pdf#page=1 readings: - statute: Income comes from all sources but leaves out "any amount excluded from income by federal or state law + statute: Income comes from all sources, "including any county, state, or federal public assistance benefits, social + security, or other retirement benefits", but leaves out "any amount excluded from income by federal or state law with the exception of income from social security benefits". Federal law leaves out of gross income the interest on state and local bonds (IRC 103(a)) and savings bond interest spent on higher education (IRC 135(a)); the return - of a pension's cost, rollovers and qualified Roth distributions (IRC 72(b)(1), 402(c)(1), 402A(d)(1), 408(d)(3), - 408A(d)(1)); the pre-tax payroll deductions of IRC 106, 125, 129, 402(e)(3) and 403(b)(1) and employer adoption - assistance (IRC 137(a)); and alimony under a divorce or separation instrument executed after 2018. + of a pension's cost, rollovers and qualified Roth distributions (IRC 72(b)(1), 402(c)(1), 402A(d)(1), 403(b)(8), + 408(d), 408A(d)(1)); the pre-tax payroll deductions of IRC 106, 125, 129, 402(e)(3) and 403(b)(1) and employer + adoption assistance (IRC 137(a)); income of bona fide residents of Puerto Rico, Guam, American Samoa and the + Northern Mariana Islands from sources there (IRC 931(a), 933); and alimony under a divorce or separation + instrument executed after 2018, since Pub. L. 115-97 section 11051 repealed IRC 71 and 61(a)(8). other: Item 10 lists pensions "including military pension and I.R.A.", salaries and wages, dividends and interest, and alimony as income. The application asks for income from salary and wages (line 5) and from interest (line - 6), and its instructions for lines 4 to 9 repeat the list. Neither leaves out the amounts federal law excludes. + 6), and its instructions for lines 4 to 9 list most of the same sources. Neither leaves out the amounts federal + law excludes. example: A renter with $20,000 of wages, $1,000 of taxable interest and $5,000 of interest on municipal bonds has income of $21,000 under the statute and $26,000 under item 10 and line 6. pe_us: @@ -6796,8 +6800,12 @@ candidates: - https://github.com/PolicyEngine/policyengine-us/pull/10697 state: ruled note: The statute names the exclusion, so it governs over the general lists, as in - us-nd:renters-refund-insurance-proceeds. Social security counts in full by the statute's own exception. The - state-law half of the clause has its own entry, us-nd:renters-refund-state-income-tax-reductions. + us-nd:renters-refund-insurance-proceeds. The definition also counts "other retirement benefits", but the exception + to the exclusion names only social security, so the exclusion reaches the parts of other retirement benefits that + federal law leaves out. An amount leaves when a federal statute or regulation leaves it out of gross income, + including by repealing the provision that counted it, as for alimony; a doctrine with no statutory basis, such as + the IRS's general welfare exclusion, doesn't remove it. Social security counts in full by the statute's own + exception. The state-law half of the clause has its own entry, us-nd:renters-refund-state-income-tax-reductions. - id: us-nd:renters-refund-state-income-tax-reductions program: renter-credit years: @@ -6822,6 +6830,12 @@ candidates: - kind: agency-practice citation: Office of Tax Commissioner, fiscal note on House Bill 1174 (2019), on section 1 url: https://ndlegis.gov/files/resource/66-2019/library/hb1174.pdf#page=1 + - kind: agency-practice + citation: Office of Tax Commissioner, fiscal note on House Bill 1174 (2019) as introduced, on sections 1 and 2 + url: https://ndlegis.gov/files/resource/66-2019/library/hb1174.pdf#page=7 + - kind: agency-practice + citation: Tax Department testimony on House Bill 1174, Senate Appropriations Committee, March 25, 2019 + url: https://ndlegis.gov/files/resource/66-2019/library/hb1174.pdf#page=28 - kind: guidance citation: Property Tax Credits for North Dakota Homeowners and Renters, item 10 url: https://www.tax.nd.gov/sites/www/files/documents/guidelines/homestead-veterans-renters/credits-for-nd-homeowners-renters-guideline.pdf#page=2 @@ -6851,12 +6865,18 @@ candidates: - https://github.com/PolicyEngine/policyengine-us/pull/10697 state: ruled note: N.D.C.C. 57-02-08.1(5)(c) doesn't say whether these reductions exclude amounts from income, so PolicyEngine - follows the Tax Commissioner's reading and counts them. The Legislative Assembly wrote the reductions as adjustments - to taxable income. In its fiscal note, the Tax Commissioner's office tied the exception for social security to the - reduction House Bill 1174 created. The exception also keeps in income the part of benefits that IRC 86 leaves out - of gross income, so it has effect even if the reductions exclude nothing. N.D.C.C. 1-02-39 lets a court weigh - legislative history and administrative construction when a statute is ambiguous, and the Commissioner kept military - pensions and net gains in item 10 after both 2019 Acts. + follows the Tax Commissioner's administrative practice, item 10 and line 7, and counts them. The Legislative + Assembly wrote the reductions as adjustments to taxable income, and both 2019 Acts call theirs a deduction in their + titles. The 2019 record leans the other way. The final fiscal note keeps benefits in the income test "even though + they are excluded from income tax", and a Tax Department witness called the retired military reduction an + exclusion. But the office's first fiscal note called sections 1 and 2 technical changes "for purposes of clarity + and consistency", and the bill's sponsor said of section 1, "I do not know why council put that in there." The + words "or state law" still do work under this reading, since N.D.C.C. 54-01.1-13 bars counting relocation + payments as income for the purposes of the state's tax laws. The exception also keeps in income the part of + benefits that IRC 86 leaves out of gross income, so it has effect even if the reductions exclude nothing. N.D.C.C. + 1-02-39 lets a court weigh legislative history and administrative construction when a statute is ambiguous, N.D.A.G. + Letter Opinion 2008-L-12 deferred to the Tax Commissioner's reading of an ambiguous property tax provision, and the + Commissioner kept military pensions and net gains in item 10 after both 2019 Acts. - id: us-nd:renters-refund-insurance-proceeds program: renter-credit years: @@ -6882,8 +6902,10 @@ candidates: follows: statute code: - policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.py + - policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py prs: - https://github.com/PolicyEngine/policyengine-us/pull/10663 + - https://github.com/PolicyEngine/policyengine-us/pull/10697 state: ruled note: The statute's text settles the case, so it governs over the guideline's general list. - id: us-nd:stillborn-subtraction-dependency-condition From df1ba6fa0c7295255a1679806504fca8692c991b Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Wed, 11 Nov 2026 15:03:23 -0500 Subject: [PATCH 06/10] Cite 54-01.1-13 and 1-02-39 in the state-law register entry, and fix its example Co-Authored-By: Claude Opus 5.5 --- source_conflicts/candidates.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source_conflicts/candidates.yaml b/source_conflicts/candidates.yaml index e94042ecbc2..e6b46be802a 100644 --- a/source_conflicts/candidates.yaml +++ b/source_conflicts/candidates.yaml @@ -6836,6 +6836,12 @@ candidates: - kind: agency-practice citation: Tax Department testimony on House Bill 1174, Senate Appropriations Committee, March 25, 2019 url: https://ndlegis.gov/files/resource/66-2019/library/hb1174.pdf#page=28 + - kind: statute + citation: N.D.C.C. 54-01.1-13 + url: https://ndlegis.gov/cencode/t54c01-1.pdf#page=6 + - kind: statute + citation: N.D.C.C. 1-02-39 + url: https://ndlegis.gov/cencode/t01c02.pdf#page=6 - kind: guidance citation: Property Tax Credits for North Dakota Homeowners and Renters, item 10 url: https://www.tax.nd.gov/sites/www/files/documents/guidelines/homestead-veterans-renters/credits-for-nd-homeowners-renters-guideline.pdf#page=2 @@ -6856,7 +6862,8 @@ candidates: military pension and I.R.A." and "Net gains from the sale of property" as income. SFN 24777 line 7 asks for capital gains. example: A renter with $30,000 of retired military benefits and no other income has income of $30,000 if the benefits - count and $0 if the reduction excludes them. + count, and less if the reduction, which reaches the part of the benefits in federal taxable income, excludes + amounts from income. pe_us: follows: gap-fill code: From 4593949f3dcde9375952ccc24b60f460c1a23dfe Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Wed, 11 Nov 2026 16:13:26 -0500 Subject: [PATCH 07/10] Limit IRC 931 to American Samoa and take possession income out before losses Answers the df1ba6fa0c review. - IRC 931 reaches only a possession with an implementing agreement in effect, and only American Samoa has one (26 CFR 1.931-1(c)). The parameter comment, the register and the tests now say so. - Puerto Rico and American Samoa income can sit in any market income component, so it now comes out of market income before losses (a new parameter, market_income_components, lists the components), less the other exclusions. A rental or self-employment loss no longer keeps it in. - Savings bond interest comes out of the interest North Dakota counts (interest_income less tax_exempt_interest_income), so a household that reports interest only as a total still gets the exclusion. - New YAML cases pin each cap; the bounds test checks that, with no loss in income, renter's refund income never falls below social security. - The state-law register entry cites the Senate hearing minutes, N.D.C.C. 57-38-04 and Letter Opinion 2008-L-12, and quotes the sponsor's full exchange. Co-Authored-By: Claude Opus 5.5 --- ...renters-refund-federal-exclusions.fixed.md | 2 +- .../renters_refund/excluded_deductions.yaml | 7 +- .../market_income_components.yaml | 37 ++++++ .../nd_renters_refund_income.yaml | 116 +++++++++++++++++- ...est_nd_renters_refund_income_exclusions.py | 65 +++++++--- .../nd_renters_refund_income.py | 48 +++++--- source_conflicts/candidates.yaml | 27 +++- 7 files changed, 258 insertions(+), 44 deletions(-) create mode 100644 policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/market_income_components.yaml diff --git a/changelog.d/nd-renters-refund-federal-exclusions.fixed.md b/changelog.d/nd-renters-refund-federal-exclusions.fixed.md index 4c81177a7f3..e56d61053df 100644 --- a/changelog.d/nd-renters-refund-federal-exclusions.fixed.md +++ b/changelog.d/nd-renters-refund-federal-exclusions.fixed.md @@ -1 +1 @@ -North Dakota renter's refund income leaves out the parts of market income that federal law excludes from gross income, as N.D.C.C. 57-02-08.1(5)(c) requires: tax-exempt interest and savings bond interest spent on higher education, the nontaxable parts of pensions and retirement distributions, the payroll deductions and employer adoption assistance that federal law excludes from wages, income from Puerto Rico, Guam, American Samoa and the Northern Mariana Islands that federal law excludes, and alimony under divorce instruments executed after 2018, besides the disability benefits it already left out. +North Dakota renter's refund income leaves out the parts of market income that federal law excludes from gross income, as N.D.C.C. 57-02-08.1(5)(c) requires: tax-exempt interest and savings bond interest spent on higher education, the nontaxable parts of pensions and retirement distributions, the payroll deductions and employer adoption assistance that federal law excludes from wages, income from Puerto Rico and American Samoa that federal law excludes, and alimony under divorce instruments executed after 2018, besides the disability benefits it already left out. diff --git a/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml b/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml index cf7327a3942..183cc3f3901 100644 --- a/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml +++ b/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml @@ -5,8 +5,9 @@ values: - us_bonds_for_higher_ed # Employer adoption assistance. - qualified_adoption_assistance_expense - # Income of bona fide residents of Guam, American Samoa or the Northern - # Mariana Islands from sources there. + # Income of bona fide residents of American Samoa from sources there or + # from a business there. Only American Samoa has the implementing + # agreement that IRC 931 requires (26 CFR 1.931-1(c)). - specified_possession_income # Income of bona fide residents of Puerto Rico from sources there. - puerto_rico_income @@ -23,5 +24,7 @@ metadata: href: https://www.law.cornell.edu/uscode/text/26/137#a - title: 26 U.S. Code § 931(a) href: https://www.law.cornell.edu/uscode/text/26/931#a + - title: 26 CFR 1.931-1(c) + href: https://www.law.cornell.edu/cfr/text/26/1.931-1#c - title: 26 U.S. Code § 933 href: https://www.law.cornell.edu/uscode/text/26/933 diff --git a/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/market_income_components.yaml b/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/market_income_components.yaml new file mode 100644 index 00000000000..f908d9342f8 --- /dev/null +++ b/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/market_income_components.yaml @@ -0,0 +1,37 @@ +description: North Dakota takes income from Puerto Rico and American Samoa out of these market income components, each counted before losses, under the Renter's Refund program. +values: + 2025-01-01: + - employment_income + - self_employment_income + - sstb_self_employment_income + - partnership_s_corp_income + - pension_income + - dividend_income + - interest_income + - gi_cash_assistance + - capital_gains + - non_sch_d_capital_gains + - other_net_gain_person + - rental_income + - farm_rent_income + - estate_income + - illicit_income + - farm_operations_income + - miscellaneous_income + - alimony_income + - strike_benefits + - retirement_distributions + - military_retirement_income + - disability_benefits + - ak_permanent_fund_dividend +metadata: + unit: list + period: year + label: North Dakota Renter's Refund market income components before losses + reference: + - title: N.D.C.C. § 57-02-08.1(5)(c) + href: https://ndlegis.gov/cencode/t57c02.pdf#page=16 + - title: 26 U.S. Code § 931(a) + href: https://www.law.cornell.edu/uscode/text/26/931#a + - title: 26 U.S. Code § 933 + href: https://www.law.cornell.edu/uscode/text/26/933 diff --git a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml index ac220d5c268..44aa4214ba3 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml @@ -464,6 +464,20 @@ # Only the 1,000 of taxable interest can leave: 1,000 + 8,000 - 1,000. nd_renters_refund_income: 8_000 +- name: North Dakota takes savings bond interest out of interest reported only as a total. + period: 2026 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: ND + interest_income: 3_000 + # IRC 135(a) excludes 2,000 of the interest. + us_bonds_for_higher_ed: 2_000 + social_security_retirement: 10_000 + output: + # 3,000 + 10,000 - 2,000. + nd_renters_refund_income: 11_000 + - name: A business loss doesn't keep savings bond interest spent on higher education in income. period: 2026 absolute_error_margin: 0.01 @@ -498,6 +512,12 @@ tax_units: tax_unit: members: [parent, child] + spm_units: + spm_unit: + members: [parent, child] + # The rental loss would qualify the family for TANF; this case leaves + # it out to test the loss alone. + tanf: 0 households: household: members: [parent, child] @@ -506,7 +526,31 @@ # 40,000 - 40,000 + 10,000 - 5,000. nd_renters_refund_income: 5_000 -- name: North Dakota leaves out income from Guam, American Samoa or the Northern Mariana Islands that federal law excludes. +- name: Employer adoption assistance comes out only up to the wages that hold it. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + parent: + age: 40 + employment_income: 3_000 + social_security_retirement: 10_000 + child: + age: 3 + is_tax_unit_dependent: true + qualified_adoption_assistance_expense: 5_000 + tax_units: + tax_unit: + members: [parent, child] + households: + household: + members: [parent, child] + state_code: ND + output: + # 3,000 - 3,000 + 10,000. + nd_renters_refund_income: 10_000 + +- name: North Dakota leaves out income from American Samoa that federal law excludes. period: 2026 absolute_error_margin: 0.01 input: @@ -517,8 +561,8 @@ tax_units: tax_unit: members: [person] - # IRC 931(a) excludes it. The model deducts it above the line, so the - # wages include it. + # IRC 931(a) excludes it for a bona fide resident of American Samoa. + # The model deducts it above the line, so the wages include it. specified_possession_income: 10_000 households: household: @@ -528,6 +572,72 @@ # 30,000 - 10,000. nd_renters_refund_income: 20_000 +- name: A rental loss doesn't keep income from American Samoa in income. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 40 + employment_income: 30_000 + rental_income: -30_000 + social_security_retirement: 10_000 + tax_units: + tax_unit: + members: [person] + # IRC 931(a) excludes 10,000 of the wages. + specified_possession_income: 10_000 + households: + household: + members: [person] + state_code: ND + output: + market_income: 0 + # 30,000 - 10,000 - 30,000 + 10,000. + nd_renters_refund_income: 0 + +- name: A self-employment loss doesn't keep income from Puerto Rico in income. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 40 + employment_income: 30_000 + self_employment_income: -35_000 + social_security_retirement: 20_000 + tax_units: + tax_unit: + members: [person] + # IRC 933 excludes 10,000 of the wages. + puerto_rico_income: 10_000 + households: + household: + members: [person] + state_code: ND + output: + # 30,000 - 10,000 - 35,000 + 20,000. + nd_renters_refund_income: 5_000 + +- name: Income from American Samoa that no market income component holds never comes out of social security. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 40 + social_security_retirement: 20_000 + tax_units: + tax_unit: + members: [person] + specified_possession_income: 10_000 + households: + household: + members: [person] + state_code: ND + output: + nd_renters_refund_income: 20_000 + - name: North Dakota's income tax reductions leave retired military benefits, capital gains and dividends in income. period: 2026 absolute_error_margin: 0.01 diff --git a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py index 562c7eb513f..22b26aa52f1 100644 --- a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py +++ b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py @@ -24,11 +24,13 @@ 2. Each excluded part lies between zero and the market_income component it comes from, so the exclusions never exceed what those components hold. Each exclusion the model deducts above the line comes out of the tax unit's - income that holds it: savings bond interest out of taxable interest, - adoption assistance out of wages after payroll deductions, and income from - Puerto Rico and the possessions out of the market income left. None comes - out of social security, so a dollar of social security raises income by a - dollar unless income stays at zero. + income that holds it: savings bond interest out of the interest North + Dakota counts, adoption assistance out of wages after payroll deductions, + and income from Puerto Rico and American Samoa out of market income before + losses, less the other exclusions. None comes out of social security, so + with no loss in income, renter's refund income never falls below social + security, and a dollar of social security raises income by a dollar unless + income stays at zero. 3. Differential: for a filer whose income comes only from sources that market_income and federal gross income share, renter's refund income equals irs_gross_income less the exclusions the federal model deducts above the @@ -38,9 +40,9 @@ For wages and alimony both read the same federal variables, so the YAML cases and invariant 4 test those against the law. 4. Moving a dollar from the taxable form of a source to its excluded form - lowers renter's refund income by that dollar, whatever losses the income - holds elsewhere. A dollar of social security raises it by a dollar, however - much of the benefit federal law taxes. + lowers renter's refund income by that dollar, beside a loss elsewhere in + income, as long as income stays above zero. A dollar of social security + raises it by a dollar, however much of the benefit federal law taxes. YAML pins one household per case. These need random amounts over many households at once, and lists read from market_income's source file and the @@ -62,10 +64,9 @@ MARKET_INCOME = PACKAGE / "variables/household/income/person/general/market_income.py" GROSS_INCOME_SOURCES = PACKAGE / "parameters/gov/irs/gross_income/sources.yaml" ABOVE_THE_LINE = PACKAGE / "parameters/gov/irs/ald/deductions.yaml" -ND_DEDUCTED_EXCLUSIONS = ( - PACKAGE - / "parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml" -) +RENTERS_REFUND = PACKAGE / "parameters/gov/states/nd/tax/property/renters_refund" +ND_DEDUCTED_EXCLUSIONS = RENTERS_REFUND / "excluded_deductions.yaml" +ND_MARKET_INCOME_COMPONENTS = RENTERS_REFUND / "market_income_components.yaml" YEAR = 2026 # Amounts are float32 in the model. TOLERANCE = 0.5 @@ -148,7 +149,9 @@ ABOVE_THE_LINE_EXCLUSIONS = { "us_bonds_for_higher_ed": "IRC 135(a)", "qualified_adoption_assistance_expense": "IRC 137(a)", - "specified_possession_income": "IRC 931(a)", + # Only American Samoa has the implementing agreement IRC 931 requires + # (26 CFR 1.931-1(c)). + "specified_possession_income": "IRC 931(a), for American Samoa", "puerto_rico_income": "IRC 933", } # The two a household records on a person; the other two are tax unit inputs. @@ -229,6 +232,9 @@ def test_every_market_income_component_has_a_stated_treatment(): "nd_renters_refund_federally_excluded_income." ) assert classified - components == set(), "stale entries above" + # Income from Puerto Rico and American Samoa comes out of these components + # before losses, so the list must match market_income's. + assert list_parameter_entries(ND_MARKET_INCOME_COMPONENTS) == components def test_each_treatment_matches_the_federal_gross_income_list(): @@ -298,6 +304,21 @@ def calculate(households, *names): return [simulation.calculate(name, YEAR).astype(float) for name in names] +def calculate_by_totals(households, *names): + """calculate, with one Simulation for each set of totals the households + report. A total one household reports becomes an input for every person in + its Simulation, which would hide the parts the others report.""" + groups = {} + for index, inputs in enumerate(households): + groups.setdefault(frozenset(set(inputs) & set(TOTALS)), []).append(index) + results = [np.zeros(len(households)) for _ in names] + for indices in groups.values(): + values = calculate([households[i] for i in indices], *names) + for result, value in zip(results, values): + result[indices] = value + return results + + amount = st.integers(min_value=0, max_value=40_000) @@ -311,18 +332,22 @@ def shared_sources(draw): disability = draw(amount) other_wages = draw(st.integers(min_value=0, max_value=150_000)) taxable_interest = draw(amount) + adoption = draw(st.integers(min_value=0, max_value=other_wages)) + possession = draw(st.integers(min_value=0, max_value=other_wages - adoption)) inputs = { # Wages cover the payroll deductions and any adoption assistance. "employment_income": sum(deductions.values()) + other_wages, **deductions, # Exclusions the federal model deducts above the line, each within the # income that holds it. - "qualified_adoption_assistance_expense": draw( - st.integers(min_value=0, max_value=other_wages) - ), + "qualified_adoption_assistance_expense": adoption, "us_bonds_for_higher_ed": draw( st.integers(min_value=0, max_value=taxable_interest) ), + "specified_possession_income": possession, + "puerto_rico_income": draw( + st.integers(min_value=0, max_value=other_wages - adoption - possession) + ), "taxable_interest_income": taxable_interest, "tax_exempt_interest_income": draw(amount), "taxable_private_pension_income": draw(amount), @@ -374,6 +399,7 @@ def shared_sources(draw): "taxable_interest_income": 3_000, "us_bonds_for_higher_ed": 2_000, "qualified_adoption_assistance_expense": 4_000, + "puerto_rico_income": 3_000, } ] ) @@ -439,7 +465,7 @@ def test_each_excluded_part_lies_within_its_component(households): "social_security", *PARTLY_EXCLUDED, ] - excluded, nd_income, social_security, *components = calculate( + excluded, nd_income, social_security, *components = calculate_by_totals( households + alone + without_social_security, *names ) assert (excluded >= -TOLERANCE).all() @@ -461,6 +487,11 @@ def test_each_excluded_part_lies_within_its_component(households): benefit[positive], abs=TOLERANCE ) assert (with_it[~positive] <= benefit[~positive] + TOLERANCE).all() + # With no loss in income, no exclusion comes out of social security. + no_loss = np.array( + [min(inputs.values(), default=0) >= 0 for inputs in households], dtype=bool + ) + assert (with_it[no_loss] >= benefit[no_loss] - TOLERANCE).all() # Each pair moves a dollar from the taxable form of a source to its excluded 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 c4e005f96fe..686edf58952 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 @@ -20,8 +20,9 @@ class nd_renters_refund_income(Variable): "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. " - "Social security counts in full. " + "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. " "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 " @@ -46,33 +47,48 @@ def formula(tax_unit, period, parameters): # the income that holds it, summed over the tax unit, because a # household may record savings bond interest spent on higher education # (IRC 135) on the student and employer adoption assistance (IRC 137) - # on the child. Income from Puerto Rico and the specified possessions - # (IRC 931, 933) can sit in any component, so it comes out of the - # market income left after the rest. None of them comes out of social - # security, and a loss elsewhere in the unit keeps neither savings bond - # interest nor adoption assistance in. + # on the child: savings bond interest out of the interest North Dakota + # counts, and adoption assistance out of wages after payroll + # deductions. Income from Puerto Rico and American Samoa (IRC 933, + # 931) can sit in any component, so it comes out of market income + # before losses, less the other exclusions. None of them comes out of + # social security, and a loss elsewhere in the unit keeps none of them + # in. holders = { - "us_bonds_for_higher_ed": "taxable_interest_income", - "qualified_adoption_assistance_expense": "irs_employment_income", + "us_bonds_for_higher_ed": max_( + add(tax_unit, period, ["interest_income"]) + - add(tax_unit, period, ["tax_exempt_interest_income"]), + 0, + ), + "qualified_adoption_assistance_expense": max_( + add(tax_unit, period, ["irs_employment_income"]), 0 + ), } deducted_exclusions = 0 without_holder = 0 for name in p.excluded_deductions: excluded = max_(add(tax_unit, period, [name]), 0) if name in holders: - holder = max_(add(tax_unit, period, [holders[name]]), 0) - deducted_exclusions = deducted_exclusions + min_(excluded, holder) + deducted_exclusions = deducted_exclusions + min_( + excluded, holders[name] + ) else: without_holder = without_holder + excluded - market_income_left = max_( - add(tax_unit, period, ["market_income"]) + # Market income before losses: each person's components, each at + # zero or more. + person = tax_unit.members + income_before_losses = 0 + for component in p.market_income_components: + income_before_losses = income_before_losses + max_( + person(component, period), 0 + ) + income_left = max_( + tax_unit.sum(income_before_losses) - person_exclusions - deducted_exclusions, 0, ) - deducted_exclusions = deducted_exclusions + min_( - without_holder, market_income_left - ) + deducted_exclusions = deducted_exclusions + min_(without_holder, income_left) # Restore premiums excluded from the federal subtotal (computed, or # supplied with a caller's subtotal). medical_expenses = add( diff --git a/source_conflicts/candidates.yaml b/source_conflicts/candidates.yaml index e6b46be802a..706f819caee 100644 --- a/source_conflicts/candidates.yaml +++ b/source_conflicts/candidates.yaml @@ -6774,6 +6774,9 @@ candidates: - kind: form citation: SFN 24777 (10-2025), lines 5 to 7 and the instructions for lines 4 to 9 url: https://www.tax.nd.gov/sites/www/files/documents/forms/homestead-disabled-renters/renters-refund-application.pdf#page=1 + - kind: regulation + citation: 26 CFR 1.931-1(c) + url: https://www.law.cornell.edu/cfr/text/26/1.931-1 readings: statute: Income comes from all sources, "including any county, state, or federal public assistance benefits, social security, or other retirement benefits", but leaves out "any amount excluded from income by federal or state law @@ -6781,9 +6784,11 @@ candidates: on state and local bonds (IRC 103(a)) and savings bond interest spent on higher education (IRC 135(a)); the return of a pension's cost, rollovers and qualified Roth distributions (IRC 72(b)(1), 402(c)(1), 402A(d)(1), 403(b)(8), 408(d), 408A(d)(1)); the pre-tax payroll deductions of IRC 106, 125, 129, 402(e)(3) and 403(b)(1) and employer - adoption assistance (IRC 137(a)); income of bona fide residents of Puerto Rico, Guam, American Samoa and the - Northern Mariana Islands from sources there (IRC 931(a), 933); and alimony under a divorce or separation - instrument executed after 2018, since Pub. L. 115-97 section 11051 repealed IRC 71 and 61(a)(8). + adoption assistance (IRC 137(a)); income of bona fide residents of Puerto Rico from sources there (IRC 933) and + of American Samoa from sources there or from a business there (IRC 931(a), which reaches only a possession with + an implementing agreement in effect, and only American Samoa has one, 26 CFR 1.931-1(c)); and alimony under a + divorce or separation instrument executed after 2018, since Pub. L. 115-97 section 11051 repealed IRC 71 and + 61(a)(8). other: Item 10 lists pensions "including military pension and I.R.A.", salaries and wages, dividends and interest, and alimony as income. The application asks for income from salary and wages (line 5) and from interest (line 6), and its instructions for lines 4 to 9 list most of the same sources. Neither leaves out the amounts federal @@ -6796,6 +6801,7 @@ candidates: - policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_federally_excluded_income.py - policyengine_us/variables/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.py - policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml + - policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/market_income_components.yaml prs: - https://github.com/PolicyEngine/policyengine-us/pull/10697 state: ruled @@ -6833,15 +6839,24 @@ candidates: - kind: agency-practice citation: Office of Tax Commissioner, fiscal note on House Bill 1174 (2019) as introduced, on sections 1 and 2 url: https://ndlegis.gov/files/resource/66-2019/library/hb1174.pdf#page=7 + - kind: statute + citation: House Bill 1174 (2019), Senate Appropriations Committee minutes, March 25, 2019, the sponsor on section 1 + url: https://ndlegis.gov/files/resource/66-2019/library/hb1174.pdf#page=25 - kind: agency-practice citation: Tax Department testimony on House Bill 1174, Senate Appropriations Committee, March 25, 2019 url: https://ndlegis.gov/files/resource/66-2019/library/hb1174.pdf#page=28 + - kind: statute + citation: N.D.C.C. 57-38-04 + url: https://ndlegis.gov/cencode/t57c38.pdf#page=25 - kind: statute citation: N.D.C.C. 54-01.1-13 url: https://ndlegis.gov/cencode/t54c01-1.pdf#page=6 - kind: statute citation: N.D.C.C. 1-02-39 url: https://ndlegis.gov/cencode/t01c02.pdf#page=6 + - kind: guidance + citation: N.D.A.G. Letter Opinion 2008-L-12 + url: https://attorneygeneral.nd.gov/wp-content/uploads/2023/02/2008-L-12.pdf - kind: guidance citation: Property Tax Credits for North Dakota Homeowners and Renters, item 10 url: https://www.tax.nd.gov/sites/www/files/documents/guidelines/homestead-veterans-renters/credits-for-nd-homeowners-renters-guideline.pdf#page=2 @@ -6876,8 +6891,10 @@ candidates: Assembly wrote the reductions as adjustments to taxable income, and both 2019 Acts call theirs a deduction in their titles. The 2019 record leans the other way. The final fiscal note keeps benefits in the income test "even though they are excluded from income tax", and a Tax Department witness called the retired military reduction an - exclusion. But the office's first fiscal note called sections 1 and 2 technical changes "for purposes of clarity - and consistency", and the bill's sponsor said of section 1, "I do not know why council put that in there." The + exclusion. In the Senate Appropriations Committee, the bill's sponsor said of section 1, "I do not know why council + put that in there", then answered "That would probably be true" when a committee member suggested it keeps the + removal of social security from income out of the homestead law. But the office's first fiscal note called + sections 1 and 2 technical changes "for purposes of clarity and consistency". The words "or state law" still do work under this reading, since N.D.C.C. 54-01.1-13 bars counting relocation payments as income for the purposes of the state's tax laws. The exception also keeps in income the part of benefits that IRC 86 leaves out of gross income, so it has effect even if the reductions exclude nothing. N.D.C.C. From 79759796359739637c041a6b4f82eee06430f36c Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Wed, 11 Nov 2026 16:17:48 -0500 Subject: [PATCH 08/10] Cite IRS Publication 570 for American Samoa as the only IRC 931 possession 26 CFR 1.931-1(c)(1) limits IRC 931 to a possession with an implementing agreement in effect but names none; IRS Publication 570 applies section 931 only to American Samoa. The register, the parameter and the test comment now cite each source for what it says. Co-Authored-By: Claude Opus 5.5 --- .../property/renters_refund/excluded_deductions.yaml | 11 +++++++---- .../tests/test_nd_renters_refund_income_exclusions.py | 5 +++-- source_conflicts/candidates.yaml | 11 +++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml b/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml index 183cc3f3901..cd4f85970ad 100644 --- a/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml +++ b/policyengine_us/parameters/gov/states/nd/tax/property/renters_refund/excluded_deductions.yaml @@ -6,8 +6,9 @@ values: # Employer adoption assistance. - qualified_adoption_assistance_expense # Income of bona fide residents of American Samoa from sources there or - # from a business there. Only American Samoa has the implementing - # agreement that IRC 931 requires (26 CFR 1.931-1(c)). + # from a business there. IRC 931 reaches only a possession with an + # implementing agreement in effect (26 CFR 1.931-1(c)(1)), and IRS + # Publication 570 applies it only to American Samoa. - specified_possession_income # Income of bona fide residents of Puerto Rico from sources there. - puerto_rico_income @@ -24,7 +25,9 @@ metadata: href: https://www.law.cornell.edu/uscode/text/26/137#a - title: 26 U.S. Code § 931(a) href: https://www.law.cornell.edu/uscode/text/26/931#a - - title: 26 CFR 1.931-1(c) - href: https://www.law.cornell.edu/cfr/text/26/1.931-1#c + - title: 26 CFR 1.931-1(c)(1) + href: https://www.law.cornell.edu/cfr/text/26/1.931-1#c_1 + - title: IRS Publication 570 + href: https://www.irs.gov/publications/p570 - title: 26 U.S. Code § 933 href: https://www.law.cornell.edu/uscode/text/26/933 diff --git a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py index 22b26aa52f1..fd4a6edced9 100644 --- a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py +++ b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py @@ -149,8 +149,9 @@ ABOVE_THE_LINE_EXCLUSIONS = { "us_bonds_for_higher_ed": "IRC 135(a)", "qualified_adoption_assistance_expense": "IRC 137(a)", - # Only American Samoa has the implementing agreement IRC 931 requires - # (26 CFR 1.931-1(c)). + # IRC 931 reaches only a possession with an implementing agreement in + # effect (26 CFR 1.931-1(c)(1)); IRS Publication 570 applies it only to + # American Samoa. "specified_possession_income": "IRC 931(a), for American Samoa", "puerto_rico_income": "IRC 933", } diff --git a/source_conflicts/candidates.yaml b/source_conflicts/candidates.yaml index 706f819caee..a3e2b906930 100644 --- a/source_conflicts/candidates.yaml +++ b/source_conflicts/candidates.yaml @@ -6775,8 +6775,11 @@ candidates: citation: SFN 24777 (10-2025), lines 5 to 7 and the instructions for lines 4 to 9 url: https://www.tax.nd.gov/sites/www/files/documents/forms/homestead-disabled-renters/renters-refund-application.pdf#page=1 - kind: regulation - citation: 26 CFR 1.931-1(c) + citation: 26 CFR 1.931-1(c)(1) url: https://www.law.cornell.edu/cfr/text/26/1.931-1 + - kind: guidance + citation: IRS Publication 570, Tax Guide for Individuals With Income From U.S. Territories + url: https://www.irs.gov/publications/p570 readings: statute: Income comes from all sources, "including any county, state, or federal public assistance benefits, social security, or other retirement benefits", but leaves out "any amount excluded from income by federal or state law @@ -6786,9 +6789,9 @@ candidates: 408(d), 408A(d)(1)); the pre-tax payroll deductions of IRC 106, 125, 129, 402(e)(3) and 403(b)(1) and employer adoption assistance (IRC 137(a)); income of bona fide residents of Puerto Rico from sources there (IRC 933) and of American Samoa from sources there or from a business there (IRC 931(a), which reaches only a possession with - an implementing agreement in effect, and only American Samoa has one, 26 CFR 1.931-1(c)); and alimony under a - divorce or separation instrument executed after 2018, since Pub. L. 115-97 section 11051 repealed IRC 71 and - 61(a)(8). + an implementing agreement in effect, 26 CFR 1.931-1(c)(1), and which IRS Publication 570 applies only to + American Samoa); and alimony under a divorce or separation instrument executed after 2018, since Pub. L. 115-97 + section 11051 repealed IRC 71 and 61(a)(8). other: Item 10 lists pensions "including military pension and I.R.A.", salaries and wages, dividends and interest, and alimony as income. The application asks for income from salary and wages (line 5) and from interest (line 6), and its instructions for lines 4 to 9 list most of the same sources. Neither leaves out the amounts federal From 406bf54a2fd58c3dc90f9264ab02adea55e70583 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Wed, 11 Nov 2026 16:43:08 -0500 Subject: [PATCH 09/10] Test the four deducted exclusions beside a loss in the shift test The shift test now also marks a dollar of income as employer adoption assistance, Puerto Rico income or American Samoa income beside a business loss, and expects renter's refund income to fall by that dollar. A formula that takes Puerto Rico and American Samoa income out of net market income fails it. Invariant 2's lower bound now names the condition it needs (no loss and no medical costs), and the TANF input in the rental-loss case says why it is there. Co-Authored-By: Claude Opus 5.5 --- .../nd_renters_refund_income.yaml | 5 +-- ...est_nd_renters_refund_income_exclusions.py | 33 +++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml index 44aa4214ba3..eecabc436de 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml @@ -515,8 +515,9 @@ spm_units: spm_unit: members: [parent, child] - # The rental loss would qualify the family for TANF; this case leaves - # it out to test the loss alone. + # Once renter's refund income counts TANF (#10724), the rental loss + # would qualify the family for it; this case sets TANF to zero to test + # the loss alone. tanf: 0 households: household: diff --git a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py index fd4a6edced9..eef1c533c42 100644 --- a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py +++ b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py @@ -28,8 +28,8 @@ Dakota counts, adoption assistance out of wages after payroll deductions, and income from Puerto Rico and American Samoa out of market income before losses, less the other exclusions. None comes out of social security, so - with no loss in income, renter's refund income never falls below social - security, and a dollar of social security raises income by a dollar unless + with no loss in income and no medical costs, renter's refund income never + falls below social security, and a dollar of social security raises income by a dollar unless income stays at zero. 3. Differential: for a filer whose income comes only from sources that market_income and federal gross income share, renter's refund income equals @@ -41,8 +41,10 @@ cases and invariant 4 test those against the law. 4. Moving a dollar from the taxable form of a source to its excluded form lowers renter's refund income by that dollar, beside a loss elsewhere in - income, as long as income stays above zero. A dollar of social security - raises it by a dollar, however much of the benefit federal law taxes. + income, as long as income stays above zero. So does marking a dollar of + income as one of the exclusions the model deducts above the line. A dollar + of social security raises it by a dollar, however much of the benefit + federal law taxes. YAML pins one household per case. These need random amounts over many households at once, and lists read from market_income's source file and the @@ -554,10 +556,17 @@ def test_a_dollar_moved_to_its_excluded_form_leaves_income( **base, "social_security_retirement": social_security + moved, } - # A dollar of taxable interest that IRC 135 excludes leaves too, though - # the federal model deducts it above the line. + # The exclusions the federal model deducts above the line leave the + # same way: a dollar of taxable interest that IRC 135 excludes, a + # dollar of wages that IRC 137 excludes as employer adoption + # assistance, and a dollar of income from Puerto Rico (IRC 933) or + # American Samoa (IRC 931), which the base's wages and taxable income + # hold before the loss. interest = {**base, "taxable_interest_income": taxable} bonds = {**interest, "us_bonds_for_higher_ed": moved} + adoption = {**base, "qualified_adoption_assistance_expense": min(moved, wages)} + puerto_rico = {**base, "puerto_rico_income": moved} + american_samoa = {**base, "specified_possession_income": moved} households += [ base, shifted, @@ -567,8 +576,12 @@ def test_a_dollar_moved_to_its_excluded_form_leaves_income( more_social_security, interest, bonds, + adoption, + puerto_rico, + american_samoa, ] (income,) = calculate(households, "nd_renters_refund_income") + size = len(households) // len(SHIFTS) for group in range(len(SHIFTS)): ( base, @@ -579,12 +592,18 @@ def test_a_dollar_moved_to_its_excluded_form_leaves_income( more_social_security, interest, bonds, - ) = income[8 * group : 8 * group + 8] + adoption, + puerto_rico, + american_samoa, + ) = income[size * group : size * group + size] assert base - shifted == pytest.approx(moved, abs=TOLERANCE) assert base - deferred == pytest.approx(deferral, abs=TOLERANCE) assert disability - paid_for == pytest.approx(moved, abs=TOLERANCE) assert more_social_security - base == pytest.approx(moved, abs=TOLERANCE) assert interest - bonds == pytest.approx(moved, abs=TOLERANCE) + assert base - adoption == pytest.approx(min(moved, wages), abs=TOLERANCE) + assert base - puerto_rico == pytest.approx(moved, abs=TOLERANCE) + assert base - american_samoa == pytest.approx(moved, abs=TOLERANCE) def test_alimony_leaves_income_only_under_a_post_2018_instrument(): From 524e04db0f03d43c616eb9fa7493570b0066f128 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Wed, 11 Nov 2026 16:56:24 -0500 Subject: [PATCH 10/10] Pin Puerto Rico income's cap and give the shift test a case with wages A YAML case puts $10,000 of Puerto Rico income beside only social security and expects income to stay at $20,000, as the American Samoa case does. The shift test gains an explicit example with $1,000 of wages, so its adoption assistance line moves a dollar on every run. Co-Authored-By: Claude Opus 5.5 --- .../nd_renters_refund_income.yaml | 19 +++++++++++++++++++ ...est_nd_renters_refund_income_exclusions.py | 13 +++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml index eecabc436de..3712cce127d 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/nd/tax/property/renters_refund/nd_renters_refund_income.yaml @@ -639,6 +639,25 @@ output: nd_renters_refund_income: 20_000 +- name: Income from Puerto Rico that no market income component holds never comes out of social security. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person: + age: 40 + social_security_retirement: 20_000 + tax_units: + tax_unit: + members: [person] + puerto_rico_income: 10_000 + households: + household: + members: [person] + state_code: ND + output: + nd_renters_refund_income: 20_000 + - name: North Dakota's income tax reductions leave retired military benefits, capital gains and dividends in income. period: 2026 absolute_error_margin: 0.01 diff --git a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py index eef1c533c42..696a9d785f5 100644 --- a/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py +++ b/policyengine_us/tests/test_nd_renters_refund_income_exclusions.py @@ -29,8 +29,8 @@ and income from Puerto Rico and American Samoa out of market income before losses, less the other exclusions. None comes out of social security, so with no loss in income and no medical costs, renter's refund income never - falls below social security, and a dollar of social security raises income by a dollar unless - income stays at zero. + falls below social security, and a dollar of social security raises income + by a dollar unless income stays at zero. 3. Differential: for a filer whose income comes only from sources that market_income and federal gross income share, renter's refund income equals irs_gross_income less the exclusions the federal model deducts above the @@ -527,6 +527,15 @@ def test_each_excluded_part_lies_within_its_component(households): social_security=10_000, loss_share=0.3, ) +# With wages, so the adoption assistance line moves a dollar too. +@example( + taxable=3_000, + exempt=0, + share=2 / 3, + wages=1_000, + social_security=10_000, + loss_share=0.3, +) def test_a_dollar_moved_to_its_excluded_form_leaves_income( taxable, exempt, share, wages, social_security, loss_share ):