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

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

public class PromotableOrderItemPriceDetailImpl
extends Object
implements PromotableOrderItemPriceDetail


Field Summary
protected  Money adjustedTotal
           
protected  boolean adjustmentsFinalized
           
protected  PromotableOrderItem promotableOrderItem
           
protected  List<PromotableOrderItemPriceDetailAdjustment> promotableOrderItemPriceDetailAdjustments
           
protected  List<PromotionDiscount> promotionDiscounts
           
protected  List<PromotionQualifier> promotionQualifiers
           
protected  int quantity
           
protected  boolean useSaleAdjustments
           
 
Constructor Summary
PromotableOrderItemPriceDetailImpl(PromotableOrderItem promotableOrderItem, int quantity)
           
 
Method Summary
 void addCandidateItemPriceDetailAdjustment(PromotableOrderItemPriceDetailAdjustment itemAdjustment)
          Adds the adjustment to the item's adjustment list and discounts the item's prices by the value of the adjustment.
 void addPromotionDiscount(PromotableCandidateItemOffer itemOffer, Set<OfferItemCriteria> itemCriteria, int qtyToMarkAsTarget)
          Adds a promotionDiscount entry to this itemDetail.
 void addPromotionQualifier(PromotableCandidateItemOffer itemOffer, OfferItemCriteria itemCriteria, int qtyToMarkAsQualifier)
          Adds a promotionQualifier entry to this itemDetail.
 String buildDetailKey()
          Creates a key that represents a unique priceDetail
protected  Money calculateAdjustmentsUnitValue()
           
 Money calculateItemUnitPriceWithAdjustments(boolean allowSalePrice)
          Returns the price to be used for this priceDetail taking into account whether or not the sales price can be used.
 Money calculateRetailAdjustmentUnitPrice()
           
 Money calculateSaleAdjustmentUnitPrice()
           
 Money calculateTotalAdjustmentValue()
          Returns the total adjustment value as the sum of the adjustments times the quantity represented by this PriceDetail
 void chooseSaleOrRetailAdjustments()
          This method will check to see if the salePriceAdjustments or retailPriceAdjustments are better and remove those that should not apply.
 void clearAllNonFinalizedQuantities()
          Clears target and qualifier quantities that were marked for a promotion that did not have enough qualifiers or targets to get applied.
protected  void finalizeAdjustments(boolean useSaleAdjustments)
           
 void finalizeQuantities()
          Updates the target and qualifier quantities to indicate the number that are being used.
 List<PromotableOrderItemPriceDetailAdjustment> getCandidateItemAdjustments()
           
 Money getFinalizedTotalWithAdjustments()
          Returns the final total for this item taking into account the finalized adjustments.
 PromotableOrderItem getPromotableOrderItem()
          Return the parent promotableOrderItem
 List<PromotionDiscount> getPromotionDiscounts()
          Returns the promotion discounts applied to this detail object.
 List<PromotionQualifier> getPromotionQualifiers()
          Returns the times this item is being used as a promotionQualifier
 int getQuantity()
          Returns the quantity associated with this priceDetail.
 int getQuantityAvailableToBeUsedAsQualifier(PromotableCandidateItemOffer itemOffer)
          Returns the quantity of this item that can be used as a qualifier for the passed in itemOffer
 int getQuantityAvailableToBeUsedAsTarget(PromotableCandidateItemOffer itemOffer)
          Returns the quantity of this item that can be used as a target for the passed in itemOffer
 boolean hasNonCombinableAdjustments()
          Returns true if this detail has nonCombinable adjustments.
protected  boolean hasOrderItemAdjustments()
           
 boolean isNonCombinableOfferApplied()
          Returns true if a non-combinable offer has been applied to this item.
 boolean isTotalitarianOfferApplied()
          Returns true if a notCombinableOffer or totalitarian offer was applied to this priceDetail.
 PromotionDiscount lookupOrCreatePromotionDiscount(PromotableCandidateItemOffer candidatePromotion)
           
 PromotionQualifier lookupOrCreatePromotionQualifier(PromotableCandidateItemOffer candidatePromotion)
           
 void removeAllAdjustments()
          Removes all adjustments from this detail.
protected  void removeRetailOnlyAdjustments()
          Removes retail only adjustments.
protected  void removeZeroDollarAdjustments(boolean useSalePrice)
          If removeUnusedAdjustments is s
 void setQuantity(int quantity)
          Sets the quantity for this price detail.
protected  PromotableOrderItemPriceDetail split(int discountQty, Long offerId)
           
 PromotableOrderItemPriceDetail splitIfNecessary()
          Checks to see that the discount quantities match the target quantities.
 boolean useSaleAdjustments()
          Returns true if the sale adjustments should be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

promotableOrderItem

protected PromotableOrderItem promotableOrderItem

promotableOrderItemPriceDetailAdjustments

protected List<PromotableOrderItemPriceDetailAdjustment> promotableOrderItemPriceDetailAdjustments

promotionDiscounts

protected List<PromotionDiscount> promotionDiscounts

promotionQualifiers

protected List<PromotionQualifier> promotionQualifiers

quantity

protected int quantity

useSaleAdjustments

protected boolean useSaleAdjustments

adjustmentsFinalized

protected boolean adjustmentsFinalized

adjustedTotal

protected Money adjustedTotal
Constructor Detail

PromotableOrderItemPriceDetailImpl

public PromotableOrderItemPriceDetailImpl(PromotableOrderItem promotableOrderItem,
                                          int quantity)
Method Detail

addCandidateItemPriceDetailAdjustment

public void addCandidateItemPriceDetailAdjustment(PromotableOrderItemPriceDetailAdjustment itemAdjustment)
Description copied from interface: PromotableOrderItemPriceDetail
Adds the adjustment to the item's adjustment list and discounts the item's prices by the value of the adjustment.

Specified by:
addCandidateItemPriceDetailAdjustment in interface PromotableOrderItemPriceDetail

getCandidateItemAdjustments

public List<PromotableOrderItemPriceDetailAdjustment> getCandidateItemAdjustments()
Specified by:
getCandidateItemAdjustments in interface PromotableOrderItemPriceDetail
Returns:

hasNonCombinableAdjustments

public boolean hasNonCombinableAdjustments()
Description copied from interface: PromotableOrderItemPriceDetail
Returns true if this detail has nonCombinable adjustments. Used primarily with legacy offers (prior to 2.0)

Specified by:
hasNonCombinableAdjustments in interface PromotableOrderItemPriceDetail
Returns:

hasOrderItemAdjustments

protected boolean hasOrderItemAdjustments()

isTotalitarianOfferApplied

public boolean isTotalitarianOfferApplied()
Description copied from interface: PromotableOrderItemPriceDetail
Returns true if a notCombinableOffer or totalitarian offer was applied to this priceDetail.

Specified by:
isTotalitarianOfferApplied in interface PromotableOrderItemPriceDetail
Returns:

isNonCombinableOfferApplied

public boolean isNonCombinableOfferApplied()
Description copied from interface: PromotableOrderItemPriceDetail
Returns true if a non-combinable offer has been applied to this item.

Specified by:
isNonCombinableOfferApplied in interface PromotableOrderItemPriceDetail

calculateSaleAdjustmentUnitPrice

public Money calculateSaleAdjustmentUnitPrice()

calculateRetailAdjustmentUnitPrice

public Money calculateRetailAdjustmentUnitPrice()

chooseSaleOrRetailAdjustments

public void chooseSaleOrRetailAdjustments()
This method will check to see if the salePriceAdjustments or retailPriceAdjustments are better and remove those that should not apply.

Specified by:
chooseSaleOrRetailAdjustments in interface PromotableOrderItemPriceDetail

removeAllAdjustments

public void removeAllAdjustments()
Description copied from interface: PromotableOrderItemPriceDetail
Removes all adjustments from this detail. Typically called when it has been determined that another "totalitarian" offer has been applied.

Specified by:
removeAllAdjustments in interface PromotableOrderItemPriceDetail

finalizeAdjustments

protected void finalizeAdjustments(boolean useSaleAdjustments)

removeRetailOnlyAdjustments

protected void removeRetailOnlyAdjustments()
Removes retail only adjustments.


removeZeroDollarAdjustments

protected void removeZeroDollarAdjustments(boolean useSalePrice)
If removeUnusedAdjustments is s

Parameters:
useSaleAdjustments -

getPromotableOrderItem

public PromotableOrderItem getPromotableOrderItem()
Description copied from interface: PromotableOrderItemPriceDetail
Return the parent promotableOrderItem

Specified by:
getPromotableOrderItem in interface PromotableOrderItemPriceDetail

getPromotionDiscounts

public List<PromotionDiscount> getPromotionDiscounts()
Description copied from interface: PromotableOrderItemPriceDetail
Returns the promotion discounts applied to this detail object.

Specified by:
getPromotionDiscounts in interface PromotableOrderItemPriceDetail
Returns:

getPromotionQualifiers

public List<PromotionQualifier> getPromotionQualifiers()
Description copied from interface: PromotableOrderItemPriceDetail
Returns the times this item is being used as a promotionQualifier

Specified by:
getPromotionQualifiers in interface PromotableOrderItemPriceDetail
Returns:

getQuantity

public int getQuantity()
Description copied from interface: PromotableOrderItemPriceDetail
Returns the quantity associated with this priceDetail.

Specified by:
getQuantity in interface PromotableOrderItemPriceDetail
Returns:

setQuantity

public void setQuantity(int quantity)
Description copied from interface: PromotableOrderItemPriceDetail
Sets the quantity for this price detail.

Specified by:
setQuantity in interface PromotableOrderItemPriceDetail

getQuantityAvailableToBeUsedAsTarget

public int getQuantityAvailableToBeUsedAsTarget(PromotableCandidateItemOffer itemOffer)
Description copied from interface: PromotableOrderItemPriceDetail
Returns the quantity of this item that can be used as a target for the passed in itemOffer

Specified by:
getQuantityAvailableToBeUsedAsTarget in interface PromotableOrderItemPriceDetail
Returns:

lookupOrCreatePromotionQualifier

public PromotionQualifier lookupOrCreatePromotionQualifier(PromotableCandidateItemOffer candidatePromotion)

lookupOrCreatePromotionDiscount

public PromotionDiscount lookupOrCreatePromotionDiscount(PromotableCandidateItemOffer candidatePromotion)

addPromotionQualifier

public void addPromotionQualifier(PromotableCandidateItemOffer itemOffer,
                                  OfferItemCriteria itemCriteria,
                                  int qtyToMarkAsQualifier)
Description copied from interface: PromotableOrderItemPriceDetail
Adds a promotionQualifier entry to this itemDetail. PromotionQualifiers record the fact that this item has been marked to be used as a qualifier for other items to receive a discount. If other conditions are met this qualifier will be finalized.

Specified by:
addPromotionQualifier in interface PromotableOrderItemPriceDetail

addPromotionDiscount

public void addPromotionDiscount(PromotableCandidateItemOffer itemOffer,
                                 Set<OfferItemCriteria> itemCriteria,
                                 int qtyToMarkAsTarget)
Description copied from interface: PromotableOrderItemPriceDetail
Adds a promotionDiscount entry to this itemDetail. PromotionDiscounts record the fact that this item has been targeted to receive a discount. If other conditions are met this discount will be finalized so that it can then be set on the underlying orderItem.

Specified by:
addPromotionDiscount in interface PromotableOrderItemPriceDetail

finalizeQuantities

public void finalizeQuantities()
Description copied from interface: PromotableOrderItemPriceDetail
Updates the target and qualifier quantities to indicate the number that are being used.

Specified by:
finalizeQuantities in interface PromotableOrderItemPriceDetail

clearAllNonFinalizedQuantities

public void clearAllNonFinalizedQuantities()
Description copied from interface: PromotableOrderItemPriceDetail
Clears target and qualifier quantities that were marked for a promotion that did not have enough qualifiers or targets to get applied.

Specified by:
clearAllNonFinalizedQuantities in interface PromotableOrderItemPriceDetail

getQuantityAvailableToBeUsedAsQualifier

public int getQuantityAvailableToBeUsedAsQualifier(PromotableCandidateItemOffer itemOffer)
Description copied from interface: PromotableOrderItemPriceDetail
Returns the quantity of this item that can be used as a qualifier for the passed in itemOffer

Specified by:
getQuantityAvailableToBeUsedAsQualifier in interface PromotableOrderItemPriceDetail
Returns:

calculateItemUnitPriceWithAdjustments

public Money calculateItemUnitPriceWithAdjustments(boolean allowSalePrice)
Description copied from interface: PromotableOrderItemPriceDetail
Returns the price to be used for this priceDetail taking into account whether or not the sales price can be used.

Specified by:
calculateItemUnitPriceWithAdjustments in interface PromotableOrderItemPriceDetail
Returns:

calculateAdjustmentsUnitValue

protected Money calculateAdjustmentsUnitValue()

buildDetailKey

public String buildDetailKey()
Creates a key that represents a unique priceDetail

Specified by:
buildDetailKey in interface PromotableOrderItemPriceDetail
Returns:

getFinalizedTotalWithAdjustments

public Money getFinalizedTotalWithAdjustments()
Description copied from interface: PromotableOrderItemPriceDetail
Returns the final total for this item taking into account the finalized adjustments. Intended to be called after the adjustments have been finalized with a call PromotableOrderItemPriceDetail.chooseSaleOrRetailAdjustments().

Specified by:
getFinalizedTotalWithAdjustments in interface PromotableOrderItemPriceDetail

calculateTotalAdjustmentValue

public Money calculateTotalAdjustmentValue()
Description copied from interface: PromotableOrderItemPriceDetail
Returns the total adjustment value as the sum of the adjustments times the quantity represented by this PriceDetail

Specified by:
calculateTotalAdjustmentValue in interface PromotableOrderItemPriceDetail
Returns:

split

protected PromotableOrderItemPriceDetail split(int discountQty,
                                               Long offerId)

splitIfNecessary

public PromotableOrderItemPriceDetail splitIfNecessary()
Description copied from interface: PromotableOrderItemPriceDetail
Checks to see that the discount quantities match the target quantities. If not, splits this item into two.

Specified by:
splitIfNecessary in interface PromotableOrderItemPriceDetail
Returns:

useSaleAdjustments

public boolean useSaleAdjustments()
Description copied from interface: PromotableOrderItemPriceDetail
Returns true if the sale adjustments should be used.

Specified by:
useSaleAdjustments in interface PromotableOrderItemPriceDetail
Returns:


Copyright © 2013. All Rights Reserved.