Car sales tax in five US states, as pure functions (and the rules that look alike but aren't)
Description and use
A modular calculator for car purchase cost that accurately reflects diverse state tax rules, implemented as separate pure functions with JSON parameters.
Problem
Designing a calculator for total car purchase cost that correctly handles diverse state tax rules.
Outcome
A modular, testable calculator that accurately reflects each state’s tax rules.
Workflow
- Read statutes to identify tax bases, local rates, fee shapes, and flat taxes.
- Define a small pure function per state with a common signature.
- Store state‑specific parameters in JSON alongside source citations.
- Write tests from hand‑worked examples.
- Use the functions to generate line items for UI.
- Maintain readability and extensibility.
Evidence
Reading the statutes first made it clear that one formula with a few parameters per state wouldn't hold up: the states differ in what they tax, which local rate applies and how fees are shaped.
One function per state stays readable.
- Record date: 2026-11-02T02:43:54.061Z