org.broadleafcommerce.core.offer.service.discount.domain
Class PromotableCandidateItemOfferImpl

java.lang.Object
  extended by org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateItemOfferImpl
All Implemented Interfaces:
PromotableCandidateItemOffer

public class PromotableCandidateItemOfferImpl
extends Object
implements PromotableCandidateItemOffer


Field Summary
protected  HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateQualifiersMap
           
protected  List<PromotableOrderItem> candidateTargets
           
protected  CandidateItemOffer delegate
           
protected  PromotableOrderItem orderItem
           
protected  Money potentialSavings
           
protected  int uses
           
 
Constructor Summary
PromotableCandidateItemOfferImpl(CandidateItemOffer candidateItemOffer)
           
 
Method Summary
 void addUse()
           
 int calculateMaximumNumberOfUses()
          Determines the maximum number of times this promotion can be used based on the ItemCriteria and promotion's maxQty setting.
 int calculateMaxUsesForItemCriteria(OfferItemCriteria itemCriteria, Offer promotion)
           
 Money calculatePotentialSavings()
          This method determines how much the customer might save using this promotion for the purpose of sorting promotions with the same priority.
 Money calculateSavingsForOrderItem(PromotableOrderItem orderItem, int qtyToReceiveSavings)
           
 PromotableCandidateItemOffer clone()
           
 HashMap<OfferItemCriteria,List<PromotableOrderItem>> getCandidateQualifiersMap()
           
 List<PromotableOrderItem> getCandidateTargets()
           
 CandidateItemOffer getDelegate()
           
 Offer getOffer()
           
 PromotableOrderItem getOrderItem()
           
 Money getPotentialSavings()
           
 int getPriority()
           
 int getUses()
           
 void reset()
           
 void setCandidateQualifiersMap(HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateItemsMap)
           
 void setCandidateTargets(List<PromotableOrderItem> candidateTargets)
           
 void setOffer(Offer offer)
           
 void setOrderItem(PromotableOrderItem orderItem)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

potentialSavings

protected Money potentialSavings

candidateQualifiersMap

protected HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateQualifiersMap

candidateTargets

protected List<PromotableOrderItem> candidateTargets

delegate

protected CandidateItemOffer delegate

orderItem

protected PromotableOrderItem orderItem

uses

protected int uses
Constructor Detail

PromotableCandidateItemOfferImpl

public PromotableCandidateItemOfferImpl(CandidateItemOffer candidateItemOffer)
Method Detail

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

calculateSavingsForOrderItem

public Money calculateSavingsForOrderItem(PromotableOrderItem orderItem,
                                          int qtyToReceiveSavings)
Specified by:
calculateSavingsForOrderItem in interface PromotableCandidateItemOffer

getPotentialSavings

public Money getPotentialSavings()
Specified by:
getPotentialSavings in interface PromotableCandidateItemOffer

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.

Specified by:
calculatePotentialSavings in interface PromotableCandidateItemOffer
Returns:

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)
Specified by:
calculateMaxUsesForItemCriteria in interface PromotableCandidateItemOffer

getDelegate

public CandidateItemOffer getDelegate()
Specified by:
getDelegate in interface PromotableCandidateItemOffer

reset

public void reset()
Specified by:
reset in interface PromotableCandidateItemOffer

setOrderItem

public void setOrderItem(PromotableOrderItem orderItem)
Specified by:
setOrderItem in interface PromotableCandidateItemOffer

clone

public PromotableCandidateItemOffer clone()
Specified by:
clone in interface PromotableCandidateItemOffer
Overrides:
clone in class Object

getPriority

public int getPriority()
Specified by:
getPriority in interface PromotableCandidateItemOffer

getOffer

public Offer getOffer()
Specified by:
getOffer in interface PromotableCandidateItemOffer

setOffer

public void setOffer(Offer offer)
Specified by:
setOffer in interface PromotableCandidateItemOffer

getOrderItem

public PromotableOrderItem getOrderItem()
Specified by:
getOrderItem in interface PromotableCandidateItemOffer

getUses

public int getUses()
Specified by:
getUses in interface PromotableCandidateItemOffer

addUse

public void addUse()
Specified by:
addUse in interface PromotableCandidateItemOffer


Copyright © 2013. All Rights Reserved.