Knowledge Base

Billing Flow Overview — From Hourly Sample to Invoice Line

This is the end-to-end picture of how a byte downloaded from a client's bucket becomes a line on their invoice. The details of each stage are in the Usage Billing Plugin and Package Setup & Pricing articles.

The flow

  1. Hourly collection — the cron samples every active storage service: egress/ingress counters straight from the storage server (MinIO/RustFS metrics), disk usage from Prometheus. Raw samples are stored as snapshots.
  2. Continuous rollup — after each pass, snapshots are aggregated into a per-bucket, per-month rollup: total egress, average storage (GiB-month), and — where billing is enabled — the billable overage and a money amount at the package's prices. Samples that cross a month boundary are split proportionally, so month totals are exact.
  3. Visibility — rollups are always visible: to staff on the S3 Usage pages, and to the client on their Usage tab (current + previous month, with the estimated amount). Nothing has been invoiced yet. The Storage column shows two values: the average occupied size of the bucket so far this month (all objects, including the objects stored in earlier months) and the GiB-month accrued so far. The GiB-month value grows through the month and equals the average size at month end. Disk billing uses the GiB-month value minus the included 1 TiB.
  4. Month closes — once a calendar month ends, its rollup is a closed month awaiting billing. The first sample of the new month calculates the closed month one last time, with the package prices and plugin settings of that moment. After that, a closed month does not change. A price or setting change made later does not apply to it.
  5. Invoice append — when Blesta generates an invoice that contains the storage service (typically the renewal invoice) and invoice integration is enabled, the plugin appends one line per unbilled closed month: egress overage and/or disk overage. The rollup is stamped with the invoice ID so it can never be billed twice. If staff billed a part of the month by hand before (see Bill now below), the line has only the rest of the month.
  6. After billing — a billed rollup is frozen. If its numbers ever change afterwards (late data, price edits), it is flagged for admin review instead of being silently re-billed.

What stops a charge

A month is only billed when all of these hold — otherwise it stays visible but uninvoiced:

  • Plugin toggles ON (collection + the egress and/or disk calculation + invoice integration),
  • Package fields ON (Billing Per Use / Bill Unlimited Disk Usage) with a price set,
  • The rollup is not flagged "review required" (missing samples, quota conflicts, or post-billing changes always flag; flagged months wait for a human).
  • The rollup is not on a manual billing hold (set from the rollup page; unlike the review flag it never clears on its own).

Bill now (manual billing)

Staff can bill usage at once, without a wait for the next renewal invoice. For example, bill the month to date before a cancellation, or bill a closed month now.

  • Where: on the rollup page (Tools > S3 Usage > View), in the Manual Billing section, click Bill Now. On the list, click Bill on a row, or tick rows and click Bill Selected.
  • Permission: the staff group needs the S3 Usage Billing: Bill Now permission (Settings > System > Staff > Staff Groups).
  • Confirmation: a dialog shows the lines and the total before Blesta creates the invoice.
  • The invoice: one new invoice for each client and currency, due today. Blesta sends it by email. Tick Add to an open, unpaid invoice of the service to add the lines to an open invoice that already bills the service. An invoice with a payment is never changed.
  • The current month: Bill Now bills the usage up to the last sample. At the month end, the automatic invoice line bills only the rest of the month.
  • Review flag: a rollup that needs review is billed only when you tick the review confirmation. The confirmation is recorded.
  • Hold: a rollup on hold cannot be billed, not even with the review confirmation. Release the hold first.
  • Audit: the Manual Billing section lists each manual bill: the date, the staff member, the invoice, the amount and the usage end time.

Why a client never pays twice

  • Each rollup keeps a billed so far amount. Each bill, manual or automatic, bills only the total minus this amount.
  • Two bills of the same rollup at the same time cannot both run. The second one bills nothing.
  • If the usage of a month becomes lower than the amount already billed, the rollup is flagged for review. Nothing is billed again.
  • If an invoice cannot be saved, the billed amount goes back. If a step stops half way, the usage stays marked as billed with no invoice. The manual bill list shows this bill as "Interrupted". Examine it, then bill the usage by hand.

Void a manual invoice

When you void a manual usage invoice, the usage of that invoice becomes unbilled again. You can then bill it again. If you set a voided invoice back to active, the rollup goes on hold, because the usage can then be on two invoices. Examine the invoices, then release the hold.

A deleted line on a manual invoice does not give the usage back. Void the invoice and bill again. If a later invoice already closed the month (the rollup shows its invoice number), the given-back usage cannot be billed from the plugin again. Add it to an invoice by hand in Blesta.

Rollout advice

Enable collection first and let it run for a while. Review the rollups and estimated amounts on the S3 Usage pages. Only then enable invoice integration — from that point, all unbilled closed months (including the ones you just reviewed) are appended to the next invoices.

Please rate this article to help us improve our Knowledge Base.

0 0