Interface RuleEngineCalculationService
-
- All Known Implementing Classes:
DefaultRuleEngineCalculationService
public interface RuleEngineCalculationServiceRuleEngineCalculationService provides methods related to order and cart calculation to be used during rule evaluation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description java.util.List<DiscountRAO>addFixedPriceEntriesDiscount(CartRAO cartRao, java.util.Map<java.lang.Integer,java.lang.Integer> selectedOrderEntryMap, java.util.Set<OrderEntryRAO> selectedOrderEntryRaos, java.math.BigDecimal fixedPrice)Creates order entry level discounts for the cartcartRao, with thefixedPricegiven as parameter and for the products from entries inselectedOrderEntryRaosand related quantities given inselectedOrderEntryMap.DiscountRAOaddFixedPriceEntryDiscount(OrderEntryRAO orderEntryRao, java.math.BigDecimal fixedPrice)Creates a new order entry level discount such that the order entry's price will be equal to the givenfixedPricemultiplied by quantity.FreeProductRAOaddFreeProductsToCart(CartRAO cartRao, ProductModel product, int quantity)Adds free product items to the cart.DiscountRAOaddOrderEntryLevelDiscount(OrderEntryRAO orderEntryRao, boolean absolute, java.math.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.java.util.List<DiscountRAO>addOrderEntryLevelDiscount(java.util.Map<java.lang.Integer,java.lang.Integer> selectedOrderEntryMap, java.util.Set<OrderEntryRAO> selectedOrderEntryRaos, boolean absolute, java.math.BigDecimal amount)Creates order entry level discounts for the cartcartRao, adds it to the cartRao and updates the cartRao totals.DiscountRAOaddOrderLevelDiscount(CartRAO cartRao, boolean absolute, java.math.BigDecimal amount)Creates a new order level discount based on the given values, adds it to the cartRao and updates the cartRao totals.java.math.BigDecimalcalculateSubTotals(CartRAO cartRao, java.util.Collection<ProductRAO> excludedProducts)Runs cart calculation for cart not including the excluded products.voidcalculateTotals(AbstractOrderRAO abstractOrderRao)performs a (re)calculation on the given abstractOrderRao and updates these properties:AbstractOrderRAO.getTotal()AbstractOrderRAO.getSubTotal()AbstractOrderRAO.getDeliveryCost()AbstractOrderRAO.getPaymentCost()ShipmentRAOchangeDeliveryMode(CartRAO cartRAO, DeliveryModeRAO deliveryModeRAO)Changes the current delivery mode to the given values, adds it to the cartRao and updates the carRao totals.java.math.BigDecimalgetAdjustedUnitPrice(int quantity, OrderEntryRAO orderEntryRao)Deprecated, for removal: This API element is subject to removal in a future version.since 1905 .intgetConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao)Deprecated, for removal: This API element is subject to removal in a future version.since 1905, please refer toRAOConsumptionSupport.getConsumedQuantityForOrderEntry(OrderEntryRAO)java.math.BigDecimalgetCurrentPrice(java.util.Set<OrderEntryRAO> orderEntryForDiscounts, java.util.Map<java.lang.Integer,java.lang.Integer> discountedOrderEntryMap)Calculates current price of the set of Order Entries using only specified quantity of units for every Order Entry.intgetProductAvailableQuantityInOrderEntry(OrderEntryRAO orderEntryRAO)Deprecated, for removal: This API element is subject to removal in a future version.since 1905 .
-
-
-
Method Detail
-
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, java.math.BigDecimal amount)
Creates a new order level discount based on the given values, adds it to the cartRao and updates the cartRao totals. If theabsoluteflag is set to true, the discount is absolute, otherwise its a percentage based discount.- Parameters:
cartRao- the cartRao to add the discount toabsolute- whether the discount is absolute or percentage-basedamount- the amount of the discount- Returns:
- the created DiscountRAO
-
addOrderEntryLevelDiscount
DiscountRAO addOrderEntryLevelDiscount(OrderEntryRAO orderEntryRao, boolean absolute, java.math.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 theabsoluteflag is set to true, the discount is absolute, otherwise its a percentage based discount.- Parameters:
orderEntryRao- the orderEntryRao to add the discount toabsolute- whether the discount is absolute or percentage-basedamount- the amount of the discount- Returns:
- the created DiscountRAO
-
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 fordeliveryModeRAO- 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 productproduct- a product to addquantity- quantity of product items to add- Returns:
- FreeProductRAO the free product to be given
-
addFixedPriceEntryDiscount
DiscountRAO addFixedPriceEntryDiscount(OrderEntryRAO orderEntryRao, java.math.BigDecimal fixedPrice)
Creates a new order entry level discount such that the order entry's price will be equal to the givenfixedPricemultiplied by quantity.- Parameters:
orderEntryRao- the orderEntryRao to add the discount tofixedPrice- the target unit price- Returns:
- the created DiscountRAO
-
calculateSubTotals
java.math.BigDecimal calculateSubTotals(CartRAO cartRao, java.util.Collection<ProductRAO> excludedProducts)
Runs cart calculation for cart not including the excluded products. CartRao argument is not modified by this process.- Parameters:
cartRao- Cart to be calculatedexcludedProducts- List of products to be excluded from the cart calculation- Returns:
- BigDecimal result of the cartSubTotals (without charges like payment or delivery) minus the excluded products
-
getCurrentPrice
java.math.BigDecimal getCurrentPrice(java.util.Set<OrderEntryRAO> orderEntryForDiscounts, java.util.Map<java.lang.Integer,java.lang.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 calculateddiscountedOrderEntryMap- Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as values- Returns:
- BigDecimal current price
-
getAdjustedUnitPrice
@Deprecated(since="1905", forRemoval=true) java.math.BigDecimal getAdjustedUnitPrice(int quantity, OrderEntryRAO orderEntryRao)Deprecated, for removal: This API element is subject to removal in a future version.since 1905 . Please usePriceAdjustmentStrategy.get(Object, int)insteadGets the total discount for line item and recalculates the discounted unit price.- Parameters:
quantity- quantity of line itemorderEntryRao- orderEntryRao to get discounted unit price for- Returns:
- adjusted unit price
-
addFixedPriceEntriesDiscount
java.util.List<DiscountRAO> addFixedPriceEntriesDiscount(CartRAO cartRao, java.util.Map<java.lang.Integer,java.lang.Integer> selectedOrderEntryMap, java.util.Set<OrderEntryRAO> selectedOrderEntryRaos, java.math.BigDecimal fixedPrice)
Creates order entry level discounts for the cartcartRao, with thefixedPricegiven as parameter and for the products from entries inselectedOrderEntryRaosand related quantities given inselectedOrderEntryMap.- Parameters:
cartRao- Cart RAO used for totals calculationsselectedOrderEntryMap- Map having orderEntry.entryNumber as keys and unit quantity to be consumed as valuesselectedOrderEntryRaos- Order entries to be discountedfixedPrice- Target price for discounted product- Returns:
- List of discounts that are generated
-
addOrderEntryLevelDiscount
java.util.List<DiscountRAO> addOrderEntryLevelDiscount(java.util.Map<java.lang.Integer,java.lang.Integer> selectedOrderEntryMap, java.util.Set<OrderEntryRAO> selectedOrderEntryRaos, boolean absolute, java.math.BigDecimal amount)
Creates order entry level discounts for the cartcartRao, adds it to the cartRao and updates the cartRao totals. Discounts are applied to entries contained within the selectedOrderEntryMapselectedOrderEntryRaosbased on strategy.- Parameters:
selectedOrderEntryMap- Map having orderEntry.entryNumber as keys and unit quantity to be consumed as valuesselectedOrderEntryRaos- Order entries to be discountedabsolute- boolean value true is discount is absolute currency amountamount- value of discount- Returns:
- List of discounts created as a result of this action
-
getConsumedQuantityForOrderEntry
@Deprecated(since="1905", forRemoval=true) int getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao)Deprecated, for removal: This API element is subject to removal in a future version.since 1905, please refer toRAOConsumptionSupport.getConsumedQuantityForOrderEntry(OrderEntryRAO)Return consumed quantity for a given order entry- Parameters:
orderEntryRao- Cart order entry- Returns:
- consumed quantity
-
getProductAvailableQuantityInOrderEntry
@Deprecated(since="1905", forRemoval=true) int getProductAvailableQuantityInOrderEntry(OrderEntryRAO orderEntryRAO)Deprecated, for removal: This API element is subject to removal in a future version.since 1905 . Please refer toRAOConsumptionSupport.getConsumableQuantity(OrderEntryRAO)give the order entry and the product, return the number of available product items to consume- Parameters:
orderEntryRAO- instance ofOrderEntryRAO- Returns:
- total number of product items to consume
-
-