Prompt
How do I handle US sales tax and EU VAT in the same system?
Latest observation
To handle US sales tax and EU VAT in the same system, build your tax logic around a jurisdiction engine rather than a single “tax rate” field.
Core idea
Treat tax as the result of:
- Where the seller is established
- Where the customer is located
- What is being sold
- Whether the product/service is taxable
- Which tax regime applies (US state/local sales tax vs EU VAT)
1) Model taxes separately
US sales tax and EU VAT behave differently, so don’t force them into one calculation rule.
US sales tax
- Usually depends on:
- Seller nexus
- Shipping destination
- State/county/city/special district rates
- Product taxability
- Often not included in displayed price until checkout.
EU VAT
- Depends on:
- Supplier/customer location
- B2C vs B2B
- VAT registration status
- Goods vs digital services
- OSS/IOSS rules
- Often included in displayed price for consumer-facing pricing in Europe.
2) Use a unified tax decision flow
A good shared flow is:
- Identify customer country/state
- Classify transaction type
- B2C / B2B
- physical goods / digital service / SaaS / shipping
- Determine applicable regime
- US sales tax
- EU VAT
- other
- Resolve taxability rules
- Apply correct rate and display method
- exclusive tax for US
- inclusive or exclusive for EU depending on pricing model
- Store tax breakdown for audit/accounting
3) Keep tax configuration by jurisdiction
Create tables/config like:
jurisdictions- country, state, region, tax_type
tax_rates- jurisdiction_id, rate, effective_date
product_tax_codes- product type, tax exemption/treatment
customer_tax_status- VAT ID, exemption certificate, business/consumer
This lets you update rates without changing code.
4) Decide on price display strategy
You need to support both:
Tax-exclusive pricing
Common in the US:
- Base price: $100
- Tax: $8.25
- Total: $108.25
Tax-inclusive pricing
Common in the EU:
- Display price: €100
- VAT included: €16.67
- Net: €83.33
Your system should support both modes per market, not just one global setting.
5) Handle registration and compliance
You may need different compliance handling:
US
- Register in states where you have nexus
- File returns per state
- Track exemption certificates
EU
- Register for VAT in one or more countries, or use OSS for cross-border B2C sales
- Store VAT IDs and validate them via VIES
- Determine reverse charge for B2B when applicable
6) Build a tax calculation service
A separate service/module should:
- Accept cart lines, shipping address, billing address, customer type, VAT ID, product code
- Return:
- tax regime
- tax rate
- tax amount per line
- total tax
- reason/rule used
Example response:
{
"regime": "EU_VAT",
"country": "DE",
"rate": 0.19,
"taxable_amount": 100.00,
"tax_amount": 19.00,
"inclusive": true
}
7) Support exemptions and reverse charge
You need logic for:
- US tax-exempt customers with certificates
- EU B2B reverse charge
- Zero-rated or exempt goods/services
- Cross-border digital service rules
Store exemption evidence and audit trail.
8) Be careful with rounding
Tax rules vary on rounding:
- Per line item vs per invoice
- Two-decimal rounding vs jurisdiction-specific methods
Pick one consistent method and make it configurable.
9) Use a tax engine if you can
For production systems, consider using:
- Avalara
- TaxJar
- Stripe Tax
- Vertex
- EU VAT/tax services
These can reduce compliance burden, especially for state-by-state US rules and EU VAT complexity.
10) Minimum viable implementation
If you're building it yourself, start with:
- Address validation
- Country/state-based jurisdiction detection
- Product tax codes
- Customer tax status
- Separate US vs EU rule sets
- Tax-inclusive/exclusive pricing support
- Audit logging
Suggested architecture
- Checkout service: gathers address and cart data
- Tax service: determines regime and computes tax
- Pricing service: handles inclusive/exclusive display
- Compliance data store: rates, registrations, VAT IDs, exemptions
- Ledger/accounting export: posts net tax collected by jurisdiction
If you want, I can also give you:
- a database schema for this,
- a sample tax calculation algorithm, or
- a TypeScript/Python implementation skeleton.