org.broadleafcommerce.core.offer.service.discount.domain
Class PromotableCandidateItemOfferImpl
java.lang.Object
org.broadleafcommerce.core.offer.service.discount.domain.AbstractPromotionRounding
org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateItemOfferImpl
- All Implemented Interfaces:
- Serializable, OfferHolder, PromotableCandidateItemOffer, PromotionRounding
public class PromotableCandidateItemOfferImpl
- extends AbstractPromotionRounding
- implements PromotableCandidateItemOffer, OfferHolder
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
offer
protected Offer offer
promotableOrder
protected PromotableOrder promotableOrder
potentialSavings
protected Money potentialSavings
uses
protected int uses
candidateQualifiersMap
protected HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateQualifiersMap
candidateTargets
protected List<PromotableOrderItem> candidateTargets
PromotableCandidateItemOfferImpl
public PromotableCandidateItemOfferImpl(PromotableOrder promotableOrder,
Offer offer)
calculatePotentialSavings
public Money calculatePotentialSavings()
- This method determines how much the customer might save using this promotion for the
purpose of sorting promotions with the same priority. The assumption is that any possible
target specified for BOGO style offers are of equal or lesser value. We are using
a calculation based on the qualifiers here strictly for rough comparative purposes.
If two promotions have the same priority, the one with the highest potential savings
will be used as the tie-breaker to determine the order to apply promotions.
This method makes a good approximation of the promotion value as determining the exact value
would require all permutations of promotions to be run resulting in a costly
operation.
- Returns:
getCurrency
public BroadleafCurrency getCurrency()
- Specified by:
getCurrency in interface OfferHolder
calculateSavingsForOrderItem
public Money calculateSavingsForOrderItem(PromotableOrderItem orderItem,
int qtyToReceiveSavings)
- Description copied from interface:
PromotableCandidateItemOffer
- Public only for unit testing - not intended to be called
- Specified by:
calculateSavingsForOrderItem in interface PromotableCandidateItemOffer
calculateTargetQuantityForTieredOffer
public int calculateTargetQuantityForTieredOffer()
- Returns the number of items that potentially could be targets for the offer. Due to combination or bogo
logic, they may not all get the tiered offer price.
- Specified by:
calculateTargetQuantityForTieredOffer in interface PromotableCandidateItemOffer
getPotentialSavings
public Money getPotentialSavings()
- Specified by:
getPotentialSavings in interface PromotableCandidateItemOffer
setPotentialSavings
public void setPotentialSavings(Money potentialSavings)
- Specified by:
setPotentialSavings in interface PromotableCandidateItemOffer
hasQualifyingItemCriteria
public boolean hasQualifyingItemCriteria()
- Specified by:
hasQualifyingItemCriteria in interface PromotableCandidateItemOffer
calculateMaximumNumberOfUses
public int calculateMaximumNumberOfUses()
- Determines the maximum number of times this promotion can be used based on the
ItemCriteria and promotion's maxQty setting.
- Specified by:
calculateMaximumNumberOfUses in interface PromotableCandidateItemOffer
calculateMaxUsesForItemCriteria
public int calculateMaxUsesForItemCriteria(OfferItemCriteria itemCriteria,
Offer promotion)
- Description copied from interface:
PromotableCandidateItemOffer
- Determines the max number of times this itemCriteria might apply. This calculation does
not take into account other promotions. It is useful only to assist in prioritizing the order to process
the promotions.
- Specified by:
calculateMaxUsesForItemCriteria in interface PromotableCandidateItemOffer
- Returns:
getCandidateQualifiersMap
public HashMap<OfferItemCriteria,List<PromotableOrderItem>> getCandidateQualifiersMap()
- Specified by:
getCandidateQualifiersMap in interface PromotableCandidateItemOffer
setCandidateQualifiersMap
public void setCandidateQualifiersMap(HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateItemsMap)
- Specified by:
setCandidateQualifiersMap in interface PromotableCandidateItemOffer
getCandidateTargets
public List<PromotableOrderItem> getCandidateTargets()
- Specified by:
getCandidateTargets in interface PromotableCandidateItemOffer
setCandidateTargets
public void setCandidateTargets(List<PromotableOrderItem> candidateTargets)
- Specified by:
setCandidateTargets in interface PromotableCandidateItemOffer
getPriority
public int getPriority()
- Specified by:
getPriority in interface PromotableCandidateItemOffer
getOffer
public Offer getOffer()
- Specified by:
getOffer in interface OfferHolder- Specified by:
getOffer in interface PromotableCandidateItemOffer
getUses
public int getUses()
- Specified by:
getUses in interface PromotableCandidateItemOffer
addUse
public void addUse()
- Specified by:
addUse in interface PromotableCandidateItemOffer
isLegacyOffer
public boolean isLegacyOffer()
- Specified by:
isLegacyOffer in interface PromotableCandidateItemOffer
Copyright © 2013. All Rights Reserved.