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 Summary
Modifier and TypeMethodDescriptionintadjustStrategyQuantity(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs) Adjusts the quantity fields of EntriesSelectionStrategyRPD such that the maximum possible number of entries will be consumed by the action.intadjustStrategyQuantity(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.default intadjustStrategyQuantity(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.default intadjustStrategyQuantity(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.<T extends AbstractRuleActionRAO>
voidconsumeOrderEntries(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> strategies, T actionRAO) Creates newOrderEntryConusmedRAOs for the given strategies, links them to the givenactionRAOand reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity fromdiscountedOrderEntryMap.consumeOrderEntries(Set<OrderEntryRAO> selectedEntries, Map<Integer, Integer> selectedEntriesMap, AbstractRuleActionRAO actionRAO) Creates newOrderEntryConusmedRAOs with the given quantity, links it to the givenactionRAOand reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity fromdiscountedOrderEntryMap.consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, AbstractRuleActionRAO actionRAO) Creates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO with the given quantity and adds the consumed entry to the given actionRAOconsumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, BigDecimal discountValue, AbstractRuleActionRAO actionRAO) Creates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO and adds the consumed entry to the given actionRAOconsumeOrderEntry(OrderEntryRAO orderEntryRAO, AbstractRuleActionRAO actionRAO) Creates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO and adds the consumed entry to the given actionRAOcreateOrderEntryConsumedRAO(OrderEntryRAO orderEntryRAO, int quantity, BigDecimal discountValue) Creates new OrderEntryConsumedRAO for given OrderEntryRAO and with given quantity.intgetConsumableQuantity(OrderEntryRAO orderEntryRao) Calculate the order entry consumable quantitydefault Set<OrderEntryConsumedRAO>getConsumedOrderEntryInfoForOrderEntry(OrderEntryRAO orderEntryRao) Calculate the order entry discount infosintgetConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao) Return consumed quantity for a given order entrygetEligibleEntryQuantities(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs) getSelectedOrderEntryQuantities(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> strategies) Gets Order Entry identifiers (orderEntry.entryNumber) and Unit Quantity To Be Consumed for the Order Entries.getSelectedOrderEntryRaos(Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs, Map<Integer, Integer> selectedOrderEntryMap) Gets Order Entry set to be discounted as a result of bundle processing.booleanhasEnoughQuantity(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs) Checks if allentriesSelectionStrategyRPDshave enough quantity.booleanIdentifies whether order entry consumption is enabledvoidmergeOrderEntryConsumed(OrderEntryConsumedRAO consumedTarget, OrderEntryConsumedRAO consumedSource) Method merges the properties of two instances ofOrderEntryConsumedRAOif the objects refer to the same order entry number and same rulevoidtrackConsumedProducts(RuleActionContext context) voidupdateActionRAOWithConsumed(AbstractRuleActionRAO actionRAO, OrderEntryConsumedRAO orderEntryConsumedRAO) Adds given OrderEntryConsumedRAO to the AbstractRuleActionRAO.consumedEntries.
-
Method Details
-
isConsumptionEnabled
boolean isConsumptionEnabled()Identifies whether order entry consumption is enabled- Returns:
truein case consumption is enabled,falseotherwise
-
trackConsumedProducts
- Parameters:
context- instance ofRuleActionContext
-
consumeOrderEntry
OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, int quantity, BigDecimal discountValue, AbstractRuleActionRAO actionRAO) Creates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO and adds the consumed entry to the given actionRAO- Parameters:
orderEntryRAO- the order entry to consumeactionRAO- the action rao to add the consumed entry toquantity- the quantity to consumediscountValue- the discount this order entry consumption gave- Returns:
- the newly created consumed entry
-
consumeOrderEntry
OrderEntryConsumedRAO consumeOrderEntry(OrderEntryRAO orderEntryRAO, AbstractRuleActionRAO actionRAO) Creates a newOrderEntryConusmedRAOthat consumes the given orderEntryRAO and adds the consumed entry to the given actionRAO- Parameters:
orderEntryRAO- the order entry to consumeactionRAO- 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 newOrderEntryConusmedRAOthat consumes the given orderEntryRAO with the given quantity and adds the consumed entry to the given actionRAO- Parameters:
orderEntryRAO- the order entry to consumequantity- the quantity to consumeactionRAO- 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 newOrderEntryConusmedRAOs for the given strategies, links them to the givenactionRAOand reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity fromdiscountedOrderEntryMap.- Parameters:
context- instance ofRuleActionContextstrategies- the selection strategiesactionRAO- theAbstractRuleActionRAOto add the newly created consumed entries to
-
consumeOrderEntries
Set<OrderEntryConsumedRAO> consumeOrderEntries(Set<OrderEntryRAO> selectedEntries, Map<Integer, Integer> selectedEntriesMap, AbstractRuleActionRAO actionRAO) Creates newOrderEntryConusmedRAOs with the given quantity, links it to the givenactionRAOand reduces available quantity of order entry by given quantity for every Order Entry from the set and using quantity fromdiscountedOrderEntryMap.- Parameters:
selectedEntries- Order Entries to be consumedselectedEntriesMap- Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as valuesactionRAO- theAbstractRuleActionRAOto add the newly created consumed entries to
-
getConsumedQuantityForOrderEntry
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 ofEntriesSelectionStrategyRPDto 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 ofEntriesSelectionStrategyRPDto pickup units according to the strategiesselectedOrderEntryMap- 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 forquantity- Consumed quantitydiscountValue- 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 updatedorderEntryConsumedRAO- to be added to the AbstractRuleActionRAO
-
mergeOrderEntryConsumed
void mergeOrderEntryConsumed(OrderEntryConsumedRAO consumedTarget, OrderEntryConsumedRAO consumedSource) Method merges the properties of two instances ofOrderEntryConsumedRAOif the objects refer to the same order entry number and same rule- Parameters:
consumedTarget- where to merge the data toconsumedSource- where to merge the data from
-
hasEnoughQuantity
boolean hasEnoughQuantity(RuleActionContext context, Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs) Checks if allentriesSelectionStrategyRPDshave 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
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 updatedmaxCount- 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 updatedcontext- instance ofRuleActionContext- 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 updatedcontext- instance ofRuleActionContextmaxCount- 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
Calculate the order entry consumable quantity- Parameters:
orderEntryRao- instance ofOrderEntryRAO- Returns:
- number of units available for consumption
-
getConsumedOrderEntryInfoForOrderEntry
default Set<OrderEntryConsumedRAO> getConsumedOrderEntryInfoForOrderEntry(OrderEntryRAO orderEntryRao) Calculate the order entry discount infos- Parameters:
orderEntryRao- instance ofOrderEntryRAO- Returns:
- The order entry discount infos
-