Class DefaultOndemandPromotionService
- java.lang.Object
-
- de.hybris.platform.integration.commons.services.impl.DefaultOndemandPromotionService
-
- All Implemented Interfaces:
OndemandPromotionService
public class DefaultOndemandPromotionService extends java.lang.Object implements OndemandPromotionService
Implementation ofOndemandPromotionServiceto distribute the promotions across the lines and units. It is important to note that unit prices are imprecise as the discounted line price may not be perfectly divisible by the quantity after the promotions are applied. This will result in a loss of cents if the unit prices are totalled.
-
-
Constructor Summary
Constructors Constructor Description DefaultOndemandPromotionService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<OndemandDiscountedOrderEntry>calculateProportionalDiscountForEntries(AbstractOrderModel abstractOrder)protected voidcalculateProportionalDiscountForEntries(AbstractOrderModel abstractOrder, java.util.List<AbstractOrderEntryModel> orderedAbstractOrderEntries, java.math.BigDecimal globalDiscountTotal, java.util.Map<AbstractOrderEntryModel,java.math.BigDecimal> orderLineEntries)Returns the discount value for the given order entry.protected OndemandDiscountedOrderEntrycreateOndemandDiscountedOrderEntry(AbstractOrderEntryModel abstractOrderEntry, java.math.BigDecimal calculatedOrderLineDiscount)Method to create the appropriate ondemandDiscountedOrderEntry with the discounted unit price.protected OndemandDiscountableEntryStrategygetDiscountableEntryStrategy()protected OndemandTaxCalculationServicegetTaxCalculationService()protected java.math.BigDecimalgetTotalOfDiscountableEntries(AbstractOrderModel abstractOrder)Return the total price that the global discount can be applied tovoidsetDiscountableEntryStrategy(OndemandDiscountableEntryStrategy discountableEntryStrategy)voidsetTaxCalculationService(OndemandTaxCalculationService taxCalculationService)
-
-
-
Method Detail
-
calculateProportionalDiscountForEntries
public java.util.List<OndemandDiscountedOrderEntry> calculateProportionalDiscountForEntries(AbstractOrderModel abstractOrder)
- Specified by:
calculateProportionalDiscountForEntriesin interfaceOndemandPromotionService
-
calculateProportionalDiscountForEntries
protected void calculateProportionalDiscountForEntries(AbstractOrderModel abstractOrder, java.util.List<AbstractOrderEntryModel> orderedAbstractOrderEntries, java.math.BigDecimal globalDiscountTotal, java.util.Map<AbstractOrderEntryModel,java.math.BigDecimal> orderLineEntries)
Returns the discount value for the given order entry. The discount is calculated proportionally to the total price of the entry in the order.- Parameters:
abstractOrder- the order modelglobalDiscountTotal- the global discount totalorderLineEntries- map of discounts to be updated
-
getTotalOfDiscountableEntries
protected java.math.BigDecimal getTotalOfDiscountableEntries(AbstractOrderModel abstractOrder)
Return the total price that the global discount can be applied to- Parameters:
abstractOrder- Hybris order or cart
-
createOndemandDiscountedOrderEntry
protected OndemandDiscountedOrderEntry createOndemandDiscountedOrderEntry(AbstractOrderEntryModel abstractOrderEntry, java.math.BigDecimal calculatedOrderLineDiscount)
Method to create the appropriate ondemandDiscountedOrderEntry with the discounted unit price.- Parameters:
abstractOrderEntry- - AbstractOrderEntry that is associated with the calculatedOrderLineTotalcalculatedOrderLineDiscount- - Calculated (with order promotions) total of the line item- Returns:
- - Wrapper which contains the AbstractOrderEntry and the discounted unit price
-
getDiscountableEntryStrategy
protected OndemandDiscountableEntryStrategy getDiscountableEntryStrategy()
-
setDiscountableEntryStrategy
public void setDiscountableEntryStrategy(OndemandDiscountableEntryStrategy discountableEntryStrategy)
-
getTaxCalculationService
protected OndemandTaxCalculationService getTaxCalculationService()
-
setTaxCalculationService
public void setTaxCalculationService(OndemandTaxCalculationService taxCalculationService)
-
-