Usage Metering & Billing Pipeline  ·  View 13 of 22  ·  Runtime

Invoice Run

Period close to downstream hand-off, with the hold path that makes the gate real.

Editable source SVG draw.io All views
Close Lateness bound elapsed? Close aggregates provisional cleared Price Rate per account parallel, idempotent Apply credits documented order Commitment drawdown Draft Assemble invoice draft state Anomaly report vs own history Review Finance controller Issue, or hold? Held for restatement Issue Issue invoice immutable from here Invoice ledger Hand off Outbox replayable Payment & tax ERP & revrec hold re-rate nightly Invoice Run — Close to Hand-Off Decision point Application we own Person or role Risk / gap Data store Queue / topic External / third party failure / alternate batch The run is resumable and keyed on account plus period, so an interruption re-enters where it stopped and never invoices an account twice. v 1.0 · owner Architecture Practice · date 2026-10

Decisions

  • The run is idempotent and resumable, keyed on account plus period. An interruption re-enters where it stopped and cannot invoice an account twice — which is the difference between a retryable job and a financial incident.
  • The draft state with an anomaly report is not ceremony: it is where a wrong figure costs a re-rate instead of a credit memo.
  • Rating is parallel per account because that is the axis that scales with the business; the run's 6-hour budget assumes it.
  • Credits and commitment drawdown apply after rating and in a documented order, so the same usage always consumes the same grants.

Assumptions

  • 1.5 million accounts closed within 6 hours of period close (stated assumption), with an RTO of 4 hours for the run itself — the slack is deliberate.
  • A held account is re-rated rather than issued late, so a hold never silently becomes a missed invoice.

Risks

  • A monthly cycle concentrates the entire run into one window; a defect found in it has hours, not days. Staggered cycle anchors would spread the risk and are not in the MVP.
  • The anomaly report is only as good as its baseline. A fast-growing account trips it every month and trains reviewers to approve, which is the most likely way a real error gets through.