Money & Payments ยท zero-dependency ยท MIT

larzdiscount

Stack discounts and promos correctly, to the cent.

Applies an ordered list of discounts to a subtotal, each to the running total so stacking order is honest and visible. Percentage (with caps and minimum-spend gating), fixed-amount, and spend-based tiered discounts; the total never goes below zero and every breakdown reconciles.

larzscript pkg install discount
View on GitHub →Learn the stack

What you get

Try it

import "discount" as discount
let rules = [
  {"type": "percent", "value": 10, "min_spend": 0, "cap": nil},
  {"type": "fixed", "value": 500, "min_spend": 2000, "cap": nil}
]
let r = discount.apply(10000, rules)
print("total:", r["total"])
print("applied", len(r["applied"]), "rules")
Output
total: 8500
applied 2 rules

Why it's in the Larz Stack

larzdiscount is a real Larzscript package (larzscript pkg install discount) - 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.