public class DefaultRuleEngineCalculationService extends java.lang.Object implements RuleEngineCalculationService
| Constructor and Description |
|---|
DefaultRuleEngineCalculationService() |
| Modifier and Type | Method and 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 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,
java.math.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. |
DiscountRAO |
addFixedPriceEntryDiscountStackable(OrderEntryRAO orderEntryRao,
java.math.BigDecimal fixedPrice)
Deprecated.
since 6.7
|
FreeProductRAO |
addFreeProductsToCart(CartRAO cartRao,
ProductModel product,
int quantity)
Adds free product items to the cart.
|
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 cart
cartRao, adds it to the cartRao and updates the cartRao
totals. |
DiscountRAO |
addOrderEntryLevelDiscount(OrderEntryRAO orderEntryRao,
boolean absolute,
java.math.BigDecimal amount)
creates a DiscountRAO for the given OrderEntryRAO based on the input.
|
protected DiscountRAO |
addOrderEntryLevelDiscount(OrderEntryRAO orderEntryRao,
boolean absolute,
java.math.BigDecimal amount,
int consumedQty) |
DiscountRAO |
addOrderEntryLevelDiscountStackable(OrderEntryRAO orderEntryRao,
boolean absolute,
java.math.BigDecimal amount)
Deprecated.
since 6.7
|
DiscountRAO |
addOrderLevelDiscount(CartRAO cartRao,
boolean absolute,
java.math.BigDecimal amount)
creates a DiscountRAO for the given CartRAO based on the input.
|
java.math.BigDecimal |
calculateSubTotals(CartRAO cartRao,
java.util.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 java.math.BigDecimal |
convertPercentageDiscountToAbsoluteDiscount(java.math.BigDecimal percentageAmount,
int quantityToConsume,
NumberedLineItem orderLineItem) |
protected java.math.BigDecimal |
convertPercentageDiscountToAbsoluteDiscount(java.math.BigDecimal percentageAmount,
Order cart) |
protected DiscountRAO |
createAbsoluteDiscountRAO(LineItem lineItem,
java.math.BigDecimal amount,
int applicableUnits) |
protected DiscountRAO |
createAbsoluteDiscountRAO(LineItem lineItem,
java.math.BigDecimal amount,
int applicableUnits,
boolean perUnit) |
protected DiscountRAO |
createDiscountRAO(AbstractDiscount discount)
Creates a new DiscountRAO based on the given AbstractDiscount.
|
protected LineItemDiscount |
createLineItemDiscount(LineItem lineItem,
boolean absolute,
java.math.BigDecimal amount)
Creates an LineItemDiscount based on the given values and adds it to the given
lineItem. |
protected LineItemDiscount |
createLineItemDiscount(LineItem lineItem,
boolean absolute,
java.math.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,
java.math.BigDecimal amount,
boolean perUnit,
int applicableUnits) |
protected OrderDiscount |
createOrderDiscount(Order cart,
boolean absolute,
java.math.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,
java.math.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() |
java.math.BigDecimal |
getAdjustedUnitPrice(int quantity,
OrderEntryRAO orderEntryRao)
Gets the total discount for line item and recalculates the discounted unit price.
|
protected int |
getConsumedQuantityForAllDiscounts(java.util.Set<AbstractRuleActionRAO> actions) |
int |
getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao)
Return consumed quantity for a given order entry
|
protected int |
getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao,
java.util.Set<AbstractRuleActionRAO> actions) |
protected CurrencyUtils |
getCurrencyUtils() |
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.
|
protected MinimumAmountValidationStrategy |
getMinimumAmountValidationStrategy() |
<T extends AbstractOrderRAO> |
getOrderTotalAvailableQuantity(T orderRAO)
Deprecated.
since 6.7
|
protected OrderUtils |
getOrderUtils() |
int |
getProductAvailableQuantityInOrderEntry(OrderEntryRAO orderEntryRAO)
give the order entry and the product, return the number of available product items to consume
|
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 |
setCurrencyUtils(CurrencyUtils currencyUtils) |
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, java.math.BigDecimal amount)
addOrderLevelDiscount in interface RuleEngineCalculationServicecartRao - the cartRAOabsolute - whether the discount is absolute or a percentage discountamount - the amountpublic java.math.BigDecimal getCurrentPrice(java.util.Set<OrderEntryRAO> orderEntryForDiscounts, java.util.Map<java.lang.Integer,java.lang.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, java.math.BigDecimal amount)
addOrderEntryLevelDiscount in interface RuleEngineCalculationServiceorderEntryRao - the orderEntryRaoabsolute - whether the discount is absolute or a percentage discountamount - the amount@Deprecated public DiscountRAO addOrderEntryLevelDiscountStackable(OrderEntryRAO orderEntryRao, boolean absolute, java.math.BigDecimal amount)
RuleEngineCalculationServiceabsolute flag is set to true, the discount
is absolute, otherwise its a percentage based discount.addOrderEntryLevelDiscountStackable in interface RuleEngineCalculationServiceorderEntryRao - the orderEntryRao to add the discount toabsolute - whether the discount is absolute or percentage-basedamount - the amount of the discountprotected DiscountRAO addOrderEntryLevelDiscount(OrderEntryRAO orderEntryRao, boolean absolute, java.math.BigDecimal amount, int consumedQty)
public int getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao)
RuleEngineCalculationServicegetConsumedQuantityForOrderEntry in interface RuleEngineCalculationServiceorderEntryRao - Cart order entryprotected int getConsumedQuantityForAllDiscounts(java.util.Set<AbstractRuleActionRAO> actions)
protected int getConsumedQuantityForOrderEntry(OrderEntryRAO orderEntryRao, java.util.Set<AbstractRuleActionRAO> actions)
@Deprecated public <T extends AbstractOrderRAO> int getOrderTotalAvailableQuantity(T orderRAO)
RuleEngineCalculationServicegetOrderTotalAvailableQuantity in interface RuleEngineCalculationServiceorderRAO - instance of AbstractOrderRAOpublic int getProductAvailableQuantityInOrderEntry(OrderEntryRAO orderEntryRAO)
RuleEngineCalculationServicegetProductAvailableQuantityInOrderEntry in interface RuleEngineCalculationServiceorderEntryRAO - instance of OrderEntryRAOpublic DiscountRAO addFixedPriceEntryDiscount(OrderEntryRAO orderEntryRao, java.math.BigDecimal fixedPrice)
RuleEngineCalculationServicefixedPrice multiplied by quantity.addFixedPriceEntryDiscount in interface RuleEngineCalculationServiceorderEntryRao - the orderEntryRao to add the discount tofixedPrice - the target unit price@Deprecated public DiscountRAO addFixedPriceEntryDiscountStackable(OrderEntryRAO orderEntryRao, java.math.BigDecimal fixedPrice)
RuleEngineCalculationServicefixedPrice multiplied by quantity.addFixedPriceEntryDiscountStackable 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 raojava.lang.IllegalArgumentException - 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, java.math.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, java.math.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, java.math.BigDecimal amount, boolean perUnit, int applicableUnits)
protected LineItemDiscount validateLineItemDiscount(LineItem lineItem, boolean absolute, Currency currency, LineItemDiscount discount)
protected LineItemDiscount createLineItemDiscount(LineItem lineItem, boolean absolute, java.math.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 - instance of Orderprotected OrderCharge createShippingCharge(Order cart, boolean absolute, java.math.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 java.math.BigDecimal calculateSubTotals(CartRAO cartRao, java.util.Collection<ProductRAO> excludedProducts)
RuleEngineCalculationServicecalculateSubTotals in interface RuleEngineCalculationServicecartRao - Cart to be calculatedexcludedProducts - List of products to be excluded from the cart calculationpublic java.math.BigDecimal getAdjustedUnitPrice(int quantity,
OrderEntryRAO orderEntryRao)
RuleEngineCalculationServicegetAdjustedUnitPrice in interface RuleEngineCalculationServicequantity - quantity of line itemorderEntryRao - orderEntryRao to get discounted unit price forpublic 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)
RuleEngineCalculationServicecartRao, with the fixedPrice given as parameter
and for the products from entries in selectedOrderEntryRaos and related quantities given in
selectedOrderEntryMap.addFixedPriceEntriesDiscount in interface RuleEngineCalculationServicecartRao - 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 productprotected DiscountRAO createAbsoluteDiscountRAO(LineItem lineItem, java.math.BigDecimal amount, int applicableUnits)
protected DiscountRAO createAbsoluteDiscountRAO(LineItem lineItem, java.math.BigDecimal amount, int applicableUnits, boolean perUnit)
public 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)
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 java.math.BigDecimal convertPercentageDiscountToAbsoluteDiscount(java.math.BigDecimal percentageAmount,
int quantityToConsume,
NumberedLineItem orderLineItem)
protected java.math.BigDecimal convertPercentageDiscountToAbsoluteDiscount(java.math.BigDecimal percentageAmount,
Order cart)
protected MinimumAmountValidationStrategy getMinimumAmountValidationStrategy()
public void setMinimumAmountValidationStrategy(MinimumAmountValidationStrategy minimumAmountValidationStrategy)
protected OrderUtils getOrderUtils()
public void setOrderUtils(OrderUtils orderUtils)
protected CurrencyUtils getCurrencyUtils()
public void setCurrencyUtils(CurrencyUtils currencyUtils)
protected RaoUtils getRaoUtils()
public void setRaoUtils(RaoUtils raoUtils)
Copyright © 2018 SAP SE. All Rights Reserved.