Skip to content

Multi-Location Order Fulfillment Strategy

  • Complexity: Moderate
  • Stack: Backend

As a business operator, I want orders to be fulfilled by splitting products across multiple warehouse locations so that orders succeed even when no single location has enough stock for every item.

Description

The OrderService uses a strategy pattern (OrderStrategy interface) to resolve which warehouse location fulfills each product in an order. Two strategies exist today:

  • SingleLocationStrategy - finds one warehouse that has all ordered products in sufficient quantity. Fails if no single location can cover the entire order.
  • MostAbundantStrategy - picks the warehouse with the highest stock for each product independently, so different products may ship from different locations. Fails if any product has insufficient stock across all locations.

Neither strategy handles the case where a single product's ordered quantity exceeds the stock at any one location but could be fulfilled by combining stock from multiple locations. This story adds a new MultiLocationStrategy that splits a product's quantity across several warehouses when needed.

Acceptance Criteria

  • [ ] A new strategy MultiLocationStrategy can be configured in the backend configuration
  • [ ] For each product, the strategy fulfills from the location with the most stock first, then continues to the next location until the full quantity is covered
  • [ ] An order with quantity exceeding any single location's stock is fulfilled by combining stock from multiple locations
  • [ ] Stock is deducted correctly from each contributing location
  • [ ] The resulting OrderDetail entries correctly reference the respective shipping locations and partial quantities
  • [ ] An order is rejected with a clear error if total stock across all locations is insufficient
  • [ ] Existing strategies (SingleLocationStrategy, MostAbundantStrategy) continue to work without changes
  • [ ] Edge cases are handled: product available at only one location, product out of stock everywhere, order with a single item vs. multiple items

Copyright © MSG Systems Romania AI Labs