From f1da85ee0eeabe962a42a6a68b59904408d255a4 Mon Sep 17 00:00:00 2001 From: David Trimmer Date: Thu, 19 Nov 2026 16:30:27 -0500 Subject: [PATCH 1/2] Fix Pennsylvania taxable income for alimony and 401(k)/403(b) deferrals Pennsylvania does not tax alimony, so the part of it in federal gross income now comes off PA taxable income. Pennsylvania taxes an employee's traditional 401(k) and 403(b) deferrals as compensation, so they are now added back to the federal wages that leave them out. Co-Authored-By: Claude Opus 5.5 --- .../pa-income-tax-alimony-401k.fixed.md | 1 + .../tax/income/nontaxable_income_sources.yaml | 6 + .../taxable_elective_deferral_sources.yaml | 20 ++ .../pa_tax_forgiveness_amount.yaml | 41 ++++ .../pa_total_taxable_income.yaml | 228 +++++++++++++++++- .../pa_tax_forgiveness_eligible_share.py | 7 +- .../pa/tax/income/pa_other_additions.py | 4 +- .../pa_taxable_elective_deferrals.py | 35 +++ .../taxable_income/pa_total_taxable_income.py | 23 +- 9 files changed, 352 insertions(+), 13 deletions(-) create mode 100644 changelog.d/pa-income-tax-alimony-401k.fixed.md create mode 100644 policyengine_us/parameters/gov/states/pa/tax/income/taxable_elective_deferral_sources.yaml create mode 100644 policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_taxable_elective_deferrals.py diff --git a/changelog.d/pa-income-tax-alimony-401k.fixed.md b/changelog.d/pa-income-tax-alimony-401k.fixed.md new file mode 100644 index 00000000000..a7911e1477b --- /dev/null +++ b/changelog.d/pa-income-tax-alimony-401k.fixed.md @@ -0,0 +1 @@ +Pennsylvania taxable income no longer includes alimony, and it now counts employees' traditional 401(k) and 403(b) contributions as taxable compensation, as the PA-40 instructions require. diff --git a/policyengine_us/parameters/gov/states/pa/tax/income/nontaxable_income_sources.yaml b/policyengine_us/parameters/gov/states/pa/tax/income/nontaxable_income_sources.yaml index 458600cc00c..9d238468ce9 100644 --- a/policyengine_us/parameters/gov/states/pa/tax/income/nontaxable_income_sources.yaml +++ b/policyengine_us/parameters/gov/states/pa/tax/income/nontaxable_income_sources.yaml @@ -9,6 +9,10 @@ values: - us_govt_interest - salt_refund_income - military_retirement_income + # Alimony is income not taxable for PA PIT purposes. The list subtracts + # the part federal gross income holds: alimony under a divorce or + # separation instrument executed before 2019. + - taxable_alimony_income # Sick pay and disability benefits other than regular wages, including # third-party insurer payments, and disability distributions (61 Pa. # Code 101.6(c)(1)). Regular sick leave pay is in employment income. @@ -38,5 +42,7 @@ metadata: # income, so this list subtracts the part of strike benefits it holds. - title: Pennsylvania Personal Income Tax Guide, Gross Compensation - income items never taxable as PA compensation href: https://www.pa.gov/agencies/revenue/forms-and-publications/pa-personal-income-tax-guide/gross-compensation.html#IncomeItemsNeverTaxablePA + - title: 2025 Pennsylvania PIT Return Instructions (PA-40 IN), income not taxable for PA PIT purposes (alimony) + href: https://www.pa.gov/content/dam/copapwp-pagov/en/revenue/documents/formsandpublications/formsforindividuals/pit/documents/2025/2025_pa-40in.pdf#page=8 - title: 2025 PA-40 Schedule T - Gambling and Lottery Winnings href: https://www.pa.gov/content/dam/copapwp-pagov/en/revenue/documents/formsandpublications/formsforindividuals/pit/documents/2025/2025_pa-40t.pdf#page=1 diff --git a/policyengine_us/parameters/gov/states/pa/tax/income/taxable_elective_deferral_sources.yaml b/policyengine_us/parameters/gov/states/pa/tax/income/taxable_elective_deferral_sources.yaml new file mode 100644 index 00000000000..cd854511c3e --- /dev/null +++ b/policyengine_us/parameters/gov/states/pa/tax/income/taxable_elective_deferral_sources.yaml @@ -0,0 +1,20 @@ +description: Pennsylvania taxes these employee elective deferrals as compensation, though federal wages leave them out. +values: + 2021-01-01: + # An employee's own contributions to an employer retirement plan, + # including salary reduction contributions, are not excludable from + # Pennsylvania compensation. No input holds 457(b) or Thrift Savings + # Plan deferrals, so none is listed. + - traditional_401k_contributions + - traditional_403b_contributions +metadata: + unit: list + period: year + label: PA taxable elective deferral sources + reference: + - title: 2025 Pennsylvania PIT Return Instructions (PA-40 IN), Line 1a, contributions to an employer-sponsored retirement plan are PA-taxable compensation + href: https://www.pa.gov/content/dam/copapwp-pagov/en/revenue/documents/formsandpublications/formsforindividuals/pit/documents/2025/2025_pa-40in.pdf#page=12 + - title: 61 Pa. Code 101.6(c)(8)(ii)(B), employee contributions to a plan, including by payroll deduction or salary reduction, are not excludable + href: https://www.pacodeandbulletin.gov/Display/pacode?file=/secure/pacode/data/061/chapter101/s101.6.html + - title: Pennsylvania Personal Income Tax Guide, Gross Compensation (DSM-12 08-2025), employee contributions to 401(k) and 403(b) plans are taxable + href: https://www.pa.gov/content/dam/copapwp-pagov/en/revenue/documents/formsandpublications/papersonalincometaxguide/documents/pitguide_grosscompensation.pdf#page=51 diff --git a/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/forgiveness/pa_tax_forgiveness_amount.yaml b/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/forgiveness/pa_tax_forgiveness_amount.yaml index a600522c2c9..1813a5f639d 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/forgiveness/pa_tax_forgiveness_amount.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/forgiveness/pa_tax_forgiveness_amount.yaml @@ -533,3 +533,44 @@ output: pa_income_tax_before_forgiveness: 184.20 pa_tax_forgiveness_amount: 184.2 + +- name: "2025 joint return with one spouse who can be claimed as a dependent: the claimable head's 401(k) deferral counts in their share" + period: 2025 + absolute_error_margin: 0.01 + input: + people: + person_a: + age: 30 + employment_income: 3000 + traditional_401k_contributions: 1000 + is_tax_unit_head: true + is_tax_unit_spouse: false + is_tax_unit_dependent: false + claimed_as_dependent_on_another_return: true + person_b: + age: 30 + employment_income: 3000 + traditional_401k_contributions: 0 + is_tax_unit_head: false + is_tax_unit_spouse: true + is_tax_unit_dependent: false + claimed_as_dependent_on_another_return: false + tax_units: + tax_unit: + members: [person_a, person_b] + filing_status: JOINT + households: + household: + members: [person_a, person_b] + state_code: PA + output: + # Each spouse's PA taxable income is 3,000, since PA taxes the head's + # 1,000 deferral as compensation (2025 PA-40 IN, page 12). Only the + # spouse can claim forgiveness: 3,000 / 6,000 = 0.5. Leaving the + # deferral out would give 3,000 / (2,000 + 3,000) = 0.6. + pa_tax_forgiveness_eligible_share: 0.5 + # Tax: 6,000 x 3.07% = 184.20. Eligibility income 6,000 is under the + # married base of 2 x 6,500 = 13,000, so the rate is 100%: + # 184.20 x 1 x 0.5 = 92.10. + pa_income_tax_before_forgiveness: 184.2 + pa_tax_forgiveness_amount: 92.1 diff --git a/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.yaml index 43ae1a25d96..e214b7133a3 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.yaml @@ -1,7 +1,8 @@ # PA total taxable income starts from federal gross income, which leaves out a -# tax unit dependent's income, and subtracts the amounts in it that Pennsylvania -# does not tax. A dependent files their own PA return (2025 PA-40 IN, page 4, -# "Minors"), so only the head's and spouse's nontaxable amounts are subtracted. +# tax unit dependent's income, adds the elective deferrals Pennsylvania taxes as +# compensation, and subtracts the amounts in it that Pennsylvania does not tax. +# A dependent files their own PA return (2025 PA-40 IN, page 4, "Minors"), so +# only the head's and spouse's amounts are added and subtracted. - name: A dependent's retirement income does not reduce the filer's PA taxable income. period: 2025 @@ -154,3 +155,224 @@ output: pa_gambling_loss_offset: 0 pa_total_taxable_income: 40_000 + +# Alimony. The 2025 PA-40 instructions (page 8) list alimony among the income +# not taxable for PA PIT purposes. Federal gross income holds alimony under a +# divorce or separation instrument executed before 2019, and Pennsylvania +# takes that part back out. + +- name: Alimony from a pre-2019 divorce is not PA taxable income and counts once in eligibility income. + period: 2025 + absolute_error_margin: 0.01 + input: + state_code: PA + employment_income: 5_000 + alimony_income: 3_000 + divorce_year: 2010 + output: + # Schedule SP line 1, PA taxable income (PA-40 line 9): 5,000, since + # alimony is not PA-taxable. Schedule SP line 3 adds the 3,000 of + # alimony: 5,000 + 3,000 = 8,000. 72 P.S. 7301(o.2) counts all moneys + # received, and Schedule SP Section III line 3 is "Alimony" (2025 PA-40 + # IN, page 38). + pa_total_taxable_income: 5_000 + pa_eligibility_income: 8_000 + +- name: Alimony under a 2018 divorce comes out of PA taxable income. + period: 2025 + absolute_error_margin: 0.01 + input: + age: 45 + state_code: PA + employment_income: 40_000 + alimony_income: 12_000 + # The last divorce year for which the recipient pays federal tax on + # alimony. + divorce_year: 2018 + output: + taxable_alimony_income: 12_000 + # 40,000 wages + 12,000 alimony. + irs_gross_income: 52_000 + # 52,000 - 12,000 alimony = 40,000. + pa_total_taxable_income: 40_000 + # 40,000 x 3.07% + pa_income_tax_before_forgiveness: 1_228 + +- name: Alimony under a 2019 divorce is in neither federal gross income nor PA taxable income. + period: 2025 + absolute_error_margin: 0.01 + input: + age: 45 + state_code: PA + employment_income: 40_000 + alimony_income: 12_000 + divorce_year: 2019 + output: + taxable_alimony_income: 0 + irs_gross_income: 40_000 + # Nothing to take out: 40,000. + pa_total_taxable_income: 40_000 + # 40,000 x 3.07% + pa_income_tax_before_forgiveness: 1_228 + +# Elective deferrals. 2025 PA-40 instructions, Line 1a (page 12): "The +# contributions you make to your employer's sponsored retirement plan are +# PA-taxable compensation, even if your contributions are not taxable for +# federal purposes or included in the state wages shown on your W-2." 61 Pa. +# Code 101.6(c)(8)(ii)(B): contributions an employee makes "whether through +# payroll deduction, a salary reduction agreement or otherwise, are not +# excludable from his income." Federal wages (irs_employment_income) leave out +# traditional 401(k) and 403(b) deferrals, so Pennsylvania adds them back. + +- name: A 401(k) contribution is PA-taxable compensation. + period: 2025 + absolute_error_margin: 0.01 + input: + state_code: PA + employment_income: 10_000 + traditional_401k_contributions: 1_000 + output: + # Federal wages are 10,000 - 1,000 = 9,000. PA-40 line 9 counts the + # 1,000 contribution as compensation: 10,000. Eligibility income starts + # from PA taxable income (Schedule SP line 1): 10,000. + irs_employment_income: 9_000 + pa_taxable_elective_deferrals: 1_000 + pa_total_taxable_income: 10_000 + pa_eligibility_income: 10_000 + +- name: A traditional 401(k) deferral is taxed by Pennsylvania on a typical wage. + period: 2025 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: PA + employment_income: 60_000 + traditional_401k_contributions: 6_000 + output: + # 60,000 - 6,000 = 54,000 federal wages. + irs_gross_income: 54_000 + pa_taxable_elective_deferrals: 6_000 + # 54,000 + 6,000 = 60,000. + pa_total_taxable_income: 60_000 + # 60,000 x 3.07% + pa_income_tax_before_forgiveness: 1_842 + +- name: Each spouse's traditional 401(k) and 403(b) deferrals are added back; a Roth 401(k) deferral is already in wages. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + head: + age: 45 + employment_income: 50_000 + traditional_401k_contributions: 5_000 + roth_401k_contributions: 2_000 + traditional_403b_contributions: 0 + spouse: + age: 43 + employment_income: 40_000 + traditional_401k_contributions: 0 + roth_401k_contributions: 0 + traditional_403b_contributions: 4_000 + tax_units: + tax_unit: + members: [head, spouse] + filing_status: JOINT + marital_units: + marital_unit: + members: [head, spouse] + households: + household: + members: [head, spouse] + state_code: PA + output: + # Head: 50,000 - 5,000 traditional = 45,000 (the Roth 2,000 stays in). + # Spouse: 40,000 - 4,000 = 36,000. + irs_employment_income: [45_000, 36_000] + pa_taxable_elective_deferrals: [5_000, 4_000] + # 45,000 + 36,000 + 5,000 + 4,000 = 90,000. + pa_total_taxable_income: 90_000 + # 90,000 x 3.07% + pa_income_tax_before_forgiveness: 2_763 + +- name: Pre-tax health insurance premiums stay out of PA compensation; the 401(k) deferral is added back. + period: 2025 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: PA + employment_income: 50_000 + pre_tax_health_insurance_premiums: 3_000 + traditional_401k_contributions: 2_000 + output: + # 50,000 - 3,000 - 2,000 = 45,000 federal wages. + irs_employment_income: 45_000 + # 72 P.S. 7301(d)(vi): compensation does not include payments made under + # a section 125 cafeteria plan for programs covering hospitalization or + # sickness. Only the 2,000 deferral comes back: 47,000. + pa_taxable_elective_deferrals: 2_000 + pa_total_taxable_income: 47_000 + +- name: A deferral equal to the wages is added back in full. + period: 2025 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: PA + employment_income: 3_000 + traditional_401k_contributions: 3_000 + output: + # max(3,000 - 3,000, 0) = 0 federal wages; the full 3,000 comes back. + irs_employment_income: 0 + pa_taxable_elective_deferrals: 3_000 + pa_total_taxable_income: 3_000 + +- name: A deferral above the wages adds back no more than the wages. + period: 2025 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: PA + employment_income: 2_000 + traditional_401k_contributions: 3_000 + output: + # Federal wages are floored at 0, so they leave out only 2,000 of the + # 3,000 deferral: min(3,000, 2,000 - 0) = 2,000. + irs_employment_income: 0 + pa_taxable_elective_deferrals: 2_000 + pa_total_taxable_income: 2_000 + +- name: A dependent's 401(k) deferral is not added to the filer's PA taxable income. + period: 2025 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + employment_income: 50_000 + traditional_401k_contributions: 0 + is_tax_unit_dependent: false + person2: + age: 17 + employment_income: 8_000 + traditional_401k_contributions: 1_000 + is_tax_unit_dependent: true + tax_units: + tax_unit: + members: [person1, person2] + marital_units: + marital_unit1: + members: [person1] + marital_unit2: + members: [person2] + households: + household: + members: [person1, person2] + state_code: PA + output: + # The dependent files their own PA return, and their wages are not in + # the filer's federal gross income, so neither is their deferral. + pa_taxable_elective_deferrals: [0, 1_000] + pa_total_taxable_income: 50_000 + # 50,000 x 3.07% + pa_income_tax_before_forgiveness: 1_535 diff --git a/policyengine_us/variables/gov/states/pa/tax/income/forgiveness/pa_tax_forgiveness_eligible_share.py b/policyengine_us/variables/gov/states/pa/tax/income/forgiveness/pa_tax_forgiveness_eligible_share.py index b59b742e5ec..2888765751b 100644 --- a/policyengine_us/variables/gov/states/pa/tax/income/forgiveness/pa_tax_forgiveness_eligible_share.py +++ b/policyengine_us/variables/gov/states/pa/tax/income/forgiveness/pa_tax_forgiveness_eligible_share.py @@ -33,7 +33,8 @@ def formula(tax_unit, period, parameters): filer = person("is_tax_unit_head_or_spouse", period) eligible = person("pa_tax_forgiveness_eligible", period) # Each filer's own Pennsylvania taxable income: federal gross income - # less the person-level amounts Pennsylvania does not tax. + # plus the elective deferrals Pennsylvania taxes, less the + # person-level amounts Pennsylvania does not tax. sources = parameters(period).gov.states.pa.tax.income.nontaxable_income_sources person_sources = [ source @@ -43,7 +44,9 @@ def formula(tax_unit, period, parameters): ).entity.is_person ] nontaxable = add(person, period, person_sources) - own = max_(0, person("irs_gross_income", period) - nontaxable) * filer + gross_income = person("irs_gross_income", period) + taxable_deferrals = person("pa_taxable_elective_deferrals", period) + own = max_(0, gross_income + taxable_deferrals - nontaxable) * filer total = tax_unit.sum(own) eligible_income = tax_unit.sum(own * eligible) # With no taxable income there is no tax; split evenly. diff --git a/policyengine_us/variables/gov/states/pa/tax/income/pa_other_additions.py b/policyengine_us/variables/gov/states/pa/tax/income/pa_other_additions.py index e445a76e6b8..abf817f32c0 100644 --- a/policyengine_us/variables/gov/states/pa/tax/income/pa_other_additions.py +++ b/policyengine_us/variables/gov/states/pa/tax/income/pa_other_additions.py @@ -11,8 +11,8 @@ class pa_other_additions(Variable): documentation = ( "Enter a positive amount for other income taxable in Pennsylvania under " "one of the eight classes (lines 1c-8, total on line 9) that PolicyEngine " - "does not otherwise include, excluding gambling winnings, which " - "PolicyEngine already includes." + "does not otherwise include, excluding gambling winnings and traditional " + "401(k) and 403(b) contributions, which PolicyEngine already includes." ) # PDF pages 8, 19-20 reference = "https://www.pa.gov/content/dam/copapwp-pagov/en/revenue/documents/formsandpublications/formsforindividuals/pit/documents/2025/2025_pa-40in.pdf#page=8" diff --git a/policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_taxable_elective_deferrals.py b/policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_taxable_elective_deferrals.py new file mode 100644 index 00000000000..efac5d2bda4 --- /dev/null +++ b/policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_taxable_elective_deferrals.py @@ -0,0 +1,35 @@ +from policyengine_us.model_api import * + + +class pa_taxable_elective_deferrals(Variable): + value_type = float + entity = Person + label = "Elective deferrals taxable by PA but not by US" + unit = USD + documentation = ( + "Traditional 401(k) and 403(b) elective deferrals that federal wages " + "leave out but Pennsylvania taxes as compensation. An employee's own " + "contributions to an employer retirement plan, whether by payroll " + "deduction or salary reduction, are not excludable from Pennsylvania " + "compensation." + ) + definition_period = YEAR + reference = ( + # 2025 PA-40 IN, Line 1a: "The contributions you make to your + # employer's sponsored retirement plan are PA-taxable compensation". + "https://www.pa.gov/content/dam/copapwp-pagov/en/revenue/documents/formsandpublications/formsforindividuals/pit/documents/2025/2025_pa-40in.pdf#page=12", + # 61 Pa. Code 101.6(c)(8)(ii)(B). + "https://www.pacodeandbulletin.gov/Display/pacode?file=/secure/pacode/data/061/chapter101/s101.6.html", + # PA PIT Guide, Gross Compensation: employee contributions taxable. + "https://www.pa.gov/content/dam/copapwp-pagov/en/revenue/documents/formsandpublications/papersonalincometaxguide/documents/pitguide_grosscompensation.pdf#page=51", + ) + defined_for = StateCode.PA + + def formula(person, period, parameters): + p = parameters(period).gov.states.pa.tax.income + deferrals = add(person, period, p.taxable_elective_deferral_sources) + # Federal wages are floored at zero, so they leave out the deferrals + # only up to the wages themselves. Add back no more than that. + employment_income = person("employment_income", period) + federal_wages = person("irs_employment_income", period) + return min_(deferrals, employment_income - federal_wages) diff --git a/policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.py b/policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.py index 223f12eb7e2..38dc9c8b53d 100644 --- a/policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.py +++ b/policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.py @@ -9,8 +9,10 @@ class pa_total_taxable_income(Variable): definition_period = YEAR reference = ( "https://www.pa.gov/content/dam/copapwp-pagov/en/revenue/documents/formsandpublications/formsforindividuals/pit/documents/2021/2021_pa-40in.pdf#page=8", - # Minors file their own PA return even if claimed as a dependent on - # a federal return. + # PDF pages 4, 8, 12: minors file their own PA return even if claimed + # as a dependent on a federal return (page 4); alimony is not taxable + # (page 8); contributions to an employer-sponsored retirement plan are + # PA-taxable compensation (page 12). "https://www.pa.gov/content/dam/copapwp-pagov/en/revenue/documents/formsandpublications/formsforindividuals/pit/documents/2025/2025_pa-40in.pdf#page=4", ) defined_for = StateCode.PA @@ -20,8 +22,17 @@ def formula(tax_unit, period, parameters): other_additions = tax_unit("pa_other_additions", period) p = parameters(period).gov.states.pa.tax.income sources = p.nontaxable_income_sources - # The sources are amounts in federal gross income, which leaves out - # dependents' income; dependents file their own PA return, so only - # the head's and spouse's amounts are subtracted. + # Federal gross income leaves out dependents' income; dependents file + # their own PA return, so only the head's and spouse's elective + # deferrals are added and only their nontaxable amounts subtracted. + pa_taxable_deferrals = tax_unit_non_dep_add( + tax_unit, period, ["pa_taxable_elective_deferrals"] + ) pa_nontaxable_income = tax_unit_non_dep_add(tax_unit, period, sources) - return max_(0, us_gross_income + other_additions - pa_nontaxable_income) + return max_( + 0, + us_gross_income + + pa_taxable_deferrals + + other_additions + - pa_nontaxable_income, + ) From 35db7d55deacbb33bac288ba6294bafb25d36f52 Mon Sep 17 00:00:00 2001 From: David Trimmer <178813244+DTrim99@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:01:32 -0500 Subject: [PATCH 2/2] Fix issues from review: floor the PA elective-deferral add-back at zero Compute the add-back as PA compensation (employment income less non-deferral pre-tax deductions, floored at zero) minus federal wages, so negative wages no longer produce a negative add-back and cafeteria-plan premiums are not added back. Add tests for negative wages and premiums that zero out federal wages. Co-Authored-By: Claude Opus 5.5 --- .../pa_total_taxable_income.yaml | 43 ++++++++++++++++++- .../pa_taxable_elective_deferrals.py | 9 ++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.yaml b/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.yaml index e214b7133a3..6c54f34b15e 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/pa/tax/income/taxable_income/pa_total_taxable_income.yaml @@ -337,7 +337,8 @@ traditional_401k_contributions: 3_000 output: # Federal wages are floored at 0, so they leave out only 2,000 of the - # 3,000 deferral: min(3,000, 2,000 - 0) = 2,000. + # 3,000 deferral. PA compensation: max(2,000 - (3,000 - 3,000), 0) = + # 2,000, so the add-back is 2,000 - 0 = 2,000. irs_employment_income: 0 pa_taxable_elective_deferrals: 2_000 pa_total_taxable_income: 2_000 @@ -376,3 +377,43 @@ pa_total_taxable_income: 50_000 # 50,000 x 3.07% pa_income_tax_before_forgiveness: 1_535 + +- name: Negative wages do not make the deferral add-back negative. + period: 2025 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: PA + employment_income: -1_000 + taxable_interest_income: 5_000 + output: + # Federal wages: max(-1,000 - 0, 0) = 0. PA compensation (PA-40 line 1a) + # is floored too: max(-1,000 - (0 - 0), 0) = 0. Add-back: 0 - 0 = 0. + irs_employment_income: 0 + pa_taxable_elective_deferrals: 0 + # 0 wages + 5,000 interest = 5,000. + irs_gross_income: 5_000 + pa_total_taxable_income: 5_000 + # 5,000 x 3.07% + pa_income_tax_before_forgiveness: 153.50 + +- name: Pre-tax premiums that push federal wages to zero limit the deferral add-back to PA compensation. + period: 2025 + absolute_error_margin: 0.01 + input: + age: 40 + state_code: PA + employment_income: 10_000 + traditional_401k_contributions: 8_000 + pre_tax_health_insurance_premiums: 4_000 + output: + # Federal wages: max(10,000 - 8,000 - 4,000, 0) = 0. + irs_employment_income: 0 + # PA compensation keeps the 8,000 deferral (61 Pa. Code + # 101.6(c)(8)(ii)(B)) but leaves out the 4,000 of cafeteria-plan + # premiums (72 P.S. 7301(d)(vi)): max(10,000 - (12,000 - 8,000), 0) = + # 6,000. Add-back: 6,000 - 0 = 6,000, not the full 8,000 deferral. + pa_taxable_elective_deferrals: 6_000 + pa_total_taxable_income: 6_000 + # 6,000 x 3.07% + pa_income_tax_before_forgiveness: 184.20 diff --git a/policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_taxable_elective_deferrals.py b/policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_taxable_elective_deferrals.py index efac5d2bda4..4a0635edd64 100644 --- a/policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_taxable_elective_deferrals.py +++ b/policyengine_us/variables/gov/states/pa/tax/income/taxable_income/pa_taxable_elective_deferrals.py @@ -28,8 +28,11 @@ class pa_taxable_elective_deferrals(Variable): def formula(person, period, parameters): p = parameters(period).gov.states.pa.tax.income deferrals = add(person, period, p.taxable_elective_deferral_sources) - # Federal wages are floored at zero, so they leave out the deferrals - # only up to the wages themselves. Add back no more than that. employment_income = person("employment_income", period) + pre_tax_contributions = person("pre_tax_contributions", period) federal_wages = person("irs_employment_income", period) - return min_(deferrals, employment_income - federal_wages) + # PA compensation keeps the deferrals but leaves out the other pre-tax + # payroll deductions, and like federal wages it is floored at zero. + # The add-back is the gap between the two, so it is never negative. + pa_wages = max_(0, employment_income - (pre_tax_contributions - deferrals)) + return pa_wages - federal_wages