java.lang.Object
com.broadleafcommerce.promotion.offer.domain.Discount
All Implemented Interfaces:
DiscountAmountTypeHolder, Serializable

public class Discount extends Object implements Serializable, DiscountAmountTypeHolder
Encapsulates all of the fields relevant to an offer's discount.
Author:
Nathan Moore (nathanmoore).
See Also:
  • Constructor Details

    • Discount

      public Discount()
  • Method Details

    • getAmount

      public BigDecimal getAmount()
      The discount amount that this discount represents. If the amount is 10, then whether it is calculated as a percentage (10%) or a currency amount ($10) is determined by methodType.
      Specified by:
      getAmount in interface DiscountAmountTypeHolder
      Returns:
      The amount of the discount to be applied.
    • getTargetType

      public String getTargetType()
      Determines the type of entity that receives the discount. The entity can be DiscountTargetType.ORDER, DiscountTargetType.ORDER_ITEM, DiscountTargetType.FULFILLMENT_GROUP, DiscountTargetType.FULFILLMENT_GROUP_ITEM. In the case of orders, order items, and free gift, the discount will be applied to their prices. In the case of fulfillment groups and group items, the discount will be applied to their fulfillment costs (e.g., shipping cost).
      Returns:
      The type of entity that can receive this discount.
      See Also:
    • getMethodType

      public String getMethodType()
      Determines the method used to apply the discount. The method can be DiscountMethodType.PERCENT_OFF, DiscountMethodType.AMOUNT_OFF, or DiscountMethodType.FIXED_PRICE.
      Specified by:
      getMethodType in interface DiscountAmountTypeHolder
      Returns:
      The method to use to apply this discount.
      See Also:
    • getTimingType

      public String getTimingType()
      Determines the timing of the discount's application. The discount can be applied either immediately as an ORDER_DISCOUNT or later as a FUTURE_CREDIT. Default value is DiscountTimingType.ORDER_DISCOUNT.
      Returns:
      The time when the discount should be applied.
      See Also:
    • getProrationType

      public String getProrationType()
      Determines how an offer's discount amount is distributed across the offer's related order item types. This can either be set to prorate across target items or target and qualifier items. Default is ProrationType.TARGET_AND_QUALIFIER.

      This property is used downstream in `OrderOperationServices` or other custom services to calculate the proper refund amounts when factoring in offer discounts.

      Returns:
      The type of order items that this discount is prorated across.
      See Also:
    • isApplicableToSalesPrice

      public boolean isApplicableToSalesPrice()
      Whether this discount should apply to an item's sale price or just its non-sale price(s). Default is true.
      Returns:
      Whether this offer should apply to an item's sale price.
    • isApplicableToDependentItems

      public boolean isApplicableToDependentItems()
      Whether this discount should apply to an item's dependent order items (e.g., add-ons). Default is false.
      Returns:
      Whether this discount should apply to an item's dependent order items.
    • setAmount

      public void setAmount(BigDecimal amount)
      The discount amount that this discount represents. If the amount is 10, then whether it is calculated as a percentage (10%) or a currency amount ($10) is determined by methodType.
      Parameters:
      amount - The amount of the discount to be applied.
    • setTargetType

      public void setTargetType(String targetType)
      Determines the type of entity that receives the discount. The entity can be DiscountTargetType.ORDER, DiscountTargetType.ORDER_ITEM, DiscountTargetType.FULFILLMENT_GROUP, DiscountTargetType.FULFILLMENT_GROUP_ITEM. In the case of orders, order items, and free gift, the discount will be applied to their prices. In the case of fulfillment groups and group items, the discount will be applied to their fulfillment costs (e.g., shipping cost).
      Parameters:
      targetType - The type of entity that can receive this discount.
      See Also:
    • setMethodType

      public void setMethodType(String methodType)
      Determines the method used to apply the discount. The method can be DiscountMethodType.PERCENT_OFF, DiscountMethodType.AMOUNT_OFF, or DiscountMethodType.FIXED_PRICE.
      Parameters:
      methodType - The method to use to apply this discount.
      See Also:
    • setTimingType

      public void setTimingType(String timingType)
      Determines the timing of the discount's application. The discount can be applied either immediately as an ORDER_DISCOUNT or later as a FUTURE_CREDIT. Default value is DiscountTimingType.ORDER_DISCOUNT.
      Parameters:
      timingType - The time when the discount should be applied.
      See Also:
    • setProrationType

      public void setProrationType(String prorationType)
      Determines how an offer's discount amount is distributed across the offer's related order item types. This can either be set to prorate across target items or target and qualifier items. Default is ProrationType.TARGET_AND_QUALIFIER.

      This property is used downstream in `OrderOperationServices` or other custom services to calculate the proper refund amounts when factoring in offer discounts.

      Parameters:
      prorationType - The type of order items that this discount is prorated across.
      See Also:
    • setApplicableToSalesPrice

      public void setApplicableToSalesPrice(boolean applicableToSalesPrice)
      Whether this discount should apply to an item's sale price or just its non-sale price(s). Default is true.
      Parameters:
      applicableToSalesPrice - Whether this discount should apply to an item's sale price.
    • setApplicableToDependentItems

      public void setApplicableToDependentItems(boolean applicableToDependentItems)
      Whether this discount should apply to an item's dependent order items (e.g., add-ons). Default is false.
      Parameters:
      applicableToDependentItems - Whether this discount should apply to an item's dependent order items.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object