Class Discount
- java.lang.Object
-
- com.broadleafcommerce.promotion.offer.domain.Discount
-
- All Implemented Interfaces:
Serializable
public class Discount extends Object implements Serializable
Encapsulates all of the fields relevant to anoffer's discount.- Author:
- Nathan Moore (nathanmoore).
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Discount()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(Object other)booleanequals(Object o)BigDecimalgetAmount()The discount amount that this discount represents.StringgetMethodType()Determines the method used to apply the discount.StringgetProrationType()Determines how an offer'sdiscount amountis distributed across the offer's related order item types.StringgetTargetType()Determines the type of entity that receives the discount.StringgetTimingType()Determines the timing of the discount's application.inthashCode()booleanisApplicableToDependentItems()Whether this discount should apply to an item's dependent order items (e.g., add-ons).booleanisApplicableToSalesPrice()Whether this discount should apply to an item's sale price or just its non-sale price(s).voidsetAmount(BigDecimal amount)The discount amount that this discount represents.voidsetApplicableToDependentItems(boolean applicableToDependentItems)Whether this discount should apply to an item's dependent order items (e.g., add-ons).voidsetApplicableToSalesPrice(boolean applicableToSalesPrice)Whether this discount should apply to an item's sale price or just its non-sale price(s).voidsetMethodType(String methodType)Determines the method used to apply the discount.voidsetProrationType(String prorationType)Determines how an offer'sdiscount amountis distributed across the offer's related order item types.voidsetTargetType(String targetType)Determines the type of entity that receives the discount.voidsetTimingType(String timingType)Determines the timing of the discount's application.StringtoString()
-
-
-
Method Detail
-
getAmount
public BigDecimal getAmount()
The discount amount that this discount represents. If the amount is10, then whether it is calculated as a percentage (10%) or a currency amount ($10) is determined bymethodType.- 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 beDiscountTargetType.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:
DiscountTargetType
-
getMethodType
public String getMethodType()
Determines the method used to apply the discount. The method can beDiscountMethodType.PERCENT_OFF,DiscountMethodType.AMOUNT_OFF, orDiscountMethodType.FIXED_PRICE.- Returns:
- The method to use to apply this discount.
- See Also:
DiscountMethodType
-
getTimingType
public String getTimingType()
Determines the timing of the discount's application. The discount can be applied eitherimmediately as an ORDER_DISCOUNTorlater as a FUTURE_CREDIT. Default value isDiscountTimingType.ORDER_DISCOUNT.- Returns:
- The time when the discount should be applied.
- See Also:
DiscountTimingType
-
getProrationType
public String getProrationType()
Determines how an offer'sdiscount amountis 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 isProrationType.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:
ProrationType,Offer.getTargetItemCriteria(),Offer.getItemQualifierCriteria()
-
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 is10, then whether it is calculated as a percentage (10%) or a currency amount ($10) is determined bymethodType.- 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 beDiscountTargetType.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:
DiscountTargetType
-
setMethodType
public void setMethodType(String methodType)
Determines the method used to apply the discount. The method can beDiscountMethodType.PERCENT_OFF,DiscountMethodType.AMOUNT_OFF, orDiscountMethodType.FIXED_PRICE.- Parameters:
methodType- The method to use to apply this discount.- See Also:
DiscountMethodType
-
setTimingType
public void setTimingType(String timingType)
Determines the timing of the discount's application. The discount can be applied eitherimmediately as an ORDER_DISCOUNTorlater as a FUTURE_CREDIT. Default value isDiscountTimingType.ORDER_DISCOUNT.- Parameters:
timingType- The time when the discount should be applied.- See Also:
DiscountTimingType
-
setProrationType
public void setProrationType(String prorationType)
Determines how an offer'sdiscount amountis 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 isProrationType.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:
ProrationType,Offer.getTargetItemCriteria(),Offer.getItemQualifierCriteria()
-
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.
-
canEqual
protected boolean canEqual(Object other)
-
-