Skip to main content

Move an order to another warehouse

Trigger. PUT /v1/commerce/orders/:id with a different warehouseId.

Outbox. order.location.changed inside the update transaction. Payload includes the new warehouse id.

Listener. OrderFulfillmentListener.handleOrderLocationChanged, wrapped by IdempotentEventHandlerService as consumer fulfillment.order-location-changed.v1.

Observed rules​

  • If the order row’s warehouseId is no longer the event’s newWarehouseId, the listener returns. A later update won.
  • Every fulfillment order that is not already CANCELLED is set to CANCELLED, and its reservations are released.
  • Reservations held on the order itself are released. The comment says stock pinned to bins cannot follow the order.
  • For CONFIRMED, FULFILLED, or DELIVERED, the listener calls createFromOrder.
  • For earlier statuses it calls applyCreatedOrder. The items array on that call is empty. applyCreatedOrder does not use that array. It loads OrderItem rows for the order. Reservation runs only when the order is still PENDING and allocatesOwnedStock is true. A confirmed order takes the createFromOrder branch above instead. Details are on What an order status does to fulfillment.

The idempotent handler records ProcessedEvent. A retry of the same outbox event should not cancel and recreate again. A new location change is a new outbox event.