Class DefaultOndemandPromotionService

  • All Implemented Interfaces:
    OndemandPromotionService

    public class DefaultOndemandPromotionService
    extends java.lang.Object
    implements OndemandPromotionService
    Implementation of OndemandPromotionService to 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 Detail

      • DefaultOndemandPromotionService

        public DefaultOndemandPromotionService()
    • Method Detail

      • 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 model
        globalDiscountTotal - the global discount total
        orderLineEntries - 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 calculatedOrderLineTotal
        calculatedOrderLineDiscount - - Calculated (with order promotions) total of the line item
        Returns:
        - Wrapper which contains the AbstractOrderEntry and the discounted unit price