Class DefaultRAOConsumptionSupport

    • Constructor Detail

      • DefaultRAOConsumptionSupport

        public DefaultRAOConsumptionSupport()
    • Method Detail

      • consumeOrderEntry

        public OrderEntryConsumedRAO consumeOrderEntry​(OrderEntryRAO orderEntryRAO,
                                                       int quantity,
                                                       java.math.BigDecimal discountValue,
                                                       AbstractRuleActionRAO actionRAO)
        Description copied from interface: RAOConsumptionSupport
        Creates a new OrderEntryConusmedRAO that consumes the given orderEntryRAO and adds the consumed entry to the given actionRAO
        Specified by:
        consumeOrderEntry in interface RAOConsumptionSupport
        Parameters:
        orderEntryRAO - the order entry to consume
        quantity - the quantity to consume
        discountValue - the discount this order entry consumption gave
        actionRAO - the action rao to add the consumed entry to
        Returns:
        the newly created consumed entry
      • consumeOrderEntry

        public OrderEntryConsumedRAO consumeOrderEntry​(OrderEntryRAO orderEntryRAO,
                                                       int quantity,
                                                       AbstractRuleActionRAO actionRAO)
        Description copied from interface: RAOConsumptionSupport
        Creates a new OrderEntryConusmedRAO that consumes the given orderEntryRAO with the given quantity and adds the consumed entry to the given actionRAO
        Specified by:
        consumeOrderEntry in interface RAOConsumptionSupport
        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

        public java.util.Set<OrderEntryConsumedRAO> consumeOrderEntries​(java.util.Set<OrderEntryRAO> selectedEntries,
                                                                        java.util.Map<java.lang.Integer,​java.lang.Integer> selectedEntriesMap,
                                                                        AbstractRuleActionRAO actionRAO)
        Description copied from interface: RAOConsumptionSupport
        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.
        Specified by:
        consumeOrderEntries in interface RAOConsumptionSupport
        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
      • getSelectedOrderEntryRaos

        public java.util.Set<OrderEntryRAO> getSelectedOrderEntryRaos​(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs,
                                                                      java.util.Map<java.lang.Integer,​java.lang.Integer> selectedOrderEntryMap)
        Description copied from interface: RAOConsumptionSupport
        Gets Order Entry set to be discounted as a result of bundle processing.
        Specified by:
        getSelectedOrderEntryRaos in interface RAOConsumptionSupport
        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

        public OrderEntryConsumedRAO createOrderEntryConsumedRAO​(OrderEntryRAO orderEntryRAO,
                                                                 int quantity,
                                                                 java.math.BigDecimal discountValue)
        Description copied from interface: RAOConsumptionSupport
        Creates new OrderEntryConsumedRAO for given OrderEntryRAO and with given quantity.
        Specified by:
        createOrderEntryConsumedRAO in interface RAOConsumptionSupport
        Parameters:
        orderEntryRAO - OrderEntryRAO to create consumed entry for
        quantity - Consumed quantity
        discountValue - the discount this order entry consumption gave
        Returns:
        created OrderEntryConsumedRAO
      • hasEnoughQuantity

        public boolean hasEnoughQuantity​(RuleActionContext context,
                                         java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
        Description copied from interface: RAOConsumptionSupport
        Checks if all entriesSelectionStrategyRPDs have enough quantity.
        Specified by:
        hasEnoughQuantity in interface RAOConsumptionSupport
        selectionStrategyRPDs - List of EntriesSelectionStrategyRPD to check
        Returns:
        true if all entries selection strategies have enough quantity. false if at least one doesn't have.
      • adjustStrategyQuantity

        public int adjustStrategyQuantity​(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs)
        Description copied from interface: RAOConsumptionSupport
        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.
        Specified by:
        adjustStrategyQuantity in interface RAOConsumptionSupport
        Parameters:
        selectionStrategyRPDs - list of EntriesSelectionStrategyRPD to be updated
        Returns:
        The multiple count used to scale the quantity fields of the strategy objects
      • adjustStrategyQuantity

        public int adjustStrategyQuantity​(java.util.Collection<EntriesSelectionStrategyRPD> selectionStrategyRPDs,
                                          int maxCount)
        Description copied from interface: RAOConsumptionSupport
        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.
        Specified by:
        adjustStrategyQuantity in interface RAOConsumptionSupport
        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
      • putEligibleEntryQuantities

        protected void putEligibleEntryQuantities​(java.util.Map<java.lang.Integer,​java.lang.Integer> entriesToBeConsumedMap,
                                                  EntriesSelectionStrategyRPD strategy)
      • adjustUnitPrice

        protected java.math.BigDecimal adjustUnitPrice​(OrderEntryRAO orderEntryRao)
      • adjustUnitPrice

        protected java.math.BigDecimal adjustUnitPrice​(OrderEntryRAO orderEntryRao,
                                                       int quantity)
      • setRaoLookupService

        public void setRaoLookupService​(RAOLookupService raoLookupService)
      • setCurrencyUtils

        public void setCurrencyUtils​(CurrencyUtils currencyUtils)
      • setSwitchService

        public void setSwitchService​(SwitchService switchService)