Functional Weave
Code in Rust

retail.sales-tax-us@1.1.1

vectors.json

6,685 bytes · view raw

[
  {"name": "California's 7.25% base on 100.00", "args": [{"minor": 10000, "currency": "USD"}, "CA", 0, "2026-09-01"], "expect": {"state": "CA", "stateRatePerMillion": 72500, "localRatePerMillion": 0, "combinedRatePerMillion": 72500, "taxable": {"minor": 10000, "currency": "USD"}, "tax": {"minor": 725, "currency": "USD"}, "total": {"minor": 10725, "currency": "USD"}}},
  {"name": "California with a 1.5% local district rate", "args": [{"minor": 10000, "currency": "USD"}, "CA", 15000, "2026-09-01"], "expect": {"state": "CA", "stateRatePerMillion": 72500, "localRatePerMillion": 15000, "combinedRatePerMillion": 87500, "taxable": {"minor": 10000, "currency": "USD"}, "tax": {"minor": 875, "currency": "USD"}, "total": {"minor": 10875, "currency": "USD"}}},
  {"name": "New York City's 8.875% needs more precision than basis points", "args": [{"minor": 1999, "currency": "USD"}, "NY", 48750, "2026-09-01"], "expect": {"state": "NY", "stateRatePerMillion": 40000, "localRatePerMillion": 48750, "combinedRatePerMillion": 88750, "taxable": {"minor": 1999, "currency": "USD"}, "tax": {"minor": 177, "currency": "USD"}, "total": {"minor": 2176, "currency": "USD"}}},
  {"name": "an exact half cent rounds up: 6.25% of 0.40 is 2.5 cents", "args": [{"minor": 40, "currency": "USD"}, "TX", 0, "2026-09-01"], "expect": {"state": "TX", "stateRatePerMillion": 62500, "localRatePerMillion": 0, "combinedRatePerMillion": 62500, "taxable": {"minor": 40, "currency": "USD"}, "tax": {"minor": 3, "currency": "USD"}, "total": {"minor": 43, "currency": "USD"}}},
  {"name": "Minnesota's 6.875% on 10.00 is 68.75 cents", "args": [{"minor": 1000, "currency": "USD"}, "MN", 0, "2026-09-01"], "expect": {"state": "MN", "stateRatePerMillion": 68750, "localRatePerMillion": 0, "combinedRatePerMillion": 68750, "taxable": {"minor": 1000, "currency": "USD"}, "tax": {"minor": 69, "currency": "USD"}, "total": {"minor": 1069, "currency": "USD"}}},
  {"name": "Missouri's 4.225% on 1.00", "args": [{"minor": 100, "currency": "USD"}, "MO", 0, "2026-09-01"], "expect": {"state": "MO", "stateRatePerMillion": 42250, "localRatePerMillion": 0, "combinedRatePerMillion": 42250, "taxable": {"minor": 100, "currency": "USD"}, "tax": {"minor": 4, "currency": "USD"}, "total": {"minor": 104, "currency": "USD"}}},
  {"name": "New Mexico with a four-decimal local rate: 8.3125% of 50.00 is 415.625 cents", "args": [{"minor": 5000, "currency": "USD"}, "NM", 34375, "2026-09-01"], "expect": {"state": "NM", "stateRatePerMillion": 48750, "localRatePerMillion": 34375, "combinedRatePerMillion": 83125, "taxable": {"minor": 5000, "currency": "USD"}, "tax": {"minor": 416, "currency": "USD"}, "total": {"minor": 5416, "currency": "USD"}}},
  {"name": "Oregon has no sales tax", "args": [{"minor": 10000, "currency": "USD"}, "OR", 0, "2026-09-01"], "expect": {"state": "OR", "stateRatePerMillion": 0, "localRatePerMillion": 0, "combinedRatePerMillion": 0, "taxable": {"minor": 10000, "currency": "USD"}, "tax": {"minor": 0, "currency": "USD"}, "total": {"minor": 10000, "currency": "USD"}}},
  {"name": "Alaska has no state tax but local ones", "args": [{"minor": 2000, "currency": "USD"}, "AK", 50000, "2026-09-01"], "expect": {"state": "AK", "stateRatePerMillion": 0, "localRatePerMillion": 50000, "combinedRatePerMillion": 50000, "taxable": {"minor": 2000, "currency": "USD"}, "tax": {"minor": 100, "currency": "USD"}, "total": {"minor": 2100, "currency": "USD"}}},
  {"name": "the District of Columbia", "args": [{"minor": 1500, "currency": "USD"}, "DC", 0, "2026-09-01"], "expect": {"state": "DC", "stateRatePerMillion": 60000, "localRatePerMillion": 0, "combinedRatePerMillion": 60000, "taxable": {"minor": 1500, "currency": "USD"}, "tax": {"minor": 90, "currency": "USD"}, "total": {"minor": 1590, "currency": "USD"}}},
  {"name": "Louisiana at 5% after its 2025 rise", "args": [{"minor": 1000, "currency": "USD"}, "LA", 0, "2026-09-01"], "expect": {"state": "LA", "stateRatePerMillion": 50000, "localRatePerMillion": 0, "combinedRatePerMillion": 50000, "taxable": {"minor": 1000, "currency": "USD"}, "tax": {"minor": 50, "currency": "USD"}, "total": {"minor": 1050, "currency": "USD"}}},
  {"name": "a refund gives negative tax, rounded away from zero", "args": [{"minor": -10000, "currency": "USD"}, "CA", 0, "2026-09-01"], "expect": {"state": "CA", "stateRatePerMillion": 72500, "localRatePerMillion": 0, "combinedRatePerMillion": 72500, "taxable": {"minor": -10000, "currency": "USD"}, "tax": {"minor": -725, "currency": "USD"}, "total": {"minor": -10725, "currency": "USD"}}},
  {"name": "a zero amount has zero tax", "args": [{"minor": 0, "currency": "USD"}, "WA", 0, "2026-09-01"], "expect": {"state": "WA", "stateRatePerMillion": 65000, "localRatePerMillion": 0, "combinedRatePerMillion": 65000, "taxable": {"minor": 0, "currency": "USD"}, "tax": {"minor": 0, "currency": "USD"}, "total": {"minor": 0, "currency": "USD"}}},
  {"name": "the first day of the data", "args": [{"minor": 10000, "currency": "USD"}, "CO", 0, "2026-01-01"], "expect": {"state": "CO", "stateRatePerMillion": 29000, "localRatePerMillion": 0, "combinedRatePerMillion": 29000, "taxable": {"minor": 10000, "currency": "USD"}, "tax": {"minor": 290, "currency": "USD"}, "total": {"minor": 10290, "currency": "USD"}}},
  {"name": "an unknown state is an error", "args": [{"minor": 100, "currency": "USD"}, "XX", 0, "2026-09-01"], "expectError": "unknown US state \"XX\""},
  {"name": "state codes are uppercase", "args": [{"minor": 100, "currency": "USD"}, "ca", 0, "2026-09-01"], "expectError": "unknown US state \"ca\""},
  {"name": "the amount must be in dollars", "args": [{"minor": 100, "currency": "GBP"}, "CA", 0, "2026-09-01"], "expectError": "US sales tax is charged in USD, received GBP"},
  {"name": "a negative local rate is an error", "args": [{"minor": 100, "currency": "USD"}, "CA", -1, "2026-09-01"], "expectError": "localRatePerMillion must be from 0 to 999999"},
  {"name": "a date before the data is refused, not answered with today's rate", "args": [{"minor": 100, "currency": "USD"}, "CA", 0, "2025-12-31"], "expectError": "no sales tax rate for CA on 2025-12-31"},
  {"name": "a malformed date is an error", "args": [{"minor": 100, "currency": "USD"}, "CA", 0, "2026-9-1"], "expectError": "onDate must be an ISO date (YYYY-MM-DD)"},
  {"name": "a trailing newline is not part of an ISO date (onDate)", "args": [{"minor": 100, "currency": "USD"}, "CA", 0, "2026-09-16\n"], "expectError": "onDate must be an ISO date (YYYY-MM-DD)"},
  {"name": "non-ASCII digits are not an ISO date (onDate)", "args": [{"minor": 100, "currency": "USD"}, "CA", 0, "٢٠٢٦-09-16"], "expectError": "onDate must be an ISO date (YYYY-MM-DD)"}
]