Interface SkuInventoryAdjustmentService<I extends SkuInventory>
- All Known Implementing Classes:
DefaultSkuInventoryAdjustmentService
public interface SkuInventoryAdjustmentService<I extends SkuInventory>
This service handles serializing updates to individual
SkuInventory
records. This handles
business logic associated with incrementing or decrementing inventory based on the type of
InventoryTransaction
being requested. This component may interact directly with a
Repository
to ensure that records are locked for update. As a result, this component is
typically transactional, and may create a new transaction on every request. Callers are urged to
keep track of successful InventoryTransaction
results to apply a compensating transaction
if necessary. The batchId can assist with this.- Author:
- Kelly Tisdell (ktisdell)
-
Method Summary
Modifier and TypeMethodDescriptioncancelInventory
(Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryAdjustmentRequestItems, String batchId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Perform the cancel of inventory to remove reserved quantity.createHardReservations
(Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryReservationRequestItems, String batchId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hard reservations that represent final inventory reservations.createSoftReservations
(Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryReservationRequestItems, String batchId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Soft reservations that represent temporary inventory reservations.createSoftReservations
(Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryReservationRequestItems, Map<String, List<InventoryTransaction>> existingSoftReservationsByReference, String batchId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Soft reservations that represent temporary inventory reservations.void
freeSoftReservations
(List<InventoryTransaction> softReservations, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Release soft reservations and add back to on-hand quantity.fulfillInventory
(Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryAdjustmentRequestItems, String batchId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Perform the fulfillment of inventory to remove reserved quantity and decrement on-hand quantity.returnInventory
(Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryAdjustmentRequestItems, String batchId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Perform the return of inventory to add back on-hand quantity.
-
Method Details
-
createSoftReservations
List<InventoryTransaction> createSoftReservations(@NonNull Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryReservationRequestItems, @NonNull String batchId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InventoryUnavailableExceptionSoft reservations that represent temporary inventory reservations.- Parameters:
skuInventoryReservationRequestItems
- - the key to the map is theSkuInventory
that needs to be updated (pre-determined outside of this method).batchId
- identifier for the current batch of items updating inventorycontextInfo
- the context around sandboxing and multitenant state- Returns:
- the created inventory transactions
- Throws:
InventoryUnavailableException
- if there was insufficient inventory to be reserved
-
createSoftReservations
List<InventoryTransaction> createSoftReservations(@NonNull Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryReservationRequestItems, Map<String, throws InventoryUnavailableExceptionList<InventoryTransaction>> existingSoftReservationsByReference, @NonNull String batchId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Soft reservations that represent temporary inventory reservations.- Parameters:
skuInventoryReservationRequestItems
- - the key to the map is theSkuInventory
that needs to be updated (pre-determined outside of this method).existingSoftReservationsByReference
- the existing soft reservations grouped by reference numberbatchId
- identifier for the current batch of items updating inventorycontextInfo
- the context around sandboxing and multitenant state- Returns:
- the created inventory transactions
- Throws:
InventoryUnavailableException
- if there was insufficient inventory to be reserved
-
createHardReservations
List<InventoryTransaction> createHardReservations(@NonNull Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryReservationRequestItems, @NonNull String batchId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InventoryUnavailableExceptionHard reservations that represent final inventory reservations.- Parameters:
skuInventoryReservationRequestItems
- - the key to the map is theSkuInventory
that needs to be updated (pre-determined outside of this method).batchId
- identifier for the current batch of items updating inventorycontextInfo
- the context around sandboxing and multitenant state- Returns:
- the created inventory transactions
- Throws:
InventoryUnavailableException
- if there was insufficient inventory to be reserved
-
fulfillInventory
List<InventoryTransaction> fulfillInventory(@NonNull Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryAdjustmentRequestItems, @NonNull String batchId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InventoryUnavailableException, InventoryNotReservedExceptionPerform the fulfillment of inventory to remove reserved quantity and decrement on-hand quantity.- Parameters:
skuInventoryAdjustmentRequestItems
- - the key to the map is theSkuInventory
that needs to be updated (pre-determined outside of this method).batchId
- identifier for the current batch of items updating inventorycontextInfo
- the context around sandboxing and multitenant state- Returns:
- the created inventory transactions
- Throws:
InventoryUnavailableException
- if there was insufficient inventory reserved or on handInventoryNotReservedException
- if there were not already hard reservations for these inventory items
-
cancelInventory
List<InventoryTransaction> cancelInventory(@NonNull Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryAdjustmentRequestItems, @NonNull String batchId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InventoryUnavailableException, InventoryNotReservedExceptionPerform the cancel of inventory to remove reserved quantity.- Parameters:
skuInventoryAdjustmentRequestItems
- - the key to the map is theSkuInventory
that needs to be updated (pre-determined outside of this method).batchId
- identifier for the current batch of items updating inventorycontextInfo
- the context around sandboxing and multitenant state- Returns:
- the created inventory transactions
- Throws:
InventoryUnavailableException
- if there was insufficient inventory reservedInventoryNotReservedException
- if there were not already hard reservations for these inventory items
-
returnInventory
List<InventoryTransaction> returnInventory(@NonNull Map<I, List<SkuInventoryAdjustmentRequestItem>> skuInventoryAdjustmentRequestItems, @NonNull String batchId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Perform the return of inventory to add back on-hand quantity.- Parameters:
skuInventoryAdjustmentRequestItems
- - the key to the map is theSkuInventory
that needs to be updated (pre-determined outside of this method).batchId
- identifier for the current batch of items updating inventorycontextInfo
- the context around sandboxing and multitenant state- Returns:
- the created inventory transactions
-
freeSoftReservations
void freeSoftReservations(@NonNull List<InventoryTransaction> softReservations, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Release soft reservations and add back to on-hand quantity. Note that this archives the soft reservation in-place, no new inventory transactions are created.- Parameters:
softReservations
- the soft reservations to freecontextInfo
- the context around sandboxing and multitenant state
-