Order Reservations and Allocations
When an order is created, it is typical that stock is reserved to be used as part of fulfilling the order. In order to achieve this, inventory must be set aside for pending orders.
In some cases, there can be a significant length of time between an order being placed, and the order being fulfilled. For example:
- An item is out of stock at all locations, with new stock expected sometime in future.
- An order has been specified as needing to be shipped on a specific date in future.
In such cases, it may be desirable to be sure that sufficient inventory is held across locations, without necessarily requiring a specific location to hold inventory for an extended period to fulfil a specific order.
This is the purpose of an order reservation. When the order enters the committed state, reservations for each line item are created. The reservations of items and corresponding quantities are reflected in the aggregate inventory levels (sum of inventory across all locations), but not at a location level as the location(s) that will fulfil the order have yet to be determined.
An order allocation is conceptually the same as an order reservation, with the difference being that allocations are tied to a location. When an allocation is created for an order, it states that the specified line items from the order are going to be packaged and fulfilled from the specified location.
Either directly after the order enters the committed state, or at a configurable time period prior to the order shipping date, the order is sent to the allocations service.
The allocations service is responsible for creating allocations from an order resource. It is responsible for the following:
- Retrieving the inventory items associated with a given product variant (as found in the order line items).
- Providing a routing mechanism for deciding which locations are used to fulfil the order.
- Geocoding the order (destination) address if the order address is used as part of the process (eg. routing orders to warehouses nearest to the delivery address).
- Querying the inventory service to determine which locations have sufficient stock levels for the required inventory items.
The allocations service routes orders to the location nearest to the order destination address that has sufficient inventory for the order line items. If no single inventory holds all the items in sufficient quantity, multiple allocations are created.
Future plans include support for alternative (custom/externally hosted) allocations services. That is to say, the routing aspect may be hosted on the organisation's servers, and implement customised routing logic. this is possible currently by using a combination of the webhooks functionality, inventory and allocation endpoints, though if this is a use case that is of particular interest to you, please contact us to discuss the scenario further.
Order fulfilments are created against order allocations. An order cannot have fulfilments created against it without first creating allocations.
Allocations can be modified to adjust items and quantities up until the point at which they are marked as completed. At this point it is not possible to modify the allocation further, and the inventory levels for the items in the allocation are permanently decreased.
The overall order reservation/allocation workflow can be summarised as follows: