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

java.lang.Object
  extended by org.broadleafcommerce.core.offer.service.discount.domain.AbstractPromotionRounding
      extended by 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

Field Summary
protected  HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateQualifiersMap
           
protected  HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateTargetsMap
           
protected  List<PromotableOrderItem> legacyCandidateTargets
           
protected  Offer offer
           
protected  Money potentialSavings
           
protected  PromotableOrder promotableOrder
           
protected  int uses
           
 
Fields inherited from class org.broadleafcommerce.core.offer.service.discount.domain.AbstractPromotionRounding
roundingMode, roundingScale, roundOfferValues
 
Constructor Summary
PromotableCandidateItemOfferImpl(PromotableOrder promotableOrder, Offer offer)
           
 
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)
          Determines the max number of times this itemCriteria might apply.
 Money calculateSavingsForOrderItem(PromotableOrderItem orderItem, int qtyToReceiveSavings)
          Public only for unit testing - not intended to be called
 int calculateTargetQuantityForTieredOffer()
          Returns the number of items that potentially could be targets for the offer.
 HashMap<OfferItemCriteria,List<PromotableOrderItem>> getCandidateQualifiersMap()
           
 HashMap<OfferItemCriteria,List<PromotableOrderItem>> getCandidateTargetsMap()
           
 BroadleafCurrency getCurrency()
           
 List<PromotableOrderItem> getLegacyCandidateTargets()
           
 Offer getOffer()
           
 Money getPotentialSavings()
           
 int getPriority()
           
 int getUses()
           
 boolean hasQualifyingItemCriteria()
           
 boolean isLegacyOffer()
           
 void resetUses()
          Resets the uses for this candidate offer item.
 void setCandidateQualifiersMap(HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateItemsMap)
           
 void setCandidateTargetsMap(HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateItemsMap)
           
 void setLegacyCandidateTargets(List<PromotableOrderItem> candidateTargets)
           
 void setPotentialSavings(Money potentialSavings)
           
 
Methods inherited from class org.broadleafcommerce.core.offer.service.discount.domain.AbstractPromotionRounding
getRoundingMode, getRoundingScale, isRoundOfferValues, setRoundingMode, setRoundingScale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

offer

protected Offer offer

promotableOrder

protected PromotableOrder promotableOrder

potentialSavings

protected Money potentialSavings

uses

protected int uses

candidateQualifiersMap

protected HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateQualifiersMap

candidateTargetsMap

protected HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateTargetsMap

legacyCandidateTargets

protected List<PromotableOrderItem> legacyCandidateTargets
Constructor Detail

PromotableCandidateItemOfferImpl

public PromotableCandidateItemOfferImpl(PromotableOrder promotableOrder,
                                        Offer offer)
Method Detail

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

getCandidateTargetsMap

public HashMap<OfferItemCriteria,List<PromotableOrderItem>> getCandidateTargetsMap()
Specified by:
getCandidateTargetsMap in interface PromotableCandidateItemOffer

setCandidateTargetsMap

public void setCandidateTargetsMap(HashMap<OfferItemCriteria,List<PromotableOrderItem>> candidateItemsMap)
Specified by:
setCandidateTargetsMap 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

resetUses

public void resetUses()
Description copied from interface: PromotableCandidateItemOffer
Resets the uses for this candidate offer item. This is mainly used in the case where we want to calculate savings and then actually apply the promotion to an item. Both scenarios run through the same logic that add uses in order to determine if various quantities of items can be targeted for a particular promotion.

Specified by:
resetUses in interface PromotableCandidateItemOffer
See Also:
ItemOfferProcessor#applyAndCompareOrderAndItemOffers(PromotableOrder, List, List)}

isLegacyOffer

public boolean isLegacyOffer()
Specified by:
isLegacyOffer in interface PromotableCandidateItemOffer

getLegacyCandidateTargets

public List<PromotableOrderItem> getLegacyCandidateTargets()
Specified by:
getLegacyCandidateTargets in interface PromotableCandidateItemOffer

setLegacyCandidateTargets

public void setLegacyCandidateTargets(List<PromotableOrderItem> candidateTargets)
Specified by:
setLegacyCandidateTargets in interface PromotableCandidateItemOffer


Copyright © 2013. All Rights Reserved.