Class CandidateItemOffer
- All Implemented Interfaces:
Serializable
Offer that can apply to an
EnhancedLineItem is part of the best permutation of all offers applicable to that line
item. This works for OrderLineItems and
FulfillmentLineItems.- Author:
- Nathan Moore (nathanmoore).
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintDetermines the number of targetorder itemsthat can be used when determining whichdiscount tierto use in discounts.protected booleanvoidbooleanMap ofItemCriteriaRulefrom anoffer's item qualifier criteriato aCollectionofEnhancedLineItemthat meet that criteria.Map ofItemCriteriaRulefrom anoffer's target item criteriato aCollectionofEnhancedLineItemthat meet that criteria.Keep track of the current iteration targets so that the estimated discount can be calculated.Optional<javax.money.MonetaryAmount>Represents the remainder of max savings per order that can be applied to qualifying items.The original, unadjusted price of the item being targeted byBaseCandidateOffer.getOffer().javax.money.MonetaryAmountPotential savings per single use ofBaseCandidateOffer.getOffer().The id of each individual usage of this promotion instance.intgetUses()Tracks the number of times this candidate offer has been used.Takes theBaseCandidateOffer.getPotentialSavings()and divides them by the item's price before multiply by 100 to get a percentage.inthashCode()voidbooleanbooleanbooleanDetermines whether to match anoffer tier's min quantityagainst the number of items in an order or to match it against the number of target item set that match anoffer's target item criteria.voidDeprecated.voidsetCandidateQualifiersMap(Map<ItemCriteriaRule, Collection<EnhancedLineItem>> candidateQualifiersMap) Map ofItemCriteriaRulefrom anoffer's item qualifier criteriato aCollectionofEnhancedLineItemthat meet that criteria.voidsetCandidateTargetsMap(Map<ItemCriteriaRule, Collection<EnhancedLineItem>> candidateTargetsMap) Map ofItemCriteriaRulefrom anoffer's target item criteriato aCollectionofEnhancedLineItemthat meet that criteria.voidsetMaxSavingsCheckRequired(boolean maxSavingsCheckRequired) voidsetMaxSavingsDiscounts(Map<LineItemOfferDetail, OfferDiscount> maxSavingsDiscounts) Keep track of the current iteration targets so that the estimated discount can be calculated.voidsetMaxSavingsQualifiers(Map<LineItemOfferDetail, OfferQualifier> maxSavingsQualifiers) voidsetMaxSavingsRemainderAmount(Optional<javax.money.MonetaryAmount> maxSavingsRemainderAmount) Represents the remainder of max savings per order that can be applied to qualifying items.voidsetOriginalPrice(BigDecimal originalPrice) The original, unadjusted price of the item being targeted byBaseCandidateOffer.getOffer().voidsetOrUpdatePromotionUsageId(String promotionUsageBaseId) voidsetPotentialSavingsQtyOne(javax.money.MonetaryAmount potentialSavingsQtyOne) Potential savings per single use ofBaseCandidateOffer.getOffer().voidsetPromotionUsageId(String promotionUsageId) The id of each individual usage of this promotion instance.voidsetUseAmountOnlyTierCalculation(boolean useAmountOnlyTierCalculation) voidsetUseQtyOnlyTierCalculation(boolean useQtyOnlyTierCalculation) Determines whether to match anoffer tier's min quantityagainst the number of items in an order or to match it against the number of target item set that match anoffer's target item criteria.voidsetUses(int uses) Tracks the number of times this candidate offer has been used.voidsetWeightedPercentSaved(BigDecimal weightedPercentSaved) Takes theBaseCandidateOffer.getPotentialSavings()and divides them by the item's price before multiply by 100 to get a percentage.inttargetQtyRequired(EnhancedOrder order) toString()Methods inherited from class com.broadleafcommerce.promotion.offer.service.dto.BaseCandidateOffer
calculateOverrideSegment, excludeDiscountedItemsFromTotal, getAllValidSegments, getCombinableOverrides, getCurrency, getDiscountAmount, getDiscountMethodType, getDiscountTargetType, getExcludedItemIds, getNonCombinableOverrides, getOffer, getOfferCodesMap, getOfferCombinabilityCriteriaKey, getOfferDtosMap, getOfferId, getOverrideOfferId, getPotentialSavings, getRoundingMode, getSegment, getStackableOverrides, initializeExcludedCartItemIds, isApplicableToDependentItems, isNotExcludedFromOffer, isRoundOfferValues, normalizeSegment, populateCombinabilityStructures, populateCombinabilityStructuresUsedBySameTargetType, populatePropertiesFromCodeData, segmentIsValid, setCombinableOverrides, setCurrency, setExcludedItemIds, setNonCombinableOverrides, setOffer, setOfferCodesMap, setOfferCombinabilityCriteriaKey, setOfferDtosMap, setOverrideOfferId, setPotentialSavings, setRoundingMode, setRoundOfferValues, setSegment, setStackableOverrides, updateAmountCurrency, updateMonetaryAmountCurrencyIfNeeded, updateOfferCombinabilityCriteria, validateCodesMatchOfferSegments
-
Constructor Details
-
CandidateItemOffer
public CandidateItemOffer()
-
-
Method Details
-
incrementUses
public void incrementUses() -
setOrUpdatePromotionUsageId
-
calculateTargetQuantityForTieredOffer
public int calculateTargetQuantityForTieredOffer()Determines the number of targetorder itemsthat can be used when determining whichdiscount tierto use in discounts.- Returns:
- the number of target items applicable for tier calculations.
-
resetUses
Deprecated. -
clearState
public void clearState() -
calculateTargetAmountForTieredOffer
- Returns:
- The monetary amount of the items that qualify for this amount based tier offer.
-
targetQtyRequired
-
getCandidateQualifiersMap
Map ofItemCriteriaRulefrom anoffer's item qualifier criteriato aCollectionofEnhancedLineItemthat meet that criteria.- Returns:
- Map of
ItemCriteriaRulefrom anoffer's item qualifier criteriato aCollectionofEnhancedLineItemthat meet that criteria.
-
getCandidateTargetsMap
Map ofItemCriteriaRulefrom anoffer's target item criteriato aCollectionofEnhancedLineItemthat meet that criteria.- Returns:
- Map of
ItemCriteriaRulefrom anoffer's target item criteriato aCollectionofEnhancedLineItemthat meet that criteria.
-
getPotentialSavingsQtyOne
public javax.money.MonetaryAmount getPotentialSavingsQtyOne()Potential savings per single use ofBaseCandidateOffer.getOffer(). TakesBaseCandidateOffer.getPotentialSavings()and divides it byuses. Used in weighting the potential savings to determine the best permutation of all applicable offers.- Returns:
- Potential savings per single use of
BaseCandidateOffer.getOffer()
-
getWeightedPercentSaved
Takes theBaseCandidateOffer.getPotentialSavings()and divides them by the item's price before multiply by 100 to get a percentage. Sometimes a more complex weighting algorithm is used such as when an offer has qualifiers that cannot be used by other offers.- Returns:
- weighted percentage of an item's price that is discounted by using
BaseCandidateOffer.getOffer().
-
getOriginalPrice
The original, unadjusted price of the item being targeted byBaseCandidateOffer.getOffer(). -
getUses
public int getUses()Tracks the number of times this candidate offer has been used. This is used while determining potential savings and the best permutation of applicable offers where we don't want to create anOfferAuditDetailbecause we're calculating potential rather than actually usages.- Returns:
- the number of times this candidate offer has been used
-
isUseQtyOnlyTierCalculation
public boolean isUseQtyOnlyTierCalculation()Determines whether to match an
offer tier's min quantityagainst the number of items in an order or to match it against the number of target item set that match anoffer's target item criteria.Consider the following offer:
- Has 2 tiers:
- 1st tier min quantity: 1
- 2nd tier: 5
- An order must meet the following target item criteria
- Has 3 items in the "Hot Sauces" category
- and 1 item in the "Merchandise" category
When
useQtyOnlyTierCalculation = true, the 2nd tier would apply if the order had 3 hot sauces, 1 t-shirt, and at least 1 of an item in any category. When it's false, then the order must have 5 sets of 3 hot sauces and 1 t-shirt, that is, 15 hot sauces and 5 t-shirts to match this offer.By default this behavior can be configured globally using
broadleaf.offer.useQuantityOnlyTierCalculation- Returns:
- whether to match an
offer tier's min quantityagainst the number of items in an order or to match it against the number of target item set that match anoffer's target item criteria.
- Has 2 tiers:
-
isUseAmountOnlyTierCalculation
public boolean isUseAmountOnlyTierCalculation()- Returns:
- Use amount only tier calculation
- See Also:
-
Offer#useAmountOnlyTierCalculation
-
isMaxSavingsCheckRequired
public boolean isMaxSavingsCheckRequired()- Returns:
- true if max Savings check is required
- See Also:
-
getMaxSavingsRemainderAmount
Represents the remainder of max savings per order that can be applied to qualifying items. Occurs when the max savings threshold is reached such that a given item can not receive the full item discount and instead qualifies for only a part of the discount due to the max threshold calculation. -
getMaxSavingsDiscounts
Keep track of the current iteration targets so that the estimated discount can be calculated. This structure is solely for assisting with the maxSavingsPerOrder calculation -
getMaxSavingsQualifiers
-
getPromotionUsageId
The id of each individual usage of this promotion instance. -
setCandidateQualifiersMap
public void setCandidateQualifiersMap(Map<ItemCriteriaRule, Collection<EnhancedLineItem>> candidateQualifiersMap) Map ofItemCriteriaRulefrom anoffer's item qualifier criteriato aCollectionofEnhancedLineItemthat meet that criteria.- Parameters:
candidateQualifiersMap- Map ofItemCriteriaRulefrom anoffer's item qualifier criteriato aCollectionofEnhancedLineItemthat meet that criteria.
-
setCandidateTargetsMap
public void setCandidateTargetsMap(Map<ItemCriteriaRule, Collection<EnhancedLineItem>> candidateTargetsMap) Map ofItemCriteriaRulefrom anoffer's target item criteriato aCollectionofEnhancedLineItemthat meet that criteria.- Parameters:
candidateTargetsMap- Map ofItemCriteriaRulefrom anoffer's target item criteriato aCollectionofEnhancedLineItemthat meet that criteria.
-
setPotentialSavingsQtyOne
public void setPotentialSavingsQtyOne(javax.money.MonetaryAmount potentialSavingsQtyOne) Potential savings per single use ofBaseCandidateOffer.getOffer(). TakesBaseCandidateOffer.getPotentialSavings()and divides it byuses. Used in weighting the potential savings to determine the best permutation of all applicable offers.- Parameters:
potentialSavingsQtyOne- Potential savings per single use ofBaseCandidateOffer.getOffer()
-
setWeightedPercentSaved
Takes theBaseCandidateOffer.getPotentialSavings()and divides them by the item's price before multiply by 100 to get a percentage. Sometimes a more complex weighting algorithm is used such as when an offer has qualifiers that cannot be used by other offers.- Parameters:
weightedPercentSaved- weighted percentage of an item's price that is discounted by usingBaseCandidateOffer.getOffer().
-
setOriginalPrice
The original, unadjusted price of the item being targeted byBaseCandidateOffer.getOffer(). -
setUses
public void setUses(int uses) Tracks the number of times this candidate offer has been used. This is used while determining potential savings and the best permutation of applicable offers where we don't want to create anOfferAuditDetailbecause we're calculating potential rather than actually usages.- Parameters:
uses- the number of times this candidate offer has been used
-
setUseQtyOnlyTierCalculation
public void setUseQtyOnlyTierCalculation(boolean useQtyOnlyTierCalculation) Determines whether to match an
offer tier's min quantityagainst the number of items in an order or to match it against the number of target item set that match anoffer's target item criteria.Consider the following offer:
- Has 2 tiers:
- 1st tier min quantity: 1
- 2nd tier: 5
- An order must meet the following target item criteria
- Has 3 items in the "Hot Sauces" category
- and 1 item in the "Merchandise" category
When
useQtyOnlyTierCalculation = true, the 2nd tier would apply if the order had 3 hot sauces, 1 t-shirt, and at least 1 of an item in any category. When it's false, then the order must have 5 sets of 3 hot sauces and 1 t-shirt, that is, 15 hot sauces and 5 t-shirts to match this offer.By default this behavior can be configured globally using
broadleaf.offer.useQuantityOnlyTierCalculation- Parameters:
useQtyOnlyTierCalculation- whether to match anoffer tier's min quantityagainst the number of items in an order or to match it against the number of target item set that match anoffer's target item criteria.
- Has 2 tiers:
-
setUseAmountOnlyTierCalculation
public void setUseAmountOnlyTierCalculation(boolean useAmountOnlyTierCalculation) - Parameters:
useAmountOnlyTierCalculation- Use amount only tier calculation- See Also:
-
Offer#useAmountOnlyTierCalculation
-
setMaxSavingsCheckRequired
public void setMaxSavingsCheckRequired(boolean maxSavingsCheckRequired) - Parameters:
maxSavingsCheckRequired- True if the offer requires a max savings check- See Also:
-
setMaxSavingsRemainderAmount
public void setMaxSavingsRemainderAmount(Optional<javax.money.MonetaryAmount> maxSavingsRemainderAmount) Represents the remainder of max savings per order that can be applied to qualifying items. Occurs when the max savings threshold is reached such that a given item can not receive the full item discount and instead qualifies for only a part of the discount due to the max threshold calculation. -
setMaxSavingsDiscounts
Keep track of the current iteration targets so that the estimated discount can be calculated. This structure is solely for assisting with the maxSavingsPerOrder calculation -
setMaxSavingsQualifiers
-
setPromotionUsageId
The id of each individual usage of this promotion instance. -
equals
- Overrides:
equalsin classBaseCandidateOffer
-
canEqual
- Overrides:
canEqualin classBaseCandidateOffer
-
hashCode
public int hashCode()- Overrides:
hashCodein classBaseCandidateOffer
-
toString
- Overrides:
toStringin classBaseCandidateOffer
-