Tax computation excludes shipping costs unless jurisdiction requires shipping tax
Why it matters
Approximately 12 US states tax shipping charges; the remaining 38 do not. When shipping is always included in the taxable subtotal — or always excluded with no jurisdiction check — the store either overcharges customers in non-taxing states or under-collects tax in states like New York, Illinois, and Pennsylvania (CWE-682, ISO 25010:2011 functional correctness). The EU VAT Directive 2006/112/EC treats shipping as part of the taxable supply, applying a different rule than most US states. US state shipping taxability rules are jurisdiction-specific and cannot be flattened to a global default. When no code comment documents the shipping tax policy, the decision becomes invisible and unauditble.
Severity rationale
High because shipping tax treatment errors produce systematic over- or under-collection across every order that involves a jurisdiction with non-default shipping tax rules, compounding into audit exposure.
Remediation
Implement jurisdiction-aware shipping tax in lib/tax.ts with a documented configuration object:
// lib/tax.ts
// Source: state revenue authority rulings. Last reviewed: 2024-01.
// US states that tax shipping charges as of 2024:
const STATES_TAXING_SHIPPING = new Set(['NY', 'IL', 'PA', 'WA', 'GA', 'IN', 'TX', 'KS'])
function buildTaxableSubtotal(
items: OrderItem[],
shippingCents: number,
address: Address
): number {
const productSubtotal = items
.filter(i => !i.is_tax_exempt)
.reduce((sum, i) => sum + i.price * i.quantity, 0)
const taxShipping = address.country === 'US'
? STATES_TAXING_SHIPPING.has(address.state)
: true // EU VAT applies to shipping
return productSubtotal + (taxShipping ? shippingCents : 0)
}
Replace any global taxableSubtotal = productSubtotal + shippingCents with this function and add a comment citing the source of the jurisdiction list.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Shipping & Tax Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-682 — Incorrect Calculation
- iso-25010:2011 · functional-correctness — Functional Correctness (Functional Suitability)
- external · us-state-shipping-taxability-rules — US state-by-state shipping taxability rules — approximately 12 states tax shipping charges (NY, IL, PA, etc.); others do not
- external · eu-vat-directive-2006-112-ec — EU VAT Directive 2006/112/EC — VAT applies to shipping charges as ancillary supply
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ecommerce-shipping-tax·automated