Class BaseCandidateOffer
- java.lang.Object
-
- com.broadleafcommerce.promotion.offer.service.dto.BaseCandidateOffer
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CandidateFulfillmentGroupOffer,CandidateItemOffer,CandidateOrderOffer
public class BaseCandidateOffer extends Object implements Serializable
- Author:
- Chad Harchar (charchar)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BaseCandidateOffer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(Object other)booleanequals(Object o)Set<String>getCombinableOverrides()Convert offer data into easier structures for combinability algorithmsjavax.money.CurrencyUnitgetCurrency()TheEnhancedOrder.getCurrency()order's currency code}.StringgetDiscountMethodType()Convenience method to access this property to improve code readabilityStringgetDiscountTargetType()Convenience method to access this property to improve code readabilitySet<String>getNonCombinableOverrides()OffergetOffer()The candidateOffer.OfferCombinabilityCriteriaKeygetOfferCombinabilityCriteriaKey()Holds the combinability criteria for this offer.StringgetOfferId()Convenience method to access this property to improve code readabilityjavax.money.MonetaryAmountgetPotentialSavings()The total potential amount saved by applying this offer to its targets.RoundingModegetRoundingMode()TheRoundingModeto use when rounding.Set<String>getStackableOverrides()inthashCode()booleanisRoundOfferValues()Determines whether to roundpotentialSavings.voidpopulateCombinabilityStructures(CandidateOffers candidateOffers)protected voidpopulateCombinabilityStructuresUsedBySameTargetType(CandidateOffers candidateOffers)voidsetCombinableOverrides(Set<String> combinableOverrides)Convert offer data into easier structures for combinability algorithmsvoidsetCurrency(javax.money.CurrencyUnit currency)TheEnhancedOrder.getCurrency()order's currency code}.voidsetNonCombinableOverrides(Set<String> nonCombinableOverrides)voidsetOffer(Offer offer)The candidateOffer.voidsetOfferCombinabilityCriteriaKey(OfferCombinabilityCriteriaKey offerCombinabilityCriteriaKey)Holds the combinability criteria for this offer.voidsetPotentialSavings(javax.money.MonetaryAmount potentialSavings)The total potential amount saved by applying this offer to its targets.voidsetRoundingMode(RoundingMode roundingMode)TheRoundingModeto use when rounding.voidsetRoundOfferValues(boolean roundOfferValues)Determines whether to roundpotentialSavings.voidsetStackableOverrides(Set<String> stackableOverrides)StringtoString()voidupdateOfferCombinabilityCriteria(CandidateOffers candidateOffers)
-
-
-
Method Detail
-
populateCombinabilityStructures
public void populateCombinabilityStructures(CandidateOffers candidateOffers)
-
populateCombinabilityStructuresUsedBySameTargetType
protected void populateCombinabilityStructuresUsedBySameTargetType(CandidateOffers candidateOffers)
-
updateOfferCombinabilityCriteria
public void updateOfferCombinabilityCriteria(CandidateOffers candidateOffers)
-
getDiscountTargetType
public String getDiscountTargetType()
Convenience method to access this property to improve code readability
-
getDiscountMethodType
public String getDiscountMethodType()
Convenience method to access this property to improve code readability
-
getOfferId
public String getOfferId()
Convenience method to access this property to improve code readability
-
getPotentialSavings
public javax.money.MonetaryAmount getPotentialSavings()
The total potential amount saved by applying this offer to its targets.- Returns:
- The total potential amount saved by applying this offer to its targets.
-
getCurrency
public javax.money.CurrencyUnit getCurrency()
TheEnhancedOrder.getCurrency()order's currency code}.- Returns:
- The
EnhancedOrder.getCurrency()order's currency code}. - See Also:
EnhancedOrder.getCurrency()
-
isRoundOfferValues
public boolean isRoundOfferValues()
Determines whether to round
potentialSavings. Default is false. Note: This is only relevant for adjustments that apply to items. The additional precision is important when multiplying by a "qty". Order and fulfillment group adjustments will always be rounded in the default implementations.It is sometimes problematic to use
DiscountMethodType.PERCENT_OFFofferswith regards to rounding. For example, consider an item that costs $9.99 and has a 50% discount. To be precise, the offer value is 4.995, but this may be a strange value to display to the user depending on the currency being used. Keeping this false produces more accurate results when using quantities > 1. For example, 20% off of $9.99 with a quantity of 5 will produce a savings of exactly $9.99 which would be expected. The savings will always be rounded to the correct precision of the currency, however theS"totalSavings" will always be displays may want to round the value unit adjustment will be up to 5 digits of precision if roundOfferValues is false. Client displays may with to round the adjustment amount if showing per quantity level adjustments.- Returns:
- whether to round
potentialSavings.
-
getRoundingMode
public RoundingMode getRoundingMode()
TheRoundingModeto use when rounding. Default isRoundingMode.HALF_EVEN.- Returns:
- The
RoundingModeto use when rounding.
-
getOfferCombinabilityCriteriaKey
public OfferCombinabilityCriteriaKey getOfferCombinabilityCriteriaKey()
Holds the combinability criteria for this offer. The offer domain contains combinability flags and rules but the criteria will vary with each execution of the offer engine. For example, if "item offer a" can be combined with any "order offer except b" and b is not in the scope of the current offer engine execution, then we can say that "item offer a" can be combined with ANY order offer. Practically, this allows us to reduce the overall complexity of offer engine by getting rid of scenarios that are irrelevant to the current execution.
-
getCombinableOverrides
public Set<String> getCombinableOverrides()
Convert offer data into easier structures for combinability algorithms
-
setOffer
public void setOffer(Offer offer)
The candidateOffer.- Parameters:
offer- The candidateOffer.
-
setPotentialSavings
public void setPotentialSavings(javax.money.MonetaryAmount potentialSavings)
The total potential amount saved by applying this offer to its targets.- Parameters:
potentialSavings- The total potential amount saved by applying this offer to its targets.
-
setCurrency
public void setCurrency(javax.money.CurrencyUnit currency)
TheEnhancedOrder.getCurrency()order's currency code}.- Parameters:
currencyCode- TheEnhancedOrder.getCurrency()order's currency code}.- See Also:
EnhancedOrder.getCurrency()
-
setRoundOfferValues
public void setRoundOfferValues(boolean roundOfferValues)
Determines whether to round
potentialSavings. Default is false. Note: This is only relevant for adjustments that apply to items. The additional precision is important when multiplying by a "qty". Order and fulfillment group adjustments will always be rounded in the default implementations.It is sometimes problematic to use
DiscountMethodType.PERCENT_OFFofferswith regards to rounding. For example, consider an item that costs $9.99 and has a 50% discount. To be precise, the offer value is 4.995, but this may be a strange value to display to the user depending on the currency being used. Keeping this false produces more accurate results when using quantities > 1. For example, 20% off of $9.99 with a quantity of 5 will produce a savings of exactly $9.99 which would be expected. The savings will always be rounded to the correct precision of the currency, however theS"totalSavings" will always be displays may want to round the value unit adjustment will be up to 5 digits of precision if roundOfferValues is false. Client displays may with to round the adjustment amount if showing per quantity level adjustments.- Parameters:
roundOfferValues- whether to roundpotentialSavings.
-
setRoundingMode
public void setRoundingMode(RoundingMode roundingMode)
TheRoundingModeto use when rounding. Default isRoundingMode.HALF_EVEN.- Parameters:
roundingMode- TheRoundingModeto use when rounding.
-
setOfferCombinabilityCriteriaKey
public void setOfferCombinabilityCriteriaKey(OfferCombinabilityCriteriaKey offerCombinabilityCriteriaKey)
Holds the combinability criteria for this offer. The offer domain contains combinability flags and rules but the criteria will vary with each execution of the offer engine. For example, if "item offer a" can be combined with any "order offer except b" and b is not in the scope of the current offer engine execution, then we can say that "item offer a" can be combined with ANY order offer. Practically, this allows us to reduce the overall complexity of offer engine by getting rid of scenarios that are irrelevant to the current execution.
-
setCombinableOverrides
public void setCombinableOverrides(Set<String> combinableOverrides)
Convert offer data into easier structures for combinability algorithms
-
setNonCombinableOverrides
public void setNonCombinableOverrides(Set<String> nonCombinableOverrides)
-
canEqual
protected boolean canEqual(Object other)
-
-