Skip to main content

Order business rules

Confirmed by code​

Implementation behavior

Status changes are accepted only when VALID_ORDER_TRANSITIONS contains the edge, or when the current status is null. The null case returns true.

Status

Enforced in both state-machine files.

Implementation behavior

CANCELLED can transition to REFUNDED. Several earlier statuses cannot go directly to REFUNDED. From RETURN_RECEIVED, PARTIALLY_RETURNED, and RETURNED, refund statuses are allowed. From PENDING or CONFIRMED, they are not.

Business intent

The repository does not say why CANCELLED is the non-return path into REFUNDED.

Status

Requires business confirmation.

Implementation behavior

DISPUTED can return to PENDING, and can go to REFUNDED or CLOSED.

Business intent

Whether operators may click that edge, or only a system flow may, is not established.

Status

Requires business confirmation.

Implementation behavior

Create and status writes that need side effects enqueue outbox rows in the same transaction. The worker dispatches them.

Status

Project rule in AGENTS.md and the command services that call outboxWriter.enqueue(tx, ...).

Inferred​

  • Admin and warehouse do not apply a second state machine. They call the API.
  • CHANNEL_FULFILLED does not reserve owned stock. resolveFulfillmentMode sets that mode for AFN, FBA, and the other partner descriptors in fulfillment-mode.util.ts. See What an order status does to fulfillment.

Unknown​

  • Reservation on create runs only for a PENDING order whose fulfillment mode allocates owned stock (OMS_MANAGED and any mode other than CHANNEL_FULFILLED and VENDOR_DROPSHIP). See What an order status does to fulfillment.
  • Create-order idempotency key.
  • Whether cancelling a partially fulfilled order restocks picked units.
  • Which transitions the admin UI offers.
  • What a wallet token costs, and whether a failed label refunds it. The debit is on order.confirmed, which is before the label.