Class CandidateItemOffer
- java.lang.Object
-
- com.broadleafcommerce.promotion.offer.service.dto.BaseCandidateOffer
-
- com.broadleafcommerce.promotion.offer.service.dto.CandidateItemOffer
-
- All Implemented Interfaces:
Serializable
public class CandidateItemOffer extends BaseCandidateOffer
DTO containing information necessary for determining if anOfferthat can apply to anEnhancedLineItemis part of the best permutation of all offers applicable to that line item. This works forOrderLineItemsandFulfillmentLineItems.- Author:
- Nathan Moore (nathanmoore).
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CandidateItemOffer()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BigDecimalcalculateTargetAmountForTieredOffer()intcalculateTargetQuantityForTieredOffer()Determines the number of targetorder itemsthat can be used when determining whichdiscount tierto use in discounts.protected booleancanEqual(Object other)voidclearState()booleanequals(Object o)Map<ItemCriteriaRule,Collection<EnhancedLineItem>>getCandidateQualifiersMap()Map ofItemCriteriaRulefrom anoffer's item qualifier criteriato aCollectionofEnhancedLineItemthat meet that criteria.Map<ItemCriteriaRule,Collection<EnhancedLineItem>>getCandidateTargetsMap()Map ofItemCriteriaRulefrom anoffer's target item criteriato aCollectionofEnhancedLineItemthat meet that criteria.BigDecimalgetOriginalPrice()The original, unadjusted price of the item being targeted byBaseCandidateOffer.getOffer().javax.money.MonetaryAmountgetPotentialSavingsQtyOne()Potential savings per single use ofBaseCandidateOffer.getOffer().intgetUses()Tracks the number of times this candidate offer has been used.BigDecimalgetWeightedPercentSaved()Takes theBaseCandidateOffer.getPotentialSavings()and divides them by the item's price before multiply by 100 to get a percentage.inthashCode()voidincrementUses()booleanisUseAmountOnlyTierCalculation()booleanisUseQtyOnlyTierCalculation()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.voidresetUses()Deprecated.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.voidsetOriginalPrice(BigDecimal originalPrice)The original, unadjusted price of the item being targeted byBaseCandidateOffer.getOffer().voidsetPotentialSavingsQtyOne(javax.money.MonetaryAmount potentialSavingsQtyOne)Potential savings per single use ofBaseCandidateOffer.getOffer().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)StringtoString()-
Methods inherited from class com.broadleafcommerce.promotion.offer.service.dto.BaseCandidateOffer
getCombinableOverrides, getCurrency, getDiscountMethodType, getDiscountTargetType, getNonCombinableOverrides, getOffer, getOfferCombinabilityCriteriaKey, getOfferId, getPotentialSavings, getRoundingMode, getStackableOverrides, isRoundOfferValues, populateCombinabilityStructures, populateCombinabilityStructuresUsedBySameTargetType, setCombinableOverrides, setCurrency, setNonCombinableOverrides, setOffer, setOfferCombinabilityCriteriaKey, setPotentialSavings, setRoundingMode, setRoundOfferValues, setStackableOverrides, updateOfferCombinabilityCriteria
-
-
-
-
Method Detail
-
incrementUses
public void incrementUses()
-
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 public void resetUses()
Deprecated.
-
clearState
public void clearState()
-
calculateTargetAmountForTieredOffer
public BigDecimal calculateTargetAmountForTieredOffer()
- Returns:
- The monetary amount of the items that qualify for this amount based tier offer.
-
targetQtyRequired
public int targetQtyRequired(EnhancedOrder order)
-
getCandidateQualifiersMap
public Map<ItemCriteriaRule,Collection<EnhancedLineItem>> 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
public Map<ItemCriteriaRule,Collection<EnhancedLineItem>> 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
public BigDecimal 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
public BigDecimal 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
-
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
public void setWeightedPercentSaved(BigDecimal weightedPercentSaved)
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
public void setOriginalPrice(BigDecimal originalPrice)
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
-
equals
public boolean equals(Object o)
- Overrides:
equalsin classBaseCandidateOffer
-
canEqual
protected boolean canEqual(Object other)
- Overrides:
canEqualin classBaseCandidateOffer
-
hashCode
public int hashCode()
- Overrides:
hashCodein classBaseCandidateOffer
-
toString
public String toString()
- Overrides:
toStringin classBaseCandidateOffer
-
-