Warehouse routing
WarehouseRouterService.determineWarehousesForOrder is the routing decision used when an order is held and when it is planned into fulfillment orders. The file comment says an older assignWarehouseToOrder used to pin order.warehouseId and made this splitter dead. This service is the one that runs now.
Rules that the code states
- Active warehouses are loaded with
deletedAt: null, ordered byprioritydescending, thencreatedAt. StockOwnership.EXTERNALis excluded from automatic routing. The comment says OMS pick and pack does not run in FBA or 3PL mirrors. An explicitorder.warehouseIdstill wins, including an FBA assignment.- If
order.warehouseIdpoints at an active warehouse, every line is assigned there. Shortfall is backordered at that warehouse, not sent to another site.EXTERNALis allowed on this explicit assignment. - Otherwise routing uses owned warehouses.
WarehouseChannelLocationrows withcontributesStocklimit the set. No mapping rows, or a filter that matches nothing, falls back to every owned warehouse so a bad mapping cannot leave the order unroutable. - Sort:
TenantSetting.preferredWarehouseIdfirst, then higherpriority. - Default
unstockedFulfillmentPolicywhen the tenant setting is missing isPASS_THROUGH.
How a line is split
- If one prioritized warehouse can cover every line (
shortfallAtis 0), the whole order stays there. - Otherwise each line takes stock from warehouses with
quantityAvailablegreater than 0, largest availability first. - Quantity nobody can cover is assigned to the primary warehouse. Primary is
preferredWarehouseIdwhen that warehouse is in the routable list, otherwise the first warehouse after the sort. The remainder isquantityBackorderedunless the line is pass-through or hold.
isLineUnstockedHold is true when policy is HOLD_AS_EXCEPTION and the line has no product, or the product manages stock and has no stock record. Products with manageStock false are not a hold.
isPassThroughOrHold is true for a missing product when policy is PASS_THROUGH or HOLD_AS_EXCEPTION, for manageStock false, and for a managed product with no stock record under those two policies. In that case the remainder is still assigned to the primary warehouse but quantityBackordered is 0.
What this is not
Setting a warehouse on the order later is Move an order. That cancels existing fulfillment orders. Routing here is the first assignment.
No HTTP route calls this service directly. It runs inside fulfillment planning.