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

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

public class PromotableOrderItemPriceDetailWrapper
extends Object
implements PromotableOrderItemPriceDetail

Modules that extend offer engine behavior can benefit from a wrapped PromotableOrderItemPriceDetail.

Author:
bpolster

Constructor Summary
PromotableOrderItemPriceDetailWrapper(PromotableOrderItemPriceDetail wrappedDetail)
           
 
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, OfferItemCriteria itemCriteria, int qtyToMarkAsTarget)
          Adds a promotionDiscount entry to this itemDetail.
 PromotionQualifier addPromotionQualifier(PromotableCandidateItemOffer itemOffer, OfferItemCriteria itemCriteria, int qtyToMarkAsQualifier)
          Adds a promotionQualifier entry to this itemDetail.
 String buildDetailKey()
          Creates a key that represents a unique priceDetail
 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 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.
 PromotableOrderItemPriceDetail copyWithFinalizedData()
          Copies the PromotableOrderItemPriceDetail with all Finalized Qualifiers, Discounts, and Adjustments
 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.
 boolean isAdjustmentsFinalized()
           
 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.
 void removeAllAdjustments()
          Removes all adjustments from this detail.
 void setAdjustmentsFinalized(boolean adjustmentsFinalized)
           
 void setQuantity(int quantity)
          Sets the quantity for this price detail.
 PromotableOrderItemPriceDetail shallowCopy()
          Copies the PromotableOrderItemPriceDetail without Qualifiers, Discounts, or Adjustments
 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
 

Constructor Detail

PromotableOrderItemPriceDetailWrapper

public PromotableOrderItemPriceDetailWrapper(PromotableOrderItemPriceDetail wrappedDetail)
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:

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

chooseSaleOrRetailAdjustments

public void chooseSaleOrRetailAdjustments()
Description copied from interface: PromotableOrderItemPriceDetail
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

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

getPromotableOrderItem

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

Specified by:
getPromotableOrderItem 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:

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:

addPromotionQualifier

public PromotionQualifier 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
Returns:

addPromotionDiscount

public void addPromotionDiscount(PromotableCandidateItemOffer itemOffer,
                                 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

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:

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

buildDetailKey

public String buildDetailKey()
Description copied from interface: PromotableOrderItemPriceDetail
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:

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:

isAdjustmentsFinalized

public boolean isAdjustmentsFinalized()
Specified by:
isAdjustmentsFinalized in interface PromotableOrderItemPriceDetail

setAdjustmentsFinalized

public void setAdjustmentsFinalized(boolean adjustmentsFinalized)
Specified by:
setAdjustmentsFinalized in interface PromotableOrderItemPriceDetail

shallowCopy

public PromotableOrderItemPriceDetail shallowCopy()
Description copied from interface: PromotableOrderItemPriceDetail
Copies the PromotableOrderItemPriceDetail without Qualifiers, Discounts, or Adjustments

Specified by:
shallowCopy in interface PromotableOrderItemPriceDetail
Returns:

copyWithFinalizedData

public PromotableOrderItemPriceDetail copyWithFinalizedData()
Description copied from interface: PromotableOrderItemPriceDetail
Copies the PromotableOrderItemPriceDetail with all Finalized Qualifiers, Discounts, and Adjustments

Specified by:
copyWithFinalizedData in interface PromotableOrderItemPriceDetail
Returns:


Copyright © 2013. All Rights Reserved.