Packs / billing-and-subscriptions-public
price-usage-with-tiers-and-invoice
Price metered usage with graduated or volume tiers and produce an invoice with base fee, usage lines, proration and tax
Install
logicpacks pack use billing-and-subscriptions-public/price-usage-with-tiers-and-invoiceget_pack billing-and-subscriptions-public/price-usage-with-tiers-and-invoiceThe second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.
Keys it needs (names only)
None.
Playbooks included
- Spec:
spec/SPEC.md(goal, steps, edge cases, don’ts) - Routes:
stdlib - Checks: 2 in
outcome/checks.yaml - Code:
billing.py - Tools: python3
Usage, last 8 weeks
New: no recorded use yet.
Purpose (from spec/SPEC.md)
Price metered usage with graduated or volume tiers and produce an invoice with base fee, usage lines, proration and tax
Goal
Customers get a correct, explainable invoice for base plan + usage, including mid-period plan changes.
Steps
- Define the plan (base, metered metrics with tiers + mode, tax_pct) as JSON.
- Aggregate usage per period (e.g. from token-management usage CSV).
billing.py invoice plan.json usage.json-> lines, subtotal, tax, total (cents).- Render with documents/invoice.
Edge cases
- Graduated vs volume give different totals at tier edges: say which in the plan.
- Proration by days; credit the unused old plan, charge the new one.
Don'ts
- Don't use floats for money.
- Don't charge for unpriced metrics: fail instead.