Skip to content

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

L2 Checks passed 3 of 3 runsv1.0.0Tech-Realm/space-billing-and-subscriptions-public

Install

logicpacks pack use billing-and-subscriptions-public/price-usage-with-tiers-and-invoice
get_pack billing-and-subscriptions-public/price-usage-with-tiers-and-invoice

The 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

  1. Define the plan (base, metered metrics with tiers + mode, tax_pct) as JSON.
  2. Aggregate usage per period (e.g. from token-management usage CSV).
  3. billing.py invoice plan.json usage.json -> lines, subtotal, tax, total (cents).
  4. 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.