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
-
Method Summary
Modifier and TypeMethodDescriptionint
Determines the number of targetorder items
that can be used when determining whichdiscount tier
to use in discounts.protected boolean
void
boolean
Map ofItemCriteriaRule
from anoffer's item qualifier criteria
to aCollection
ofEnhancedLineItem
that meet that criteria.Map ofItemCriteriaRule
from anoffer's target item criteria
to aCollection
ofEnhancedLineItem
that 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.MonetaryAmount
Potential savings per single use ofBaseCandidateOffer.getOffer()
.The id of each individual usage of this promotion instance.int
getUses()
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.int
hashCode()
void
boolean
boolean
boolean
Determines whether to match anoffer tier's min quantity
against 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
.void
Deprecated.void
setCandidateQualifiersMap
(Map<ItemCriteriaRule, Collection<EnhancedLineItem>> candidateQualifiersMap) Map ofItemCriteriaRule
from anoffer's item qualifier criteria
to aCollection
ofEnhancedLineItem
that meet that criteria.void
setCandidateTargetsMap
(Map<ItemCriteriaRule, Collection<EnhancedLineItem>> candidateTargetsMap) Map ofItemCriteriaRule
from anoffer's target item criteria
to aCollection
ofEnhancedLineItem
that meet that criteria.void
setMaxSavingsCheckRequired
(boolean maxSavingsCheckRequired) void
setMaxSavingsDiscounts
(Map<LineItemOfferDetail, OfferDiscount> maxSavingsDiscounts) Keep track of the current iteration targets so that the estimated discount can be calculated.void
setMaxSavingsQualifiers
(Map<LineItemOfferDetail, OfferQualifier> maxSavingsQualifiers) void
setMaxSavingsRemainderAmount
(Optional<javax.money.MonetaryAmount> maxSavingsRemainderAmount) Represents the remainder of max savings per order that can be applied to qualifying items.void
setOriginalPrice
(BigDecimal originalPrice) The original, unadjusted price of the item being targeted byBaseCandidateOffer.getOffer()
.void
setOrUpdatePromotionUsageId
(String promotionUsageBaseId) void
setPotentialSavingsQtyOne
(javax.money.MonetaryAmount potentialSavingsQtyOne) Potential savings per single use ofBaseCandidateOffer.getOffer()
.void
setPromotionUsageId
(String promotionUsageId) The id of each individual usage of this promotion instance.void
setUseAmountOnlyTierCalculation
(boolean useAmountOnlyTierCalculation) void
setUseQtyOnlyTierCalculation
(boolean useQtyOnlyTierCalculation) Determines whether to match anoffer tier's min quantity
against 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
.void
setUses
(int uses) Tracks the number of times this candidate offer has been used.void
setWeightedPercentSaved
(BigDecimal weightedPercentSaved) Takes theBaseCandidateOffer.getPotentialSavings()
and divides them by the item's price before multiply by 100 to get a percentage.int
targetQtyRequired
(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 items
that can be used when determining whichdiscount tier
to 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 ofItemCriteriaRule
from anoffer's item qualifier criteria
to aCollection
ofEnhancedLineItem
that meet that criteria.- Returns:
- Map of
ItemCriteriaRule
from anoffer's item qualifier criteria
to aCollection
ofEnhancedLineItem
that meet that criteria.
-
getCandidateTargetsMap
Map ofItemCriteriaRule
from anoffer's target item criteria
to aCollection
ofEnhancedLineItem
that meet that criteria.- Returns:
- Map of
ItemCriteriaRule
from anoffer's target item criteria
to aCollection
ofEnhancedLineItem
that 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 anOfferAuditDetail
because 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 quantity
against 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 quantity
against 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 ofItemCriteriaRule
from anoffer's item qualifier criteria
to aCollection
ofEnhancedLineItem
that meet that criteria.- Parameters:
candidateQualifiersMap
- Map ofItemCriteriaRule
from anoffer's item qualifier criteria
to aCollection
ofEnhancedLineItem
that meet that criteria.
-
setCandidateTargetsMap
public void setCandidateTargetsMap(Map<ItemCriteriaRule, Collection<EnhancedLineItem>> candidateTargetsMap) Map ofItemCriteriaRule
from anoffer's target item criteria
to aCollection
ofEnhancedLineItem
that meet that criteria.- Parameters:
candidateTargetsMap
- Map ofItemCriteriaRule
from anoffer's target item criteria
to aCollection
ofEnhancedLineItem
that 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 anOfferAuditDetail
because 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 quantity
against 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 quantity
against 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:
equals
in classBaseCandidateOffer
-
canEqual
- Overrides:
canEqual
in classBaseCandidateOffer
-
hashCode
public int hashCode()- Overrides:
hashCode
in classBaseCandidateOffer
-
toString
- Overrides:
toString
in classBaseCandidateOffer
-