Tax is not applied to tax-exempt products
Why it matters
Charging sales tax on groceries in states like Texas or California — where food sold for home consumption is exempt — is a regulatory compliance failure that overcharges customers and exposes the store to audit liability. IRS Publication 334 and state-level tax codes define categories of exempt goods (groceries, prescription drugs, clothing in some states, medical devices). When the product schema has no is_tax_exempt flag, the tax calculation applies the full rate to every line item, making exemption enforcement impossible without a code change for each new product type added to the catalog. CWE-682 applies: the calculation is incorrect for exempt products.
Severity rationale
Critical because taxing exempt product categories violates state-specific sales tax rules, exposing the business to regulatory audit penalties and class-action refund claims from systematically overcharged customers.
Remediation
Add a tax exemption flag to the product schema and reference it in lib/tax.ts:
-- Migration
ALTER TABLE products ADD COLUMN is_tax_exempt BOOLEAN NOT NULL DEFAULT FALSE;
// lib/tax.ts
function calculateTax(
items: OrderItem[],
address: Address
): number {
const taxableSubtotal = items.reduce((sum, item) => {
return sum + (item.is_tax_exempt ? 0 : item.price * item.quantity)
}, 0)
const rate = getTaxRate(address)
return Math.round(taxableSubtotal * rate)
}
Seed exempt products with is_tax_exempt = true during data entry and verify the calculation result is lower than the full-cart total for a cart that contains exempt items. Do not rely on product name pattern-matching to determine exemption — use the schema field.
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 · irs-publication-334-tax-exempt-products — IRS Publication 334 and state sales tax exemption statutes — product-level tax exemptions (groceries, prescriptions, clothing)
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ecommerce-shipping-tax·automated