public class DefaultRuleEngineCalculationService extends Object implements RuleEngineCalculationService
| Constructor and Description |
|---|
DefaultRuleEngineCalculationService() |
| Modifier and Type | Method and Description |
|---|---|
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. |
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. |
FreeProductRAO |
addFreeProductsToCart(CartRAO cartRao,
ProductModel product,
int quantity)
Adds free product items to the cart.
|
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. |
DiscountRAO |
addOrderEntryLevelDiscount(OrderEntryRAO orderEntryRao,
boolean absolute,
BigDecimal amount)
creates a DiscountRAO for the given OrderEntryRAO based on the input.
|
DiscountRAO |
addOrderLevelDiscount(CartRAO cartRao,
boolean absolute,
BigDecimal amount)
creates a DiscountRAO for the given CartRAO based on the input.
|
BigDecimal |
calculateSubTotals(CartRAO cartRao,
Collection<ProductRAO> excludedProducts)
Runs cart calculation for cart not including the excluded products.
|
void |
calculateTotals(AbstractOrderRAO cartRao)
performs a (re)calculation on the given abstractOrderRao and updates these properties:
AbstractOrderRAO.getTotal()
AbstractOrderRAO.getSubTotal()
AbstractOrderRAO.getDeliveryCost()
AbstractOrderRAO.getPaymentCost()
|
ShipmentRAO |
changeDeliveryMode(CartRAO cartRao,
DeliveryModeRAO mode)
Changes the current delivery mode to the given values, adds it to the cartRao and updates the carRao totals.
|
protected DiscountRAO |
createDiscountRAO(AbstractDiscount discount)
Creates a new DiscountRAO based on the given AbstractDiscount.
|
protected LineItemDiscount |
createLineItemDiscount(LineItem lineItem,
boolean absolute,
BigDecimal amount)
Creates an LineItemDiscount based on the given values and adds it to the given
lineItem. |
protected LineItemDiscount |
createLineItemDiscount(LineItem lineItem,
boolean absolute,
BigDecimal amount,
boolean perUnit)
Creates an LineItemDiscount based on the given values and adds it to the given
lineItem. |
protected LineItemDiscount |
createLineItemDiscount(LineItem lineItem,
boolean absolute,
BigDecimal amount,
boolean perUnit,
int applicableUnits) |
protected OrderDiscount |
createOrderDiscount(Order cart,
boolean absolute,
BigDecimal amount)
Creates an OrderDiscount based on the given values and adds it to the given
cart. |
protected ShipmentRAO |
createShipmentRAO(DeliveryModeRAO mode)
Creates a new ShipmentRAO based on the given Delivery Mode.
|
protected OrderCharge |
createShippingCharge(Order cart,
boolean absolute,
BigDecimal value)
creates an
OrderCharge of AbstractCharge.ChargeType.SHIPPING for the given values and adds it to the given cart. |
protected void |
ensureOrderEntryRAOEntryNumbers(AbstractOrderRAO abstractOrderRao)
for the given
AbstractOrderRAO this method ensures that each of the AbstractOrderRAO.getEntries()
has a entry number set. |
protected NumberedLineItem |
findLineItem(Order cart,
OrderEntryRAO entryRao)
returns the corresponding NumberedLineItem for the given
entryRao. |
protected OrderEntryRAO |
findOrderEntryRAO(AbstractOrderRAO order,
NumberedLineItem lineItem)
returns the corresponding OrderEntryRAO for the given
lineItem. |
protected Converter<AbstractOrderRAO,Order> |
getAbstractOrderRaoToOrderConverter() |
BigDecimal |
getAdjustedUnitPrice(int quantity,
OrderEntryRAO orderEntryRao)
Gets the total discount for line item and recalculates the discounted unit price.
|
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.
|
protected MinimumAmountValidationStrategy |
getMinimumAmountValidationStrategy() |
protected OrderUtils |
getOrderUtils() |
protected Converter<ProductModel,ProductRAO> |
getProductConverter() |
protected RaoUtils |
getRaoUtils() |
protected void |
recalculateTotals(AbstractOrderRAO cartRao,
Order cart)
Uses the given
cart to recalculate the totals of the given cartRao. |
protected void |
removeShippingCharges(Order cart)
Returns all Shipping charges from the Order.
|
void |
setAbstractOrderRaoToOrderConverter(Converter<AbstractOrderRAO,Order> abstractOrderRaoToOrderConverter) |
void |
setMinimumAmountValidationStrategy(MinimumAmountValidationStrategy minimumAmountValidationStrategy) |
void |
setOrderUtils(OrderUtils orderUtils) |
void |
setProductConverter(Converter<ProductModel,ProductRAO> productConverter) |
void |
setRaoUtils(RaoUtils raoUtils) |
protected LineItemDiscount |
validateLineItemDiscount(LineItem lineItem,
boolean absolute,
Currency currency,
LineItemDiscount discount) |
public DiscountRAO addOrderLevelDiscount(CartRAO cartRao, boolean absolute, BigDecimal amount)
addOrderLevelDiscount in interface RuleEngineCalculationServicecartRao - the cartRAOabsolute - whether the discount is absolute or a percentage discountamount - the amountpublic BigDecimal getCurrentPrice(Set<OrderEntryRAO> orderEntryForDiscounts, Map<Integer,Integer> discountedOrderEntryMap)
RuleEngineCalculationServicegetCurrentPrice in interface RuleEngineCalculationServiceorderEntryForDiscounts - set with Order Entries which price need to be calculateddiscountedOrderEntryMap - Map having orderEntry.entryNumber as keys and Unit Quantity To Be Consumed as valuespublic DiscountRAO addOrderEntryLevelDiscount(OrderEntryRAO orderEntryRao, boolean absolute, BigDecimal amount)
addOrderEntryLevelDiscount in interface RuleEngineCalculationServiceorderEntryRao - the orderEntryRaoabsolute - whether the discount is absolute or a percentage discountamount - the amountpublic DiscountRAO addFixedPriceEntryDiscount(OrderEntryRAO orderEntryRao, BigDecimal fixedPrice)
RuleEngineCalculationServicefixedPrice multiplied by quantity.addFixedPriceEntryDiscount in interface RuleEngineCalculationServiceorderEntryRao - the orderEntryRao to add the discount tofixedPrice - the target unit pricepublic FreeProductRAO addFreeProductsToCart(CartRAO cartRao, ProductModel product, int quantity)
RuleEngineCalculationServiceaddFreeProductsToCart in interface RuleEngineCalculationServicecartRao - cart where to add the productproduct - a product to addquantity - quantity of product items to addprotected void ensureOrderEntryRAOEntryNumbers(AbstractOrderRAO abstractOrderRao)
AbstractOrderRAO this method ensures that each of the AbstractOrderRAO.getEntries()
has a entry number set. Note: This method only sets OrderEntryRAO#setEntryNumber(Integer) if it is not yet
set, it does not check for duplicates or any other inconsistencies.abstractOrderRao - the AbstractOrderRAO to checkpublic ShipmentRAO changeDeliveryMode(CartRAO cartRao, DeliveryModeRAO mode)
RuleEngineCalculationServicechangeDeliveryMode in interface RuleEngineCalculationServicecartRao - the cartRao to change the delivery mode formode - the new delivery modepublic void calculateTotals(AbstractOrderRAO cartRao)
RuleEngineCalculationServicecalculateTotals in interface RuleEngineCalculationServicecartRao - the abstractOrderRao to calculateprotected NumberedLineItem findLineItem(Order cart, OrderEntryRAO entryRao)
entryRao. The lookup is based on both having the
same entryNumber.cart - the cart to look up the line item fromentryRao - the entry raoIllegalArgumentException - if no corresponding NumberedLineItem can be foundprotected OrderEntryRAO findOrderEntryRAO(AbstractOrderRAO order, NumberedLineItem lineItem)
lineItem. The lookup is based on both having the
same entryNumber.order - the order to look up the order entry rao fromlineItem - the line itemprotected void recalculateTotals(AbstractOrderRAO cartRao, Order cart)
cart to recalculate the totals of the given cartRao.cartRao - the cartRao to updatecart - the cart to use for calculationprotected OrderDiscount createOrderDiscount(Order cart, boolean absolute, BigDecimal amount)
cart.cart - the cart to add the order discount toabsolute - whether the discount is absolute or percentage basedamount - the amountprotected DiscountRAO createDiscountRAO(AbstractDiscount discount)
discount - the discountprotected LineItemDiscount createLineItemDiscount(LineItem lineItem, boolean absolute, BigDecimal amount, boolean perUnit)
lineItem. Sets perUnit
value for partial line discountslineItem - the line item to add the order discount toabsolute - whether the discount is absolute or percentage basedamount - the amountperUnit - true if the discount does not necessarily apply to whole line itemprotected LineItemDiscount createLineItemDiscount(LineItem lineItem, boolean absolute, BigDecimal amount, boolean perUnit, int applicableUnits)
protected LineItemDiscount validateLineItemDiscount(LineItem lineItem, boolean absolute, Currency currency, LineItemDiscount discount)
protected LineItemDiscount createLineItemDiscount(LineItem lineItem, boolean absolute, BigDecimal amount)
lineItem.lineItem - the line item to add the order discount toabsolute - whether the discount is absolute or percentage basedamount - the amountprotected void removeShippingCharges(Order cart)
cart - protected OrderCharge createShippingCharge(Order cart, boolean absolute, BigDecimal value)
OrderCharge of AbstractCharge.ChargeType.SHIPPING for the given values and adds it to the given cart.cart - the given cart to apply the shipping charge toabsolute - whether the shipping charge is percentage-based or absolute.value - the value of the chargeprotected ShipmentRAO createShipmentRAO(DeliveryModeRAO mode)
protected Converter<ProductModel,ProductRAO> getProductConverter()
public void setProductConverter(Converter<ProductModel,ProductRAO> productConverter)
protected Converter<AbstractOrderRAO,Order> getAbstractOrderRaoToOrderConverter()
public void setAbstractOrderRaoToOrderConverter(Converter<AbstractOrderRAO,Order> abstractOrderRaoToOrderConverter)
public BigDecimal calculateSubTotals(CartRAO cartRao, Collection<ProductRAO> excludedProducts)
RuleEngineCalculationServicecalculateSubTotals in interface RuleEngineCalculationServicecartRao - Cart to be calculatedexcludedProducts - List of products to be excluded from the cart calculationpublic BigDecimal getAdjustedUnitPrice(int quantity, OrderEntryRAO orderEntryRao)
RuleEngineCalculationServicegetAdjustedUnitPrice in interface RuleEngineCalculationServicequantity - quantity of line itemorderEntryRao - orderEntryRao to get discounted unit price forpublic List<DiscountRAO> addFixedPriceEntriesDiscount(CartRAO cartRao, Map<Integer,Integer> selectedOrderEntryMap, Set<OrderEntryRAO> selectedOrderEntryRaos, BigDecimal fixedPrice)
RuleEngineCalculationServicecartRao, with the fixedPrice given as parameter
and for the products from entries in selectedOrderEntryRaos and related quantities given in
selectedOrderEntryMap.addFixedPriceEntriesDiscount in interface RuleEngineCalculationServiceselectedOrderEntryMap - Map having orderEntry.entryNumber as keys and unit quantity to be consumed as valuesselectedOrderEntryRaos - Order entries to be discountedfixedPrice - Target price for discounted productpublic List<DiscountRAO> addOrderEntryLevelDiscount(Map<Integer,Integer> selectedOrderEntryMap, Set<OrderEntryRAO> selectedOrderEntryRaos, boolean absolute, BigDecimal amount)
RuleEngineCalculationServicecartRao, adds it to the cartRao and updates the cartRao
totals. Discounts are applied to entries contained within the selectedOrderEntryMap selectedOrderEntryRaos
based on strategy.addOrderEntryLevelDiscount in interface RuleEngineCalculationServiceselectedOrderEntryMap - 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 discountprotected MinimumAmountValidationStrategy getMinimumAmountValidationStrategy()
public void setMinimumAmountValidationStrategy(MinimumAmountValidationStrategy minimumAmountValidationStrategy)
protected OrderUtils getOrderUtils()
public void setOrderUtils(OrderUtils orderUtils)
protected RaoUtils getRaoUtils()
public void setRaoUtils(RaoUtils raoUtils)
Copyright © 2017 SAP SE. All Rights Reserved.