Interface RAOConsumptionSupport

All Known Implementing Classes:
DefaultRAOConsumptionSupport

public interface RAOConsumptionSupport
Provides consumption related functionality to consume, track, and calculate quantity of available items to be consumed
  • Method Details

    • isConsumptionEnabled

      boolean isConsumptionEnabled()
      Identifies whether order entry consumption is enabled
      Returns:
      true in case consumption is enabled, false otherwise
    • trackConsumedProducts

      void trackConsumedProducts(RuleActionContext context)
      Parameters:
      context - instance of RuleActionContext
    • consumeOrderEntry

      OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, BigDecimal discountValue, AbstractRuleActionRAO actionRAO)
      Creates a new OrderEntryConusmedRAO that consumes the given orderEntryRAO and adds the consumed entry to the given actionRAO
      Parameters:
      orderEntryRAO - the order entry to consume
      actionRAO - the action rao to add the consumed entry to
      quantity - the quantity to consume
      discountValue - the discount this order entry consumption gave
      Returns:
      the newly created consumed entry
    • consumeOrderEntry

      OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, AbstractRuleActionRAO actionRAO)
      Creates a new OrderEntryConusmedRAO that consumes the given orderEntryRAO and adds the consumed entry to the given actionRAO
      Parameters:
      orderEntryRAO - the order entry to consume
      actionRAO - the action rao to add the consumed entry to
      Returns:
      the newly created consumed entry
    • consumeOrderEntry

      OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, AbstractRuleActionRAO actionRAO)
      Creates a new OrderEntryConusmedRAO that consumes the given orderEntryRAO with the given quantity and adds the consumed entry to the given actionRAO
      Parameters:
      orderEntryRAO - the order entry to consume
      quantity - the quantity to consume
      actionRAO - the action rao to add the consumed entry to
      Returns:
      the newly created consumed entry
    • consumeOrderEntries

      <T extends AbstractRuleActionRAO> void consumeOrderEntries(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> strategies, T actionRAO)
      Creates new OrderEntryConusmedRAOs for the given strategies, links them to the given actionRAO and reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity from discountedOrderEntryMap.
      Parameters:
      context - instance of RuleActionContext
      strategies - the selection strategies
      actionRAO - the AbstractRuleActionRAO to add the newly created consumed entries to
    • consumeOrderEntries

      Set<OrderEntryConsumedRAO> consumeOrderEntries(Set<OrderEntryRAO> selectedEntries, Map<Integer,Integer> selectedEntriesMap, AbstractRuleActionRAO actionRAO)
      Creates new OrderEntryConusmedRAOs with the given quantity, links it to the given actionRAO and reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity from discountedOrderEntryMap.
      Parameters:
      selectedEntries - Order Entries to be consumed
      selectedEntriesMap - Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as values
      actionRAO - the AbstractRuleActionRAO to add the newly created consumed entries to
    • getConsumedQuantityForOrderEntry

      int getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao)
      Return consumed quantity for a given order entry
      Parameters:
      orderEntryRao - Cart order entry
      Returns:
      consumed quantity
    • getSelectedOrderEntryQuantities

      Map<Integer,Integer> getSelectedOrderEntryQuantities(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> strategies)
      Gets Order Entry identifiers (orderEntry.entryNumber) and Unit Quantity To Be Consumed for the Order Entries.
      Parameters:
      strategies - list of EntriesSelectionStrategyRPD to pickup units according to the strategies
      Returns:
      Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as values
    • getSelectedOrderEntryRaos

      Set<OrderEntryRAO> getSelectedOrderEntryRaos(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, Map<Integer,Integer> selectedOrderEntryMap)
      Gets Order Entry set to be discounted as a result of bundle processing.
      Parameters:
      selectionStrategyRPDs - list of EntriesSelectionStrategyRPD to pickup units according to the strategies
      selectedOrderEntryMap - Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as values
    • createOrderEntryConsumedRAO

      OrderEntryConsumedRAO createOrderEntryConsumedRAO(OrderEntryRAO orderEntryRAO, int quantity, BigDecimal discountValue)
      Creates new OrderEntryConsumedRAO for given OrderEntryRAO and with given quantity.
      Parameters:
      orderEntryRAO - OrderEntryRAO to create consumed entry for
      quantity - Consumed quantity
      discountValue - the discount this order entry consumption gave
      Returns:
      created OrderEntryConsumedRAO
    • updateActionRAOWithConsumed

      void updateActionRAOWithConsumed(AbstractRuleActionRAO actionRAO, OrderEntryConsumedRAO orderEntryConsumedRAO)
      Adds given OrderEntryConsumedRAO to the AbstractRuleActionRAO.consumedEntries.
      Parameters:
      actionRAO - AbstractRuleActionRAO to be updated
      orderEntryConsumedRAO - to be added to the AbstractRuleActionRAO
    • mergeOrderEntryConsumed

      void mergeOrderEntryConsumed(OrderEntryConsumedRAO consumedTarget, OrderEntryConsumedRAO consumedSource)
      Method merges the properties of two instances of OrderEntryConsumedRAO if the objects refer to the same order entry number and same rule
      Parameters:
      consumedTarget - where to merge the data to
      consumedSource - where to merge the data from
    • hasEnoughQuantity

      boolean hasEnoughQuantity(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
      Checks if all entriesSelectionStrategyRPDs have enough quantity.
      Parameters:
      selectionStrategyRPDs - List of EntriesSelectionStrategyRPD to check
      Returns:
      true if all entries selection strategies have enough quantity. false if at least one doesn't have.
    • getEligibleEntryQuantities

      Map<Integer,Integer> getEligibleEntryQuantities(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
    • adjustStrategyQuantity

      int adjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
      Adjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action. This is done by finding the highest integer multiple that the strategy.quantity can be multiplied by that there is sufficient quantity in the associated OrderEntryRAO object. This figure is then multiplied by the original quantity of the selection strategy.
      Parameters:
      selectionStrategyRPDs - list of EntriesSelectionStrategyRPD to be updated
      Returns:
      The multiple count used to scale the quantity fields of the strategy objects
    • adjustStrategyQuantity

      int adjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, int maxCount)
      Adjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action. This is done by finding the highest integer multiple that the strategy.quantity can be multiplied by that there is sufficient quantity in the associated OrderEntryRAO object. This figure is then multiplied by the original quantity of the selection strategy.
      Parameters:
      selectionStrategyRPDs - list of EntriesSelectionStrategyRPD to be updated
      maxCount - when maxCount is greater than 0, this parameter acts as an absolute maximum for the multiple.
      Returns:
      The multiple count used to scale the quantity fields of the strategy objects
    • adjustStrategyQuantity

      default int adjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, RuleActionContext context)
      Adjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action. This is done by finding the highest integer multiple that the strategy.quantity can be multiplied by that there is sufficient quantity in the associated OrderEntryRAO object. This figure is then multiplied by the original quantity of the selection strategy.
      Parameters:
      selectionStrategyRPDs - list of EntriesSelectionStrategyRPD to be updated
      context - instance of RuleActionContext
      Returns:
      The multiple count used to scale the quantity fields of the strategy objects
    • adjustStrategyQuantity

      default int adjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, RuleActionContext context, int maxCount)
      Adjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action. This is done by finding the highest integer multiple that the strategy.quantity can be multiplied by that there is sufficient quantity in the associated OrderEntryRAO object. This figure is then multiplied by the original quantity of the selection strategy.
      Parameters:
      selectionStrategyRPDs - list of EntriesSelectionStrategyRPD to be updated
      context - instance of RuleActionContext
      maxCount - when maxCount is greater than 0, this parameter acts as an absolute maximum for the multiple.
      Returns:
      The multiple count used to scale the quantity fields of the strategy objects
    • getConsumableQuantity

      int getConsumableQuantity(OrderEntryRAO orderEntryRao)
      Calculate the order entry consumable quantity
      Parameters:
      orderEntryRao - instance of OrderEntryRAO
      Returns:
      number of units available for consumption
    • getConsumedOrderEntryInfoForOrderEntry

      default Set<OrderEntryConsumedRAO> getConsumedOrderEntryInfoForOrderEntry(OrderEntryRAO orderEntryRao)
      Calculate the order entry discount infos
      Parameters:
      orderEntryRao - instance of OrderEntryRAO
      Returns:
      The order entry discount infos