/** * Vela Payroll Engine — United States Tax Jurisdiction * * Based on IRS 2025 tax year. * Source: https://www.irs.gov/newsroom/irs-provides-tax-inflation-adjustments-for-tax-year-2025 * * Federal Income Tax — Single Filer * ┌──────────────────────────────────┬────────┐ * │ Taxable Income │ Rate │ * ├──────────────────────────────────┼────────┤ * │ $0 – $11,925 │ 10% │ * │ $11,926 – $48,475 │ 12% │ * │ $48,476 – $103,350 │ 22% │ * │ $103,351 – $197,300 │ 24% │ * │ $197,301 – $250,525 │ 32% │ * │ $250,526 – $626,350 │ 35% │ * │ $626,351 and over │ 37% │ * └──────────────────────────────────┴────────┘ * * Standard Deduction (Single): $15,000 (2025) * * FICA Taxes: * - Social Security: 6.2% employee + 6.2% employer on wages up to $176,100 * - Medicare: 1.45% employee + 1.45% employer (no cap) * - Additional Medicare Tax: 0.9% employee on wages over $200,000 (single) * * State Tax: Handled via optional `stateTaxRate` parameter (flat rate override). * Set to 0 for no-state-tax states (TX, FL, WA, NV, etc.) */ import { TaxJurisdiction, TaxBracket, DeductionLineItem, EmployerContribution, progressiveTaxCalc, round2, } from "../types"; const FEDERAL_BRACKETS: TaxBracket[] = [ { min: 0, max: 11_925, rate: 0.10 }, { min: 11_925, max: 48_475, rate: 0.12 }, { min: 48_475, max: 103_350, rate: 0.22 }, { min: 103_350, max: 197_300, rate: 0.24 }, { min: 197_300, max: 250_525, rate: 0.32 }, { min: 250_525, max: 626_350, rate: 0.35 }, { min: 626_350, max: null, rate: 0.37 }, ]; const STANDARD_DEDUCTION = 15_000; // 2025 single filer const SS_RATE = 0.062; // 6.2% employee + 6.2% employer const SS_WAGE_BASE = 176_100; // 2025 const MEDICARE_RATE = 0.0145; // 1.45% employee + 1.45% employer const ADDITIONAL_MEDICARE_RATE = 0.009; // 0.9% employee only const ADDITIONAL_MEDICARE_THRESHOLD = 200_000; // single filer export interface USTaxOptions { /** Flat state income tax rate (e.g. 0.05 for 5%). Set to 0 for no state tax. */ stateTaxRate?: number; /** State name for display purposes */ stateName?: string; } export class USTax implements TaxJurisdiction { readonly name = "United States"; readonly countryCode = "US"; readonly currency = "USD"; private stateTaxRate: number; private stateName: string; constructor(options?: USTaxOptions) { this.stateTaxRate = options?.stateTaxRate ?? 0.05; // default 5% this.stateName = options?.stateName ?? "State"; } calculate(grossAnnual: number): { deductions: DeductionLineItem[]; employerContributions: EmployerContribution[]; } { // 1. Federal Income Tax (on taxable income after standard deduction) const taxableIncome = Math.max(0, grossAnnual - STANDARD_DEDUCTION); const federalTax = progressiveTaxCalc(taxableIncome, FEDERAL_BRACKETS); // 2. Social Security (capped at wage base) const ssWages = Math.min(grossAnnual, SS_WAGE_BASE); const ssEmployee = round2(ssWages * SS_RATE); const ssEmployer = ssEmployee; // 3. Medicare (no cap) const medicareEmployee = round2(grossAnnual * MEDICARE_RATE); const medicareEmployer = medicareEmployee; // 4. Additional Medicare Tax (> $200k for single filer, employee only) let additionalMedicare = 0; if (grossAnnual > ADDITIONAL_MEDICARE_THRESHOLD) { additionalMedicare = round2( (grossAnnual - ADDITIONAL_MEDICARE_THRESHOLD) * ADDITIONAL_MEDICARE_RATE ); } // 5. State Income Tax (flat rate override) const stateTax = round2(grossAnnual * this.stateTaxRate); // Build deductions const deductions: DeductionLineItem[] = [ { name: "Federal Income Tax", amount: round2(federalTax), type: "tax", description: "IRS federal withholding (2025, single filer)", }, { name: "Social Security Tax", amount: ssEmployee, type: "tax", description: `6.2% on wages up to $${SS_WAGE_BASE.toLocaleString()}`, }, { name: "Medicare Tax", amount: medicareEmployee, type: "tax", description: "1.45% of gross wages", }, ]; if (additionalMedicare > 0) { deductions.push({ name: "Additional Medicare Tax", amount: additionalMedicare, type: "tax", description: "0.9% on wages over $200,000 (single)", }); } if (this.stateTaxRate > 0) { deductions.push({ name: `${this.stateName} State Income Tax`, amount: stateTax, type: "tax", description: `${(this.stateTaxRate * 100).toFixed(1)}% flat state rate`, }); } // Employer contributions const employerContributions: EmployerContribution[] = [ { name: "Social Security (Employer)", amount: ssEmployer, description: "6.2% matching contribution", }, { name: "Medicare (Employer)", amount: medicareEmployer, description: "1.45% matching contribution", }, ]; return { deductions, employerContributions }; } }