Interface RuleEngineCalculationService

All Known Implementing Classes:
DefaultRuleEngineCalculationService

public interface RuleEngineCalculationService
RuleEngineCalculationService provides methods related to order and cart calculation to be used during rule evaluation.
  • Method Details

    • calculateTotals

      void calculateTotals(AbstractOrderRAO abstractOrderRao)
      performs a (re)calculation on the given abstractOrderRao and updates these properties:
      Parameters:
      abstractOrderRao - the abstractOrderRao to calculate
    • addOrderLevelDiscount

      DiscountRAO addOrderLevelDiscount(CartRAO cartRao, boolean absolute, BigDecimal amount)
      Creates a new order level discount based on the given values, adds it to the cartRao and updates the cartRao totals. If the absolute flag is set to true, the discount is absolute, otherwise its a percentage based discount.
      Parameters:
      cartRao - the cartRao to add the discount to
      absolute - whether the discount is absolute or percentage-based
      amount - the amount of the discount
      Returns:
      the created DiscountRAO
    • addOrderEntryLevelDiscount

      DiscountRAO addOrderEntryLevelDiscount(OrderEntryRAO orderEntryRao, boolean absolute, BigDecimal amount)
      Creates a new order entry level discount based on the given values, adds it to the corresponding orderRao and updates the orderRao totals. If the absolute flag is set to true, the discount is absolute, otherwise its a percentage based discount.
      Parameters:
      orderEntryRao - the orderEntryRao to add the discount to
      absolute - whether the discount is absolute or percentage-based
      amount - the amount of the discount
      Returns:
      the created DiscountRAO
    • addOrderEntryLevelDiscount

      default Set<DiscountRAO> addOrderEntryLevelDiscount(OrderEntryRAO orderEntryRAO, boolean absolute, BigDecimal amount, boolean perUnit)
      Create a set of order entry level discounts based on the given value, absolute flag and perUnit flag, adds it to the corresponding orderRao and updates the orderRao totals. If the absolute flag is set to true, the discount is absolute, otherwise it's a percentage based discount. If the perUnit flag is set to true, it means give discount on each product of order entry, If the perUnit flag is set to false, it means give discount to the whole order entry
      Parameters:
      orderEntryRAO - the orderEntryRao to add the discount to
      absolute - whether the discount is absolute or percentage-based
      amount - the amount of the discount
      perUnit - whether the discount is given to each product of order entry or the whole order entry
      Returns:
      the created DiscountRAO set
    • changeDeliveryMode

      ShipmentRAO changeDeliveryMode(CartRAO cartRAO, DeliveryModeRAO deliveryModeRAO)
      Changes the current delivery mode to the given values, adds it to the cartRao and updates the carRao totals.
      Parameters:
      cartRAO - the cartRao to change the delivery mode for
      deliveryModeRAO - the new delivery mode
      Returns:
      the ShipmentRAO
    • addFreeProductsToCart

      FreeProductRAO addFreeProductsToCart(CartRAO cartRao, ProductModel product, int quantity)
      Adds free product items to the cart.
      Parameters:
      cartRao - cart where to add the product
      product - a product to add
      quantity - quantity of product items to add
      Returns:
      FreeProductRAO the free product to be given
    • addFixedPriceEntryDiscount

      DiscountRAO addFixedPriceEntryDiscount(OrderEntryRAO orderEntryRao, BigDecimal fixedPrice)
      Creates a new order entry level discount such that the order entry's price will be equal to the given fixedPrice multiplied by quantity.
      Parameters:
      orderEntryRao - the orderEntryRao to add the discount to
      fixedPrice - the target unit price
      Returns:
      the created DiscountRAO
    • getCurrentPrice

      BigDecimal getCurrentPrice(Set<OrderEntryRAO> orderEntryForDiscounts, Map<Integer,Integer> discountedOrderEntryMap)
      Calculates current price of the set of Order Entries using only specified quantity of units for every Order Entry.
      Parameters:
      orderEntryForDiscounts - set with Order Entries which price need to be calculated
      discountedOrderEntryMap - Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as values
      Returns:
      BigDecimal current price
    • addFixedPriceEntriesDiscount

      List<DiscountRAO> addFixedPriceEntriesDiscount(CartRAO cartRao, Map<Integer,Integer> selectedOrderEntryMap, Set<OrderEntryRAO> selectedOrderEntryRaos, BigDecimal fixedPrice)
      Creates order entry level discounts for the cart cartRao, with the fixedPrice given as parameter and for the products from entries in selectedOrderEntryRaos and related quantities given in selectedOrderEntryMap.
      Parameters:
      cartRao - Cart RAO used for totals calculations
      selectedOrderEntryMap - Map having orderEntry.entryNumber as keys and unit quantity to be consumed as values
      selectedOrderEntryRaos - Order entries to be discounted
      fixedPrice - Target price for discounted product
      Returns:
      List of discounts that are generated
    • addOrderEntryLevelDiscount

      List<DiscountRAO> addOrderEntryLevelDiscount(Map<Integer,Integer> selectedOrderEntryMap, Set<OrderEntryRAO> selectedOrderEntryRaos, boolean absolute, BigDecimal amount)
      Creates order entry level discounts for the cart cartRao, adds it to the cartRao and updates the cartRao totals. Discounts are applied to entries contained within the selectedOrderEntryMap selectedOrderEntryRaos based on strategy.
      Parameters:
      selectedOrderEntryMap - Map having orderEntry.entryNumber as keys and unit quantity to be consumed as values
      selectedOrderEntryRaos - Order entries to be discounted
      absolute - boolean value true is discount is absolute currency amount
      amount - value of discount
      Returns:
      List of discounts created as a result of this action