← Back to all products
$29
Tax Calculator
Sales tax calculator with multi-jurisdiction support, exemption handling, and reporting.
JSONMarkdownPython
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 9 files
tax-calculator/
├── LICENSE
├── README.md
├── examples/
│ └── invoice_items.json
├── free-sample.zip
├── guide/
│ ├── 01_features.md
│ ├── 02_cli-reference.md
│ └── 03_buyer-types.md
├── index.html
└── src/
└── tax_calculator.py
📖 Documentation Preview README excerpt
Tax Calculator
Part of the Payment Stack by CodeVault
A multi-jurisdiction tax calculation engine supporting sales tax (US), VAT (EU/UK), and GST (AU/NZ/CA/IN). Handles geo-based rate lookups, product category adjustments, buyer exemptions, and multi-item invoice calculations.
Features
- 45+ country tax rates with standard and reduced tiers
- All 50 US state sales tax rates (including zero-tax states)
- 6 product categories with rate adjustments (digital, physical, food, education, etc.)
- 5 buyer types with exemption rules (individual, business, nonprofit, reseller, etc.)
- Tax-inclusive and tax-exclusive calculation modes
- Multi-item invoice tax calculation with per-line breakdowns
- Formatted currency output for USD, EUR, GBP, JPY, CAD, AUD
- No API calls — all rates stored locally for offline use
- Python stdlib only — zero dependencies
Quick Start
# Run the full demo
python src/tax_calculator.py --action demo
# Calculate tax for a US purchase
python src/tax_calculator.py --action calculate --country US --state CA --amount 9999
# Calculate VAT for a German purchase
python src/tax_calculator.py --action calculate --country DE --amount 5000
# Look up a country's tax rules
python src/tax_calculator.py --action lookup --country GB
# Calculate tax on a food product (reduced rate)
python src/tax_calculator.py --action calculate --country FR --amount 2000 --category food
# Calculate for a nonprofit (exempt)
python src/tax_calculator.py --action calculate --country US --state NY --amount 9999 --buyer-type nonprofit
# Process invoice from JSON
python src/tax_calculator.py --action invoice --country GB --input examples/invoice_items.json
# List all supported countries
python src/tax_calculator.py --action list-countries
# List US state rates
python src/tax_calculator.py --action list-us-states
CLI Reference
| Flag | Description |
|---|---|
--action, -a | Action to perform (required) |
--country | ISO 3166-1 alpha-2 country code (e.g. US, DE, AU) |
--state | State/province code (required for US) |
--amount | Amount in cents |
--category | Product category (default: digital_goods) |
--buyer-type | Buyer type for exemptions (default: individual) |
--tax-inclusive | Amount already includes tax (EU-style) |
... continues with setup instructions, usage examples, and more.
📄 Code Sample .py preview
src/tax_calculator.py
#!/usr/bin/env python3
"""
Tax Calculator — Payment Stack by DataNest
A multi-jurisdiction tax calculation engine supporting sales tax, VAT, and GST.
Handles geo-based rate lookups, product category exemptions, tax-inclusive
and tax-exclusive pricing, and formatted invoice line items.
Why this exists:
Tax calculation is deceptively complex. You need different rates for
different regions, different rules for digital vs. physical goods, and
exemptions for certain buyer types (nonprofits, resellers). Getting it
wrong means audit risk and unhappy customers. This tool codifies tax
rules into a deterministic calculator with clear audit output.
Usage:
python tax_calculator.py --action calculate --country US --state CA --amount 9999
python tax_calculator.py --action lookup --country DE
python tax_calculator.py --action invoice --input invoice_items.json
python tax_calculator.py --action demo
License: MIT
"""
from __future__ import annotations
import argparse
import json
import logging
import sys
from dataclasses import dataclass, field, asdict
from datetime import datetime, timezone
from enum import Enum
from pathlib import Path
from typing import Any, Optional
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
LOG = logging.getLogger("tax-calculator")
# ---------------------------------------------------------------------------
# Tax Types & Jurisdictions
# ---------------------------------------------------------------------------
class TaxType(str, Enum):
"""Types of consumption tax around the world."""
SALES_TAX = "sales_tax" # US-style: added on top of price
VAT = "vat" # EU-style: usually included in price
# ... 589 more lines ...