larztax
Sales tax / VAT / GST, done correctly to the cent.
Build a stack of taxes, then add them onto a tax-exclusive price or extract them from a tax-inclusive one. Handles compound taxes that stack on the running total, rounds each line half-up, and absorbs any drift into the final line so net plus taxes always equals the gross exactly.
larzscript pkg install tax
What you get
- Inclusive and exclusive tax
- Compound taxes (tax on tax)
- Every breakdown reconciles exactly
- Ships no rate tables - math only
Try it
import "tax" as tax print(tax.exclusive($100.00, 0.08)) print(tax.inclusive($108.00, 0.08)) print(tax.compound($100.00, [0.05, 0.1]))
Output
{base: $100.00, tax: $8.00, total: $108.00}
{base: $100.00, tax: $8.00, total: $108.00}
{base: $100.00, taxes: [{rate: 0.05, amount: $5.00}, {rate: 0.1, amount: $10.50}], total: $115.50}Why it's in the Larz Stack
larztax is a real Larzscript package (larzscript pkg install tax) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.