diff --git a/changelog.d/lpl-income-tax-rules.added.md b/changelog.d/lpl-income-tax-rules.added.md new file mode 100644 index 00000000000..be2fdf5b67d --- /dev/null +++ b/changelog.d/lpl-income-tax-rules.added.md @@ -0,0 +1 @@ +Add federal early-distribution tax, missed-RMD excise, California 2.5% early-distribution tax, section 1256 60/40, home sale exclusion, savings bond education exclusion, long-term care per diem limit, annuity exclusion ratio and Simplified Method, and lot-level holding-period, wash-sale, RIC loss and bond discount rules. diff --git a/changelog.d/state-govt-fund-dividends.added.md b/changelog.d/state-govt-fund-dividends.added.md new file mode 100644 index 00000000000..777af889719 --- /dev/null +++ b/changelog.d/state-govt-fund-dividends.added.md @@ -0,0 +1 @@ +Add California, Connecticut and New York subtractions for mutual fund dividends attributable to U.S. government obligations, with per-fund quarterly 50% asset tests. diff --git a/docs/_toc.yml b/docs/_toc.yml index 4d8610ecec6..5efd2577f2a 100644 --- a/docs/_toc.yml +++ b/docs/_toc.yml @@ -68,6 +68,8 @@ parts: - file: usage/microsimulation - file: usage/chunked-calculations - file: usage/parameter-discovery + - file: usage/us-govt-fund-dividends + - file: usage/lpl-income-tax-rules - file: usage/social-security-calculator sections: - file: usage/social-security/RULINGS diff --git a/docs/usage/lpl-income-tax-rules.md b/docs/usage/lpl-income-tax-rules.md new file mode 100644 index 00000000000..a35a5c5ec1b --- /dev/null +++ b/docs/usage/lpl-income-tax-rules.md @@ -0,0 +1,148 @@ +# Retirement, capital gain and lot-level income tax rules + +These rules were added for portfolio simulations that compute 2026 individual +income tax. Every new input defaults to zero or false, so callers that omit +them get the same results as before. + +## How results reach the tax calculation + +| Result | Reaches the tax calculation | +|---|---| +| Early-distribution tax, missed-RMD excise | `form_5329_additional_taxes`, added beside `qualified_retirement_penalty` in federal tax (and in Iowa's federal tax deduction) | +| California 2.5% / 6% | `ca_early_distribution_additional_tax`, added to California tax before refundable credits | +| Long-term gains (60% of §1256, home sale gain, long-term lot results) | `long_term_capital_gain_adjustments`, part of `long_term_capital_gains` | +| Annuities, Simplified Method, LTC per diem | new federal gross income sources | +| Savings bond exclusion | formula for the existing `us_bonds_for_higher_ed` deduction | +| Short-term gains, dividend reclassification, bond interest | `apply_investment_lot_adjustments` (see below) | + +`short_term_capital_gains`, the dividend inputs and `taxable_interest_income` +are plain inputs that datasets uprate, so a formula cannot add to them. Call +`policyengine_us.tools.investment_lots.apply_investment_lot_adjustments(situation, year)` +before `Simulation(situation=...)`; it computes `short_term_capital_gain_adjustments`, +`investment_lot_interest_adjustment`, `dividends_failing_qualified_holding_period` +and `section_199a_dividends_failing_holding_period` and folds them into those +inputs. + +A caller that sets `long_term_capital_gains` directly replaces its formula, +including the adjustments; set `long_term_capital_gains_before_response` +instead. A caller that sets `qualified_retirement_penalty` should leave the +Form 5329 inputs empty. + +## Rules + +**Early distributions (IRC 72(t), 72(q); Form 5329 Part I).** 10% of early +plan and IRA distributions, 25% for SIMPLE IRA distributions in the first two +years, 10% of premature annuity distributions, less exceptions. The simulator +decides which exception applies; PolicyEngine applies the caps: first-time +homebuyer $10,000 lifetime, birth or adoption $5,000 per child, emergency +$1,000 a year, domestic abuse $10,500 (2026, Notice 2025-67), disaster +$22,000 per disaster, medical expenses above the AGI floor. Inputs: +`early_distributions_from_retirement_plans`, +`early_distributions_from_simple_ira_first_two_years`, +`early_distributions_from_annuity_contracts` and the `early_distribution_*` +exception fields. These are memo amounts already in the retirement income +inputs. `early_withdrawal_penalty` remains the CD penalty deduction only. + +**California (R&TC 17085(c); FTB 3805P).** 2.5% of the federal base, and 6% of +the SIMPLE two-year base. `ca_early_distributions_not_excepted_in_california` +carries amounts California does not except (529-to-Roth, IRA-to-HSA, +qualified recovery assistance distributions). + +**Required minimum distributions (IRC 401(a)(9), 4974).** Applicable age +73 for people born 1951–1959 and 75 from 1960 (IRC 401(a)(9)(C)(v)). The +divisor is the Uniform Lifetime Table (Treas. Reg. 1.401(a)(9)-9(c)) or an +override for the Joint and Last Survivor Table. QLACs are excluded if total +premiums are within $210,000 (2026). The first year can be deferred to +April 1, and the still-working exception applies to employer plans. IRA and +employer-plan shortfalls are measured separately. The excise is 25% of the +shortfall, or 10% if corrected timely, less any waiver. Beneficiary RMDs +come in as amounts (`rmd_inherited_*`). + +**Section 1256 contracts.** `section_1256_net_gain` (Form 6781 line 7, +including year-end mark-to-market) is split 60% long-term and 40% short-term. + +**Home sale (IRC 121).** $250,000 exclusion, or $500,000 for a married couple +when the spouse meets the use test. Other features: +- ownership and use of 24 of the last 60 months each; +- the two-year bar on a second exclusion; +- the reduced exclusion for job, health or unforeseen-circumstance moves; +- no exclusion for the nonqualified-use share or for depreciation after + May 6, 1997. + +The depreciation part should also go in +`unrecaptured_section_1250_gain_before_losses`. + +**Savings bonds (IRC 135; Form 8815).** Interest × (qualified expenses ÷ +proceeds), phased out over $101,800–$116,800 of modified AGI ($152,650–$182,650 +joint) in 2026, and none on separate returns. Modified AGI leaves out taxable +Social Security, which PolicyEngine computes from an AGI that already includes +the exclusion. `savings_bond_education_exclusion_magi_override` supplies an +exact figure. Treasury parameters record the $10,000 annual purchase limit and +the 3-month interest forfeiture before 5 years. Interest deferral is the +simulator's choice of when to report interest. Excluded bond interest should +be removed from `us_govt_interest_person`, so states do not subtract it again. + +**Long-term care per diem (IRC 7702B(d); Form 8853 Section C).** Per diem +benefits above the greater of $430 × days (2026) and actual costs, less +reimbursements, are taxable. + +**Annuity contracts (IRC 72(b), (c), (e)).** Three slots per person, +`annuity_contract__*`: +- exclusion ratio of investment ÷ expected return; +- the exclusion stops once the investment is recovered, for starting dates + after 1986; +- withdrawals are taxed income first, after any pre-August 14, 1982 + investment; +- partial annuitization splits the investment. + +Contracts aggregated under IRC 72(e)(12) go in one slot. A 1035 exchange is +not a taxable event: carry the investment into the new slot. The Simplified +Method (IRC 72(d)) covers qualified-plan annuities with after-tax cost. Neither +may also be reported in `taxable_pension_income`. + +**Lot-level rules.** Five slots of each kind per person. Sales and bond +gains entered here must be left out of the aggregate gain inputs. Dividend +lots describe dividends already in the dividend inputs. +- Qualified dividend holding period: more than 60 days in the 121-day window + (90 days of 181 for long-period preferred). For section 199A REIT + dividends, more than 45 days of 91. Days held must exclude hedged days. +- Wash sales (IRC 1091): substantially identical purchases within 30 days + before or after a loss sale disallow the matching share of the loss. An + IRA purchase disallows it permanently (Rev. Rul. 2008-5). The deferred + amount (`wash_sale_disallowed_loss_deferred`) must be added to the + replacement basis by the simulator. +- RIC shares held six months or less (IRC 852(b)(4)): the loss is disallowed + up to exempt-interest dividends (not for daily-dividend funds), then is + long-term up to capital gain dividends. +- Bonds: OID under the constant-yield method (zero if de minimis), reduced by + any acquisition premium fraction; ratable market discount, as interest at + sale or currently by election; and bond premium amortization under IRC 171. + +## Not modeled + +- **Federal 10% tax:** whether a distribution meets an exception is the + simulator's decision; the domestic-abuse 50%-of-balance limit is also left + to it. +- **California exceptions:** which SECURE Act exceptions California has + adopted (birth or adoption, for example) is not certain; amounts California + does not except go in the California-only input. +- **Required minimum distributions:** + - beneficiary RMD computation; + - the pre-2022 Uniform Lifetime Table (earlier years use the 2022 table); + - 403(b) aggregation beyond one combined group. +- **Annuities:** + - expected return from the Treas. Reg. 1.72-9 tables; + - the deduction for unrecovered investment at death; + - the IRC 72(s) distribution-at-death rules. +- **Bonds:** + - constant-yield market discount; + - premium amortization computation; + - tax-exempt bond premium; + - short-term obligations. +- **Lot rules:** straddles, constructive sales, and wash sales across spouses. +- **Not income tax (left out):** + - state annuity premium taxes; + - estate, inheritance and gift taxes; + - crypto broker reporting; + - withholding, MEC 7-pay and Table V; + - product charges. diff --git a/docs/usage/us-govt-fund-dividends.md b/docs/usage/us-govt-fund-dividends.md new file mode 100644 index 00000000000..c5f0f61e08c --- /dev/null +++ b/docs/usage/us-govt-fund-dividends.md @@ -0,0 +1,96 @@ +# Fund dividends from U.S. government obligations + +Federal law bars states from taxing interest on U.S. government obligations +(31 U.S.C. § 3124). A shareholder who receives that interest through a +regulated investment company (a mutual fund, ETF or money market fund) gets +the exemption only as each state's law passes it through. California, +Connecticut and New York pass it through only for a fund that holds at least +50% of the value of its total assets in qualifying obligations **at the close +of each quarter of the fund's taxable year**. PolicyEngine models that test +fund by fund. + +## Rules modeled + +| State | Subtraction | Asset test | Line | +|---|---|---|---| +| California | `ca_us_govt_fund_dividend_subtraction` | ≥ 50% of total assets in obligations exempt from California tax at each quarter-end; a qualified fund of funds (IRC 852(g)(2)) is exempt from the test from 2011 | Schedule CA (540), line 2, column B | +| Connecticut | `ct_us_govt_fund_dividend_subtraction` | ≥ 50% of total assets (IRC 851(c)(4)) in obligations that federal law bars states from taxing, at each quarter-end | CT-1040, line 40 | +| New York | `ny_us_govt_fund_dividend_subtraction` | ≥ 50% of total assets in U.S. obligations at each quarter-end | IT-201, line 28 | + +Sources: Cal. Rev. & Tax. Code § 17145; Conn. Gen. Stat. § 12-718 and Conn. +Agencies Regs. § 12-701(a)(20)-3; N.Y. Tax Law § 612(c)(1) and TSB-M-92(4)I. + +Direct holdings of U.S. obligations stay on `us_govt_interest_person` (or +`us_govt_interest`), which every state already subtracts. Do not put fund +dividends there: each subtraction is counted once, from its own input. + +## Inputs per fund + +Each person has 10 fund slots, `us_govt_fund_1_*` to `us_govt_fund_10_*`. +Use one slot per fund held in a taxable account and never merge funds. + +| Field | Type | Meaning | +|---|---|---| +| `us_govt_fund__ordinary_dividends` | USD | Ordinary dividends from the fund (Form 1099-DIV box 1a; no capital gain distributions). A memo of dividends already in `qualified_dividend_income` / `non_qualified_dividend_income`; it adds no income. | +| `us_govt_fund__govt_income_share` | 0–1 | Share of the fund's ordinary dividends from U.S. government obligations, from the issuer's annual tax supplement. Sets the amount only. | +| `us_govt_fund__govt_asset_share_q1` … `_q4` | 0–1 | Share of total assets in qualifying U.S. government obligations at the close of each quarter of the fund's taxable year. Sets eligibility only. | +| `us_govt_fund__asset_test_evidence` | enum | `QUARTERLY_ASSET_SHARES` (default), `ISSUER_CONFIRMED_MET` or `ISSUER_CONFIRMED_NOT_MET`. | +| `us_govt_fund__qualified_fund_of_funds` | bool | Qualified fund of funds; used only by California. | + +Subtraction per fund = `ordinary_dividends × govt_income_share` if the fund +passes the state's test, else 0. The person's total is capped at +`ordinary_dividend_income`, and dependents' amounts stay off the filer's +return. + +### Using an issuer's annual tax supplement + +Issuers publish a "percentage of income from U.S. government obligations" +table each January or February. Use it this way: + +1. `govt_income_share` = the fund's percentage for the calendar year, as a + fraction (98.67% → `0.9867`). +2. If the supplement states that the fund met the California, Connecticut + and New York 50% requirement, set `asset_test_evidence` to + `ISSUER_CONFIRMED_MET`. If it marks the fund as not meeting it (often an + asterisk), set `ISSUER_CONFIRMED_NOT_MET`. +3. If the supplement says nothing about the test, supply the four quarter-end + asset shares from the fund's holdings reports (N-PORT, N-MFP or annual and + semi-annual reports) and leave the evidence at `QUARTERLY_ASSET_SHARES`. + +The income percentage never establishes the asset test. A fund can report +more than 50% of income from U.S. obligations and still fail a quarter. + +### What counts toward the asset share + +Count U.S. Treasury bills, notes, bonds and savings bonds, and obligations of +agencies whose interest federal law exempts from state tax (for example +Federal Farm Credit Banks, Federal Home Loan Banks and the Tennessee Valley +Authority). Do not count repurchase agreements, even when Treasuries +collateralize them (NY TSB-M-88(5)I; Appeal of H. Lon Henry, Cal. SBE), or +Ginnie Mae, Fannie Mae and Freddie Mac securities (Conn. Agencies Regs. +§ 12-701(a)(20)-3). Measure at the close of each quarter of the **fund's** +taxable year, which need not be the calendar year. + +California's asset base also counts California municipal obligations, and +Connecticut's counts territorial obligations. The slots carry U.S. government +obligations only, so for a fund that reaches 50% only with those holdings, +use the issuer's statement. + +### Missing data + +Every quarterly share defaults to 0, which fails the test. A fund with fewer +than four quarter-end shares, or with only an income share, gets no +subtraction. Supply the issuer's statement instead for a fund whose first +taxable year was shorter than four quarters. + +## Example + +`scripts/us_govt_fund_dividends_household.py` runs a New York household +through `Simulation` with two funds, one passing and one failing. + +## Not modeled + +States without a 50% asset test (most others) let shareholders subtract the +U.S. government share of fund dividends. They are not wired to these slots +yet. New Jersey's separate 80% "qualified investment fund" rule +(N.J.S.A. 54A:6-14.1) is also not modeled. diff --git a/policyengine_us/parameters/gov/irs/capital_gains/home_sale_exclusion/amount.yaml b/policyengine_us/parameters/gov/irs/capital_gains/home_sale_exclusion/amount.yaml new file mode 100644 index 00000000000..596bb7b2459 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/capital_gains/home_sale_exclusion/amount.yaml @@ -0,0 +1,12 @@ +description: The IRS excludes up to this amount of gain on the sale of a main home for each qualifying individual. +values: + 1997-05-07: 250_000 +metadata: + unit: currency-USD + period: year + label: Home sale gain exclusion + reference: + - title: 26 U.S. Code § 121 + href: https://www.law.cornell.edu/uscode/text/26/121 + - title: IRS Publication 523, Selling Your Home + href: https://www.irs.gov/publications/p523 diff --git a/policyengine_us/parameters/gov/irs/capital_gains/home_sale_exclusion/joint_amount.yaml b/policyengine_us/parameters/gov/irs/capital_gains/home_sale_exclusion/joint_amount.yaml new file mode 100644 index 00000000000..e50b10fbc7d --- /dev/null +++ b/policyengine_us/parameters/gov/irs/capital_gains/home_sale_exclusion/joint_amount.yaml @@ -0,0 +1,12 @@ +description: The IRS excludes up to this amount of gain on the sale of a main home on a joint return when either spouse meets the ownership test, both meet the use test and neither excluded gain on another home in the prior two years. +values: + 1997-05-07: 500_000 +metadata: + unit: currency-USD + period: year + label: Home sale gain exclusion, joint return + reference: + - title: 26 U.S. Code § 121 + href: https://www.law.cornell.edu/uscode/text/26/121 + - title: IRS Publication 523, Selling Your Home + href: https://www.irs.gov/publications/p523 diff --git a/policyengine_us/parameters/gov/irs/capital_gains/home_sale_exclusion/required_months.yaml b/policyengine_us/parameters/gov/irs/capital_gains/home_sale_exclusion/required_months.yaml new file mode 100644 index 00000000000..338992d6ce0 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/capital_gains/home_sale_exclusion/required_months.yaml @@ -0,0 +1,12 @@ +description: A person must own and use the home as a main home for at least this many months in the lookback window. +values: + 1997-05-07: 24 +metadata: + unit: month + period: year + label: Home sale exclusion ownership and use months required + reference: + - title: 26 U.S. Code § 121 + href: https://www.law.cornell.edu/uscode/text/26/121 + - title: IRS Publication 523, Selling Your Home + href: https://www.irs.gov/publications/p523 diff --git a/policyengine_us/parameters/gov/irs/capital_gains/section_1256/long_term_share.yaml b/policyengine_us/parameters/gov/irs/capital_gains/section_1256/long_term_share.yaml new file mode 100644 index 00000000000..fddbdebef67 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/capital_gains/section_1256/long_term_share.yaml @@ -0,0 +1,12 @@ +description: The IRS treats this share of the gain or loss on section 1256 contracts as long-term, and the rest as short-term, regardless of holding period. +values: + 1981-06-23: 0.6 +metadata: + unit: /1 + period: year + label: Section 1256 contract long-term share + reference: + - title: 26 U.S. Code § 1256(a)(3) + href: https://www.law.cornell.edu/uscode/text/26/1256 + - title: Instructions for Form 6781 + href: https://www.irs.gov/forms-pubs/about-form-6781 diff --git a/policyengine_us/parameters/gov/irs/gross_income/annuities/simplified_method_payments.yaml b/policyengine_us/parameters/gov/irs/gross_income/annuities/simplified_method_payments.yaml new file mode 100644 index 00000000000..c4d9cac4d2d --- /dev/null +++ b/policyengine_us/parameters/gov/irs/gross_income/annuities/simplified_method_payments.yaml @@ -0,0 +1,33 @@ +description: Under the Simplified Method the IRS divides the cost in a qualified plan annuity by this expected number of monthly payments, by age at the annuity starting date (single-life annuities). +brackets: + - threshold: + 1998-01-01: 0 + amount: + 1998-01-01: 360 + - threshold: + 1998-01-01: 56 + amount: + 1998-01-01: 310 + - threshold: + 1998-01-01: 61 + amount: + 1998-01-01: 260 + - threshold: + 1998-01-01: 66 + amount: + 1998-01-01: 210 + - threshold: + 1998-01-01: 71 + amount: + 1998-01-01: 160 +metadata: + type: single_amount + threshold_unit: year + amount_unit: month + period: year + label: Simplified Method expected payments, single life + reference: + - title: 26 U.S. Code § 72(d)(1)(B)(iii) + href: https://www.law.cornell.edu/uscode/text/26/72#d_1_B + - title: IRS Publication 575, Simplified Method Worksheet, Table 1 + href: https://www.irs.gov/publications/p575 diff --git a/policyengine_us/parameters/gov/irs/gross_income/annuities/simplified_method_payments_joint.yaml b/policyengine_us/parameters/gov/irs/gross_income/annuities/simplified_method_payments_joint.yaml new file mode 100644 index 00000000000..790ea738325 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/gross_income/annuities/simplified_method_payments_joint.yaml @@ -0,0 +1,33 @@ +description: Under the Simplified Method the IRS divides the cost in a qualified plan annuity paid over more than one life by this expected number of monthly payments, by the annuitants' combined ages at the starting date. +brackets: + - threshold: + 1998-01-01: 0 + amount: + 1998-01-01: 410 + - threshold: + 1998-01-01: 111 + amount: + 1998-01-01: 360 + - threshold: + 1998-01-01: 121 + amount: + 1998-01-01: 310 + - threshold: + 1998-01-01: 131 + amount: + 1998-01-01: 260 + - threshold: + 1998-01-01: 141 + amount: + 1998-01-01: 210 +metadata: + type: single_amount + threshold_unit: year + amount_unit: month + period: year + label: Simplified Method expected payments, more than one life + reference: + - title: 26 U.S. Code § 72(d)(1)(B)(iv) + href: https://www.law.cornell.edu/uscode/text/26/72#d_1_B + - title: IRS Publication 575, Simplified Method Worksheet, Table 2 + href: https://www.irs.gov/publications/p575 diff --git a/policyengine_us/parameters/gov/irs/gross_income/long_term_care_per_diem_limit.yaml b/policyengine_us/parameters/gov/irs/gross_income/long_term_care_per_diem_limit.yaml new file mode 100644 index 00000000000..31a9aa5ed44 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/gross_income/long_term_care_per_diem_limit.yaml @@ -0,0 +1,19 @@ +description: The IRS excludes per diem payments under qualified long-term care insurance contracts and accelerated death benefits up to this amount per day, or actual long-term care costs if greater. +# Years before 2022 are not entered; earlier years use the 2022 amount. +values: + 1997-01-01: 390 + 2023-01-01: 420 + 2024-01-01: 410 + 2025-01-01: 420 + 2026-01-01: 430 +metadata: + unit: currency-USD + period: year + label: Long-term care per diem exclusion limit + reference: + - title: 26 U.S. Code § 7702B(d) + href: https://www.law.cornell.edu/uscode/text/26/7702B#d + - title: Rev. Proc. 2025-32 section 4.62 + href: "https://www.irs.gov/pub/irs-drop/rp-25-32.pdf#page=35" + - title: Instructions for Form 8853, Section C + href: https://www.irs.gov/instructions/i8853 diff --git a/policyengine_us/parameters/gov/irs/gross_income/sources.yaml b/policyengine_us/parameters/gov/irs/gross_income/sources.yaml index 4a8b93cc8b8..10517dab999 100644 --- a/policyengine_us/parameters/gov/irs/gross_income/sources.yaml +++ b/policyengine_us/parameters/gov/irs/gross_income/sources.yaml @@ -54,6 +54,12 @@ values: - salt_refund_income # Military retirement pay and survivor benefit plan payments (IRC § 61, Form 1040 line 5b). - military_retirement_income + # Per diem long-term care benefits above the IRC 7702B(d) limit (Form 8853 Section C). + - taxable_long_term_care_per_diem_benefits + # Annuity contracts outside qualified plans (IRC 72(b), (e)) and qualified + # plan annuities under the Simplified Method (IRC 72(d)), from detailed inputs. + - taxable_annuity_contract_income + - simplified_method_taxable_annuity metadata: diff --git a/policyengine_us/parameters/gov/irs/investment_lots/de_minimis_discount_rate.yaml b/policyengine_us/parameters/gov/irs/investment_lots/de_minimis_discount_rate.yaml new file mode 100644 index 00000000000..1ec02c49f84 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/investment_lots/de_minimis_discount_rate.yaml @@ -0,0 +1,10 @@ +description: OID or market discount below this fraction of the stated redemption price times complete years to maturity is treated as zero (de minimis). +values: + 1984-07-19: 0.0025 +metadata: + unit: /1 + period: year + label: OID and market discount de minimis rate per year + reference: + - title: 26 U.S. Code § 1273(a)(3), § 1278(a)(2)(C) + href: https://www.law.cornell.edu/uscode/text/26/1273 diff --git a/policyengine_us/parameters/gov/irs/investment_lots/qualified_dividend_min_days.yaml b/policyengine_us/parameters/gov/irs/investment_lots/qualified_dividend_min_days.yaml new file mode 100644 index 00000000000..c3d8e9df7ad --- /dev/null +++ b/policyengine_us/parameters/gov/irs/investment_lots/qualified_dividend_min_days.yaml @@ -0,0 +1,10 @@ +description: A dividend is qualified only if the stock was held more than this many days in the 121-day period beginning 60 days before the ex-dividend date. +values: + 2003-01-01: 60 +metadata: + unit: day + period: year + label: Qualified dividend holding period + reference: + - title: 26 U.S. Code § 1(h)(11)(B)(iii) + href: https://www.law.cornell.edu/uscode/text/26/1#h_11_B_iii diff --git a/policyengine_us/parameters/gov/irs/investment_lots/qualified_dividend_preferred_min_days.yaml b/policyengine_us/parameters/gov/irs/investment_lots/qualified_dividend_preferred_min_days.yaml new file mode 100644 index 00000000000..6b11f740492 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/investment_lots/qualified_dividend_preferred_min_days.yaml @@ -0,0 +1,10 @@ +description: A preferred stock dividend attributable to periods over 366 days is qualified only if the stock was held more than this many days in the 181-day period beginning 90 days before the ex-dividend date. +values: + 2003-01-01: 90 +metadata: + unit: day + period: year + label: Qualified dividend holding period, preferred stock + reference: + - title: 26 U.S. Code § 1(h)(11)(B)(iii)(II), § 246(c)(2) + href: https://www.law.cornell.edu/uscode/text/26/246#c diff --git a/policyengine_us/parameters/gov/irs/investment_lots/ric_short_holding_months.yaml b/policyengine_us/parameters/gov/irs/investment_lots/ric_short_holding_months.yaml new file mode 100644 index 00000000000..c4b7823e149 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/investment_lots/ric_short_holding_months.yaml @@ -0,0 +1,10 @@ +description: A loss on regulated investment company shares held this many months or less is disallowed to the extent of exempt-interest dividends and long-term to the extent of capital gain dividends. +values: + 1987-01-01: 6 +metadata: + unit: month + period: year + label: RIC share short holding period + reference: + - title: 26 U.S. Code § 852(b)(4) + href: https://www.law.cornell.edu/uscode/text/26/852#b_4 diff --git a/policyengine_us/parameters/gov/irs/investment_lots/section_199a_dividend_min_days.yaml b/policyengine_us/parameters/gov/irs/investment_lots/section_199a_dividend_min_days.yaml new file mode 100644 index 00000000000..3a9ddc2746c --- /dev/null +++ b/policyengine_us/parameters/gov/irs/investment_lots/section_199a_dividend_min_days.yaml @@ -0,0 +1,10 @@ +description: A qualified REIT dividend counts for the section 199A deduction only if the shares were held more than this many days in the 91-day period beginning 45 days before the ex-dividend date. +values: + 2018-01-01: 45 +metadata: + unit: day + period: year + label: Section 199A REIT dividend holding period + reference: + - title: 26 CFR 1.199A-3(c)(2)(ii) + href: https://www.law.cornell.edu/cfr/text/26/1.199A-3 diff --git a/policyengine_us/parameters/gov/irs/investment_lots/wash_sale_window_days.yaml b/policyengine_us/parameters/gov/irs/investment_lots/wash_sale_window_days.yaml new file mode 100644 index 00000000000..f59b62c3638 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/investment_lots/wash_sale_window_days.yaml @@ -0,0 +1,10 @@ +description: A loss sale is a wash sale if substantially identical stock or securities are acquired within this many days before or after the sale. +values: + 1954-01-01: 30 +metadata: + unit: day + period: year + label: Wash sale window + reference: + - title: 26 U.S. Code § 1091(a) + href: https://www.law.cornell.edu/uscode/text/26/1091 diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/annuity_rate.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/annuity_rate.yaml new file mode 100644 index 00000000000..36e8dc49360 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/annuity_rate.yaml @@ -0,0 +1,10 @@ +description: The IRS imposes this additional tax rate on premature distributions from annuity contracts included in gross income. +values: + 1987-01-01: 0.1 +metadata: + unit: /1 + period: year + label: Annuity premature distribution additional tax rate + reference: + - title: 26 U.S. Code § 72(q)(1) + href: https://www.law.cornell.edu/uscode/text/26/72#q diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/birth_or_adoption.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/birth_or_adoption.yaml new file mode 100644 index 00000000000..d710a69f9fa --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/birth_or_adoption.yaml @@ -0,0 +1,11 @@ +description: The IRS excepts qualified birth or adoption distributions from the additional tax up to this amount per child. +values: + 1987-01-01: 0 + 2020-01-01: 5_000 +metadata: + unit: currency-USD + period: year + label: Early distribution birth or adoption exception cap per child + reference: + - title: 26 U.S. Code § 72(t)(2)(H) + href: https://www.law.cornell.edu/uscode/text/26/72#t_2_H diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/domestic_abuse_victim.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/domestic_abuse_victim.yaml new file mode 100644 index 00000000000..ab512cc4bed --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/domestic_abuse_victim.yaml @@ -0,0 +1,15 @@ +description: The IRS excepts distributions to domestic abuse victims from the additional tax up to this amount, indexed for inflation. +values: + 1987-01-01: 0 + 2024-01-01: 10_000 + 2025-01-01: 10_300 + 2026-01-01: 10_500 +metadata: + unit: currency-USD + period: year + label: Early distribution domestic abuse victim exception cap + reference: + - title: 26 U.S. Code § 72(t)(2)(K) + href: https://www.law.cornell.edu/uscode/text/26/72#t_2_K + - title: IRS Notice 2025-67 + href: https://www.irs.gov/pub/irs-drop/n-25-67.pdf diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/emergency_personal_expense.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/emergency_personal_expense.yaml new file mode 100644 index 00000000000..8f7a136120c --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/emergency_personal_expense.yaml @@ -0,0 +1,11 @@ +description: The IRS excepts emergency personal expense distributions from the additional tax up to this amount per year. +values: + 1987-01-01: 0 + 2024-01-01: 1_000 +metadata: + unit: currency-USD + period: year + label: Early distribution emergency personal expense exception annual cap + reference: + - title: 26 U.S. Code § 72(t)(2)(I) + href: https://www.law.cornell.edu/uscode/text/26/72#t_2_I diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/first_time_homebuyer.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/first_time_homebuyer.yaml new file mode 100644 index 00000000000..5db68842fa6 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/first_time_homebuyer.yaml @@ -0,0 +1,11 @@ +description: The IRS excepts IRA distributions for a first-time home purchase from the additional tax up to this lifetime amount. +values: + 1987-01-01: 0 + 1998-01-01: 10_000 +metadata: + unit: currency-USD + period: year + label: Early distribution first-time homebuyer exception lifetime cap + reference: + - title: 26 U.S. Code § 72(t)(2)(F), (t)(8)(B) + href: https://www.law.cornell.edu/uscode/text/26/72#t_8 diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/qualified_disaster.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/qualified_disaster.yaml new file mode 100644 index 00000000000..1d3e65a8852 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/exception_caps/qualified_disaster.yaml @@ -0,0 +1,11 @@ +description: The IRS excepts qualified disaster recovery distributions from the additional tax up to this amount per disaster. +values: + 1987-01-01: 0 + 2021-01-01: 22_000 +metadata: + unit: currency-USD + period: year + label: Early distribution qualified disaster exception cap per disaster + reference: + - title: 26 U.S. Code § 72(t)(2)(M), (t)(11)(B) + href: https://www.law.cornell.edu/uscode/text/26/72#t_11 diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/rate.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/rate.yaml new file mode 100644 index 00000000000..8b466a6bf3b --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/rate.yaml @@ -0,0 +1,12 @@ +description: The IRS imposes this additional tax rate on early distributions from qualified retirement plans and IRAs included in gross income. +values: + 1987-01-01: 0.1 +metadata: + unit: /1 + period: year + label: Early distribution additional tax rate + reference: + - title: 26 U.S. Code § 72(t) + href: https://www.law.cornell.edu/uscode/text/26/72#t + - title: 2025 Instructions for Form 5329, Part I + href: https://www.irs.gov/instructions/i5329 diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/simple_ira_rate.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/simple_ira_rate.yaml new file mode 100644 index 00000000000..a3deccb7a51 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/early_distribution_tax/simple_ira_rate.yaml @@ -0,0 +1,13 @@ +description: The IRS imposes this additional tax rate, in place of the general rate, on early SIMPLE IRA distributions received in the first two years of participation. +values: + 1987-01-01: 0.1 + 1997-01-01: 0.25 +metadata: + unit: /1 + period: year + label: SIMPLE IRA two-year early distribution additional tax rate + reference: + - title: 26 U.S. Code § 72(t)(6) + href: https://www.law.cornell.edu/uscode/text/26/72#t_6 + - title: 2025 Instructions for Form 5329, line 4 + href: https://www.irs.gov/instructions/i5329 diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/applicable_age.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/applicable_age.yaml new file mode 100644 index 00000000000..3e9301655a4 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/applicable_age.yaml @@ -0,0 +1,31 @@ +description: The IRS requires minimum distributions to begin in the year a person attains this age, by birth year. +brackets: + - threshold: + 1987-01-01: 0 + amount: + # Age 70 1/2 before 2020 and 72 from 2020; whole years approximate 70 1/2. + 1987-01-01: 70 + 2020-01-01: 72 + - threshold: + 1987-01-01: 1951 + amount: + 1987-01-01: 70 + 2020-01-01: 72 + 2023-01-01: 73 + - threshold: + 1987-01-01: 1960 + amount: + 1987-01-01: 70 + 2020-01-01: 72 + 2023-01-01: 75 +metadata: + type: single_amount + threshold_unit: year + amount_unit: year + period: year + label: Required minimum distribution applicable age by birth year + reference: + - title: 26 U.S. Code § 401(a)(9)(C)(v) + href: https://www.law.cornell.edu/uscode/text/26/401#a_9_C_v + - title: Proposed Treas. Reg. § 1.401(a)(9)-2(b)(2)(v) (2024), birth year 1959 uses age 73 + href: https://www.federalregister.gov/documents/2024/07/19/2024-14542/required-minimum-distributions diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/corrected_excise_rate.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/corrected_excise_rate.yaml new file mode 100644 index 00000000000..4f1257c63bb --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/corrected_excise_rate.yaml @@ -0,0 +1,11 @@ +description: The IRS imposes this reduced excise tax rate on a missed required minimum distribution corrected within the correction window. +values: + 1987-01-01: 0.5 + 2023-01-01: 0.1 +metadata: + unit: /1 + period: year + label: Corrected missed required minimum distribution excise tax rate + reference: + - title: 26 U.S. Code § 4974(e) + href: https://www.law.cornell.edu/uscode/text/26/4974#e diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/excise_rate.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/excise_rate.yaml new file mode 100644 index 00000000000..377c623c200 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/excise_rate.yaml @@ -0,0 +1,13 @@ +description: The IRS imposes this excise tax rate on the amount by which required minimum distributions exceed distributions received. +values: + 1987-01-01: 0.5 + 2023-01-01: 0.25 +metadata: + unit: /1 + period: year + label: Missed required minimum distribution excise tax rate + reference: + - title: 26 U.S. Code § 4974(a) + href: https://www.law.cornell.edu/uscode/text/26/4974 + - title: 2025 Instructions for Form 5329, Part IX + href: https://www.irs.gov/instructions/i5329 diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/qlac_premium_limit.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/qlac_premium_limit.yaml new file mode 100644 index 00000000000..0a542b1e157 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/qlac_premium_limit.yaml @@ -0,0 +1,16 @@ +description: The IRS excludes a qualifying longevity annuity contract from the required minimum distribution balance only if premiums do not exceed this amount. +values: + 1987-01-01: 0 + 2023-01-01: 200_000 + 2024-01-01: 200_000 + 2025-01-01: 210_000 + 2026-01-01: 210_000 +metadata: + unit: currency-USD + period: year + label: Qualifying longevity annuity contract premium limit + reference: + - title: 26 CFR 1.401(a)(9)-6, A-17(b)(2)(i); SECURE 2.0 Act § 202 + href: https://www.law.cornell.edu/cfr/text/26/1.401(a)(9)-6 + - title: IRS Notice 2025-67 + href: https://www.irs.gov/pub/irs-drop/n-25-67.pdf diff --git a/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/uniform_lifetime_table.yaml b/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/uniform_lifetime_table.yaml new file mode 100644 index 00000000000..895bef592b6 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/retirement_distributions/required_minimum_distributions/uniform_lifetime_table.yaml @@ -0,0 +1,209 @@ +description: The IRS divides the prior year-end account balance by this distribution period, by age at the end of the distribution year, to compute a required minimum distribution. +brackets: + - threshold: + 1987-01-01: 0 + amount: + 1987-01-01: 27.4 + - threshold: + 1987-01-01: 73 + amount: + 1987-01-01: 26.5 + - threshold: + 1987-01-01: 74 + amount: + 1987-01-01: 25.5 + - threshold: + 1987-01-01: 75 + amount: + 1987-01-01: 24.6 + - threshold: + 1987-01-01: 76 + amount: + 1987-01-01: 23.7 + - threshold: + 1987-01-01: 77 + amount: + 1987-01-01: 22.9 + - threshold: + 1987-01-01: 78 + amount: + 1987-01-01: 22.0 + - threshold: + 1987-01-01: 79 + amount: + 1987-01-01: 21.1 + - threshold: + 1987-01-01: 80 + amount: + 1987-01-01: 20.2 + - threshold: + 1987-01-01: 81 + amount: + 1987-01-01: 19.4 + - threshold: + 1987-01-01: 82 + amount: + 1987-01-01: 18.5 + - threshold: + 1987-01-01: 83 + amount: + 1987-01-01: 17.7 + - threshold: + 1987-01-01: 84 + amount: + 1987-01-01: 16.8 + - threshold: + 1987-01-01: 85 + amount: + 1987-01-01: 16.0 + - threshold: + 1987-01-01: 86 + amount: + 1987-01-01: 15.2 + - threshold: + 1987-01-01: 87 + amount: + 1987-01-01: 14.4 + - threshold: + 1987-01-01: 88 + amount: + 1987-01-01: 13.7 + - threshold: + 1987-01-01: 89 + amount: + 1987-01-01: 12.9 + - threshold: + 1987-01-01: 90 + amount: + 1987-01-01: 12.2 + - threshold: + 1987-01-01: 91 + amount: + 1987-01-01: 11.5 + - threshold: + 1987-01-01: 92 + amount: + 1987-01-01: 10.8 + - threshold: + 1987-01-01: 93 + amount: + 1987-01-01: 10.1 + - threshold: + 1987-01-01: 94 + amount: + 1987-01-01: 9.5 + - threshold: + 1987-01-01: 95 + amount: + 1987-01-01: 8.9 + - threshold: + 1987-01-01: 96 + amount: + 1987-01-01: 8.4 + - threshold: + 1987-01-01: 97 + amount: + 1987-01-01: 7.8 + - threshold: + 1987-01-01: 98 + amount: + 1987-01-01: 7.3 + - threshold: + 1987-01-01: 99 + amount: + 1987-01-01: 6.8 + - threshold: + 1987-01-01: 100 + amount: + 1987-01-01: 6.4 + - threshold: + 1987-01-01: 101 + amount: + 1987-01-01: 6.0 + - threshold: + 1987-01-01: 102 + amount: + 1987-01-01: 5.6 + - threshold: + 1987-01-01: 103 + amount: + 1987-01-01: 5.2 + - threshold: + 1987-01-01: 104 + amount: + 1987-01-01: 4.9 + - threshold: + 1987-01-01: 105 + amount: + 1987-01-01: 4.6 + - threshold: + 1987-01-01: 106 + amount: + 1987-01-01: 4.3 + - threshold: + 1987-01-01: 107 + amount: + 1987-01-01: 4.1 + - threshold: + 1987-01-01: 108 + amount: + 1987-01-01: 3.9 + - threshold: + 1987-01-01: 109 + amount: + 1987-01-01: 3.7 + - threshold: + 1987-01-01: 110 + amount: + 1987-01-01: 3.5 + - threshold: + 1987-01-01: 111 + amount: + 1987-01-01: 3.4 + - threshold: + 1987-01-01: 112 + amount: + 1987-01-01: 3.3 + - threshold: + 1987-01-01: 113 + amount: + 1987-01-01: 3.1 + - threshold: + 1987-01-01: 114 + amount: + 1987-01-01: 3.0 + - threshold: + 1987-01-01: 115 + amount: + 1987-01-01: 2.9 + - threshold: + 1987-01-01: 116 + amount: + 1987-01-01: 2.8 + - threshold: + 1987-01-01: 117 + amount: + 1987-01-01: 2.7 + - threshold: + 1987-01-01: 118 + amount: + 1987-01-01: 2.5 + - threshold: + 1987-01-01: 119 + amount: + 1987-01-01: 2.3 + - threshold: + 1987-01-01: 120 + amount: + 1987-01-01: 2.0 +metadata: + type: single_amount + threshold_unit: year + amount_unit: /1 + period: year + label: Uniform Lifetime Table distribution period + reference: + - title: 26 CFR 1.401(a)(9)-9(c), Uniform Lifetime Table + href: https://www.ecfr.gov/current/title-26/chapter-I/subchapter-A/part-1/subject-group-ECFR6f4e0c3f8a8b8e1/section-1.401(a)(9)-9 + - title: IRS Publication 590-B, Appendix B, Table III + href: https://www.irs.gov/publications/p590b diff --git a/policyengine_us/parameters/gov/irs/savings_bond_education_exclusion/available_married_filing_separately.yaml b/policyengine_us/parameters/gov/irs/savings_bond_education_exclusion/available_married_filing_separately.yaml new file mode 100644 index 00000000000..c78de82a758 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/savings_bond_education_exclusion/available_married_filing_separately.yaml @@ -0,0 +1,10 @@ +description: The IRS allows the savings bond education interest exclusion on a married filing separately return, if this is true. +values: + 1990-01-01: false +metadata: + unit: bool + period: year + label: Savings bond education exclusion available when filing separately + reference: + - title: 26 U.S. Code § 135(d)(2) + href: https://www.law.cornell.edu/uscode/text/26/135#d_2 diff --git a/policyengine_us/parameters/gov/irs/savings_bond_education_exclusion/phase_out/length.yaml b/policyengine_us/parameters/gov/irs/savings_bond_education_exclusion/phase_out/length.yaml new file mode 100644 index 00000000000..3bebaa57b1f --- /dev/null +++ b/policyengine_us/parameters/gov/irs/savings_bond_education_exclusion/phase_out/length.yaml @@ -0,0 +1,24 @@ +description: The IRS phases out the savings bond education interest exclusion over this range of modified adjusted gross income, by filing status. +JOINT: + 1990-01-01: 30_000 +SINGLE: + 1990-01-01: 15_000 +HEAD_OF_HOUSEHOLD: + 1990-01-01: 15_000 +SURVIVING_SPOUSE: + 1990-01-01: 15_000 +SEPARATE: + 1990-01-01: 1 +metadata: + unit: currency-USD + period: year + breakdown: + - filing_status + label: Savings bond education exclusion phase-out range + reference: + - title: 26 U.S. Code § 135(b)(2) + href: https://www.law.cornell.edu/uscode/text/26/135 + - title: Rev. Proc. 2025-32 section 4.17 + href: "https://www.irs.gov/pub/irs-drop/rp-25-32.pdf#page=20" + - title: 2025 Form 8815, lines 10 and 12 + href: https://www.irs.gov/pub/irs-pdf/f8815.pdf diff --git a/policyengine_us/parameters/gov/irs/savings_bond_education_exclusion/phase_out/start.yaml b/policyengine_us/parameters/gov/irs/savings_bond_education_exclusion/phase_out/start.yaml new file mode 100644 index 00000000000..b9ab16a7836 --- /dev/null +++ b/policyengine_us/parameters/gov/irs/savings_bond_education_exclusion/phase_out/start.yaml @@ -0,0 +1,37 @@ +description: The IRS begins to phase out the savings bond education interest exclusion when modified adjusted gross income exceeds this amount, by filing status. +# Values before 2023 are not entered; earlier years use the 2023 amounts. +JOINT: + 1990-01-01: 137_800 + 2024-01-01: 145_200 + 2025-01-01: 149_250 + 2026-01-01: 152_650 +SINGLE: + 1990-01-01: 91_850 + 2024-01-01: 96_800 + 2025-01-01: 99_500 + 2026-01-01: 101_800 +HEAD_OF_HOUSEHOLD: + 1990-01-01: 91_850 + 2024-01-01: 96_800 + 2025-01-01: 99_500 + 2026-01-01: 101_800 +SURVIVING_SPOUSE: + 1990-01-01: 91_850 + 2024-01-01: 96_800 + 2025-01-01: 99_500 + 2026-01-01: 101_800 +SEPARATE: + 1990-01-01: 0 +metadata: + unit: currency-USD + period: year + breakdown: + - filing_status + label: Savings bond education exclusion phase-out start + reference: + - title: 26 U.S. Code § 135(b)(2) + href: https://www.law.cornell.edu/uscode/text/26/135 + - title: Rev. Proc. 2025-32 section 4.17 + href: "https://www.irs.gov/pub/irs-drop/rp-25-32.pdf#page=20" + - title: 2025 Form 8815, lines 10 and 12 + href: https://www.irs.gov/pub/irs-pdf/f8815.pdf diff --git a/policyengine_us/parameters/gov/states/ca/tax/income/agi/subtractions.yaml b/policyengine_us/parameters/gov/states/ca/tax/income/agi/subtractions.yaml index 13260aaa4b0..59c62ffcd7b 100644 --- a/policyengine_us/parameters/gov/states/ca/tax/income/agi/subtractions.yaml +++ b/policyengine_us/parameters/gov/states/ca/tax/income/agi/subtractions.yaml @@ -4,12 +4,14 @@ values: - taxable_social_security - taxable_unemployment_compensation - us_govt_interest + - ca_us_govt_fund_dividend_subtraction - salt_refund_income - ca_other_subtractions 2025-01-01: - taxable_social_security - taxable_unemployment_compensation - us_govt_interest + - ca_us_govt_fund_dividend_subtraction - salt_refund_income - ca_military_retirement_exclusion - ca_other_subtractions diff --git a/policyengine_us/parameters/gov/states/ca/tax/income/agi/us_govt_fund_dividends/asset_threshold.yaml b/policyengine_us/parameters/gov/states/ca/tax/income/agi/us_govt_fund_dividends/asset_threshold.yaml new file mode 100644 index 00000000000..dbaa25ef8df --- /dev/null +++ b/policyengine_us/parameters/gov/states/ca/tax/income/agi/us_govt_fund_dividends/asset_threshold.yaml @@ -0,0 +1,13 @@ +description: California treats a regulated investment company's dividends attributable to U.S. government obligations as exempt only if this share of the value of its total assets consists of obligations exempt from California tax at the close of each quarter of its taxable year. +values: + 1987-01-01: 0.5 + +metadata: + unit: /1 + period: year + label: California U.S. government obligation fund asset test threshold + reference: + - title: Cal. Rev. & Tax. Code § 17145(a) + href: https://law.justia.com/codes/california/code-rtc/division-2/part-10/chapter-3/article-3/section-17145/ + - title: 2025 California Schedule CA (540) instructions, Part I, Section A, line 2 + href: https://www.ftb.ca.gov/forms/2025/2025-540-ca-instructions.html diff --git a/policyengine_us/parameters/gov/states/ca/tax/income/agi/us_govt_fund_dividends/qualified_fund_of_funds_exempt.yaml b/policyengine_us/parameters/gov/states/ca/tax/income/agi/us_govt_fund_dividends/qualified_fund_of_funds_exempt.yaml new file mode 100644 index 00000000000..26a571a8ed2 --- /dev/null +++ b/policyengine_us/parameters/gov/states/ca/tax/income/agi/us_govt_fund_dividends/qualified_fund_of_funds_exempt.yaml @@ -0,0 +1,13 @@ +description: California lets a qualified fund of funds pay exempt-interest dividends without meeting the quarterly asset test, if this is true. +values: + 1987-01-01: false + # Applies to taxable years beginning on or after December 23, 2010. + 2011-01-01: true + +metadata: + unit: bool + period: year + label: California qualified fund of funds exempt from U.S. government obligation asset test + reference: + - title: Cal. Rev. & Tax. Code § 17145(d), (e) + href: https://law.justia.com/codes/california/code-rtc/division-2/part-10/chapter-3/article-3/section-17145/ diff --git a/policyengine_us/parameters/gov/states/ca/tax/income/early_distribution_tax/rate.yaml b/policyengine_us/parameters/gov/states/ca/tax/income/early_distribution_tax/rate.yaml new file mode 100644 index 00000000000..81674a935dc --- /dev/null +++ b/policyengine_us/parameters/gov/states/ca/tax/income/early_distribution_tax/rate.yaml @@ -0,0 +1,12 @@ +description: California imposes this additional tax rate on early distributions subject to the federal additional tax. +values: + 1987-01-01: 0.025 +metadata: + unit: /1 + period: year + label: California early distribution additional tax rate + reference: + - title: Cal. Rev. & Tax. Code § 17085(c) + href: https://law.justia.com/codes/california/code-rtc/division-2/part-10/chapter-3/article-2/section-17085/ + - title: 2025 Instructions for Form FTB 3805P + href: https://www.ftb.ca.gov/forms/2025/2025-3805p-instructions.html diff --git a/policyengine_us/parameters/gov/states/ca/tax/income/early_distribution_tax/simple_ira_rate.yaml b/policyengine_us/parameters/gov/states/ca/tax/income/early_distribution_tax/simple_ira_rate.yaml new file mode 100644 index 00000000000..0f07a834689 --- /dev/null +++ b/policyengine_us/parameters/gov/states/ca/tax/income/early_distribution_tax/simple_ira_rate.yaml @@ -0,0 +1,12 @@ +description: California imposes this additional tax rate on early SIMPLE IRA distributions in the first two years of participation. +values: + 1997-01-01: 0.06 +metadata: + unit: /1 + period: year + label: California SIMPLE IRA two-year early distribution additional tax rate + reference: + - title: Cal. Rev. & Tax. Code § 17085(c) + href: https://law.justia.com/codes/california/code-rtc/division-2/part-10/chapter-3/article-2/section-17085/ + - title: 2025 Instructions for Form FTB 3805P + href: https://www.ftb.ca.gov/forms/2025/2025-3805p-instructions.html diff --git a/policyengine_us/parameters/gov/states/ct/tax/income/subtractions/subtractions.yaml b/policyengine_us/parameters/gov/states/ct/tax/income/subtractions/subtractions.yaml index 2cb8935c118..217ab9eaf85 100644 --- a/policyengine_us/parameters/gov/states/ct/tax/income/subtractions/subtractions.yaml +++ b/policyengine_us/parameters/gov/states/ct/tax/income/subtractions/subtractions.yaml @@ -2,6 +2,7 @@ description: Connecticut subtracts these sources from the adjusted gross income. values: 2021-01-01: - us_govt_interest #ln 39 + - ct_us_govt_fund_dividend_subtraction #ln 40 - ct_social_security_benefit_adjustment #ln 41 - military_retirement_income #ln 44 diff --git a/policyengine_us/parameters/gov/states/ct/tax/income/subtractions/us_govt_fund_dividends/asset_threshold.yaml b/policyengine_us/parameters/gov/states/ct/tax/income/subtractions/us_govt_fund_dividends/asset_threshold.yaml new file mode 100644 index 00000000000..be515ad884b --- /dev/null +++ b/policyengine_us/parameters/gov/states/ct/tax/income/subtractions/us_govt_fund_dividends/asset_threshold.yaml @@ -0,0 +1,15 @@ +description: Connecticut subtracts a regulated investment company's exempt dividends only if this share of the value of its total assets consists of obligations that federal law bars states from taxing at the close of each quarter of its taxable year. +values: + 1991-01-01: 0.5 + +metadata: + unit: /1 + period: year + label: Connecticut U.S. government obligation fund asset test threshold + reference: + - title: Conn. Gen. Stat. § 12-718 + href: https://law.justia.com/codes/connecticut/title-12/chapter-229/section-12-718/ + - title: Conn. Agencies Regs. § 12-701(a)(20)-3(a)(2) + href: https://regulations.justia.com/states/connecticut/title-12/subtitle-740-a/part-i/section-12-701-a-20-3/ + - title: 2025 Form CT-1040 Instructions, line 40 + href: https://portal.ct.gov/-/media/drs/forms/2025/income/2025-ct-1040-instructions_1225.pdf#page=8 diff --git a/policyengine_us/parameters/gov/states/ny/tax/income/agi/subtractions/sources.yaml b/policyengine_us/parameters/gov/states/ny/tax/income/agi/subtractions/sources.yaml index 30ced102407..ea978667962 100644 --- a/policyengine_us/parameters/gov/states/ny/tax/income/agi/subtractions/sources.yaml +++ b/policyengine_us/parameters/gov/states/ny/tax/income/agi/subtractions/sources.yaml @@ -3,6 +3,8 @@ values: 2020-01-01: - taxable_social_security - us_govt_interest + # N.Y. Tax Law § 612(c)(1) / Form IT-201 line 28: qualifying fund dividends. + - ny_us_govt_fund_dividend_subtraction - investment_in_529_plan - ny_pension_exclusion # N.Y. Tax Law § 612(c)(3-b) / Form IT-221 (IT-225 S-124). diff --git a/policyengine_us/parameters/gov/states/ny/tax/income/agi/subtractions/us_govt_fund_dividends/asset_threshold.yaml b/policyengine_us/parameters/gov/states/ny/tax/income/agi/subtractions/us_govt_fund_dividends/asset_threshold.yaml new file mode 100644 index 00000000000..a65681488dc --- /dev/null +++ b/policyengine_us/parameters/gov/states/ny/tax/income/agi/subtractions/us_govt_fund_dividends/asset_threshold.yaml @@ -0,0 +1,15 @@ +description: New York subtracts a regulated investment company's dividends attributable to interest on U.S. obligations only if this share of the value of its total assets consists of U.S. obligations at the close of each quarter of its taxable year. +values: + 1987-04-01: 0.5 + +metadata: + unit: /1 + period: year + label: New York U.S. government obligation fund asset test threshold + reference: + - title: N.Y. Tax Law § 612(c)(1) + href: https://newyork.public.law/laws/n.y._tax_law_section_612 + - title: TSB-M-92(4)I, Taxation of Dividends Paid by Regulated Investment Companies + href: https://www.tax.ny.gov/pdf/memos/income/m92_4i.pdf + - title: 2025 Form IT-201-I, line 28 + href: https://www.tax.ny.gov/pdf/2025/inc/it201i_2025.pdf#page=9 diff --git a/policyengine_us/parameters/gov/treasury/savings_bonds/annual_purchase_limit.yaml b/policyengine_us/parameters/gov/treasury/savings_bonds/annual_purchase_limit.yaml new file mode 100644 index 00000000000..4c1cc760929 --- /dev/null +++ b/policyengine_us/parameters/gov/treasury/savings_bonds/annual_purchase_limit.yaml @@ -0,0 +1,13 @@ +description: The Treasury limits electronic purchases of each series of savings bonds (EE and I) to this amount per person per calendar year. Not a tax rule; for portfolio simulators. +values: + 2008-01-01: 5_000 + 2012-01-01: 10_000 +metadata: + unit: currency-USD + period: year + label: Savings bond annual electronic purchase limit per series + reference: + - title: 31 CFR 363.52 (Series EE) and 31 CFR 359 (Series I) + href: https://www.ecfr.gov/current/title-31/subtitle-B/chapter-II/subchapter-A/part-363 + - title: TreasuryDirect, Buying I bonds and EE bonds + href: https://www.treasurydirect.gov/savings-bonds/buy-a-bond/ diff --git a/policyengine_us/parameters/gov/treasury/savings_bonds/early_redemption_forfeited_months.yaml b/policyengine_us/parameters/gov/treasury/savings_bonds/early_redemption_forfeited_months.yaml new file mode 100644 index 00000000000..3495f1cffef --- /dev/null +++ b/policyengine_us/parameters/gov/treasury/savings_bonds/early_redemption_forfeited_months.yaml @@ -0,0 +1,12 @@ +description: Savings bonds redeemed before five years forfeit this many months of interest. Not a tax rule; the reduced interest is what is reported as income. +values: + 2003-02-01: 3 +metadata: + unit: month + period: year + label: Savings bond early redemption interest forfeiture + reference: + - title: 31 CFR 359.6 and 351.2 + href: https://www.ecfr.gov/current/title-31/subtitle-B/chapter-II/subchapter-A/part-359 + - title: TreasuryDirect, Cashing EE or I savings bonds + href: https://www.treasurydirect.gov/savings-bonds/cash-a-bond/ diff --git a/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_exclusion.yaml b/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_exclusion.yaml new file mode 100644 index 00000000000..6b07e50b95e --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_exclusion.yaml @@ -0,0 +1,181 @@ +# IRC 135 / Form 8815 savings bond interest exclusion (2026 phase-out). +- name: 'Single in the phase-out: 4,000 x 0.9 x (1 - 6,200/15,000)' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + employment_income: 104000 + taxable_interest_income: 4000 + tax_units: + tax_unit: + members: + - person1 + filing_status: SINGLE + savings_bond_education_qualified_expenses: 9000 + savings_bond_redemption_proceeds: 10000 + savings_bond_redemption_interest: 4000 + households: + household: + members: + - person1 + state_code: TX + output: + savings_bond_education_exclusion_magi: 108000 + savings_bond_education_exclusion: 2112 + us_bonds_for_higher_ed: 2112 + adjusted_gross_income: 105888 +- name: 'Single below the phase-out: full 3,600' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + employment_income: 60000 + taxable_interest_income: 4000 + tax_units: + tax_unit: + members: + - person1 + filing_status: SINGLE + savings_bond_education_qualified_expenses: 9000 + savings_bond_redemption_proceeds: 10000 + savings_bond_redemption_interest: 4000 + households: + household: + members: + - person1 + state_code: TX + output: + savings_bond_education_exclusion: 3600 +- name: 'Single above $116,800: none' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + employment_income: 120000 + taxable_interest_income: 4000 + tax_units: + tax_unit: + members: + - person1 + filing_status: SINGLE + savings_bond_education_qualified_expenses: 9000 + savings_bond_redemption_proceeds: 10000 + savings_bond_redemption_interest: 4000 + households: + household: + members: + - person1 + state_code: TX + output: + savings_bond_education_exclusion: 0 +- name: 'Joint at $150,000: full' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + employment_income: 146000 + taxable_interest_income: 4000 + person2: + age: 45 + is_tax_unit_spouse: true + tax_units: + tax_unit: + members: + - person1 + - person2 + filing_status: JOINT + savings_bond_education_qualified_expenses: 9000 + savings_bond_redemption_proceeds: 10000 + savings_bond_redemption_interest: 4000 + households: + household: + members: + - person1 + - person2 + state_code: TX + output: + savings_bond_education_exclusion: 3600 +- name: 'Married filing separately: none' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + employment_income: 60000 + taxable_interest_income: 4000 + tax_units: + tax_unit: + members: + - person1 + filing_status: SEPARATE + savings_bond_education_qualified_expenses: 9000 + savings_bond_redemption_proceeds: 10000 + savings_bond_redemption_interest: 4000 + households: + household: + members: + - person1 + state_code: TX + output: + savings_bond_education_exclusion: 0 +- name: 'Expenses exceed proceeds: all interest' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + employment_income: 60000 + taxable_interest_income: 4000 + tax_units: + tax_unit: + members: + - person1 + filing_status: SINGLE + savings_bond_education_qualified_expenses: 12000 + savings_bond_redemption_proceeds: 10000 + savings_bond_redemption_interest: 4000 + households: + household: + members: + - person1 + state_code: TX + output: + savings_bond_education_exclusion: 4000 +- name: Existing us_bonds_for_higher_ed input still used as given + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + employment_income: 60000 + us_bonds_for_higher_ed: 1000 + tax_units: + tax_unit: + members: + - person1 + filing_status: SINGLE + households: + household: + members: + - person1 + state_code: TX + output: + adjusted_gross_income: 59000 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_additional_tax.yaml b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_additional_tax.yaml new file mode 100644 index 00000000000..abc819113b0 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_additional_tax.yaml @@ -0,0 +1,228 @@ +# Form 5329 Part I: IRC 72(t) and 72(q) additional tax. +- name: '$20,000 early IRA distribution, no exception: 10%' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_ira_distributions: 20000 + early_distributions_from_retirement_plans: 20000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + early_distribution_additional_tax: 2000 + form_5329_additional_taxes: 2000 +- name: Emergency expense capped at $1,000, uncapped exception, and SIMPLE two-year 25% + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + early_distributions_from_retirement_plans: 20000 + early_distribution_emergency_personal_expense: 3000 + early_distribution_exceptions_uncapped: 2000 + early_distributions_from_simple_ira_first_two_years: 4000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + early_distribution_allowed_exceptions: 3000 + early_distribution_additional_tax: 2700 +- name: First-time homebuyer lifetime cap less prior use + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + early_distributions_from_retirement_plans: 15000 + early_distribution_first_time_homebuyer: 15000 + early_distribution_first_time_homebuyer_prior_use: 4000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + early_distribution_allowed_exceptions: 6000 + early_distribution_additional_tax: 900 +- name: Birth or adoption, $5,000 per child, two children + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + early_distributions_from_retirement_plans: 12000 + early_distribution_birth_or_adoption: 12000 + early_distribution_birth_or_adoption_children: 2 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + early_distribution_additional_tax: 200 +- name: Domestic abuse victim cap $10,500 in 2026 + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + early_distributions_from_retirement_plans: 12000 + early_distribution_domestic_abuse_victim: 12000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + early_distribution_allowed_exceptions: 10500 + early_distribution_additional_tax: 150 +- name: Qualified disaster, $22,000 per disaster + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + early_distributions_from_retirement_plans: 30000 + early_distribution_qualified_disaster: 30000 + early_distribution_qualified_disasters: 1 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + early_distribution_additional_tax: 800 +- name: Annuity contract premature distribution under 72(q) with exception + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + early_distributions_from_annuity_contracts: 8000 + early_distribution_exceptions_annuity: 3000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + early_distribution_additional_tax: 500 +- name: Dependent's early distribution stays off the filer's return + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + employment_income: 50000 + person2: + age: 19 + is_tax_unit_dependent: true + early_distributions_from_retirement_plans: 10000 + tax_units: + tax_unit: + members: + - person1 + - person2 + filing_status: HEAD_OF_HOUSEHOLD + households: + household: + members: + - person1 + - person2 + state_code: TX + output: + early_distribution_additional_tax: + - 0 + - 1000 + form_5329_additional_taxes: 0 +- name: Existing qualified_retirement_penalty input unchanged when detailed inputs are omitted + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + tax_units: + tax_unit: + members: + - person1 + qualified_retirement_penalty: 500 + households: + household: + members: + - person1 + state_code: TX + output: + form_5329_additional_taxes: 0 + income_tax_before_refundable_credits: 500 +- name: Additional tax adds to federal tax before refundable credits + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + early_distributions_from_retirement_plans: 20000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + income_tax_before_refundable_credits: 2000 diff --git a/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/retirement_additional_taxes/missed_rmd_excise_tax.yaml b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/retirement_additional_taxes/missed_rmd_excise_tax.yaml new file mode 100644 index 00000000000..a09c80b0234 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/irs/tax/federal_income/retirement_additional_taxes/missed_rmd_excise_tax.yaml @@ -0,0 +1,292 @@ +# IRC 401(a)(9) required minimum distributions and IRC 4974 excise (Form 5329 Part IX). +- name: 'Age 75 (born 1951): $246,000 / 24.6 = $10,000; $5,000 short at 25%' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 75 + is_tax_unit_head: true + rmd_ira_prior_year_end_balance: 246000 + rmd_ira_distributions_taken: 5000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + rmd_distribution_period: 24.6 + required_minimum_distribution: 10000 + missed_rmd_excise_tax: 1250 + form_5329_additional_taxes: 1250 +- name: 'Shortfall corrected timely: 10%' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 75 + is_tax_unit_head: true + rmd_ira_prior_year_end_balance: 246000 + rmd_ira_distributions_taken: 5000 + rmd_shortfall_corrected_timely: true + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + missed_rmd_excise_tax: 500 +- name: First distribution year at 73 deferred to April 1 + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 73 + is_tax_unit_head: true + rmd_ira_prior_year_end_balance: 300000 + rmd_first_year_deferred: true + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + required_minimum_distribution: 0 + missed_rmd_excise_tax: 0 +- name: 'Age 73 first year not deferred: 26.5' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 73 + is_tax_unit_head: true + rmd_ira_prior_year_end_balance: 265000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + required_minimum_distribution: 10000 + missed_rmd_excise_tax: 2500 +- name: Deferred prior-year amount plus current year both due + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 74 + is_tax_unit_head: true + rmd_ira_prior_year_end_balance: 255000 + rmd_prior_year_deferred_amount: 8000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + rmd_distribution_period: 25.5 + required_minimum_distribution: 18000 + missed_rmd_excise_tax: 4500 +- name: 'Born 1960 (age 66): applicable age 75, nothing due' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 66 + is_tax_unit_head: true + rmd_ira_prior_year_end_balance: 500000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + required_minimum_distribution: 0 + missed_rmd_excise_tax: 0 +- name: QLAC within the $210,000 premium limit is excluded + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 75 + is_tax_unit_head: true + rmd_ira_prior_year_end_balance: 410000 + rmd_qlac_value_ira: 164000 + rmd_qlac_premiums_paid: 150000 + rmd_ira_distributions_taken: 10000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + required_minimum_distribution: 10000 + missed_rmd_excise_tax: 0 +- name: 'QLAC premiums above the limit: contract stays in the balance' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 75 + is_tax_unit_head: true + rmd_ira_prior_year_end_balance: 410000 + rmd_qlac_value_ira: 164000 + rmd_qlac_premiums_paid: 250000 + rmd_ira_distributions_taken: 10000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + required_minimum_distribution_ira: 16666.67 + missed_rmd_excise_tax: 1666.67 +- name: 'Still working: employer plan RMD deferred, IRA still due' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 75 + is_tax_unit_head: true + rmd_employer_plan_prior_year_end_balance: 246000 + rmd_employer_plan_still_working: true + rmd_ira_prior_year_end_balance: 24600 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + required_minimum_distribution_employer_plan: 0 + required_minimum_distribution: 1000 + missed_rmd_excise_tax: 250 +- name: IRA excess cannot cover an employer plan shortfall + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 75 + is_tax_unit_head: true + rmd_employer_plan_prior_year_end_balance: 246000 + rmd_ira_prior_year_end_balance: 246000 + rmd_ira_distributions_taken: 20000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + missed_rmd_excise_tax: 2500 +- name: Waiver for reasonable error + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 75 + is_tax_unit_head: true + rmd_ira_prior_year_end_balance: 246000 + rmd_excise_waiver_amount: 4000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + missed_rmd_excise_tax: 1500 +- name: Inherited account shortfall supplied by the simulator + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 50 + is_tax_unit_head: true + rmd_inherited_required_amount: 5000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + missed_rmd_excise_tax: 1250 +- name: 'Spouse more than 10 years younger: Joint Life table override' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 75 + is_tax_unit_head: true + rmd_ira_prior_year_end_balance: 270000 + rmd_distribution_period_override: 27.0 + rmd_ira_distributions_taken: 10000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + required_minimum_distribution: 10000 + missed_rmd_excise_tax: 0 diff --git a/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/ca_early_distribution_additional_tax.yaml b/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/ca_early_distribution_additional_tax.yaml new file mode 100644 index 00000000000..c77d57a44fa --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/ca_early_distribution_additional_tax.yaml @@ -0,0 +1,66 @@ +# FTB 3805P: 2.5% (6% SIMPLE two-year) additional tax. +- name: CA 2.5% and 6% on the federal subject amounts + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + early_distributions_from_retirement_plans: 20000 + early_distribution_emergency_personal_expense: 3000 + early_distribution_exceptions_uncapped: 2000 + early_distributions_from_simple_ira_first_two_years: 4000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: CA + output: + ca_early_distribution_additional_tax: 665 +- name: CA adds 2.5% on amounts California does not except + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + ca_early_distributions_not_excepted_in_california: 1000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: CA + output: + ca_early_distribution_additional_tax: 25 + early_distribution_additional_tax: 0 +- name: Federal-only tax outside CA + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + early_distributions_from_retirement_plans: 20000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: NV + output: + ca_early_distribution_additional_tax: 0 + early_distribution_additional_tax: 2000 diff --git a/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/ca_us_govt_fund_dividend_subtraction.yaml b/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/ca_us_govt_fund_dividend_subtraction.yaml new file mode 100644 index 00000000000..6c4ddba898c --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/ca_us_govt_fund_dividend_subtraction.yaml @@ -0,0 +1,485 @@ +# CA subtraction for regulated investment company dividends attributable to +# U.S. government obligations, applied fund by fund with the quarterly 50% asset test. + +- name: CA fund at exactly 50% at every quarter-end passes; $1,000 x 35% = $350 + # The test is at least 50% at the close of each quarter, so 50% passes. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 350 + ca_agi_subtractions: 350 + adjusted_gross_income: 1_000 + ca_agi: 650 + +- name: CA one quarter at 49.99% fails even though the annual average is above 50% + # Quarter-end shares 90%, 49.99%, 90%, 90% average 77.5%; every quarter must pass. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.9 + us_govt_fund_1_govt_asset_share_q2: 0.4999 + us_govt_fund_1_govt_asset_share_q3: 0.9 + us_govt_fund_1_govt_asset_share_q4: 0.9 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 0 + ca_agi_subtractions: 0 + ca_agi: 1_000 + +- name: CA same $1,000 x 35% fund fails when one quarter is below 50% + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.49 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 0 + ca_agi: 1_000 + +- name: CA an annual income share alone does not establish the asset test + # A 98% income share with no quarter-end asset data is missing data, which fails. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.98 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 0 + ca_agi_subtractions: 0 + ca_agi: 1_000 + +- name: CA three of four quarter-end shares supplied fails + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.8 + us_govt_fund_1_govt_asset_share_q2: 0.8 + us_govt_fund_1_govt_asset_share_q3: 0.8 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 0 + +- name: CA issuer statement that the fund met the quarterly test qualifies it + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_asset_test_evidence: ISSUER_CONFIRMED_MET + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 350 + ca_agi: 650 + +- name: CA issuer statement that the fund did not meet the test overrides quarterly shares + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 1 + us_govt_fund_1_govt_asset_share_q2: 1 + us_govt_fund_1_govt_asset_share_q3: 1 + us_govt_fund_1_govt_asset_share_q4: 1 + us_govt_fund_1_asset_test_evidence: ISSUER_CONFIRMED_NOT_MET + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 0 + ca_agi: 1_000 + +- name: CA two funds tested separately; only the passing fund is subtracted + # Fund 1: $1,000 x 35% = $350, passes. Fund 2: $2,000 x 80% fails in quarter 2. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 3_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + us_govt_fund_2_ordinary_dividends: 2_000 + us_govt_fund_2_govt_income_share: 0.8 + us_govt_fund_2_govt_asset_share_q1: 0.7 + us_govt_fund_2_govt_asset_share_q2: 0.45 + us_govt_fund_2_govt_asset_share_q3: 0.7 + us_govt_fund_2_govt_asset_share_q4: 0.7 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 350 + ca_agi_subtractions: 350 + adjusted_gross_income: 3_000 + ca_agi: 2_650 + +- name: CA qualified fund of funds without asset data + # Cal. Rev. & Tax. Code 17145(d) exempts a qualified fund of funds from the asset test; CT and NY do not. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_qualified_fund_of_funds: true + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 350 + +- name: CA direct Treasury interest alone is unchanged by the fund rule + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_interest_income: 500 + us_govt_interest_person: 500 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 0 + ca_agi_subtractions: 500 + ca_agi: 0 + +- name: CA direct Treasury interest and a passing fund are each subtracted once + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_interest_income: 500 + us_govt_interest_person: 500 + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 350 + ca_agi_subtractions: 850 + adjusted_gross_income: 1_500 + ca_agi: 650 + +- name: CA retirement account distribution gets no fund subtraction + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_ira_distributions: 1_000 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 0 + ca_agi_subtractions: 0 + ca_agi: 1_000 + +- name: CA fund slot filled for an IRA-held fund is capped at zero ordinary dividends + # Dividends earned inside an IRA are not ordinary dividend income, so the cap is $0. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_ira_distributions: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 1 + us_govt_fund_1_govt_asset_share_q1: 1 + us_govt_fund_1_govt_asset_share_q2: 1 + us_govt_fund_1_govt_asset_share_q3: 1 + us_govt_fund_1_govt_asset_share_q4: 1 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 0 + ca_agi_subtractions: 0 + ca_agi: 1_000 + +- name: CA subtraction capped at ordinary dividends in federal AGI + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 400 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 1 + us_govt_fund_1_govt_asset_share_q1: 1 + us_govt_fund_1_govt_asset_share_q2: 1 + us_govt_fund_1_govt_asset_share_q3: 1 + us_govt_fund_1_govt_asset_share_q4: 1 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 400 + ca_agi: 0 + +- name: CA existing caller without fund inputs keeps prior results + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + taxable_interest_income: 200 + us_govt_interest_person: 200 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: 0 + ca_agi_subtractions: 200 + ca_agi: 1_000 + +- name: CA joint filers each with a passing fund + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + person2: + age: 45 + is_tax_unit_spouse: true + non_qualified_dividend_income: 2_000 + us_govt_fund_1_ordinary_dividends: 2_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.6 + us_govt_fund_1_govt_asset_share_q2: 0.6 + us_govt_fund_1_govt_asset_share_q3: 0.6 + us_govt_fund_1_govt_asset_share_q4: 0.6 + tax_units: + tax_unit: + members: [person1, person2] + filing_status: JOINT + households: + household: + members: [person1, person2] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: [350, 700] + ca_agi_subtractions: 1_050 + ca_agi: 1_950 + +- name: CA dependent's fund dividends are not on the filer's return + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + employment_income: 50_000 + person2: + age: 15 + is_tax_unit_dependent: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1, person2] + filing_status: HEAD_OF_HOUSEHOLD + households: + household: + members: [person1, person2] + state_code: CA + output: + ca_us_govt_fund_dividend_subtraction: [0, 350] + ca_agi_subtractions: 0 + +- name: CA fund rule does not apply to a household in another state + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: MA + output: + ca_us_govt_fund_dividend_subtraction: 0 diff --git a/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/integration.yaml b/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/integration.yaml index a141c0e62d0..ebb19da1730 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/integration.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ca/tax/income/integration.yaml @@ -141,3 +141,65 @@ state_fips: 6 output: state_income_tax: 216_156 + +- name: CA 2026 single, $100,000 wages, passing U.S. government fund + # $1,000 fund dividends x 35% = $350 subtracted; the 9.3% bracket cuts tax by $350 x 9.3% = $32.55. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + employment_income: 100_000 + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + filing_status: SINGLE + households: + household: + members: [person1] + state_code: CA + output: + adjusted_gross_income: 101_000 + ca_us_govt_fund_dividend_subtraction: 350 + ca_agi: 100_650 + ca_taxable_income: 94_750 + ca_income_tax: 4_971.31 + +- name: CA 2026 single, $100,000 wages, fund fails one quarter + # Quarter 3 at 49.99% fails the test. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + employment_income: 100_000 + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.4999 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + filing_status: SINGLE + households: + household: + members: [person1] + state_code: CA + output: + adjusted_gross_income: 101_000 + ca_us_govt_fund_dividend_subtraction: 0 + ca_agi: 101_000 + ca_taxable_income: 95_100 + ca_income_tax: 5_003.86 diff --git a/policyengine_us/tests/policy/baseline/gov/states/ct/tax/income/integration.yaml b/policyengine_us/tests/policy/baseline/gov/states/ct/tax/income/integration.yaml index 7b53b9c598d..34f6ddc3443 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ct/tax/income/integration.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ct/tax/income/integration.yaml @@ -179,3 +179,66 @@ # ct_amt 0; non-refundable credits 0 (no property tax) -> before-refundable 2,070. # ct_income_tax = 2,070 - ct_refundable_credits 250 = 1,820. ct_income_tax: 1_820 + +- name: CT 2026 single, $100,000 wages, passing U.S. government fund + # Line 40 subtracts $350. Tax: 2% x 10,000 + 4.5% x 40,000 + 5.5% x 50,000 + 6% x 650 = 4,789, + # plus the 2% phase-out add-back of 9 x $25 = $225: $5,014. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + employment_income: 100_000 + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + filing_status: SINGLE + households: + household: + members: [person1] + state_code: CT + output: + adjusted_gross_income: 101_000 + ct_us_govt_fund_dividend_subtraction: 350 + ct_agi: 100_650 + ct_taxable_income: 100_650 + ct_income_tax: 5_014 + +- name: CT 2026 single, $100,000 wages, fund fails one quarter + # $350 more taxed at 6% adds $21. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + employment_income: 100_000 + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.4999 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + filing_status: SINGLE + households: + household: + members: [person1] + state_code: CT + output: + adjusted_gross_income: 101_000 + ct_us_govt_fund_dividend_subtraction: 0 + ct_agi: 101_000 + ct_taxable_income: 101_000 + ct_income_tax: 5_035 diff --git a/policyengine_us/tests/policy/baseline/gov/states/ct/tax/income/subtractions/ct_us_govt_fund_dividend_subtraction.yaml b/policyengine_us/tests/policy/baseline/gov/states/ct/tax/income/subtractions/ct_us_govt_fund_dividend_subtraction.yaml new file mode 100644 index 00000000000..ff1eb28c008 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/ct/tax/income/subtractions/ct_us_govt_fund_dividend_subtraction.yaml @@ -0,0 +1,489 @@ +# CT subtraction for regulated investment company dividends attributable to +# U.S. government obligations, applied fund by fund with the quarterly 50% asset test. + +- name: CT fund at exactly 50% at every quarter-end passes; $1,000 x 35% = $350 + # The test is at least 50% at the close of each quarter, so 50% passes. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 350 + ct_agi_subtractions: 350 + adjusted_gross_income: 1_000 + ct_agi: 650 + +- name: CT one quarter at 49.99% fails even though the annual average is above 50% + # Quarter-end shares 90%, 49.99%, 90%, 90% average 77.5%; every quarter must pass. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.9 + us_govt_fund_1_govt_asset_share_q2: 0.4999 + us_govt_fund_1_govt_asset_share_q3: 0.9 + us_govt_fund_1_govt_asset_share_q4: 0.9 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 0 + ct_agi_subtractions: 0 + ct_agi: 1_000 + +- name: CT same $1,000 x 35% fund fails when one quarter is below 50% + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.49 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 0 + ct_agi: 1_000 + +- name: CT an annual income share alone does not establish the asset test + # A 98% income share with no quarter-end asset data is missing data, which fails. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.98 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 0 + ct_agi_subtractions: 0 + ct_agi: 1_000 + +- name: CT three of four quarter-end shares supplied fails + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.8 + us_govt_fund_1_govt_asset_share_q2: 0.8 + us_govt_fund_1_govt_asset_share_q3: 0.8 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 0 + +- name: CT issuer statement that the fund met the quarterly test qualifies it + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_asset_test_evidence: ISSUER_CONFIRMED_MET + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 350 + ct_agi: 650 + +- name: CT issuer statement that the fund did not meet the test overrides quarterly shares + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 1 + us_govt_fund_1_govt_asset_share_q2: 1 + us_govt_fund_1_govt_asset_share_q3: 1 + us_govt_fund_1_govt_asset_share_q4: 1 + us_govt_fund_1_asset_test_evidence: ISSUER_CONFIRMED_NOT_MET + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 0 + ct_agi: 1_000 + +- name: CT two funds tested separately; only the passing fund is subtracted + # Fund 1: $1,000 x 35% = $350, passes. Fund 2: $2,000 x 80% fails in quarter 2. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 3_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + us_govt_fund_2_ordinary_dividends: 2_000 + us_govt_fund_2_govt_income_share: 0.8 + us_govt_fund_2_govt_asset_share_q1: 0.7 + us_govt_fund_2_govt_asset_share_q2: 0.45 + us_govt_fund_2_govt_asset_share_q3: 0.7 + us_govt_fund_2_govt_asset_share_q4: 0.7 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 350 + ct_agi_subtractions: 350 + adjusted_gross_income: 3_000 + ct_agi: 2_650 + +- name: CT qualified fund of funds without asset data + # Cal. Rev. & Tax. Code 17145(d) exempts a qualified fund of funds from the asset test; CT and NY do not. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_qualified_fund_of_funds: true + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 0 + +- name: CT direct Treasury interest alone is unchanged by the fund rule + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_interest_income: 500 + us_govt_interest_person: 500 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 0 + ct_agi_subtractions: 500 + ct_agi: 0 + +- name: CT direct Treasury interest and a passing fund are each subtracted once + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_interest_income: 500 + us_govt_interest_person: 500 + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 350 + ct_agi_subtractions: 850 + adjusted_gross_income: 1_500 + ct_agi: 650 + +- name: CT retirement account distribution gets no fund subtraction + # CT's existing pension and annuity subtraction (line 48b) covers the IRA distribution. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_ira_distributions: 1_000 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 0 + ct_pension_annuity_subtraction: 1_000 + ct_agi_subtractions: 1_000 + ct_agi: 0 + +- name: CT fund slot filled for an IRA-held fund is capped at zero ordinary dividends + # Dividends earned inside an IRA are not ordinary dividend income, so the cap is $0. + # CT's existing pension and annuity subtraction (line 48b) covers the IRA distribution. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_ira_distributions: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 1 + us_govt_fund_1_govt_asset_share_q1: 1 + us_govt_fund_1_govt_asset_share_q2: 1 + us_govt_fund_1_govt_asset_share_q3: 1 + us_govt_fund_1_govt_asset_share_q4: 1 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 0 + ct_pension_annuity_subtraction: 1_000 + ct_agi_subtractions: 1_000 + ct_agi: 0 + +- name: CT subtraction capped at ordinary dividends in federal AGI + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 400 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 1 + us_govt_fund_1_govt_asset_share_q1: 1 + us_govt_fund_1_govt_asset_share_q2: 1 + us_govt_fund_1_govt_asset_share_q3: 1 + us_govt_fund_1_govt_asset_share_q4: 1 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 400 + ct_agi: 0 + +- name: CT existing caller without fund inputs keeps prior results + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + taxable_interest_income: 200 + us_govt_interest_person: 200 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: 0 + ct_agi_subtractions: 200 + ct_agi: 1_000 + +- name: CT joint filers each with a passing fund + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + person2: + age: 45 + is_tax_unit_spouse: true + non_qualified_dividend_income: 2_000 + us_govt_fund_1_ordinary_dividends: 2_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.6 + us_govt_fund_1_govt_asset_share_q2: 0.6 + us_govt_fund_1_govt_asset_share_q3: 0.6 + us_govt_fund_1_govt_asset_share_q4: 0.6 + tax_units: + tax_unit: + members: [person1, person2] + filing_status: JOINT + households: + household: + members: [person1, person2] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: [350, 700] + ct_agi_subtractions: 1_050 + ct_agi: 1_950 + +- name: CT dependent's fund dividends are not on the filer's return + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + employment_income: 50_000 + person2: + age: 15 + is_tax_unit_dependent: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1, person2] + filing_status: HEAD_OF_HOUSEHOLD + households: + household: + members: [person1, person2] + state_code: CT + output: + ct_us_govt_fund_dividend_subtraction: [0, 350] + ct_agi_subtractions: 0 + +- name: CT fund rule does not apply to a household in another state + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: MA + output: + ct_us_govt_fund_dividend_subtraction: 0 diff --git a/policyengine_us/tests/policy/baseline/gov/states/ma/tax/income/integration_ma.yaml b/policyengine_us/tests/policy/baseline/gov/states/ma/tax/income/integration_ma.yaml index 1ed43d2f079..7e3943c664d 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ma/tax/income/integration_ma.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ma/tax/income/integration_ma.yaml @@ -405,3 +405,53 @@ ma_senior_circuit_breaker: 966.00 ma_refundable_credits: 180 + 966 ma_income_tax: 376.50 - 12.50 - 180 - 966 + +- name: MA 2026 single without U.S. government fund inputs + # Fund inputs drive only the CA, CT and NY subtractions, so MA results do not move. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + employment_income: 60_000 + non_qualified_dividend_income: 1_000 + tax_units: + tax_unit: + members: [person1] + filing_status: SINGLE + households: + household: + members: [person1] + state_code: MA + output: + ma_agi: 61_000 + ma_income_tax: 2_730 + +- name: MA 2026 single with U.S. government fund inputs is unchanged + # Fund inputs drive only the CA, CT and NY subtractions, so MA results do not move. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + employment_income: 60_000 + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + filing_status: SINGLE + households: + household: + members: [person1] + state_code: MA + output: + ma_agi: 61_000 + ma_income_tax: 2_730 diff --git a/policyengine_us/tests/policy/baseline/gov/states/ny/tax/income/adjusted_gross_income/ny_us_govt_fund_dividend_subtraction.yaml b/policyengine_us/tests/policy/baseline/gov/states/ny/tax/income/adjusted_gross_income/ny_us_govt_fund_dividend_subtraction.yaml new file mode 100644 index 00000000000..981bd2734a1 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/gov/states/ny/tax/income/adjusted_gross_income/ny_us_govt_fund_dividend_subtraction.yaml @@ -0,0 +1,485 @@ +# NY subtraction for regulated investment company dividends attributable to +# U.S. government obligations, applied fund by fund with the quarterly 50% asset test. + +- name: NY fund at exactly 50% at every quarter-end passes; $1,000 x 35% = $350 + # The test is at least 50% at the close of each quarter, so 50% passes. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 350 + ny_agi_subtractions: 350 + adjusted_gross_income: 1_000 + ny_agi: 650 + +- name: NY one quarter at 49.99% fails even though the annual average is above 50% + # Quarter-end shares 90%, 49.99%, 90%, 90% average 77.5%; every quarter must pass. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.9 + us_govt_fund_1_govt_asset_share_q2: 0.4999 + us_govt_fund_1_govt_asset_share_q3: 0.9 + us_govt_fund_1_govt_asset_share_q4: 0.9 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 0 + ny_agi_subtractions: 0 + ny_agi: 1_000 + +- name: NY same $1,000 x 35% fund fails when one quarter is below 50% + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.49 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 0 + ny_agi: 1_000 + +- name: NY an annual income share alone does not establish the asset test + # A 98% income share with no quarter-end asset data is missing data, which fails. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.98 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 0 + ny_agi_subtractions: 0 + ny_agi: 1_000 + +- name: NY three of four quarter-end shares supplied fails + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.8 + us_govt_fund_1_govt_asset_share_q2: 0.8 + us_govt_fund_1_govt_asset_share_q3: 0.8 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 0 + +- name: NY issuer statement that the fund met the quarterly test qualifies it + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_asset_test_evidence: ISSUER_CONFIRMED_MET + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 350 + ny_agi: 650 + +- name: NY issuer statement that the fund did not meet the test overrides quarterly shares + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 1 + us_govt_fund_1_govt_asset_share_q2: 1 + us_govt_fund_1_govt_asset_share_q3: 1 + us_govt_fund_1_govt_asset_share_q4: 1 + us_govt_fund_1_asset_test_evidence: ISSUER_CONFIRMED_NOT_MET + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 0 + ny_agi: 1_000 + +- name: NY two funds tested separately; only the passing fund is subtracted + # Fund 1: $1,000 x 35% = $350, passes. Fund 2: $2,000 x 80% fails in quarter 2. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 3_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + us_govt_fund_2_ordinary_dividends: 2_000 + us_govt_fund_2_govt_income_share: 0.8 + us_govt_fund_2_govt_asset_share_q1: 0.7 + us_govt_fund_2_govt_asset_share_q2: 0.45 + us_govt_fund_2_govt_asset_share_q3: 0.7 + us_govt_fund_2_govt_asset_share_q4: 0.7 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 350 + ny_agi_subtractions: 350 + adjusted_gross_income: 3_000 + ny_agi: 2_650 + +- name: NY qualified fund of funds without asset data + # Cal. Rev. & Tax. Code 17145(d) exempts a qualified fund of funds from the asset test; CT and NY do not. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_qualified_fund_of_funds: true + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 0 + +- name: NY direct Treasury interest alone is unchanged by the fund rule + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_interest_income: 500 + us_govt_interest_person: 500 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 0 + ny_agi_subtractions: 500 + ny_agi: 0 + +- name: NY direct Treasury interest and a passing fund are each subtracted once + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_interest_income: 500 + us_govt_interest_person: 500 + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 350 + ny_agi_subtractions: 850 + adjusted_gross_income: 1_500 + ny_agi: 650 + +- name: NY retirement account distribution gets no fund subtraction + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_ira_distributions: 1_000 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 0 + ny_agi_subtractions: 0 + ny_agi: 1_000 + +- name: NY fund slot filled for an IRA-held fund is capped at zero ordinary dividends + # Dividends earned inside an IRA are not ordinary dividend income, so the cap is $0. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + taxable_ira_distributions: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 1 + us_govt_fund_1_govt_asset_share_q1: 1 + us_govt_fund_1_govt_asset_share_q2: 1 + us_govt_fund_1_govt_asset_share_q3: 1 + us_govt_fund_1_govt_asset_share_q4: 1 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 0 + ny_agi_subtractions: 0 + ny_agi: 1_000 + +- name: NY subtraction capped at ordinary dividends in federal AGI + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 400 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 1 + us_govt_fund_1_govt_asset_share_q1: 1 + us_govt_fund_1_govt_asset_share_q2: 1 + us_govt_fund_1_govt_asset_share_q3: 1 + us_govt_fund_1_govt_asset_share_q4: 1 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 400 + ny_agi: 0 + +- name: NY existing caller without fund inputs keeps prior results + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + taxable_interest_income: 200 + us_govt_interest_person: 200 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: 0 + ny_agi_subtractions: 200 + ny_agi: 1_000 + +- name: NY joint filers each with a passing fund + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + person2: + age: 45 + is_tax_unit_spouse: true + non_qualified_dividend_income: 2_000 + us_govt_fund_1_ordinary_dividends: 2_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.6 + us_govt_fund_1_govt_asset_share_q2: 0.6 + us_govt_fund_1_govt_asset_share_q3: 0.6 + us_govt_fund_1_govt_asset_share_q4: 0.6 + tax_units: + tax_unit: + members: [person1, person2] + filing_status: JOINT + households: + household: + members: [person1, person2] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: [350, 700] + ny_agi_subtractions: 1_050 + ny_agi: 1_950 + +- name: NY dependent's fund dividends are not on the filer's return + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + employment_income: 50_000 + person2: + age: 15 + is_tax_unit_dependent: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1, person2] + filing_status: HEAD_OF_HOUSEHOLD + households: + household: + members: [person1, person2] + state_code: NY + output: + ny_us_govt_fund_dividend_subtraction: [0, 350] + ny_agi_subtractions: 0 + +- name: NY fund rule does not apply to a household in another state + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + households: + household: + members: [person1] + state_code: MA + output: + ny_us_govt_fund_dividend_subtraction: 0 diff --git a/policyengine_us/tests/policy/baseline/gov/states/ny/tax/income/integration.yaml b/policyengine_us/tests/policy/baseline/gov/states/ny/tax/income/integration.yaml index 23210643e02..1d9c7ed9d3c 100644 --- a/policyengine_us/tests/policy/baseline/gov/states/ny/tax/income/integration.yaml +++ b/policyengine_us/tests/policy/baseline/gov/states/ny/tax/income/integration.yaml @@ -404,3 +404,66 @@ ny_main_income_tax: 0 ny_supplemental_tax: 0 ny_income_tax_before_credits: 0 + +- name: NY 2026 single, $100,000 wages, passing U.S. government fund + # Line 28 subtracts $350; taxable income 100,650 - 8,000 standard deduction = 92,650. + # Tax Law 601(c)(1)(vii) rates 3.9/4.4/5.15/5.4/5.9%; the 5.9% bracket cuts tax by $20.65. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + employment_income: 100_000 + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.5 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + filing_status: SINGLE + households: + household: + members: [person1] + state_code: NY + output: + adjusted_gross_income: 101_000 + ny_us_govt_fund_dividend_subtraction: 350 + ny_agi: 100_650 + ny_taxable_income: 92_650 + ny_income_tax: 4_898.10 + +- name: NY 2026 single, $100,000 wages, fund fails one quarter + # Quarter 3 at 49.99% fails the test. + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + employment_income: 100_000 + non_qualified_dividend_income: 1_000 + us_govt_fund_1_ordinary_dividends: 1_000 + us_govt_fund_1_govt_income_share: 0.35 + us_govt_fund_1_govt_asset_share_q1: 0.5 + us_govt_fund_1_govt_asset_share_q2: 0.5 + us_govt_fund_1_govt_asset_share_q3: 0.4999 + us_govt_fund_1_govt_asset_share_q4: 0.5 + tax_units: + tax_unit: + members: [person1] + filing_status: SINGLE + households: + household: + members: [person1] + state_code: NY + output: + adjusted_gross_income: 101_000 + ny_us_govt_fund_dividend_subtraction: 0 + ny_agi: 101_000 + ny_taxable_income: 93_000 + ny_income_tax: 4_918.75 diff --git a/policyengine_us/tests/policy/baseline/household/income/person/annuities/simplified_method_taxable_annuity.yaml b/policyengine_us/tests/policy/baseline/household/income/person/annuities/simplified_method_taxable_annuity.yaml new file mode 100644 index 00000000000..ac4d932afb1 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/person/annuities/simplified_method_taxable_annuity.yaml @@ -0,0 +1,72 @@ +# IRC 72(d) Simplified Method. +- name: 'Single life at 65: 260 payments' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + qualified_annuity_gross_payments: 24000 + qualified_annuity_cost: 31000 + qualified_annuity_monthly_payments_this_year: 12 + qualified_annuity_starting_age: 65 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + simplified_method_taxable_annuity: 22569.23 +- name: 'Joint, combined ages 130: 310 payments' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + qualified_annuity_gross_payments: 24000 + qualified_annuity_cost: 31000 + qualified_annuity_monthly_payments_this_year: 12 + qualified_annuity_starting_age: 65 + qualified_annuity_combined_starting_age: 130 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + simplified_method_taxable_annuity: 22800 +- name: Cost nearly recovered + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + qualified_annuity_gross_payments: 24000 + qualified_annuity_cost: 31000 + qualified_annuity_monthly_payments_this_year: 12 + qualified_annuity_starting_age: 65 + qualified_annuity_cost_recovered: 30500 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + simplified_method_taxable_annuity: 23500 diff --git a/policyengine_us/tests/policy/baseline/household/income/person/annuities/taxable_annuity_contract_income.yaml b/policyengine_us/tests/policy/baseline/household/income/person/annuities/taxable_annuity_contract_income.yaml new file mode 100644 index 00000000000..3e96d4d133d --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/person/annuities/taxable_annuity_contract_income.yaml @@ -0,0 +1,166 @@ +# IRC 72(b), (e): exclusion ratio and withdrawals from annuity contracts. +- name: Exclusion ratio 100,000 / 200,000 + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + annuity_contract_1_annuity_payments: 12000 + annuity_contract_1_investment_in_contract: 100000 + annuity_contract_1_expected_return: 200000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + taxable_annuity_contract_income: 6000 +- name: Exclusion stops at the unrecovered investment + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + annuity_contract_1_annuity_payments: 12000 + annuity_contract_1_investment_in_contract: 100000 + annuity_contract_1_expected_return: 200000 + annuity_contract_1_investment_recovered: 97000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + taxable_annuity_contract_income: 9000 +- name: 'Starting date before 1987: exclusion continues' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + annuity_contract_1_annuity_payments: 12000 + annuity_contract_1_investment_in_contract: 100000 + annuity_contract_1_expected_return: 200000 + annuity_contract_1_investment_recovered: 120000 + annuity_contract_1_starting_date_before_1987: true + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + taxable_annuity_contract_income: 6000 +- name: Withdrawal taxed income first up to the gain + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + annuity_contract_2_withdrawals: 30000 + annuity_contract_2_cash_value: 150000 + annuity_contract_2_investment_in_contract: 130000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + taxable_annuity_contract_income: 20000 +- name: Pre-August 14, 1982 investment comes out first + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + annuity_contract_2_withdrawals: 30000 + annuity_contract_2_cash_value: 150000 + annuity_contract_2_investment_in_contract: 130000 + annuity_contract_2_pre_august_1982_investment: 25000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + taxable_annuity_contract_income: 5000 +- name: Partial annuitization splits the investment + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + annuity_contract_1_annuity_payments: 10000 + annuity_contract_1_investment_in_contract: 100000 + annuity_contract_1_expected_return: 100000 + annuity_contract_1_annuitized_share: 0.4 + annuity_contract_1_withdrawals: 20000 + annuity_contract_1_cash_value: 150000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + taxable_annuity_contract_income: 26000 +- name: Two contracts add; included in gross income + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + annuity_contract_1_annuity_payments: 12000 + annuity_contract_1_investment_in_contract: 100000 + annuity_contract_1_expected_return: 200000 + annuity_contract_2_withdrawals: 30000 + annuity_contract_2_cash_value: 150000 + annuity_contract_2_investment_in_contract: 130000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + taxable_annuity_contract_income: 26000 + adjusted_gross_income: 26000 diff --git a/policyengine_us/tests/policy/baseline/household/income/person/capital_gains/home_sale/home_sale_gain_exclusion.yaml b/policyengine_us/tests/policy/baseline/household/income/person/capital_gains/home_sale/home_sale_gain_exclusion.yaml new file mode 100644 index 00000000000..ececf6f21d6 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/person/capital_gains/home_sale/home_sale_gain_exclusion.yaml @@ -0,0 +1,185 @@ +# IRC 121 exclusion of gain on the sale of a main home. +- name: 'Single: $300,000 gain, $250,000 excluded, $50,000 long-term' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + home_sale_gain: 300000 + home_sale_ownership_months: 36 + home_sale_use_months: 36 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + home_sale_gain_exclusion: 250000 + home_sale_taxable_gain: 50000 + long_term_capital_gains: 50000 +- name: 'Married, spouse meets the use test: $500,000' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 50 + is_tax_unit_head: true + home_sale_gain: 300000 + home_sale_ownership_months: 36 + home_sale_use_months: 36 + home_sale_spouse_meets_use_test: true + person2: + age: 50 + is_tax_unit_spouse: true + tax_units: + tax_unit: + members: + - person1 + - person2 + filing_status: JOINT + households: + household: + members: + - person1 + - person2 + state_code: TX + output: + home_sale_gain_exclusion: + - 300000 + - 0 + home_sale_taxable_gain: + - 0 + - 0 +- name: 'Married, spouse fails the use test: $250,000' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 50 + is_tax_unit_head: true + home_sale_gain: 300000 + home_sale_ownership_months: 36 + home_sale_use_months: 36 + person2: + age: 50 + is_tax_unit_spouse: true + tax_units: + tax_unit: + members: + - person1 + - person2 + filing_status: JOINT + households: + household: + members: + - person1 + - person2 + state_code: TX + output: + home_sale_gain_exclusion: + - 250000 + - 0 +- name: Depreciation and nonqualified use are not excluded + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + home_sale_gain: 300000 + home_sale_ownership_months: 36 + home_sale_use_months: 36 + home_sale_depreciation_after_may_6_1997: 20000 + home_sale_nonqualified_use_share: 0.2 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + home_sale_gain_exclusion: 224000 + home_sale_taxable_gain: 76000 +- name: 'Reduced exclusion: 12 of 24 months' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + home_sale_gain: 300000 + home_sale_ownership_months: 13 + home_sale_use_months: 12 + home_sale_reduced_exclusion_qualifies: true + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + home_sale_gain_exclusion: 125000 + home_sale_taxable_gain: 175000 +- name: Prior exclusion within two years and no reduced exclusion + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + home_sale_gain: 300000 + home_sale_ownership_months: 36 + home_sale_use_months: 36 + home_sale_excluded_gain_within_two_years: true + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + home_sale_gain_exclusion: 0 +- name: 'Owned 10 months without a reduced exclusion: short-term' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + home_sale_gain: 40000 + home_sale_ownership_months: 10 + home_sale_use_months: 10 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + home_sale_gain_exclusion: 0 + home_sale_taxable_short_term_gain: 40000 + home_sale_taxable_gain: 0 diff --git a/policyengine_us/tests/policy/baseline/household/income/person/capital_gains/section_1256/section_1256_net_gain.yaml b/policyengine_us/tests/policy/baseline/household/income/person/capital_gains/section_1256/section_1256_net_gain.yaml new file mode 100644 index 00000000000..d9c6b06be35 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/person/capital_gains/section_1256/section_1256_net_gain.yaml @@ -0,0 +1,66 @@ +# IRC 1256 60/40 split. +- name: 'Gain: 60% long-term, 40% short-term' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + section_1256_net_gain: 10000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + section_1256_long_term_gain: 6000 + section_1256_short_term_gain: 4000 + long_term_capital_gains: 6000 + short_term_capital_gain_adjustments: 4000 +- name: Loss splits the same way + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + section_1256_net_gain: -5000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + section_1256_long_term_gain: -3000 + section_1256_short_term_gain: -2000 +- name: Adds to other long-term gains + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + section_1256_net_gain: 10000 + long_term_capital_gains_before_response: 1000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + long_term_capital_gains: 7000 diff --git a/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/bond_discount_and_premium.yaml b/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/bond_discount_and_premium.yaml new file mode 100644 index 00000000000..286531c597e --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/bond_discount_and_premium.yaml @@ -0,0 +1,160 @@ +# IRC 1272 OID, 1276 market discount, 171 premium. +- name: 'OID: 900 x (1.03^2 - 1) - 20 = 34.81' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + bond_lot_1_adjusted_issue_price_start: 900 + bond_lot_1_yield_per_accrual_period: 0.03 + bond_lot_1_accrual_periods_held: 2 + bond_lot_1_stated_redemption_price: 1000 + bond_lot_1_issue_price: 880 + bond_lot_1_complete_years_to_maturity_at_issue: 5 + bond_lot_1_qualified_stated_interest: 20 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + investment_lot_interest_adjustment: 34.81 +- name: De minimis OID is zero + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + bond_lot_1_adjusted_issue_price_start: 900 + bond_lot_1_yield_per_accrual_period: 0.03 + bond_lot_1_accrual_periods_held: 2 + bond_lot_1_stated_redemption_price: 1000 + bond_lot_1_issue_price: 995 + bond_lot_1_complete_years_to_maturity_at_issue: 5 + bond_lot_1_qualified_stated_interest: 20 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + investment_lot_interest_adjustment: 0 +- name: Acquisition premium fraction reduces OID + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + bond_lot_1_adjusted_issue_price_start: 900 + bond_lot_1_yield_per_accrual_period: 0.03 + bond_lot_1_accrual_periods_held: 2 + bond_lot_1_stated_redemption_price: 1000 + bond_lot_1_issue_price: 880 + bond_lot_1_complete_years_to_maturity_at_issue: 5 + bond_lot_1_qualified_stated_interest: 20 + bond_lot_1_acquisition_premium_fraction: 0.5 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + investment_lot_interest_adjustment: 17.4 +- name: 'Market discount at sale: accrued part of gain is interest' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + bond_lot_1_stated_redemption_price: 1000 + bond_lot_1_market_discount: 50 + bond_lot_1_complete_years_to_maturity_at_purchase: 2 + bond_lot_1_days_held: 365 + bond_lot_1_days_purchase_to_maturity: 730 + bond_lot_1_disposition_gain: 40 + bond_lot_1_disposition_long_term: false + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + investment_lot_interest_adjustment: 25 + investment_lot_short_term_gain: 15 +- name: Market discount below de minimis stays capital + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + bond_lot_1_stated_redemption_price: 1000 + bond_lot_1_market_discount: 4 + bond_lot_1_complete_years_to_maturity_at_purchase: 2 + bond_lot_1_days_held: 365 + bond_lot_1_days_purchase_to_maturity: 730 + bond_lot_1_disposition_gain: 40 + bond_lot_1_disposition_long_term: true + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + investment_lot_interest_adjustment: 0 + investment_lot_long_term_gain: 40 +- name: Current inclusion election and premium amortization + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + bond_lot_1_stated_redemption_price: 1000 + bond_lot_1_market_discount: 50 + bond_lot_1_complete_years_to_maturity_at_purchase: 2 + bond_lot_1_days_held: 365 + bond_lot_1_days_purchase_to_maturity: 730 + bond_lot_1_market_discount_included_currently: true + bond_lot_2_premium_amortization: 10 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + investment_lot_interest_adjustment: 15 diff --git a/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/qualified_dividend_holding_period.yaml b/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/qualified_dividend_holding_period.yaml new file mode 100644 index 00000000000..e8497b4c3b6 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/qualified_dividend_holding_period.yaml @@ -0,0 +1,69 @@ +# IRC 1(h)(11)(B)(iii) and Treas. Reg. 1.199A-3(c)(2)(ii) holding periods. +- name: 60 days fails, 61 days passes + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + dividend_lot_1_qualified_dividends_reported: 1000 + dividend_lot_1_days_held_in_window: 60 + dividend_lot_2_qualified_dividends_reported: 2000 + dividend_lot_2_days_held_in_window: 61 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + dividends_failing_qualified_holding_period: 1000 +- name: Long-period preferred needs more than 90 days + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + dividend_lot_1_qualified_dividends_reported: 1000 + dividend_lot_1_days_held_in_window: 75 + dividend_lot_1_preferred_long_period: true + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + dividends_failing_qualified_holding_period: 1000 +- name: Section 199A dividends need more than 45 days + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + dividend_lot_1_section_199a_dividends_reported: 500 + dividend_lot_1_days_held_in_199a_window: 45 + dividend_lot_2_section_199a_dividends_reported: 300 + dividend_lot_2_days_held_in_199a_window: 46 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + section_199a_dividends_failing_holding_period: 500 diff --git a/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/ric_six_month_loss.yaml b/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/ric_six_month_loss.yaml new file mode 100644 index 00000000000..db5b643e3ab --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/ric_six_month_loss.yaml @@ -0,0 +1,75 @@ +# IRC 852(b)(4) losses on RIC shares held six months or less. +- name: Exempt-interest dividends disallowed, then capital gain dividends long-term + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + fund_sale_1_loss: 800 + fund_sale_1_held_six_months_or_less: true + fund_sale_1_exempt_interest_dividends: 200 + fund_sale_1_capital_gain_dividends: 250 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + ric_loss_disallowed_exempt_interest: 200 + investment_lot_long_term_gain: -250 + investment_lot_short_term_gain: -350 +- name: 'Held more than six months: no adjustment' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + fund_sale_1_loss: 800 + fund_sale_1_held_six_months_or_less: false + fund_sale_1_exempt_interest_dividends: 200 + fund_sale_1_capital_gain_dividends: 250 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + ric_loss_disallowed_exempt_interest: 0 + investment_lot_short_term_gain: -800 + investment_lot_long_term_gain: 0 +- name: 'Daily-dividend fund: no exempt-interest disallowance' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + fund_sale_1_loss: 800 + fund_sale_1_held_six_months_or_less: true + fund_sale_1_exempt_interest_dividends: 200 + fund_sale_1_daily_dividend_fund: true + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + ric_loss_disallowed_exempt_interest: 0 + investment_lot_short_term_gain: -800 diff --git a/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/wash_sale.yaml b/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/wash_sale.yaml new file mode 100644 index 00000000000..26045a5f5c6 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/person/investment_lots/wash_sale.yaml @@ -0,0 +1,129 @@ +# IRC 1091 wash sales. +- name: 'Repurchase 30 days after: 60 of 100 shares disallowed' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + wash_sale_1_loss: 1000 + wash_sale_1_shares_sold: 100 + wash_sale_1_sale_day: 9000 + wash_sale_1_purchase_1_day: 9030 + wash_sale_1_purchase_1_shares: 60 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + wash_sale_disallowed_loss_deferred: 600 + investment_lot_short_term_gain: -400 +- name: Repurchase 31 days before is outside the window + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + wash_sale_1_loss: 1000 + wash_sale_1_shares_sold: 100 + wash_sale_1_sale_day: 9000 + wash_sale_1_purchase_1_day: 8969 + wash_sale_1_purchase_1_shares: 100 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + wash_sale_disallowed_loss_deferred: 0 + investment_lot_short_term_gain: -1000 +- name: 'Replacement in an IRA: disallowed permanently' + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + wash_sale_1_loss: 1000 + wash_sale_1_shares_sold: 100 + wash_sale_1_sale_day: 9000 + wash_sale_1_purchase_1_day: 8970 + wash_sale_1_purchase_1_shares: 40 + wash_sale_1_purchase_1_in_ira: true + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + wash_sale_disallowed_loss_permanent: 400 + wash_sale_disallowed_loss_deferred: 0 + investment_lot_short_term_gain: -600 +- name: Replacement shares beyond the shares sold are not counted twice + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + wash_sale_1_loss: 1000 + wash_sale_1_shares_sold: 100 + wash_sale_1_sale_day: 9000 + wash_sale_1_purchase_1_day: 9010 + wash_sale_1_purchase_1_shares: 80 + wash_sale_1_purchase_2_day: 9020 + wash_sale_1_purchase_2_shares: 80 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + wash_sale_disallowed_loss_deferred: 1000 + investment_lot_short_term_gain: 0 +- name: Allowed long-term loss flows to long-term gains + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + wash_sale_1_loss: 1000 + wash_sale_1_shares_sold: 100 + wash_sale_1_sale_day: 9000 + wash_sale_1_long_term: true + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + investment_lot_long_term_gain: -1000 + long_term_capital_gains: -1000 diff --git a/policyengine_us/tests/policy/baseline/household/income/person/long_term_care/taxable_long_term_care_per_diem_benefits.yaml b/policyengine_us/tests/policy/baseline/household/income/person/long_term_care/taxable_long_term_care_per_diem_benefits.yaml new file mode 100644 index 00000000000..510658a6fb7 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/person/long_term_care/taxable_long_term_care_per_diem_benefits.yaml @@ -0,0 +1,68 @@ +# IRC 7702B(d) per diem limit ($430 in 2026), Form 8853 Section C. +- name: Benefits above $430 x 365 + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + long_term_care_per_diem_benefits: 200000 + long_term_care_per_diem_days: 365 + long_term_care_qualified_costs: 120000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + taxable_long_term_care_per_diem_benefits: 43050 +- name: Actual costs above the per diem limit + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + long_term_care_per_diem_benefits: 200000 + long_term_care_per_diem_days: 365 + long_term_care_qualified_costs: 180000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + taxable_long_term_care_per_diem_benefits: 20000 +- name: Reimbursements reduce the exclusion + period: 2026 + absolute_error_margin: 0.01 + input: + people: + person1: + age: 45 + is_tax_unit_head: true + long_term_care_per_diem_benefits: 50000 + long_term_care_per_diem_days: 100 + long_term_care_cost_reimbursements: 10000 + tax_units: + tax_unit: + members: + - person1 + households: + household: + members: + - person1 + state_code: TX + output: + taxable_long_term_care_per_diem_benefits: 17000 + adjusted_gross_income: 17000 diff --git a/policyengine_us/tools/investment_lots.py b/policyengine_us/tools/investment_lots.py new file mode 100644 index 00000000000..d66ddcfc7f0 --- /dev/null +++ b/policyengine_us/tools/investment_lots.py @@ -0,0 +1,51 @@ +"""Fold lot-level results into PolicyEngine's aggregate income inputs. + +short_term_capital_gains, the dividend inputs and taxable_interest_income +are plain inputs (their datasets are uprated), so computed short-term, +dividend and interest results cannot flow into them by formula. This helper +runs one pass to compute those results from the lot-level inputs and returns +a situation with them applied, ready for the normal Simulation. Long-term +results already flow into long_term_capital_gains by formula and are left +alone. + +Usage: + from policyengine_us import Simulation + from policyengine_us.tools.investment_lots import apply_investment_lot_adjustments + sim = Simulation(situation=apply_investment_lot_adjustments(situation, 2026)) +""" + +import copy + +# Computed variable -> [(input it adjusts, sign)]. +ADJUSTMENTS = { + "short_term_capital_gain_adjustments": [("short_term_capital_gains", 1)], + "investment_lot_interest_adjustment": [("taxable_interest_income", 1)], + "dividends_failing_qualified_holding_period": [ + ("qualified_dividend_income", -1), + ("non_qualified_dividend_income", 1), + ], + "section_199a_dividends_failing_holding_period": [ + ("qualified_reit_and_ptp_income", -1), + ], +} + + +def apply_investment_lot_adjustments(situation: dict, year) -> dict: + from policyengine_us import Simulation + + year = str(year) + sim = Simulation(situation=situation) + people = list(situation["people"]) + adjusted = copy.deepcopy(situation) + for computed, targets in ADJUSTMENTS.items(): + values = sim.calculate(computed, int(year)) + for person_id, value in zip(people, values): + if value == 0: + continue + person = adjusted["people"][person_id] + for target, sign in targets: + current = person.get(target, {}).get(year, 0) + person.setdefault(target, {})[year] = float(current) + sign * float( + value + ) + return adjusted diff --git a/policyengine_us/tools/us_govt_obligation_funds.py b/policyengine_us/tools/us_govt_obligation_funds.py new file mode 100644 index 00000000000..6f0c73105fe --- /dev/null +++ b/policyengine_us/tools/us_govt_obligation_funds.py @@ -0,0 +1,124 @@ +"""Per-fund inputs for state subtractions of mutual fund dividends that are +attributable to interest on U.S. government obligations. + +PolicyEngine has no entity for a single holding, so each person carries a +fixed number of fund slots. Each slot describes one regulated investment +company (mutual fund, ETF or money market fund) held in a taxable account: + +- ``us_govt_fund__ordinary_dividends``: the fund's ordinary dividends for + the year (Form 1099-DIV box 1a, which excludes capital gain distributions). + These dividends must already be in the person's dividend inputs + (``qualified_dividend_income`` or ``non_qualified_dividend_income``). The + slot is a memo line that says which part of those dividends came from the + fund; it never adds income. +- ``us_govt_fund__govt_income_share``: the share of the fund's ordinary + dividends attributable to interest on U.S. government obligations, as the + fund reports it in its annual tax supplement. It sets the size of the + subtraction, never eligibility. +- ``us_govt_fund__govt_asset_share_q1`` to ``_q4``: the share of the + value of the fund's total assets (IRC 851(c)(4)) held in qualifying U.S. + government obligations at the close of each quarter of the fund's taxable + year. These set eligibility, never the size of the subtraction. +- ``us_govt_fund__asset_test_evidence``: which evidence establishes the + asset test (quarterly shares, or the issuer's own statement that the fund + met or did not meet it). +- ``us_govt_fund__qualified_fund_of_funds``: whether the fund is a + qualified fund of funds under IRC 852(g)(2), which California exempts from + its asset test. + +Missing data fails the asset test: every quarterly share defaults to 0, and a +fund qualifies only on four quarter-end shares at or above the threshold or +on the issuer's statement that it met the test. An income share alone, of +any size, never qualifies a fund. +""" + +import numpy as np +from policyengine_core.enums import Enum + +# The number of fund slots per person. Funds beyond this number need a +# second person or a larger constant; each slot is applied separately, so +# funds must never be merged into one slot. +US_GOVT_OBLIGATION_FUND_SLOTS = 10 + +US_GOVT_FUND_QUARTERS = (1, 2, 3, 4) + + +class USGovtFundAssetTestEvidence(Enum): + QUARTERLY_ASSET_SHARES = "Quarter-end asset shares supplied for each quarter" + ISSUER_CONFIRMED_MET = "Fund issuer states the fund met the quarterly test" + ISSUER_CONFIRMED_NOT_MET = ( + "Fund issuer states the fund did not meet the quarterly test" + ) + + +def us_govt_fund_variable(slot: int, field: str) -> str: + return f"us_govt_fund_{slot}_{field}" + + +def us_govt_fund_eligible_dividends( + person, + period, + asset_threshold, + qualified_fund_of_funds_exempt=False, +): + """Sum, over a person's fund slots, the ordinary dividends attributable + to U.S. government obligations from funds that pass a state's asset test. + + Each fund is tested on its own: a fund passes when the issuer states it + met the test, or when the quarterly-shares evidence is chosen and the + share at the close of every quarter is at least ``asset_threshold``. + When ``qualified_fund_of_funds_exempt`` is true, a qualified fund of + funds passes without the asset test. A passing fund contributes its + ordinary dividends times its income share; a failing fund contributes + nothing. + """ + evidence_values = USGovtFundAssetTestEvidence + total = 0 + for slot in range(1, US_GOVT_OBLIGATION_FUND_SLOTS + 1): + dividends = np.maximum( + person(us_govt_fund_variable(slot, "ordinary_dividends"), period), + 0, + ) + income_share = np.clip( + person(us_govt_fund_variable(slot, "govt_income_share"), period), + 0, + 1, + ) + evidence = person(us_govt_fund_variable(slot, "asset_test_evidence"), period) + meets_every_quarter = True + for quarter in US_GOVT_FUND_QUARTERS: + asset_share = person( + us_govt_fund_variable(slot, f"govt_asset_share_q{quarter}"), + period, + ) + meets_every_quarter = meets_every_quarter & (asset_share >= asset_threshold) + passes_on_quarterly_shares = ( + evidence == evidence_values.QUARTERLY_ASSET_SHARES + ) & meets_every_quarter + passes_on_issuer_statement = evidence == evidence_values.ISSUER_CONFIRMED_MET + passes = passes_on_quarterly_shares | passes_on_issuer_statement + if qualified_fund_of_funds_exempt: + passes = passes | person( + us_govt_fund_variable(slot, "qualified_fund_of_funds"), period + ) + total = total + passes * dividends * income_share + return total + + +def us_govt_fund_state_subtraction( + person, + period, + asset_threshold, + qualified_fund_of_funds_exempt=False, +): + """A person's state subtraction for fund dividends attributable to U.S. + government obligations, capped at the ordinary dividends included in + federal gross income. Dividends earned inside an IRA or other retirement + account are not in ordinary dividend income, so the cap keeps a misfiled + retirement-account fund from producing a subtraction. + """ + eligible = us_govt_fund_eligible_dividends( + person, period, asset_threshold, qualified_fund_of_funds_exempt + ) + ordinary_dividends = np.maximum(person("ordinary_dividend_income", period), 0) + return np.minimum(eligible, ordinary_dividends) diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_exclusion.py b/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_exclusion.py new file mode 100644 index 00000000000..31dd9122426 --- /dev/null +++ b/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_exclusion.py @@ -0,0 +1,40 @@ +from policyengine_us.model_api import * + + +class savings_bond_education_exclusion(Variable): + value_type = float + entity = TaxUnit + label = "Excludable savings bond interest used for higher education" + documentation = "Form 8815 lines 4-14: interest times qualified expenses over proceeds (at most 1), phased out by modified AGI; none on a separate return." + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/135", + "https://www.irs.gov/pub/irs-pdf/f8815.pdf", + ) + + def formula(tax_unit, period, parameters): + p = parameters(period).gov.irs.savings_bond_education_exclusion + expenses = max_( + 0, + tax_unit("savings_bond_education_qualified_expenses", period) + - tax_unit("savings_bond_education_nontaxable_benefits", period), + ) + proceeds = tax_unit("savings_bond_redemption_proceeds", period) + interest = max_(0, tax_unit("savings_bond_redemption_interest", period)) + ratio = np.clip( + np.divide( + expenses, proceeds, out=np.zeros_like(expenses), where=proceeds > 0 + ), + 0, + 1, + ) + tentative = interest * ratio + filing_status = tax_unit("filing_status", period) + start = p.phase_out.start[filing_status] + length = p.phase_out.length[filing_status] + magi = tax_unit("savings_bond_education_exclusion_magi", period) + reduction = np.clip((magi - start) / length, 0, 1) + separate = filing_status == filing_status.possible_values.SEPARATE + allowed = ~separate | p.available_married_filing_separately + return allowed * tentative * (1 - reduction) diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_exclusion_magi.py b/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_exclusion_magi.py new file mode 100644 index 00000000000..15dd1b37082 --- /dev/null +++ b/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_exclusion_magi.py @@ -0,0 +1,43 @@ +from policyengine_us.model_api import * + + +class savings_bond_education_exclusion_magi(Variable): + value_type = float + entity = TaxUnit + label = "Modified AGI for the savings bond education exclusion" + documentation = ( + "Form 8815 line 9 worksheet: gross income less above-the-line " + "deductions other than the exclusion itself and the student loan " + "interest deduction. Taxable Social Security benefits are left out " + "and unemployment compensation is counted in full, because both are " + "computed from an AGI that includes this exclusion; supply " + "savings_bond_education_exclusion_magi_override to use an exact " + "figure. Foreign and possession exclusions are not added back." + ) + unit = USD + definition_period = YEAR + reference = "https://www.irs.gov/pub/irs-pdf/f8815.pdf" + + def formula(tax_unit, period, parameters): + override = tax_unit("savings_bond_education_exclusion_magi_override", period) + p = parameters(period).gov.irs + sources = [ + s + for s in p.gross_income.sources + if s not in ("taxable_social_security", "taxable_unemployment_compensation") + ] + person = tax_unit.members + not_dependent = ~person("is_tax_unit_dependent", period) + gross = 0 + for source in sources + ["unemployment_compensation"]: + gross += not_dependent * max_(0, add(person, period, [source])) + excluded = {"us_bonds_for_higher_ed", "student_loan_interest_ald"} + deductions = [d for d in p.ald.deductions if d not in excluded] + alds = tax_unit_non_dep_add( + tax_unit, + period, + deductions, + include_dependents=p.ald.filer_amounts_recorded_on_dependents, + ) + magi = tax_unit.sum(gross) - alds + return where(override > 0, override, magi) diff --git a/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_inputs.py b/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_inputs.py new file mode 100644 index 00000000000..2b58fe73898 --- /dev/null +++ b/policyengine_us/variables/gov/irs/income/taxable_income/adjusted_gross_income/above_the_line_deductions/savings_bond_education/savings_bond_education_inputs.py @@ -0,0 +1,54 @@ +"""Form 8815 inputs. The interest must already be in taxable_interest_income +(Series EE and I bond interest, deferred or not, is reported when the +simulator recognizes it).""" + +from policyengine_us.model_api import * + +_REF = ( + "https://www.law.cornell.edu/uscode/text/26/135", + "https://www.irs.gov/pub/irs-pdf/f8815.pdf", +) + + +def _money(name, label, documentation): + globals()[name] = type( + name, + (Variable,), + dict( + value_type=float, + entity=TaxUnit, + definition_period=YEAR, + unit=USD, + label=label, + documentation=documentation, + reference=_REF, + __module__=__name__, + ), + ) + + +_money( + "savings_bond_education_qualified_expenses", + "Qualified higher education expenses for the savings bond exclusion", + "Tuition and fees for the filer, spouse or dependents (Form 8815 line 2); excludes room and board.", +) +_money( + "savings_bond_education_nontaxable_benefits", + "Nontaxable educational benefits for the savings bond exclusion", + "Scholarships, employer assistance, and expenses used for other education benefits (Form 8815 line 3).", +) +_money( + "savings_bond_redemption_proceeds", + "Proceeds of post-1989 Series EE and I bonds cashed this year", + "Principal and interest (Form 8815 line 5), for bonds issued after 1989 to an owner at least 24 years old at issue.", +) +_money( + "savings_bond_redemption_interest", + "Interest included in post-1989 Series EE and I bond proceeds", + "Interest part of the proceeds (Form 8815 line 6).", +) +_money( + "savings_bond_education_exclusion_magi_override", + "Modified AGI for the savings bond exclusion, if supplied", + "Exact Form 8815 line 9 modified AGI; 0 uses PolicyEngine's computation.", +) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/income_tax_before_refundable_credits.py b/policyengine_us/variables/gov/irs/tax/federal_income/income_tax_before_refundable_credits.py index b834251b858..6cf0135f23f 100644 --- a/policyengine_us/variables/gov/irs/tax/federal_income/income_tax_before_refundable_credits.py +++ b/policyengine_us/variables/gov/irs/tax/federal_income/income_tax_before_refundable_credits.py @@ -24,6 +24,7 @@ def formula(tax_unit, period, parameters): "recapture_of_investment_credit", "unreported_payroll_tax", "qualified_retirement_penalty", + "form_5329_additional_taxes", ], ) subtracted_components = add( diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/income_tax_chapter_1.py b/policyengine_us/variables/gov/irs/tax/federal_income/income_tax_chapter_1.py index 237030d0c45..28818c33683 100644 --- a/policyengine_us/variables/gov/irs/tax/federal_income/income_tax_chapter_1.py +++ b/policyengine_us/variables/gov/irs/tax/federal_income/income_tax_chapter_1.py @@ -35,6 +35,7 @@ def formula(tax_unit, period, parameters): "income_tax_before_credits", "recapture_of_investment_credit", "qualified_retirement_penalty", + "form_5329_additional_taxes", ], ) nonrefundable_credits = tax_unit( diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_additional_tax.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_additional_tax.py new file mode 100644 index 00000000000..33b2fbea525 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_additional_tax.py @@ -0,0 +1,30 @@ +from policyengine_us.model_api import * + + +class early_distribution_additional_tax(Variable): + value_type = float + entity = Person + label = "Additional tax on early distributions" + documentation = "Form 5329 Part I line 4: 10% (25% for SIMPLE IRA distributions in the first two years) of early distributions not excepted." + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/72#t", + "https://www.law.cornell.edu/uscode/text/26/72#q", + "https://www.irs.gov/instructions/i5329", + ) + + def formula(person, period, parameters): + p = parameters(period).gov.irs.retirement_distributions.early_distribution_tax + plans = max_( + 0, + person("early_distributions_from_retirement_plans", period) + - person("early_distribution_allowed_exceptions", period), + ) + annuities = max_( + 0, + person("early_distributions_from_annuity_contracts", period) + - max_(person("early_distribution_exceptions_annuity", period), 0), + ) + simple = person("early_distribution_simple_ira_tax_base", period) + return p.rate * plans + p.annuity_rate * annuities + p.simple_ira_rate * simple diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_additional_tax_base.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_additional_tax_base.py new file mode 100644 index 00000000000..e08b554f720 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_additional_tax_base.py @@ -0,0 +1,26 @@ +from policyengine_us.model_api import * + + +class early_distribution_additional_tax_base(Variable): + value_type = float + entity = Person + label = "Early distributions from plans, IRAs and annuities subject to the additional tax at the general rate" + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/72#t", + "https://www.law.cornell.edu/uscode/text/26/72#q", + ) + + def formula(person, period, parameters): + plans = max_( + 0, + person("early_distributions_from_retirement_plans", period) + - person("early_distribution_allowed_exceptions", period), + ) + annuities = max_( + 0, + person("early_distributions_from_annuity_contracts", period) + - max_(person("early_distribution_exceptions_annuity", period), 0), + ) + return plans + annuities diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_allowed_exceptions.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_allowed_exceptions.py new file mode 100644 index 00000000000..007465aaef1 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_allowed_exceptions.py @@ -0,0 +1,70 @@ +from policyengine_us.model_api import * + + +class early_distribution_allowed_exceptions(Variable): + value_type = float + entity = Person + label = "Early distributions from plans and IRAs excepted from the additional tax" + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/72#t_2", + "https://www.irs.gov/instructions/i5329", + ) + + def formula(person, period, parameters): + p = parameters( + period + ).gov.irs.retirement_distributions.early_distribution_tax.exception_caps + homebuyer = min_( + person("early_distribution_first_time_homebuyer", period), + max_( + 0, + p.first_time_homebuyer + - person("early_distribution_first_time_homebuyer_prior_use", period), + ), + ) + birth = min_( + person("early_distribution_birth_or_adoption", period), + p.birth_or_adoption + * person("early_distribution_birth_or_adoption_children", period), + ) + emergency = min_( + person("early_distribution_emergency_personal_expense", period), + p.emergency_personal_expense, + ) + abuse = min_( + person("early_distribution_domestic_abuse_victim", period), + p.domestic_abuse_victim, + ) + disaster = min_( + person("early_distribution_qualified_disaster", period), + p.qualified_disaster + * person("early_distribution_qualified_disasters", period), + ) + # The medical exception is limited to the tax unit's medical expenses + # above the AGI floor (the section 213 amount, itemized or not), + # shared among members in proportion to their claims. + medical_claim = max_(person("early_distribution_medical_expense", period), 0) + unit_claim = person.tax_unit.sum(medical_claim) + unit_cap = person.tax_unit("early_distribution_medical_expense_cap", period) + share = np.divide( + medical_claim, + unit_claim, + out=np.zeros_like(medical_claim), + where=unit_claim > 0, + ) + medical = min_(medical_claim, share * unit_cap) + excepted = ( + max_(person("early_distribution_exceptions_uncapped", period), 0) + + homebuyer + + birth + + emergency + + abuse + + disaster + + medical + ) + return min_( + excepted, + max_(person("early_distributions_from_retirement_plans", period), 0), + ) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_inputs.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_inputs.py new file mode 100644 index 00000000000..e01336a4cb7 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_inputs.py @@ -0,0 +1,147 @@ +"""Inputs for the additional tax on early distributions (Form 5329 Part I). + +Amounts are the taxable parts of distributions already reported in the +person's retirement income inputs (for example taxable_ira_distributions or +taxable_pension_income); they are memo lines and add no income. The +simulator decides which exception a distribution meets; PolicyEngine applies +the statutory dollar caps. +""" + +from policyengine_us.model_api import * + +_REF = ( + "https://www.law.cornell.edu/uscode/text/26/72#t", + "https://www.irs.gov/instructions/i5329", +) + + +def _money(name, label, documentation, reference=_REF): + globals()[name] = type( + name, + (Variable,), + dict( + value_type=float, + entity=Person, + definition_period=YEAR, + unit=USD, + label=label, + documentation=documentation, + reference=reference, + __module__=__name__, + ), + ) + + +def _count(name, label, documentation): + globals()[name] = type( + name, + (Variable,), + dict( + value_type=int, + entity=Person, + definition_period=YEAR, + label=label, + documentation=documentation, + reference=_REF, + __module__=__name__, + ), + ) + + +_money( + "early_distributions_from_retirement_plans", + "Early distributions from qualified plans and IRAs", + "Taxable distributions received before age 59 1/2 from qualified plans, " + "403(b) and governmental 457(b) plans and IRAs (Form 5329 line 1), " + "excluding SIMPLE IRA distributions in the first two years of " + "participation and rollovers.", +) +_money( + "early_distributions_from_simple_ira_first_two_years", + "Early SIMPLE IRA distributions in the first two years of participation", + "Taxable early distributions from a SIMPLE IRA received within two years " + "of first participation (IRC 72(t)(6)).", +) +_money( + "early_distributions_from_annuity_contracts", + "Premature distributions from annuity contracts", + "Taxable distributions received before age 59 1/2 from annuity contracts " + "outside qualified plans (IRC 72(q)).", + ("https://www.law.cornell.edu/uscode/text/26/72#q",), +) +_money( + "early_distribution_exceptions_uncapped", + "Early distributions excepted under uncapped exceptions", + "Part of early_distributions_from_retirement_plans that meets an " + "exception with no dollar cap: death, disability, terminal illness, " + "substantially equal periodic payments, separation from service in or " + "after the year of age 55 (plans only), QDRO, IRS levy, reservist, " + "health insurance while unemployed or higher education (IRAs only), " + "corrective distributions and similar.", +) +_money( + "early_distribution_exceptions_simple_ira", + "SIMPLE IRA two-year early distributions excepted", + "Part of early_distributions_from_simple_ira_first_two_years that meets " + "any IRC 72(t)(2) exception.", +) +_money( + "early_distribution_exceptions_annuity", + "Annuity premature distributions excepted", + "Part of early_distributions_from_annuity_contracts that meets an IRC " + "72(q)(2) exception: death, disability, substantially equal periodic " + "payments, immediate annuities, investment before August 14, 1982 and " + "similar.", + ("https://www.law.cornell.edu/uscode/text/26/72#q_2",), +) +_money( + "early_distribution_first_time_homebuyer", + "IRA early distributions for a first-time home purchase", + "IRA distributions used for qualified first-time homebuyer expenses (IRC " + "72(t)(2)(F)). Capped at the lifetime limit less prior use.", +) +_money( + "early_distribution_first_time_homebuyer_prior_use", + "First-time homebuyer exception used in earlier years", + "Amount of the lifetime first-time homebuyer exception claimed in prior years.", +) +_money( + "early_distribution_birth_or_adoption", + "Qualified birth or adoption distributions", + "Distributions within one year of a birth or adoption (IRC 72(t)(2)(H)).", +) +_count( + "early_distribution_birth_or_adoption_children", + "Children born or adopted for the birth or adoption exception", + "Number of children whose birth or adoption the distributions relate to; " + "each child carries its own cap.", +) +_money( + "early_distribution_emergency_personal_expense", + "Emergency personal expense distributions", + "Emergency personal expense distributions (IRC 72(t)(2)(I)); one per year, capped.", +) +_money( + "early_distribution_domestic_abuse_victim", + "Distributions to a domestic abuse victim", + "Eligible distributions to a domestic abuse victim (IRC 72(t)(2)(K)). " + "The simulator should also limit them to 50% of the vested balance.", +) +_money( + "early_distribution_qualified_disaster", + "Qualified disaster recovery distributions", + "Qualified disaster recovery distributions (IRC 72(t)(2)(M)).", +) +_count( + "early_distribution_qualified_disasters", + "Qualified disasters for the disaster exception", + "Number of federally declared disasters the distributions relate to; " + "each disaster carries its own cap.", +) +_money( + "early_distribution_medical_expense", + "Early distributions claimed under the medical expense exception", + "Early distributions claimed against unreimbursed medical expenses above " + "the AGI floor (IRC 72(t)(2)(B)). Capped at the tax unit's medical " + "expenses above the floor.", +) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_medical_expense_cap.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_medical_expense_cap.py new file mode 100644 index 00000000000..fe1a20f8cf2 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_medical_expense_cap.py @@ -0,0 +1,19 @@ +from policyengine_us.model_api import * + + +class early_distribution_medical_expense_cap(Variable): + value_type = float + entity = TaxUnit + label = "Medical expenses above the AGI floor for the early distribution exception" + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/72#t_2_B", + "https://www.irs.gov/instructions/i5329", + ) + + def formula(tax_unit, period, parameters): + # IRC 72(t)(2)(B) excepts distributions up to the amount allowable as + # a medical deduction under section 213, whether or not the filer + # itemizes: medical expenses above the AGI floor. + return tax_unit("medical_expense_deduction", period) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_simple_ira_tax_base.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_simple_ira_tax_base.py new file mode 100644 index 00000000000..f71b4b8b5ab --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/early_distribution_simple_ira_tax_base.py @@ -0,0 +1,17 @@ +from policyengine_us.model_api import * + + +class early_distribution_simple_ira_tax_base(Variable): + value_type = float + entity = Person + label = "Early SIMPLE IRA distributions subject to the two-year additional tax rate" + unit = USD + definition_period = YEAR + reference = "https://www.law.cornell.edu/uscode/text/26/72#t_6" + + def formula(person, period, parameters): + return max_( + 0, + person("early_distributions_from_simple_ira_first_two_years", period) + - max_(person("early_distribution_exceptions_simple_ira", period), 0), + ) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/form_5329_additional_taxes.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/form_5329_additional_taxes.py new file mode 100644 index 00000000000..c160f7eb138 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/form_5329_additional_taxes.py @@ -0,0 +1,27 @@ +from policyengine_us.model_api import * + + +class form_5329_additional_taxes(Variable): + value_type = float + entity = TaxUnit + label = "Additional taxes on qualified plans, IRAs and annuities computed from detailed inputs" + documentation = ( + "Early distribution tax (Form 5329 Part I) and excise tax on missed " + "required minimum distributions (Part IX), for the head and spouse. " + "Schedule 2 line 8. Computed from detailed inputs; callers that " + "supply qualified_retirement_penalty directly should leave these " + "inputs empty so the tax is not counted twice." + ) + unit = USD + definition_period = YEAR + reference = ( + "https://www.irs.gov/instructions/i5329", + "https://www.irs.gov/pub/irs-pdf/f1040s2.pdf", + ) + + def formula(tax_unit, period, parameters): + return tax_unit_non_dep_add( + tax_unit, + period, + ["early_distribution_additional_tax", "missed_rmd_excise_tax"], + ) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/missed_rmd_excise_tax.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/missed_rmd_excise_tax.py new file mode 100644 index 00000000000..6579d720cff --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/missed_rmd_excise_tax.py @@ -0,0 +1,48 @@ +from policyengine_us.model_api import * + + +class missed_rmd_excise_tax(Variable): + value_type = float + entity = Person + label = "Excise tax on missed required minimum distributions" + documentation = "Form 5329 Part IX: 25% (10% if corrected timely) of required distributions not taken, less any waiver. IRA and employer plan shortfalls are measured separately." + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/4974", + "https://www.irs.gov/instructions/i5329", + ) + + def formula(person, period, parameters): + p = parameters( + period + ).gov.irs.retirement_distributions.required_minimum_distributions + # The deferred prior-year amount is due from the IRA or plan it came + # from; it is measured with the IRA group here. + ira_due = person("required_minimum_distribution_ira", period) + max_( + 0, person("rmd_prior_year_deferred_amount", period) + ) + ira_shortfall = max_(0, ira_due - person("rmd_ira_distributions_taken", period)) + plan_shortfall = max_( + 0, + person("required_minimum_distribution_employer_plan", period) + - person("rmd_employer_plan_distributions_taken", period), + ) + inherited_shortfall = max_( + 0, + person("rmd_inherited_required_amount", period) + - person("rmd_inherited_distributions_taken", period), + ) + shortfall = max_( + 0, + ira_shortfall + + plan_shortfall + + inherited_shortfall + - max_(0, person("rmd_excise_waiver_amount", period)), + ) + rate = where( + person("rmd_shortfall_corrected_timely", period), + p.corrected_excise_rate, + p.excise_rate, + ) + return rate * shortfall diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution.py new file mode 100644 index 00000000000..993e4b41d3b --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution.py @@ -0,0 +1,23 @@ +from policyengine_us.model_api import * + + +class required_minimum_distribution(Variable): + value_type = float + entity = Person + label = "Required minimum distribution due this year" + documentation = "Owner required distributions from IRAs and employer plans due by the end of the year, plus a deferred first-year amount and inherited-account amounts." + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/401#a_9", + "https://www.law.cornell.edu/cfr/text/26/1.401(a)(9)-5", + "https://www.irs.gov/publications/p590b", + ) + + def formula(person, period, parameters): + return ( + person("required_minimum_distribution_ira", period) + + person("required_minimum_distribution_employer_plan", period) + + max_(0, person("rmd_prior_year_deferred_amount", period)) + + max_(0, person("rmd_inherited_required_amount", period)) + ) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution_employer_plan.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution_employer_plan.py new file mode 100644 index 00000000000..06aebbaed76 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution_employer_plan.py @@ -0,0 +1,32 @@ +from policyengine_us.model_api import * + + +class required_minimum_distribution_employer_plan(Variable): + value_type = float + entity = Person + label = "Required minimum distribution from the person's own employer plans" + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/401#a_9_C", + "https://www.law.cornell.edu/cfr/text/26/1.401(a)(9)-5", + ) + + def formula(person, period, parameters): + p = parameters( + period + ).gov.irs.retirement_distributions.required_minimum_distributions + qlac_ok = person("rmd_qlac_premiums_paid", period) <= p.qlac_premium_limit + balance = max_( + 0, + person("rmd_employer_plan_prior_year_end_balance", period) + - qlac_ok * max_(0, person("rmd_qlac_value_employer_plan", period)), + ) + distribution_period = person("rmd_distribution_period", period) + amount = np.divide( + balance, + distribution_period, + out=np.zeros_like(balance), + where=distribution_period > 0, + ) + return where(person("rmd_employer_plan_still_working", period), 0, amount) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution_inputs.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution_inputs.py new file mode 100644 index 00000000000..7b67885b3b2 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution_inputs.py @@ -0,0 +1,141 @@ +"""Inputs for required minimum distributions and the excise tax on missed +distributions (IRC 401(a)(9), 408(a)(6), 4974; Form 5329 Part IX).""" + +from policyengine_us.model_api import * + +_REF = ( + "https://www.law.cornell.edu/uscode/text/26/401#a_9", + "https://www.law.cornell.edu/uscode/text/26/4974", + "https://www.irs.gov/publications/p590b", +) + + +def _input(name, value_type, label, documentation, unit=None): + attributes = dict( + value_type=value_type, + entity=Person, + definition_period=YEAR, + label=label, + documentation=documentation, + reference=_REF, + __module__=__name__, + ) + if unit: + attributes["unit"] = unit + globals()[name] = type(name, (Variable,), attributes) + + +_input( + "rmd_ira_prior_year_end_balance", + float, + "Traditional, SEP and SIMPLE IRA balance at the end of the prior year", + "Aggregate December 31 balance of the person's own traditional, SEP and " + "SIMPLE IRAs (not Roth or inherited IRAs). IRAs may be aggregated.", + USD, +) +_input( + "rmd_ira_distributions_taken", + float, + "IRA distributions counted toward the IRA required minimum distribution", + "Distributions from the person's own traditional, SEP and SIMPLE IRAs in " + "the year, excluding rollovers and corrective distributions.", + USD, +) +_input( + "rmd_employer_plan_prior_year_end_balance", + float, + "Employer plan balance at the end of the prior year", + "December 31 balance of the person's own 401(a), 401(k), 403(b) and " + "governmental 457(b) accounts. Use one plan, or plans whose required " + "distributions may be aggregated (403(b)s); plans that cannot be " + "aggregated need their shortfalls computed separately.", + USD, +) +_input( + "rmd_employer_plan_distributions_taken", + float, + "Employer plan distributions counted toward the plan required minimum distribution", + "Distributions from the employer plans in rmd_employer_plan_prior_year_end_balance.", + USD, +) +_input( + "rmd_employer_plan_still_working", + bool, + "Still working for the plan sponsor (and not a 5% owner)", + "Defers employer plan required distributions until retirement (IRC 401(a)(9)(C)(i)(II)).", +) +_input( + "rmd_qlac_value_ira", + float, + "Value of qualifying longevity annuity contracts held in IRAs", + "December 31 value of QLACs included in the IRA balance; excluded from " + "the required distribution base if premiums are within the limit.", + USD, +) +_input( + "rmd_qlac_value_employer_plan", + float, + "Value of qualifying longevity annuity contracts held in employer plans", + "December 31 value of QLACs included in the employer plan balance.", + USD, +) +_input( + "rmd_qlac_premiums_paid", + float, + "Total premiums paid for qualifying longevity annuity contracts", + "Cumulative QLAC premiums across all plans and IRAs. Above the limit, " + "the contracts are not QLACs and stay in the balance.", + USD, +) +_input( + "rmd_first_year_deferred", + bool, + "First required distribution deferred to April 1 of next year", + "The current year is the first distribution year and the person will " + "take its required distribution by April 1 of next year.", +) +_input( + "rmd_prior_year_deferred_amount", + float, + "Required distribution for the prior year deferred to April 1 of this year", + "First-year required distribution from last year that is due by April 1 " + "of this year.", + USD, +) +_input( + "rmd_distribution_period_override", + float, + "Distribution period overriding the Uniform Lifetime Table", + "For a sole spouse beneficiary more than 10 years younger, the Joint and " + "Last Survivor Table period. 0 uses the Uniform Lifetime Table.", +) +_input( + "rmd_inherited_required_amount", + float, + "Required distributions from inherited accounts", + "Beneficiary required distributions from inherited IRAs and plans, as " + "computed by the simulator (Single Life Table or 10-year rule).", + USD, +) +_input( + "rmd_inherited_distributions_taken", + float, + "Distributions taken from inherited accounts", + "Distributions from inherited IRAs and plans in the year.", + USD, +) +_input( + "rmd_shortfall_corrected_timely", + bool, + "Missed required distribution corrected within the correction window", + "The shortfall was distributed within the IRC 4974(e) correction window, " + "so the reduced rate applies.", +) +_input( + "rmd_excise_waiver_amount", + float, + "Shortfall for which the excise tax waiver is requested", + "Part of the shortfall due to reasonable error that is being remedied " + "(IRC 4974(d)).", + USD, +) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution_ira.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution_ira.py new file mode 100644 index 00000000000..eb04fe44e87 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/required_minimum_distribution_ira.py @@ -0,0 +1,32 @@ +from policyengine_us.model_api import * + + +class required_minimum_distribution_ira(Variable): + value_type = float + entity = Person + label = "Required minimum distribution from the person's own IRAs" + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/408#a_6", + "https://www.law.cornell.edu/cfr/text/26/1.408-8", + "https://www.irs.gov/publications/p590b", + ) + + def formula(person, period, parameters): + p = parameters( + period + ).gov.irs.retirement_distributions.required_minimum_distributions + qlac_ok = person("rmd_qlac_premiums_paid", period) <= p.qlac_premium_limit + balance = max_( + 0, + person("rmd_ira_prior_year_end_balance", period) + - qlac_ok * max_(0, person("rmd_qlac_value_ira", period)), + ) + distribution_period = person("rmd_distribution_period", period) + return np.divide( + balance, + distribution_period, + out=np.zeros_like(balance), + where=distribution_period > 0, + ) diff --git a/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/rmd_distribution_period.py b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/rmd_distribution_period.py new file mode 100644 index 00000000000..d679cdc10c2 --- /dev/null +++ b/policyengine_us/variables/gov/irs/tax/federal_income/retirement_additional_taxes/rmd_distribution_period.py @@ -0,0 +1,29 @@ +from policyengine_us.model_api import * + + +class rmd_distribution_period(Variable): + value_type = float + entity = Person + label = "Distribution period for required minimum distributions" + documentation = "Uniform Lifetime Table period at the age attained this year, or the override; 0 before the first distribution year." + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/401#a_9_C_v", + "https://www.irs.gov/publications/p590b", + ) + + def formula(person, period, parameters): + p = parameters( + period + ).gov.irs.retirement_distributions.required_minimum_distributions + age = person("age", period) + applicable_age = p.applicable_age.calc(person("birth_year", period)) + required = age >= applicable_age + # The first distribution year's amount may wait until April 1 of next year. + first_year_deferred = person("rmd_first_year_deferred", period) & ( + age == applicable_age + ) + override = person("rmd_distribution_period_override", period) + table_period = p.uniform_lifetime_table.calc(age) + distribution_period = where(override > 0, override, table_period) + return where(required & ~first_year_deferred, distribution_period, 0) diff --git a/policyengine_us/variables/gov/states/ca/tax/income/ca_early_distribution_additional_tax.py b/policyengine_us/variables/gov/states/ca/tax/income/ca_early_distribution_additional_tax.py new file mode 100644 index 00000000000..d01b05cb9c5 --- /dev/null +++ b/policyengine_us/variables/gov/states/ca/tax/income/ca_early_distribution_additional_tax.py @@ -0,0 +1,34 @@ +from policyengine_us.model_api import * + + +class ca_early_distribution_additional_tax(Variable): + value_type = float + entity = TaxUnit + label = "California additional tax on early distributions" + documentation = ( + "FTB 3805P Part I: 2.5% (6% for SIMPLE IRA distributions in the " + "first two years) of the early distributions subject to the federal " + "additional tax, plus 2.5% of amounts California does not except." + ) + unit = USD + definition_period = YEAR + reference = ( + "https://law.justia.com/codes/california/code-rtc/division-2/part-10/chapter-3/article-2/section-17085/", + "https://www.ftb.ca.gov/forms/2025/2025-3805p-instructions.html", + ) + defined_for = StateCode.CA + + def formula(tax_unit, period, parameters): + p = parameters(period).gov.states.ca.tax.income.early_distribution_tax + general = tax_unit_non_dep_add( + tax_unit, + period, + [ + "early_distribution_additional_tax_base", + "ca_early_distributions_not_excepted_in_california", + ], + ) + simple = tax_unit_non_dep_add( + tax_unit, period, ["early_distribution_simple_ira_tax_base"] + ) + return p.rate * general + p.simple_ira_rate * simple diff --git a/policyengine_us/variables/gov/states/ca/tax/income/ca_early_distributions_not_excepted_in_california.py b/policyengine_us/variables/gov/states/ca/tax/income/ca_early_distributions_not_excepted_in_california.py new file mode 100644 index 00000000000..b7453e98eda --- /dev/null +++ b/policyengine_us/variables/gov/states/ca/tax/income/ca_early_distributions_not_excepted_in_california.py @@ -0,0 +1,17 @@ +from policyengine_us.model_api import * + + +class ca_early_distributions_not_excepted_in_california(Variable): + value_type = float + entity = Person + label = "Early distributions excepted federally but not in California" + documentation = ( + "Early distributions that meet a federal exception California has " + "not adopted (for example 529-to-Roth IRA rollovers, IRA-to-HSA " + "rollovers and qualified recovery assistance distributions), and " + "that are includible in California income." + ) + unit = USD + definition_period = YEAR + reference = "https://www.ftb.ca.gov/forms/2025/2025-3805p-instructions.html" + defined_for = StateCode.CA diff --git a/policyengine_us/variables/gov/states/ca/tax/income/ca_income_tax_before_refundable_credits.py b/policyengine_us/variables/gov/states/ca/tax/income/ca_income_tax_before_refundable_credits.py index 2775488ba83..596807b34aa 100644 --- a/policyengine_us/variables/gov/states/ca/tax/income/ca_income_tax_before_refundable_credits.py +++ b/policyengine_us/variables/gov/states/ca/tax/income/ca_income_tax_before_refundable_credits.py @@ -18,4 +18,6 @@ def formula(tax_unit, period, parameters): # Form 540 lines 61-62: AMT and mental health services tax amt = tax_unit("ca_amt", period) mhst = tax_unit("ca_mental_health_services_tax", period) - return tax_after_credits + amt + mhst + # FTB 3805P additional taxes on early distributions (Form 540 line 63). + early = tax_unit("ca_early_distribution_additional_tax", period) + return tax_after_credits + amt + mhst + early diff --git a/policyengine_us/variables/gov/states/ca/tax/income/ca_us_govt_fund_dividend_subtraction.py b/policyengine_us/variables/gov/states/ca/tax/income/ca_us_govt_fund_dividend_subtraction.py new file mode 100644 index 00000000000..55c45dc3546 --- /dev/null +++ b/policyengine_us/variables/gov/states/ca/tax/income/ca_us_govt_fund_dividend_subtraction.py @@ -0,0 +1,40 @@ +from policyengine_us.model_api import * +from policyengine_us.tools.us_govt_obligation_funds import ( + us_govt_fund_state_subtraction, +) + + +class ca_us_govt_fund_dividend_subtraction(Variable): + value_type = float + entity = Person + label = "California subtraction for fund dividends from U.S. government obligations" + documentation = ( + "Ordinary dividends from regulated investment companies that are " + "attributable to interest on U.S. government obligations, from each " + "fund that met California's asset test at the close of every quarter " + "of its taxable year or is a qualified fund of funds. Direct holdings " + "of U.S. obligations are subtracted through us_govt_interest." + ) + unit = USD + definition_period = YEAR + reference = ( + # Cal. Rev. & Tax. Code § 17145(a), (b)(4), (c), (d) + "https://law.justia.com/codes/california/code-rtc/division-2/part-10/chapter-3/article-3/section-17145/", + # Schedule CA (540), Part I, Section A, line 2, column B + "https://www.ftb.ca.gov/forms/2025/2025-540-ca-instructions.html", + ) + defined_for = StateCode.CA + + def formula(person, period, parameters): + p = parameters(period).gov.states.ca.tax.income.agi.us_govt_fund_dividends + # California's asset base counts every obligation exempt from + # California tax, including California municipal obligations; the + # fund slots carry only U.S. government obligations, so a fund that + # needs California municipal holdings to reach 50% must use the + # issuer's statement as evidence. + return us_govt_fund_state_subtraction( + person, + period, + p.asset_threshold, + p.qualified_fund_of_funds_exempt, + ) diff --git a/policyengine_us/variables/gov/states/ct/tax/income/subtractions/ct_us_govt_fund_dividend_subtraction.py b/policyengine_us/variables/gov/states/ct/tax/income/subtractions/ct_us_govt_fund_dividend_subtraction.py new file mode 100644 index 00000000000..214d826dd44 --- /dev/null +++ b/policyengine_us/variables/gov/states/ct/tax/income/subtractions/ct_us_govt_fund_dividend_subtraction.py @@ -0,0 +1,34 @@ +from policyengine_us.model_api import * +from policyengine_us.tools.us_govt_obligation_funds import ( + us_govt_fund_state_subtraction, +) + + +class ct_us_govt_fund_dividend_subtraction(Variable): + value_type = float + entity = Person + label = "Connecticut subtraction for exempt dividends from qualifying mutual funds" + documentation = ( + "Exempt dividends from regulated investment companies derived from " + "U.S. government obligations, from each fund that met Connecticut's " + "asset test at the close of every quarter of its taxable year " + "(Form CT-1040 line 40). Direct holdings of U.S. obligations go on " + "line 39 through us_govt_interest." + ) + unit = USD + definition_period = YEAR + reference = ( + # Conn. Gen. Stat. § 12-718 + "https://law.justia.com/codes/connecticut/title-12/chapter-229/section-12-718/", + # Conn. Agencies Regs. § 12-701(a)(20)-3(a)(2) + "https://regulations.justia.com/states/connecticut/title-12/subtitle-740-a/part-i/section-12-701-a-20-3/", + # Line 40 + "https://portal.ct.gov/-/media/drs/forms/2025/income/2025-ct-1040-instructions_1225.pdf#page=8", + ) + defined_for = StateCode.CT + + def formula(person, period, parameters): + p = parameters( + period + ).gov.states.ct.tax.income.subtractions.us_govt_fund_dividends + return us_govt_fund_state_subtraction(person, period, p.asset_threshold) diff --git a/policyengine_us/variables/gov/states/ia/tax/income/including_married_filing_separately/deductions/ia_fedtax_deduction.py b/policyengine_us/variables/gov/states/ia/tax/income/including_married_filing_separately/deductions/ia_fedtax_deduction.py index 142704c2bd8..e257e849ba4 100644 --- a/policyengine_us/variables/gov/states/ia/tax/income/including_married_filing_separately/deductions/ia_fedtax_deduction.py +++ b/policyengine_us/variables/gov/states/ia/tax/income/including_married_filing_separately/deductions/ia_fedtax_deduction.py @@ -38,6 +38,7 @@ def formula(person, period, parameters): [ "unreported_payroll_tax", "qualified_retirement_penalty", + "form_5329_additional_taxes", "recapture_of_investment_credit", ], ) diff --git a/policyengine_us/variables/gov/states/ny/tax/income/adjusted_gross_income/ny_us_govt_fund_dividend_subtraction.py b/policyengine_us/variables/gov/states/ny/tax/income/adjusted_gross_income/ny_us_govt_fund_dividend_subtraction.py new file mode 100644 index 00000000000..3cdf12ab404 --- /dev/null +++ b/policyengine_us/variables/gov/states/ny/tax/income/adjusted_gross_income/ny_us_govt_fund_dividend_subtraction.py @@ -0,0 +1,34 @@ +from policyengine_us.model_api import * +from policyengine_us.tools.us_govt_obligation_funds import ( + us_govt_fund_state_subtraction, +) + + +class ny_us_govt_fund_dividend_subtraction(Variable): + value_type = float + entity = Person + label = "New York subtraction for fund dividends from U.S. government obligations" + documentation = ( + "Dividends from regulated investment companies attributable to " + "interest on U.S. obligations, from each fund that met New York's " + "asset test at the close of every quarter of its taxable year (Form " + "IT-201 line 28, together with direct U.S. obligation interest from " + "us_govt_interest)." + ) + unit = USD + definition_period = YEAR + reference = ( + # N.Y. Tax Law § 612(c)(1) + "https://newyork.public.law/laws/n.y._tax_law_section_612", + # TSB-M-92(4)I + "https://www.tax.ny.gov/pdf/memos/income/m92_4i.pdf", + # Line 28 + "https://www.tax.ny.gov/pdf/2025/inc/it201i_2025.pdf#page=9", + ) + defined_for = StateCode.NY + + def formula(person, period, parameters): + p = parameters( + period + ).gov.states.ny.tax.income.agi.subtractions.us_govt_fund_dividends + return us_govt_fund_state_subtraction(person, period, p.asset_threshold) diff --git a/policyengine_us/variables/household/income/person/annuities/annuity_contract_inputs.py b/policyengine_us/variables/household/income/person/annuities/annuity_contract_inputs.py new file mode 100644 index 00000000000..6b76f6bed4b --- /dev/null +++ b/policyengine_us/variables/household/income/person/annuities/annuity_contract_inputs.py @@ -0,0 +1,89 @@ +"""Per-contract inputs for annuity contracts held outside qualified plans +(IRC 72(b), (c), (e)). Three slots per person, one contract each. Contracts +issued by the same company to the same owner in one calendar year are +aggregated under IRC 72(e)(12): put them in one slot. A 1035 exchange is not +a taxable event; carry the old contract's investment into the new slot. For +partial annuitization (IRC 72(a)(2)), set annuitized_share so the investment +is split between annuity payments and withdrawals. + +Amounts here must not also be reported in taxable_pension_income.""" + +from policyengine_us.model_api import * + +ANNUITY_CONTRACT_SLOTS = 3 +_REF = ( + "https://www.law.cornell.edu/uscode/text/26/72", + "https://www.irs.gov/publications/p939", +) +_FIELDS = { + "annuity_payments": ( + float, + USD, + "Payments received as an annuity", + "Amounts received as an annuity under the contract this year (IRC 72(a)).", + ), + "investment_in_contract": ( + float, + USD, + "Investment in the contract", + "Premiums paid less amounts previously received tax-free, adjusted for any refund feature (IRC 72(c)(1), (2)).", + ), + "expected_return": ( + float, + USD, + "Expected return at the annuity starting date", + "Total expected return (IRC 72(c)(3)) from the Treas. Reg. 1.72-9 tables; sets the exclusion ratio.", + ), + "investment_recovered": ( + float, + USD, + "Investment already recovered tax-free", + "Cumulative amounts excluded in prior years under the exclusion ratio.", + ), + "starting_date_before_1987": ( + bool, + None, + "Annuity starting date before 1987", + "For starting dates before 1987 the exclusion continues after the investment is recovered (IRC 72(b)(2) applies only after 1986).", + ), + "annuitized_share": ( + float, + "/1", + "Share of the contract annuitized", + "Partial annuitization: share of the investment allocated to the annuity payments; 0 is read as 1 when there are annuity payments.", + ), + "withdrawals": ( + float, + USD, + "Amounts not received as an annuity", + "Withdrawals, partial surrenders and other amounts not received as an annuity (IRC 72(e)).", + ), + "cash_value": ( + float, + USD, + "Cash value immediately before the withdrawals", + "Cash value of the contract before the withdrawals (IRC 72(e)(3)).", + ), + "pre_august_1982_investment": ( + float, + USD, + "Investment made before August 14, 1982", + "Remaining investment from before August 14, 1982; withdrawals recover it first, tax-free (IRC 72(e)(5)(B)).", + ), +} + +for _slot in range(1, ANNUITY_CONTRACT_SLOTS + 1): + for _field, (_type, _unit, _label, _doc) in _FIELDS.items(): + _name = f"annuity_contract_{_slot}_{_field}" + _attrs = dict( + value_type=_type, + entity=Person, + definition_period=YEAR, + label=f"Annuity contract {_slot}: {_label.lower()}", + documentation=_doc, + reference=_REF, + __module__=__name__, + ) + if _unit: + _attrs["unit"] = _unit + globals()[_name] = type(_name, (Variable,), _attrs) diff --git a/policyengine_us/variables/household/income/person/annuities/simplified_method_inputs.py b/policyengine_us/variables/household/income/person/annuities/simplified_method_inputs.py new file mode 100644 index 00000000000..53b673566d5 --- /dev/null +++ b/policyengine_us/variables/household/income/person/annuities/simplified_method_inputs.py @@ -0,0 +1,66 @@ +"""Simplified Method inputs (IRC 72(d)) for annuities from qualified plans, +403(b) plans and IRAs-in-annuity-form with after-tax cost. The gross payments +here must not also be reported in taxable_pension_income.""" + +from policyengine_us.model_api import * + +_REF = ( + "https://www.law.cornell.edu/uscode/text/26/72#d", + "https://www.irs.gov/publications/p575", +) + + +def _input(name, value_type, label, documentation, unit=None): + attributes = dict( + value_type=value_type, + entity=Person, + definition_period=YEAR, + label=label, + documentation=documentation, + reference=_REF, + __module__=__name__, + ) + if unit: + attributes["unit"] = unit + globals()[name] = type(name, (Variable,), attributes) + + +_input( + "qualified_annuity_gross_payments", + float, + "Gross qualified plan annuity payments with after-tax cost", + "Gross annuity payments this year from a qualified plan annuity with an annuity starting date after November 18, 1996 (Form 1099-R box 1).", + USD, +) +_input( + "qualified_annuity_cost", + float, + "Cost in the qualified plan annuity", + "After-tax contributions (investment in the contract) at the annuity starting date.", + USD, +) +_input( + "qualified_annuity_monthly_payments_this_year", + int, + "Monthly payments received this year", + "Number of monthly payments received this year.", +) +_input( + "qualified_annuity_starting_age", + int, + "Annuitant's age at the annuity starting date", + "Age at the annuity starting date (single life).", +) +_input( + "qualified_annuity_combined_starting_age", + int, + "Combined ages at the starting date for a joint annuity", + "Sum of the annuitants' ages for a joint and survivor annuity; 0 for a single-life annuity.", +) +_input( + "qualified_annuity_cost_recovered", + float, + "Cost already recovered tax-free", + "Amounts excluded in earlier years under the Simplified Method.", + USD, +) diff --git a/policyengine_us/variables/household/income/person/annuities/simplified_method_taxable_annuity.py b/policyengine_us/variables/household/income/person/annuities/simplified_method_taxable_annuity.py new file mode 100644 index 00000000000..896d0536fd0 --- /dev/null +++ b/policyengine_us/variables/household/income/person/annuities/simplified_method_taxable_annuity.py @@ -0,0 +1,31 @@ +from policyengine_us.model_api import * + + +class simplified_method_taxable_annuity(Variable): + value_type = float + entity = Person + label = "Taxable qualified plan annuity under the Simplified Method" + documentation = "Gross payments less (cost / expected monthly payments) per payment, the exclusion stopping when the cost is recovered (Pub. 575 Simplified Method Worksheet)." + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/72#d", + "https://www.irs.gov/publications/p575", + ) + + def formula(person, period, parameters): + p = parameters(period).gov.irs.gross_income.annuities + gross = max_(0, person("qualified_annuity_gross_payments", period)) + cost = max_(0, person("qualified_annuity_cost", period)) + combined = person("qualified_annuity_combined_starting_age", period) + expected = where( + combined > 0, + p.simplified_method_payments_joint.calc(combined), + p.simplified_method_payments.calc( + person("qualified_annuity_starting_age", period) + ), + ) + months = person("qualified_annuity_monthly_payments_this_year", period) + excluded = cost / expected * months + remaining = max_(0, cost - person("qualified_annuity_cost_recovered", period)) + return max_(0, gross - min_(min_(excluded, remaining), gross)) diff --git a/policyengine_us/variables/household/income/person/annuities/taxable_annuity_contract_income.py b/policyengine_us/variables/household/income/person/annuities/taxable_annuity_contract_income.py new file mode 100644 index 00000000000..2e9f6a53234 --- /dev/null +++ b/policyengine_us/variables/household/income/person/annuities/taxable_annuity_contract_income.py @@ -0,0 +1,65 @@ +from policyengine_us.model_api import * + +ANNUITY_CONTRACT_SLOTS = 3 + + +class taxable_annuity_contract_income(Variable): + value_type = float + entity = Person + label = "Taxable income from annuity contracts outside qualified plans" + documentation = ( + "Per contract: annuity payments less the exclusion ratio part " + "(investment over expected return), with the exclusion stopping once " + "the investment is recovered for starting dates after 1986; plus " + "withdrawals taxed income-first, after any pre-August 14, 1982 " + "investment is recovered." + ) + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/72#b", + "https://www.law.cornell.edu/uscode/text/26/72#e", + "https://www.irs.gov/publications/p939", + ) + + def formula(person, period, parameters): + total = 0 + for slot in range(1, ANNUITY_CONTRACT_SLOTS + 1): + + def v(field): + return person(f"annuity_contract_{slot}_{field}", period) + + payments = max_(0, v("annuity_payments")) + investment = max_(0, v("investment_in_contract")) + share = v("annuitized_share") + share = where((share <= 0) & (payments > 0), 1, np.clip(share, 0, 1)) + annuity_investment = investment * share + expected = max_(0, v("expected_return")) + ratio = np.clip( + np.divide( + annuity_investment, + expected, + out=np.zeros_like(expected), + where=expected > 0, + ), + 0, + 1, + ) + excluded = payments * ratio + unrecovered = max_( + 0, annuity_investment - max_(0, v("investment_recovered")) + ) + excluded = where( + v("starting_date_before_1987"), excluded, min_(excluded, unrecovered) + ) + annuity_taxable = payments - excluded + # Withdrawals: tax-free up to remaining pre-August 14, 1982 + # investment, then income first up to the gain in the contract. + withdrawals = max_(0, v("withdrawals")) + pre_1982 = max_(0, v("pre_august_1982_investment")) + after_grandfather = max_(0, withdrawals - pre_1982) + deferred_investment = max_(0, investment - annuity_investment) + gain = max_(0, v("cash_value") - deferred_investment) + withdrawal_taxable = min_(after_grandfather, gain) + total = total + annuity_taxable + withdrawal_taxable + return total diff --git a/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_gain_exclusion.py b/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_gain_exclusion.py new file mode 100644 index 00000000000..228acd656ca --- /dev/null +++ b/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_gain_exclusion.py @@ -0,0 +1,46 @@ +from policyengine_us.model_api import * + + +class home_sale_gain_exclusion(Variable): + value_type = float + entity = Person + label = "Excluded gain on the sale of a main home" + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/121", + "https://www.irs.gov/publications/p523", + ) + + def formula(person, period, parameters): + p = parameters(period).gov.irs.capital_gains.home_sale_exclusion + gain = max_(0, person("home_sale_gain", period)) + depreciation = max_( + 0, person("home_sale_depreciation_after_may_6_1997", period) + ) + nonqualified = np.clip(person("home_sale_nonqualified_use_share", period), 0, 1) + excludable_gain = max_(0, gain - depreciation) * (1 - nonqualified) + owned = person("home_sale_ownership_months", period) + used = person("home_sale_use_months", period) + prior = person("home_sale_excluded_gain_within_two_years", period) + meets_full = (owned >= p.required_months) & (used >= p.required_months) & ~prior + # Reduced exclusion: the shortest of ownership, use and time since + # the last exclusion, over 24 months (IRC 121(c)(1)). + since_prior = where( + prior, + person("home_sale_months_since_prior_exclusion", period), + p.required_months, + ) + fraction = np.clip( + np.minimum(np.minimum(owned, used), since_prior) / p.required_months, 0, 1 + ) + reduced = person("home_sale_reduced_exclusion_qualifies", period) & ~meets_full + # A married couple in one tax unit is treated as filing jointly; + # filing_status itself depends on capital gains through dependency tests. + joint = person.tax_unit("tax_unit_married", period) + spouse_ok = person("home_sale_spouse_meets_use_test", period) & ~person( + "home_sale_spouse_excluded_gain_within_two_years", period + ) + full_limit = where(joint & spouse_ok, p.joint_amount, p.amount) + limit = where(meets_full, full_limit, where(reduced, fraction * p.amount, 0)) + return min_(excludable_gain, limit) diff --git a/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_inputs.py b/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_inputs.py new file mode 100644 index 00000000000..7b195533296 --- /dev/null +++ b/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_inputs.py @@ -0,0 +1,90 @@ +"""Inputs for the exclusion of gain on the sale of a main home (IRC 121). +Enter them on the seller (for a jointly owned home on a joint return, on +the head). The gain must not also be reported in capital gains inputs.""" + +from policyengine_us.model_api import * + +_REF = ( + "https://www.law.cornell.edu/uscode/text/26/121", + "https://www.irs.gov/publications/p523", +) + + +def _input(name, value_type, label, documentation, unit=None): + attributes = dict( + value_type=value_type, + entity=Person, + definition_period=YEAR, + label=label, + documentation=documentation, + reference=_REF, + __module__=__name__, + ) + if unit: + attributes["unit"] = unit + globals()[name] = type(name, (Variable,), attributes) + + +_input( + "home_sale_gain", + float, + "Gain on the sale of a main home", + "Amount realized less adjusted basis, before the section 121 exclusion. A loss is not deductible; enter 0.", + USD, +) +_input( + "home_sale_ownership_months", + int, + "Months the seller owned the home in the 5 years before the sale", + "Months of ownership in the 60 months ending on the sale date.", +) +_input( + "home_sale_use_months", + int, + "Months the seller used the home as a main home in the 5 years before the sale", + "Months of use as a main home in the 60 months ending on the sale date.", +) +_input( + "home_sale_spouse_meets_use_test", + bool, + "Spouse also used the home as a main home for 24 months", + "On a joint return, whether the spouse meets the use test (needed for the joint amount).", +) +_input( + "home_sale_excluded_gain_within_two_years", + bool, + "Seller excluded gain on another home in the prior 2 years", + "IRC 121(b)(3): bars the exclusion unless a reduced exclusion applies.", +) +_input( + "home_sale_spouse_excluded_gain_within_two_years", + bool, + "Spouse excluded gain on another home in the prior 2 years", + "On a joint return, bars the joint amount.", +) +_input( + "home_sale_reduced_exclusion_qualifies", + bool, + "Sale due to a change of employment, health or unforeseen circumstances", + "IRC 121(c): a seller failing the 24-month or 2-year tests gets a fraction of the exclusion.", +) +_input( + "home_sale_months_since_prior_exclusion", + int, + "Months since the last sale with an excluded gain", + "Used for the reduced exclusion; leave 0 if there was no prior exclusion in the last 2 years.", +) +_input( + "home_sale_nonqualified_use_share", + float, + "Share of the gain allocated to nonqualified use", + "IRC 121(b)(5): periods after 2008 the home was not the main home (before it became one), over total ownership.", + "/1", +) +_input( + "home_sale_depreciation_after_may_6_1997", + float, + "Depreciation claimed on the home after May 6, 1997", + "IRC 121(d)(6): gain up to this depreciation is not excluded. Also report it in unrecaptured_section_1250_gain_before_losses.", + USD, +) diff --git a/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_taxable_gain.py b/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_taxable_gain.py new file mode 100644 index 00000000000..73c01883a3a --- /dev/null +++ b/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_taxable_gain.py @@ -0,0 +1,19 @@ +from policyengine_us.model_api import * + + +class home_sale_taxable_gain(Variable): + value_type = float + entity = Person + label = "Taxable long-term gain on the sale of a main home" + documentation = "Gain above the section 121 exclusion, long-term when the home was owned more than 12 months." + unit = USD + definition_period = YEAR + reference = "https://www.law.cornell.edu/uscode/text/26/121" + + def formula(person, period, parameters): + taxable = max_( + 0, + person("home_sale_gain", period) + - person("home_sale_gain_exclusion", period), + ) + return where(person("home_sale_ownership_months", period) > 12, taxable, 0) diff --git a/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_taxable_short_term_gain.py b/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_taxable_short_term_gain.py new file mode 100644 index 00000000000..97feed06938 --- /dev/null +++ b/policyengine_us/variables/household/income/person/capital_gains/home_sale/home_sale_taxable_short_term_gain.py @@ -0,0 +1,21 @@ +from policyengine_us.model_api import * + + +class home_sale_taxable_short_term_gain(Variable): + value_type = float + entity = Person + label = "Taxable short-term gain on the sale of a main home" + documentation = ( + "Gain above the section 121 exclusion on a home owned 12 months or less." + ) + unit = USD + definition_period = YEAR + reference = "https://www.law.cornell.edu/uscode/text/26/121" + + def formula(person, period, parameters): + taxable = max_( + 0, + person("home_sale_gain", period) + - person("home_sale_gain_exclusion", period), + ) + return where(person("home_sale_ownership_months", period) > 12, 0, taxable) diff --git a/policyengine_us/variables/household/income/person/capital_gains/long_term_capital_gain_adjustments.py b/policyengine_us/variables/household/income/person/capital_gains/long_term_capital_gain_adjustments.py new file mode 100644 index 00000000000..e644e38805f --- /dev/null +++ b/policyengine_us/variables/household/income/person/capital_gains/long_term_capital_gain_adjustments.py @@ -0,0 +1,14 @@ +from policyengine_us.model_api import * + + +class long_term_capital_gain_adjustments(Variable): + value_type = float + entity = Person + label = "long-term capital gain amounts computed from detailed inputs" + unit = USD + definition_period = YEAR + adds = [ + "section_1256_long_term_gain", + "home_sale_taxable_gain", + "investment_lot_long_term_gain", + ] diff --git a/policyengine_us/variables/household/income/person/capital_gains/long_term_capital_gains.py b/policyengine_us/variables/household/income/person/capital_gains/long_term_capital_gains.py index 86d1e3e9d59..caf48e27782 100644 --- a/policyengine_us/variables/household/income/person/capital_gains/long_term_capital_gains.py +++ b/policyengine_us/variables/household/income/person/capital_gains/long_term_capital_gains.py @@ -15,4 +15,5 @@ class long_term_capital_gains(Variable): adds = [ "long_term_capital_gains_before_response", "capital_gains_behavioral_response", + "long_term_capital_gain_adjustments", ] diff --git a/policyengine_us/variables/household/income/person/capital_gains/section_1256/section_1256_long_term_gain.py b/policyengine_us/variables/household/income/person/capital_gains/section_1256/section_1256_long_term_gain.py new file mode 100644 index 00000000000..f91f4d0ad2b --- /dev/null +++ b/policyengine_us/variables/household/income/person/capital_gains/section_1256/section_1256_long_term_gain.py @@ -0,0 +1,16 @@ +from policyengine_us.model_api import * + + +class section_1256_long_term_gain(Variable): + value_type = float + entity = Person + label = "Long-term part of section 1256 contract gain or loss" + documentation = "Section 1256(a)(3): 60% of the marked-to-market net gain or loss is long-term and 40% short-term." + unit = USD + definition_period = YEAR + reference = "https://www.law.cornell.edu/uscode/text/26/1256#a_3" + + def formula(person, period, parameters): + share = parameters(period).gov.irs.capital_gains.section_1256.long_term_share + net = person("section_1256_net_gain", period) + return net * share diff --git a/policyengine_us/variables/household/income/person/capital_gains/section_1256/section_1256_net_gain.py b/policyengine_us/variables/household/income/person/capital_gains/section_1256/section_1256_net_gain.py new file mode 100644 index 00000000000..8323ec4f3a9 --- /dev/null +++ b/policyengine_us/variables/household/income/person/capital_gains/section_1256/section_1256_net_gain.py @@ -0,0 +1,20 @@ +from policyengine_us.model_api import * + + +class section_1256_net_gain(Variable): + value_type = float + entity = Person + label = "Net gain or loss on section 1256 contracts" + documentation = ( + "Net gain (negative for loss) on regulated futures, foreign currency " + "contracts, nonequity options, dealer equity options and dealer " + "securities futures, including the year-end mark-to-market of open " + "positions (Form 6781 Part I line 7, after any loss carryback " + "election). Do not also report it in short- or long-term gains." + ) + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/1256", + "https://www.irs.gov/forms-pubs/about-form-6781", + ) diff --git a/policyengine_us/variables/household/income/person/capital_gains/section_1256/section_1256_short_term_gain.py b/policyengine_us/variables/household/income/person/capital_gains/section_1256/section_1256_short_term_gain.py new file mode 100644 index 00000000000..4247549728e --- /dev/null +++ b/policyengine_us/variables/household/income/person/capital_gains/section_1256/section_1256_short_term_gain.py @@ -0,0 +1,16 @@ +from policyengine_us.model_api import * + + +class section_1256_short_term_gain(Variable): + value_type = float + entity = Person + label = "Short-term part of section 1256 contract gain or loss" + documentation = "Section 1256(a)(3): 60% of the marked-to-market net gain or loss is long-term and 40% short-term." + unit = USD + definition_period = YEAR + reference = "https://www.law.cornell.edu/uscode/text/26/1256#a_3" + + def formula(person, period, parameters): + share = parameters(period).gov.irs.capital_gains.section_1256.long_term_share + net = person("section_1256_net_gain", period) + return net * (1 - share) diff --git a/policyengine_us/variables/household/income/person/capital_gains/short_term_capital_gain_adjustments.py b/policyengine_us/variables/household/income/person/capital_gains/short_term_capital_gain_adjustments.py new file mode 100644 index 00000000000..60f6d8c0b34 --- /dev/null +++ b/policyengine_us/variables/household/income/person/capital_gains/short_term_capital_gain_adjustments.py @@ -0,0 +1,14 @@ +from policyengine_us.model_api import * + + +class short_term_capital_gain_adjustments(Variable): + value_type = float + entity = Person + label = "short-term capital gain amounts computed from detailed inputs" + unit = USD + definition_period = YEAR + adds = [ + "section_1256_short_term_gain", + "home_sale_taxable_short_term_gain", + "investment_lot_short_term_gain", + ] diff --git a/policyengine_us/variables/household/income/person/dividends/us_govt_obligation_funds/us_govt_obligation_fund_inputs.py b/policyengine_us/variables/household/income/person/dividends/us_govt_obligation_funds/us_govt_obligation_fund_inputs.py new file mode 100644 index 00000000000..6ca6317cef3 --- /dev/null +++ b/policyengine_us/variables/household/income/person/dividends/us_govt_obligation_funds/us_govt_obligation_fund_inputs.py @@ -0,0 +1,121 @@ +"""Per-fund input slots for dividends attributable to U.S. government +obligations. See policyengine_us/tools/us_govt_obligation_funds.py for the +meaning of each field and the missing-data rule. + +The slots are built in a loop so every slot carries identical metadata; each +generated class is a plain input variable named, for example, +``us_govt_fund_1_ordinary_dividends``. +""" + +from policyengine_us.model_api import * +from policyengine_us.tools.us_govt_obligation_funds import ( + US_GOVT_FUND_QUARTERS, + US_GOVT_OBLIGATION_FUND_SLOTS, + USGovtFundAssetTestEvidence, + us_govt_fund_variable, +) + +_REFERENCE = ( + # Cal. Rev. & Tax. Code § 17145(a), (b)(4), (d) + "https://law.justia.com/codes/california/code-rtc/division-2/part-10/chapter-3/article-3/section-17145/", + # Conn. Gen. Stat. § 12-718 + "https://law.justia.com/codes/connecticut/title-12/chapter-229/section-12-718/", + # N.Y. Tax Law § 612(c)(1) + "https://newyork.public.law/laws/n.y._tax_law_section_612", +) + + +def _input_class(name, attributes): + attributes = { + "entity": Person, + "definition_period": YEAR, + "reference": _REFERENCE, + "__module__": __name__, + **attributes, + } + globals()[name] = type(name, (Variable,), attributes) + + +for _slot in range(1, US_GOVT_OBLIGATION_FUND_SLOTS + 1): + _input_class( + us_govt_fund_variable(_slot, "ordinary_dividends"), + dict( + value_type=float, + unit=USD, + label=f"Ordinary dividends from U.S. government obligation fund {_slot}", + documentation=( + "Ordinary dividends (Form 1099-DIV box 1a, excluding capital " + "gain distributions) the person received in a taxable account " + f"from fund {_slot}. A memo of dividends already reported in " + "qualified_dividend_income or non_qualified_dividend_income; " + "it does not add income. Leave out dividends earned inside an " + "IRA, 401(k) or other retirement account." + ), + ), + ) + _input_class( + us_govt_fund_variable(_slot, "govt_income_share"), + dict( + value_type=float, + unit="/1", + label=f"U.S. government obligation income share of fund {_slot}", + documentation=( + "Share of the fund's ordinary dividends attributable to " + "interest on U.S. government obligations, from the fund's " + "annual tax supplement. Sets the subtraction amount only; it " + "never shows that the fund passed a state's asset test." + ), + ), + ) + for _quarter in US_GOVT_FUND_QUARTERS: + _input_class( + us_govt_fund_variable(_slot, f"govt_asset_share_q{_quarter}"), + dict( + value_type=float, + unit="/1", + label=( + f"U.S. government obligation asset share of fund {_slot} " + f"at the close of fiscal quarter {_quarter}" + ), + documentation=( + "Share of the value of the fund's total assets (IRC " + "851(c)(4)) held in U.S. government obligations whose " + "interest states may not tax under federal law, at the " + f"close of quarter {_quarter} of the fund's taxable year. " + "Excludes repurchase agreements and Ginnie Mae, Fannie Mae " + "and Freddie Mac securities. Defaults to 0, which fails " + "the asset test, so missing data never qualifies a fund." + ), + ), + ) + _input_class( + us_govt_fund_variable(_slot, "asset_test_evidence"), + dict( + value_type=Enum, + possible_values=USGovtFundAssetTestEvidence, + default_value=USGovtFundAssetTestEvidence.QUARTERLY_ASSET_SHARES, + label=f"Evidence for the asset test of fund {_slot}", + documentation=( + "QUARTERLY_ASSET_SHARES tests the four quarter-end asset " + "shares. ISSUER_CONFIRMED_MET or ISSUER_CONFIRMED_NOT_MET uses " + "the issuer's explicit statement that the fund did or did not " + "meet the quarterly 50% test for California, Connecticut and " + "New York; never infer it from the income share." + ), + ), + ) + _input_class( + us_govt_fund_variable(_slot, "qualified_fund_of_funds"), + dict( + value_type=bool, + default_value=False, + label=f"Fund {_slot} is a qualified fund of funds", + documentation=( + "Whether the fund is a qualified fund of funds under IRC " + "852(g)(2): at least 50% of the value of its total assets is " + "in other regulated investment companies at the close of " + "each quarter. California exempts such a fund from its asset " + "test; Connecticut and New York do not." + ), + ), + ) diff --git a/policyengine_us/variables/household/income/person/investment_lots/investment_lot_calculations.py b/policyengine_us/variables/household/income/person/investment_lots/investment_lot_calculations.py new file mode 100644 index 00000000000..c67eaf69e2f --- /dev/null +++ b/policyengine_us/variables/household/income/person/investment_lots/investment_lot_calculations.py @@ -0,0 +1,266 @@ +"""Results of the lot-level rules. Long-term results flow into +long_term_capital_gains automatically; short-term, dividend and interest +results are applied by apply_investment_lot_adjustments.""" + +from policyengine_us.model_api import * + +LOT_SLOTS = 5 +WASH_SALE_PURCHASES = 3 + + +def _p(period, parameters): + return parameters(period).gov.irs.investment_lots + + +def _wash_sale_parts(person, period, parameters): + """Per slot: allowed loss, loss disallowed with basis added to a taxable + replacement, and loss disallowed permanently (IRA replacement, Rev. Rul. + 2008-5). Replacement shares are matched in purchase order.""" + window = _p(period, parameters).wash_sale_window_days + parts = [] + for slot in range(1, LOT_SLOTS + 1): + + def v(field): + return person(f"wash_sale_{slot}_{field}", period) + + loss = max_(0, v("loss")) + sold = max_(0, v("shares_sold")) + sale_day = v("sale_day") + remaining = sold + deferred_shares = 0 + permanent_shares = 0 + for k in range(1, WASH_SALE_PURCHASES + 1): + day = v(f"purchase_{k}_day") + shares = max_(0, v(f"purchase_{k}_shares")) + in_window = (shares > 0) & (abs(day - sale_day) <= window) + matched = where(in_window, min_(shares, remaining), 0) + remaining = remaining - matched + in_ira = v(f"purchase_{k}_in_ira") + permanent_shares = permanent_shares + where(in_ira, matched, 0) + deferred_shares = deferred_shares + where(in_ira, 0, matched) + per_share = np.divide(loss, sold, out=np.zeros_like(loss), where=sold > 0) + deferred = per_share * deferred_shares + permanent = per_share * permanent_shares + parts.append((loss - deferred - permanent, deferred, permanent, v("long_term"))) + return parts + + +def _fund_sale_parts(person, period, parameters): + """Per slot: (short-term loss, long-term loss, disallowed loss).""" + parts = [] + for slot in range(1, LOT_SLOTS + 1): + + def v(field): + return person(f"fund_sale_{slot}_{field}", period) + + loss = max_(0, v("loss")) + short = v("held_six_months_or_less") + disallowed = where( + short & ~v("daily_dividend_fund"), + min_(loss, max_(0, v("exempt_interest_dividends"))), + 0, + ) + after = loss - disallowed + long_part = where(short, min_(after, max_(0, v("capital_gain_dividends"))), 0) + parts.append((after - long_part, long_part, disallowed)) + return parts + + +def _bond_parts(person, period, parameters): + """Per slot: (interest income adjustment, capital gain, gain is long-term). + Interest = OID accrued + market discount recognized - premium amortized.""" + p = _p(period, parameters) + parts = [] + for slot in range(1, LOT_SLOTS + 1): + + def v(field): + return person(f"bond_lot_{slot}_{field}", period) + + # OID under the constant yield method (IRC 1272(a)(3)), zero when de minimis. + srpm = max_(0, v("stated_redemption_price")) + discount = max_(0, srpm - v("issue_price")) + de_minimis = discount < p.de_minimis_discount_rate * srpm * v( + "complete_years_to_maturity_at_issue" + ) + aip = max_(0, v("adjusted_issue_price_start")) + growth = (1 + v("yield_per_accrual_period")) ** v("accrual_periods_held") - 1 + oid = max_(0, aip * growth - max_(0, v("qualified_stated_interest"))) + oid = where(de_minimis, 0, oid) * ( + 1 - np.clip(v("acquisition_premium_fraction"), 0, 1) + ) + # Market discount accrued ratably (IRC 1276(b)(1)), zero when de minimis. + md = max_(0, v("market_discount")) + md_de_minimis = md < p.de_minimis_discount_rate * srpm * v( + "complete_years_to_maturity_at_purchase" + ) + to_maturity = v("days_purchase_to_maturity") + accrued = md * np.clip( + np.divide( + v("days_held"), + to_maturity, + out=np.zeros(md.shape), + where=to_maturity > 0, + ), + 0, + 1, + ) + accrued = where(md_de_minimis, 0, accrued) + already = max_(0, v("market_discount_included_before")) + current = v("market_discount_included_currently") + gain = v("disposition_gain") + # With the current inclusion election the accrual is interest each + # year; otherwise gain up to the accrued discount is interest at sale. + md_interest = where( + current, + max_(0, accrued - already), + min_(max_(0, gain), max_(0, accrued - already)), + ) + disposed_md = where(current, 0, md_interest) + capital = gain - disposed_md + interest = oid + md_interest - max_(0, v("premium_amortization")) + parts.append((interest, capital, v("disposition_long_term"))) + return parts + + +def _var(name, label, doc, compute, reference): + def formula(person, period, parameters): + return compute(person, period, parameters) + + globals()[name] = type( + name, + (Variable,), + dict( + value_type=float, + entity=Person, + definition_period=YEAR, + unit=USD, + label=label, + documentation=doc, + reference=reference, + formula=formula, + __module__=__name__, + ), + ) + + +def _sum(parts, index, when=None): + total = 0 + for part in parts: + value = part[index] + if when is not None: + value = where(when(part), value, 0) + total = total + value + return total + + +_var( + "investment_lot_short_term_gain", + "Short-term gain or loss from lot-level rules", + "Allowed short-term wash-sale losses, RIC losses that stay short-term, and short-term bond gains (negative for losses).", + lambda person, period, parameters: ( + -_sum(_wash_sale_parts(person, period, parameters), 0, lambda x: ~x[3]) + - _sum(_fund_sale_parts(person, period, parameters), 0) + + _sum(_bond_parts(person, period, parameters), 1, lambda x: ~x[2]) + ), + ( + "https://www.law.cornell.edu/uscode/text/26/1091", + "https://www.law.cornell.edu/uscode/text/26/852#b_4", + ), +) +_var( + "investment_lot_long_term_gain", + "Long-term gain or loss from lot-level rules", + "Allowed long-term wash-sale losses, RIC losses recharacterized as long-term, and long-term bond gains (negative for losses).", + lambda person, period, parameters: ( + -_sum(_wash_sale_parts(person, period, parameters), 0, lambda x: x[3]) + - _sum(_fund_sale_parts(person, period, parameters), 1) + + _sum(_bond_parts(person, period, parameters), 1, lambda x: x[2]) + ), + ( + "https://www.law.cornell.edu/uscode/text/26/1091", + "https://www.law.cornell.edu/uscode/text/26/852#b_4", + ), +) +_var( + "wash_sale_disallowed_loss_deferred", + "Wash sale losses added to replacement basis", + "Disallowed losses the simulator must add to the basis of the replacement lots (IRC 1091(d)).", + lambda person, period, parameters: _sum( + _wash_sale_parts(person, period, parameters), 1 + ), + ("https://www.law.cornell.edu/uscode/text/26/1091#d",), +) +_var( + "wash_sale_disallowed_loss_permanent", + "Wash sale losses disallowed permanently", + "Losses disallowed because the replacement was bought in an IRA; no basis adjustment (Rev. Rul. 2008-5).", + lambda person, period, parameters: _sum( + _wash_sale_parts(person, period, parameters), 2 + ), + ("https://www.irs.gov/pub/irs-drop/rr-08-05.pdf",), +) +_var( + "ric_loss_disallowed_exempt_interest", + "RIC share losses disallowed for exempt-interest dividends", + "Losses on RIC shares held six months or less, disallowed to the extent of exempt-interest dividends (IRC 852(b)(4)(B)).", + lambda person, period, parameters: _sum( + _fund_sale_parts(person, period, parameters), 2 + ), + ("https://www.law.cornell.edu/uscode/text/26/852#b_4",), +) +_var( + "investment_lot_interest_adjustment", + "Interest income adjustment from bond lots", + "OID accrued plus market discount treated as interest, less amortizable bond premium.", + lambda person, period, parameters: _sum(_bond_parts(person, period, parameters), 0), + ( + "https://www.law.cornell.edu/uscode/text/26/1272", + "https://www.law.cornell.edu/uscode/text/26/1276", + "https://www.law.cornell.edu/uscode/text/26/171", + ), +) + + +def _disqualified_dividends(person, period, parameters): + p = _p(period, parameters) + total = 0 + for slot in range(1, LOT_SLOTS + 1): + days = person(f"dividend_lot_{slot}_days_held_in_window", period) + minimum = where( + person(f"dividend_lot_{slot}_preferred_long_period", period), + p.qualified_dividend_preferred_min_days, + p.qualified_dividend_min_days, + ) + amount = max_( + 0, person(f"dividend_lot_{slot}_qualified_dividends_reported", period) + ) + total = total + where(days > minimum, 0, amount) + return total + + +def _disqualified_199a(person, period, parameters): + p = _p(period, parameters) + total = 0 + for slot in range(1, LOT_SLOTS + 1): + days = person(f"dividend_lot_{slot}_days_held_in_199a_window", period) + amount = max_( + 0, person(f"dividend_lot_{slot}_section_199a_dividends_reported", period) + ) + total = total + where(days > p.section_199a_dividend_min_days, 0, amount) + return total + + +_var( + "dividends_failing_qualified_holding_period", + "Reported qualified dividends failing the holding period", + "Dividends reported as qualified on holdings not held more than 60 days (90 for long-period preferred) in the window; they are ordinary dividends.", + _disqualified_dividends, + ("https://www.law.cornell.edu/uscode/text/26/1#h_11_B_iii",), +) +_var( + "section_199a_dividends_failing_holding_period", + "Section 199A dividends failing the 45-day holding period", + "Section 199A dividends on shares not held more than 45 days in the 91-day window; not qualified REIT dividends.", + _disqualified_199a, + ("https://www.law.cornell.edu/cfr/text/26/1.199A-3",), +) diff --git a/policyengine_us/variables/household/income/person/investment_lots/investment_lot_inputs.py b/policyengine_us/variables/household/income/person/investment_lots/investment_lot_inputs.py new file mode 100644 index 00000000000..3520118e4a5 --- /dev/null +++ b/policyengine_us/variables/household/income/person/investment_lots/investment_lot_inputs.py @@ -0,0 +1,193 @@ +"""Lot-level inputs for holding-period, wash-sale, RIC loss and bond +discount rules. Amounts entered here must be left out of the aggregate +inputs they adjust (short_term_capital_gains, long_term_capital_gains, +qualified and non-qualified dividends, taxable_interest_income); +policyengine_us.tools.investment_lots.apply_investment_lot_adjustments folds +the computed results into those inputs. Dates are day numbers on one scale +(for example days since 2000-01-01).""" + +from policyengine_us.model_api import * + +LOT_SLOTS = 5 +WASH_SALE_PURCHASES = 3 + +_REF = { + "dividend_lot": ( + "https://www.law.cornell.edu/uscode/text/26/1#h_11_B_iii", + "https://www.law.cornell.edu/cfr/text/26/1.199A-3", + ), + "wash_sale": ( + "https://www.law.cornell.edu/uscode/text/26/1091", + "https://www.irs.gov/publications/p550", + ), + "fund_sale": ("https://www.law.cornell.edu/uscode/text/26/852#b_4",), + "bond_lot": ( + "https://www.law.cornell.edu/uscode/text/26/1272", + "https://www.law.cornell.edu/uscode/text/26/1276", + "https://www.law.cornell.edu/uscode/text/26/171", + "https://www.irs.gov/publications/p1212", + ), +} + +_FIELDS = { + "dividend_lot": { + "qualified_dividends_reported": ( + float, + USD, + "Dividends reported as qualified (1099-DIV box 1b) on the holding", + ), + "days_held_in_window": ( + int, + None, + "Days held, unhedged, in the 121-day (181-day for long-period preferred) window", + ), + "preferred_long_period": ( + bool, + None, + "Preferred stock dividend attributable to more than 366 days", + ), + "section_199a_dividends_reported": ( + float, + USD, + "Section 199A dividends reported (1099-DIV box 5) on the holding", + ), + "days_held_in_199a_window": ( + int, + None, + "Days held in the 91-day window for section 199A dividends", + ), + }, + "wash_sale": { + "loss": (float, USD, "Loss realized on the sale (positive)"), + "shares_sold": (float, None, "Shares or units sold at a loss"), + "sale_day": (int, None, "Sale date as a day number"), + "long_term": (bool, None, "Lot sold was held more than one year"), + }, + "fund_sale": { + "loss": (float, USD, "Loss realized on RIC shares (positive)"), + "held_six_months_or_less": (bool, None, "Shares held six months or less"), + "capital_gain_dividends": ( + float, + USD, + "Capital gain dividends (including designated undistributed gains) on the shares", + ), + "exempt_interest_dividends": ( + float, + USD, + "Exempt-interest dividends on the shares", + ), + "daily_dividend_fund": ( + bool, + None, + "Fund declares exempt-interest dividends daily and pays at least monthly (IRC 852(b)(4)(E))", + ), + }, + "bond_lot": { + "adjusted_issue_price_start": ( + float, + USD, + "Adjusted issue price at the start of the year (OID bonds)", + ), + "yield_per_accrual_period": ( + float, + "/1", + "Yield to maturity per accrual period", + ), + "accrual_periods_held": ( + float, + None, + "Accrual periods held this year (fractions allowed)", + ), + "qualified_stated_interest": ( + float, + USD, + "Qualified stated interest received this year", + ), + "stated_redemption_price": (float, USD, "Stated redemption price at maturity"), + "issue_price": (float, USD, "Issue price"), + "complete_years_to_maturity_at_issue": ( + int, + None, + "Complete years to maturity at issue", + ), + "acquisition_premium_fraction": ( + float, + "/1", + "Acquisition premium fraction reducing OID (IRC 1272(a)(7))", + ), + "market_discount": (float, USD, "Market discount at purchase"), + "complete_years_to_maturity_at_purchase": ( + int, + None, + "Complete years to maturity at purchase", + ), + "days_held": (int, None, "Days held from purchase to disposition or year-end"), + "days_purchase_to_maturity": (int, None, "Days from purchase to maturity"), + "disposition_gain": ( + float, + USD, + "Gain on disposition this year (0 if not disposed)", + ), + "disposition_long_term": ( + bool, + None, + "Bond held more than one year at disposition", + ), + "market_discount_included_currently": ( + bool, + None, + "Election to include market discount currently (IRC 1278(b))", + ), + "market_discount_included_before": ( + float, + USD, + "Market discount already included in income", + ), + "premium_amortization": ( + float, + USD, + "Bond premium amortized this year under an IRC 171 election", + ), + }, +} + +for _kind, _fields in _FIELDS.items(): + for _slot in range(1, LOT_SLOTS + 1): + for _field, (_type, _unit, _label) in _fields.items(): + _name = f"{_kind}_{_slot}_{_field}" + _attrs = dict( + value_type=_type, + entity=Person, + definition_period=YEAR, + label=f"{_kind.replace('_', ' ').capitalize()} {_slot}: {_label}", + reference=_REF[_kind], + __module__=__name__, + ) + if _unit: + _attrs["unit"] = _unit + globals()[_name] = type(_name, (Variable,), _attrs) + if _kind == "wash_sale": + for _slot in range(1, LOT_SLOTS + 1): + for _k in range(1, WASH_SALE_PURCHASES + 1): + for _field, _type, _label in ( + ("day", int, "acquisition date as a day number"), + ( + "shares", + float, + "shares or units acquired (substantially identical)", + ), + ("in_ira", bool, "acquired in an IRA or Roth IRA"), + ): + _name = f"wash_sale_{_slot}_purchase_{_k}_{_field}" + globals()[_name] = type( + _name, + (Variable,), + dict( + value_type=_type, + entity=Person, + definition_period=YEAR, + label=f"Wash sale {_slot}, purchase {_k}: {_label}", + reference=_REF["wash_sale"], + __module__=__name__, + ), + ) diff --git a/policyengine_us/variables/household/income/person/long_term_care/long_term_care_per_diem_inputs.py b/policyengine_us/variables/household/income/person/long_term_care/long_term_care_per_diem_inputs.py new file mode 100644 index 00000000000..6a0ec846494 --- /dev/null +++ b/policyengine_us/variables/household/income/person/long_term_care/long_term_care_per_diem_inputs.py @@ -0,0 +1,53 @@ +"""Form 8853 Section C inputs, entered on the insured (chronically or +terminally ill) person, aggregating every contract that covers them.""" + +from policyengine_us.model_api import * + +_REF = ( + "https://www.law.cornell.edu/uscode/text/26/7702B#d", + "https://www.irs.gov/instructions/i8853", +) + + +def _input(name, value_type, label, documentation, unit=None): + attributes = dict( + value_type=value_type, + entity=Person, + definition_period=YEAR, + label=label, + documentation=documentation, + reference=_REF, + __module__=__name__, + ) + if unit: + attributes["unit"] = unit + globals()[name] = type(name, (Variable,), attributes) + + +_input( + "long_term_care_per_diem_benefits", + float, + "Per diem long-term care benefits received", + "Gross per diem or other periodic payments under qualified long-term care insurance contracts and per diem accelerated death benefits (Form 1099-LTC box 1 or 2, per diem basis).", + USD, +) +_input( + "long_term_care_per_diem_days", + int, + "Days in the long-term care period", + "Days in the period(s) for which the per diem payments were made (Form 8853 line 18).", +) +_input( + "long_term_care_qualified_costs", + float, + "Qualified long-term care services costs incurred", + "Costs incurred for qualified long-term care services in the period (Form 8853 line 19).", + USD, +) +_input( + "long_term_care_cost_reimbursements", + float, + "Reimbursements of long-term care costs", + "Reimbursements for those services received from other sources (Form 8853 line 21).", + USD, +) diff --git a/policyengine_us/variables/household/income/person/long_term_care/taxable_long_term_care_per_diem_benefits.py b/policyengine_us/variables/household/income/person/long_term_care/taxable_long_term_care_per_diem_benefits.py new file mode 100644 index 00000000000..de0d50577eb --- /dev/null +++ b/policyengine_us/variables/household/income/person/long_term_care/taxable_long_term_care_per_diem_benefits.py @@ -0,0 +1,26 @@ +from policyengine_us.model_api import * + + +class taxable_long_term_care_per_diem_benefits(Variable): + value_type = float + entity = Person + label = "Taxable per diem long-term care benefits" + documentation = "Form 8853 Section C: per diem payments above the greater of the daily limit times days and actual costs, less reimbursements (Schedule 1 line 8e)." + unit = USD + definition_period = YEAR + reference = ( + "https://www.law.cornell.edu/uscode/text/26/7702B#d", + "https://www.irs.gov/instructions/i8853", + ) + + def formula(person, period, parameters): + limit = parameters(period).gov.irs.gross_income.long_term_care_per_diem_limit + benefits = max_(0, person("long_term_care_per_diem_benefits", period)) + daily_limit = limit * person("long_term_care_per_diem_days", period) + costs = max_(0, person("long_term_care_qualified_costs", period)) + excludable = max_( + 0, + max_(daily_limit, costs) + - max_(0, person("long_term_care_cost_reimbursements", period)), + ) + return max_(0, benefits - excludable) diff --git a/policyengine_us/variables/household/income/person/misc/us_bonds_for_higher_ed.py b/policyengine_us/variables/household/income/person/misc/us_bonds_for_higher_ed.py index 886f5305181..a2c903c1878 100644 --- a/policyengine_us/variables/household/income/person/misc/us_bonds_for_higher_ed.py +++ b/policyengine_us/variables/household/income/person/misc/us_bonds_for_higher_ed.py @@ -8,3 +8,18 @@ class us_bonds_for_higher_ed(Variable): unit = USD definition_period = YEAR reference = "https://www.law.cornell.edu/uscode/text/26/135" + documentation = ( + "Savings bond interest excluded under IRC 135 (Form 8815 line 14), " + "taken as a deduction from gross income. Set it directly, or set the " + "Form 8815 inputs (savings_bond_education_qualified_expenses and " + "related) for PolicyEngine to compute it; it is assigned to the head." + ) + + def formula(person, period, parameters): + proceeds = person.tax_unit("savings_bond_redemption_proceeds", period) + if not np.any(proceeds > 0): + # No Form 8815 inputs: skip the computation, which reads gross + # income, so callers without them see no change. + return np.zeros(person.count) + head = person("is_tax_unit_head", period) + return head * person.tax_unit("savings_bond_education_exclusion", period) diff --git a/scripts/lpl_income_tax_rules_household.py b/scripts/lpl_income_tax_rules_household.py new file mode 100644 index 00000000000..a2467f623ec --- /dev/null +++ b/scripts/lpl_income_tax_rules_household.py @@ -0,0 +1,90 @@ +"""Household example for the retirement, capital gain and lot-level rules. + +Run: python scripts/lpl_income_tax_rules_household.py [STATE] + +A single filer, age 45, has $90,000 of wages, a $20,000 early IRA +distribution with no exception, a $10,000 net gain on regulated futures +(section 1256 contracts) and two lots: +- a $1,000 qualified dividend on stock held 50 days around the ex-date, and +- a $1,000 short-term loss sale repurchased 10 days later (a wash sale). + +"Before" is how a caller without the new fields reports this: the futures +gain as short-term, the dividend as qualified, the loss deducted, and no +early-distribution tax. "After" sends the new fields; the lot results are +folded in with apply_investment_lot_adjustments. +""" + +import sys + +from policyengine_us import Simulation +from policyengine_us.tools.investment_lots import apply_investment_lot_adjustments + +YEAR = 2026 +STATE = sys.argv[1] if len(sys.argv) > 1 else "TX" + + +def situation(after: bool) -> dict: + person = { + "age": 45, + "employment_income": 90_000, + "taxable_ira_distributions": 20_000, + "qualified_dividend_income": 1_000, + } + if after: + person.update( + { + "early_distributions_from_retirement_plans": 20_000, + "section_1256_net_gain": 10_000, + "dividend_lot_1_qualified_dividends_reported": 1_000, + "dividend_lot_1_days_held_in_window": 50, + "wash_sale_1_loss": 1_000, + "wash_sale_1_shares_sold": 100, + "wash_sale_1_sale_day": 9_400, + "wash_sale_1_purchase_1_day": 9_410, + "wash_sale_1_purchase_1_shares": 100, + } + ) + else: + person.update({"short_term_capital_gains": 10_000 - 1_000}) + return { + "people": {"filer": {k: {str(YEAR): v} for k, v in person.items()}}, + "tax_units": { + "tax_unit": {"members": ["filer"], "filing_status": {str(YEAR): "SINGLE"}} + }, + "households": { + "household": {"members": ["filer"], "state_code": {str(YEAR): STATE}} + }, + } + + +def results(after: bool) -> dict: + sit = situation(after) + if after: + sit = apply_investment_lot_adjustments(sit, YEAR) + sim = Simulation(situation=sit) + + def calc(variable): + return float(sim.calculate(variable, YEAR).sum()) + + out = { + "Federal AGI": calc("adjusted_gross_income"), + "Long-term capital gains": calc("long_term_capital_gains"), + "Short-term capital gains": calc("short_term_capital_gains"), + "Qualified dividends": calc("qualified_dividend_income"), + "Taxable income": calc("taxable_income"), + "Early distribution tax": calc("form_5329_additional_taxes"), + "Federal income tax": calc("income_tax"), + } + if STATE == "CA": + out["CA early distribution tax"] = calc("ca_early_distribution_additional_tax") + out["State income tax"] = calc("state_income_tax") + return out + + +if __name__ == "__main__": + before, after = results(False), results(True) + print(f"{STATE} {YEAR}, single filer") + print(f"{'':28}{'before':>14}{'after':>14}{'change':>12}") + for label in after: + b, a = before.get(label, 0.0), after[label] + print(f"{label:28}{b:>14,.2f}{a:>14,.2f}{a - b:>12,.2f}") diff --git a/scripts/us_govt_fund_dividends_household.py b/scripts/us_govt_fund_dividends_household.py new file mode 100644 index 00000000000..d18935b27c7 --- /dev/null +++ b/scripts/us_govt_fund_dividends_household.py @@ -0,0 +1,95 @@ +"""Household example: a state subtraction for mutual fund dividends attributable +to U.S. government obligations, through the normal Simulation API. + +Run: python scripts/us_govt_fund_dividends_household.py [STATE] + +A single filer in the state (default NY) has $100,000 of wages and $3,000 of +ordinary dividends from two funds in a taxable account: + +- Fund 1, a Treasury fund: $1,000 of dividends, 35% from U.S. government + obligations, at exactly 50% of assets in U.S. government obligations at + every fiscal quarter-end. It passes the 50% test. +- Fund 2, a government money market fund: $2,000 of dividends, 80% from U.S. + government obligations, 49.99% at one quarter-end. It fails, though its + annual income share is above 50%. + +"Before" omits the fund fields, which is how an existing caller looks; "after" +adds them. Only fund 1 contributes: $1,000 x 35% = $350. +""" + +import sys + +from policyengine_us import Simulation + +YEAR = "2026" +STATE = sys.argv[1] if len(sys.argv) > 1 else "NY" + +# The fields the portfolio simulator sends for each fund slot, per person. +FUND_FIELDS = { + # Fund 1: passes at exactly 50% every quarter-end. + "us_govt_fund_1_ordinary_dividends": 1_000, + "us_govt_fund_1_govt_income_share": 0.35, + "us_govt_fund_1_govt_asset_share_q1": 0.50, + "us_govt_fund_1_govt_asset_share_q2": 0.50, + "us_govt_fund_1_govt_asset_share_q3": 0.50, + "us_govt_fund_1_govt_asset_share_q4": 0.50, + "us_govt_fund_1_asset_test_evidence": "QUARTERLY_ASSET_SHARES", + "us_govt_fund_1_qualified_fund_of_funds": False, + # Fund 2: fails in quarter 2. + "us_govt_fund_2_ordinary_dividends": 2_000, + "us_govt_fund_2_govt_income_share": 0.80, + "us_govt_fund_2_govt_asset_share_q1": 0.70, + "us_govt_fund_2_govt_asset_share_q2": 0.4999, + "us_govt_fund_2_govt_asset_share_q3": 0.70, + "us_govt_fund_2_govt_asset_share_q4": 0.70, + "us_govt_fund_2_asset_test_evidence": "QUARTERLY_ASSET_SHARES", + "us_govt_fund_2_qualified_fund_of_funds": False, +} + + +def situation(with_funds: bool) -> dict: + person = { + "age": 45, + "employment_income": 100_000, + # The simulator already reports every fund dividend here. + "non_qualified_dividend_income": 3_000, + } + if with_funds: + person.update(FUND_FIELDS) + return { + "people": {"filer": {k: {YEAR: v} for k, v in person.items()}}, + "tax_units": { + "tax_unit": {"members": ["filer"], "filing_status": {YEAR: "SINGLE"}} + }, + "households": { + "household": {"members": ["filer"], "state_code": {YEAR: STATE}} + }, + } + + +def results(with_funds: bool) -> dict: + sim = Simulation(situation=situation(with_funds)) + s = STATE.lower() + + def calc(variable): + return float(sim.calculate(variable, int(YEAR)).sum()) + + return { + "Federal AGI": calc("adjusted_gross_income"), + "State fund dividend subtraction": calc( + f"{s}_us_govt_fund_dividend_subtraction" + ), + "State AGI": calc(f"{s}_agi"), + "State taxable income": calc(f"{s}_taxable_income"), + "State income tax": calc(f"{s}_income_tax"), + } + + +if __name__ == "__main__": + before = results(with_funds=False) + after = results(with_funds=True) + print(f"{STATE} {YEAR}, single filer") + print(f"{'':34}{'before':>14}{'after':>14}{'change':>12}") + for label in before: + b, a = before[label], after[label] + print(f"{label:34}{b:>14,.2f}{a:>14,.2f}{a - b:>12,.2f}")