Orders and order lifecycle – system description

The order tables, lifecycle states, the provisioning steps, content filtering of the list, and the cancel, confirm and refund endpoints.

Overview

List and details of orders, payment confirmation, refund and cancellation. The order lifecycle is handled by the Dlbtorder library. Table names carry the installation's own prefix in the database.

Data model

TableRole
orderorder header: beneficiary, billed and payer client, state, payment method, totals
order_itemitems with list price, plan price, discounts, granted quantity
order_documentproforma and invoice

Lifecycle (Dlbtorder)

States: draft → pending_payment → paid → provisioned; side branches cancelled, failed. Methods: preview(), create() (Dlbtpricing recalculates the price), pay(), markPaid(), provision(), refund(), cancel(), issueProforma(), issueInvoice().

provision(): for a plan syncClientPlan or materialise(..., 'order', false); for an add-on package Dlbtresource::grant; for other items the ledger, for a function Dlbtentitlement::grant(..., 'order'); for a credit top-up the wallet.

Endpoints

  • order.list (list): filtered to the clients within content permission (getAllowedCompanyIds); filter is the company group and company pair (order.companies → shared company picker).
  • order.info (view): getOrder($id, $allowed); the invoice link only with finance/invoice::list.
  • order.cancel → Dlbtorder::cancel(id, 'admin'); order.confirm → Dlbtorder::markPaid(id, 'manual'), which also starts provisioning. Both need cancel + content permission.
  • order.refund (refund + content permission): Dlbtorder::refund(id, amount, reason, actor); error codes error_refund_*; the button also requires finance/invoice::list.

The keys (list, view, cancel, refund, debug) are not classified in the seeds.