Skip to main content

Reports

Read-only analytics reports over the separate analytical database (ADR 0012). Served by cmd/reports (:8092), never by the api.

📄️Authorize a return (AuthorizeReturn)

Authorizes one order group's return and publishes `ReturnAuthorized`. The group must be SHIPPED or DELIVERED (`group-not-shipped` otherwise); the lines are resolved against the placed group (`validation-failed` on an unknown lineNo) and the disposition is decided from the read models. A repeat of the same key and body replays the first answer when it was the 201. A refusal that depends on state that can change (`group-not-shipped`, `no-return-destination`, `validation-failed`, `concurrent-update`) is not stored -- the key is released and the same key and body executes again.

📄️Cancel a return (CancelReturn)

The shopper's cancellation, allowed while AUTHORIZED (before anything is in transit); publishes `ReturnCancelled` with reason `SHOPPER_REQUESTED` and answers `200` with the CANCELLED authorization. An authorization whose `expiresAt` passed untouched is cancelled by this very call with reason `EXPIRED` and also answers `200` (the lazy expiry IS the cancellation; this route never answers `authorization-expired`). Cancelling again, or after RECEIVED/CLOSED_KEEP, is `409 illegal-transition`.

📄️Returns performance per UTC day, reason Pareto and freshness

Per UTC day of the business instant (`authorizedAt`, `receivedAt`): the returns authorized (a return is born authorized, so this is both 'opened' and 'approved'), the returns received (`ReturnCompleted`) and, over the receipts whose authorization is also projected, the p50 and p95 of `receivedAt - authorizedAt` in seconds (`null` on a day without a sample; a negative duration counts as 0). `reasonPareto` ranks the range's authorizations by reason code, at most 5 entries; `share` is over ALL authorizations of the range. `freshness` is the projection's lag. Days without activity are omitted, an empty range answers empty arrays. The return RATE and the refund figures are deliberately absent: their facts are not in this context's own events (ADR 0012).