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 Details

    • createSoftReservations

      List<InventoryTransaction> createSoftReservations(@NonNull Map<I,List<SkuInventoryAdjustmentRequestItem>> skuInventoryReservationRequestItems, @NonNull String batchId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InventoryUnavailableException
      Soft reservations that represent temporary inventory reservations.
      Parameters:
      skuInventoryReservationRequestItems - - the key to the map is the SkuInventory that needs to be updated (pre-determined outside of this method).
      batchId - identifier for the current batch of items updating inventory
      contextInfo - 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,List<InventoryTransaction>> existingSoftReservationsByReference, @NonNull String batchId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) throws InventoryUnavailableException
      Soft reservations that represent temporary inventory reservations.
      Parameters:
      skuInventoryReservationRequestItems - - the key to the map is the SkuInventory that needs to be updated (pre-determined outside of this method).
      existingSoftReservationsByReference - the existing soft reservations grouped by reference number
      batchId - identifier for the current batch of items updating inventory
      contextInfo - 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 InventoryUnavailableException
      Hard reservations that represent final inventory reservations.
      Parameters:
      skuInventoryReservationRequestItems - - the key to the map is the SkuInventory that needs to be updated (pre-determined outside of this method).
      batchId - identifier for the current batch of items updating inventory
      contextInfo - 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, InventoryNotReservedException
      Perform the fulfillment of inventory to remove reserved quantity and decrement on-hand quantity.
      Parameters:
      skuInventoryAdjustmentRequestItems - - the key to the map is the SkuInventory that needs to be updated (pre-determined outside of this method).
      batchId - identifier for the current batch of items updating inventory
      contextInfo - the context around sandboxing and multitenant state
      Returns:
      the created inventory transactions
      Throws:
      InventoryUnavailableException - if there was insufficient inventory reserved or on hand
      InventoryNotReservedException - 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, InventoryNotReservedException
      Perform the cancel of inventory to remove reserved quantity.
      Parameters:
      skuInventoryAdjustmentRequestItems - - the key to the map is the SkuInventory that needs to be updated (pre-determined outside of this method).
      batchId - identifier for the current batch of items updating inventory
      contextInfo - the context around sandboxing and multitenant state
      Returns:
      the created inventory transactions
      Throws:
      InventoryUnavailableException - if there was insufficient inventory reserved
      InventoryNotReservedException - 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 the SkuInventory that needs to be updated (pre-determined outside of this method).
      batchId - identifier for the current batch of items updating inventory
      contextInfo - 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 free
      contextInfo - the context around sandboxing and multitenant state