Class Discount
java.lang.Object
com.broadleafcommerce.promotion.offer.domain.Discount
- All Implemented Interfaces:
DiscountAmountTypeHolder
,Serializable
Encapsulates all of the fields relevant to an
offer's discount
.- Author:
- Nathan Moore (nathanmoore).
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
The discount amount that this discount represents.Determines the method used to apply the discount.Determines how an offer'sdiscount amount
is distributed across the offer's related order item types.Determines the type of entity that receives the discount.Determines the timing of the discount's application.int
hashCode()
boolean
Whether this discount should apply to an item's dependent order items (e.g., add-ons).boolean
Whether this discount should apply to an item's sale price or just its non-sale price(s).void
setAmount
(BigDecimal amount) The discount amount that this discount represents.void
setApplicableToDependentItems
(boolean applicableToDependentItems) Whether this discount should apply to an item's dependent order items (e.g., add-ons).void
setApplicableToSalesPrice
(boolean applicableToSalesPrice) Whether this discount should apply to an item's sale price or just its non-sale price(s).void
setMethodType
(String methodType) Determines the method used to apply the discount.void
setProrationType
(String prorationType) Determines how an offer'sdiscount amount
is distributed across the offer's related order item types.void
setTargetType
(String targetType) Determines the type of entity that receives the discount.void
setTimingType
(String timingType) Determines the timing of the discount's application.toString()
-
Constructor Details
-
Discount
public Discount()
-
-
Method Details
-
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
.- Specified by:
getAmount
in interfaceDiscountAmountTypeHolder
- Returns:
- The amount of the discount to be applied.
-
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:
-
getMethodType
Determines the method used to apply the discount. The method can beDiscountMethodType.PERCENT_OFF
,DiscountMethodType.AMOUNT_OFF
, orDiscountMethodType.FIXED_PRICE
.- Specified by:
getMethodType
in interfaceDiscountAmountTypeHolder
- Returns:
- The method to use to apply this discount.
- See Also:
-
getTimingType
Determines the timing of the discount's application. The discount can be applied eitherimmediately as an ORDER_DISCOUNT
orlater as a FUTURE_CREDIT
. Default value isDiscountTimingType.ORDER_DISCOUNT
.- Returns:
- The time when the discount should be applied.
- See Also:
-
getProrationType
Determines how an offer'sdiscount 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 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:
-
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
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
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:
-
setMethodType
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:
-
setTimingType
Determines the timing of the discount's application. The discount can be applied eitherimmediately as an ORDER_DISCOUNT
orlater as a FUTURE_CREDIT
. Default value isDiscountTimingType.ORDER_DISCOUNT
.- Parameters:
timingType
- The time when the discount should be applied.- See Also:
-
setProrationType
Determines how an offer'sdiscount 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 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:
-
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
-
canEqual
-
hashCode
public int hashCode() -
toString
-