Class PromotableOrderItemPriceDetailImpl
java.lang.Object
org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItemPriceDetailImpl
- All Implemented Interfaces:
PromotableOrderItemPriceDetail
public class PromotableOrderItemPriceDetailImpl
extends Object
implements PromotableOrderItemPriceDetail
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.broadleafcommerce.common.money.Moneyprotected booleanprotected PromotableOrderItemprotected List<PromotableOrderItemPriceDetailAdjustment>protected List<PromotionDiscount>protected List<PromotionQualifier>protected intprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionPromotableOrderItemPriceDetailImpl(PromotableOrderItem promotableOrderItem, int quantity) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the adjustment to the item's adjustment list and discounts the item's prices by the value of the adjustment.voidaddPromotionDiscount(PromotableCandidateItemOffer itemOffer, OfferItemCriteria itemCriteria, int qtyToMarkAsTarget) Adds a promotionDiscount entry to this itemDetail.addPromotionQualifier(PromotableCandidateItemOffer itemOffer, OfferItemCriteria itemCriteria, int qtyToMarkAsQualifier) Adds a promotionQualifier entry to this itemDetail.Creates a key that represents a unique priceDetailprotected org.broadleafcommerce.common.money.MoneybuildPreciseMoneyFromAdjustment(org.broadleafcommerce.common.money.Money original, org.broadleafcommerce.common.money.Money adjustment) protected org.broadleafcommerce.common.money.Moneyorg.broadleafcommerce.common.money.MoneycalculateItemUnitPriceWithAdjustments(boolean allowSalePrice) Returns the price to be used for this priceDetail taking into account whether or not the sales price can be used.org.broadleafcommerce.common.money.Moneyorg.broadleafcommerce.common.money.Moneyorg.broadleafcommerce.common.money.MoneyReturns the total adjustment value as the sum of the adjustments times the quantity represented by this PriceDetailvoidThis method will check to see if the salePriceAdjustments or retailPriceAdjustments are better and remove those that should not apply.voidClears target and qualifier quantities that were marked for a promotion that did not have enough qualifiers or targets to get applied.Copies thePromotableOrderItemPriceDetailwith all Finalized Qualifiers, Discounts, and Adjustmentsprotected voidfinalizeAdjustments(boolean useSaleAdjustments) voidUpdates the target and qualifier quantities to indicate the number that are being used.org.broadleafcommerce.common.money.MoneyReturns the final total for this item taking into account the finalized adjustments.Return the parent promotableOrderItemReturns the promotion discounts applied to this detail object.Returns the times this item is being used as a promotionQualifierintReturns the quantity associated with this priceDetail.intReturns the quantity of this item that can be used as a qualifier for the passed in itemOfferintReturns the quantity of this item that can be used as a target for the passed in itemOfferbooleanReturns true if this detail has nonCombinable adjustments.protected booleanbooleanbooleanReturns true if a non-combinable offer has been applied to this item.booleanReturns true if a notCombinableOffer or totalitarian offer was applied to this priceDetail.lookupOrCreatePromotionDiscount(PromotableCandidateItemOffer candidatePromotion) lookupOrCreatePromotionQualifier(PromotableCandidateItemOffer candidatePromotion) voidRemoves all adjustments from this detail.protected voidRemoves retail only adjustments.protected voidremoveZeroDollarAdjustments(boolean useSalePrice) If removeUnusedAdjustments is sprotected booleanrestrictQualifier(Offer offer, boolean targetType) protected booleanrestrictTarget(Offer offer, boolean targetType) voidsetAdjustmentsFinalized(boolean adjustmentsFinalized) voidsetQuantity(int quantity) Sets the quantity for this price detail.Copies thePromotableOrderItemPriceDetailwithout Qualifiers, Discounts, or Adjustmentsprotected PromotableOrderItemPriceDetailChecks to see that the discount quantities match the target quantities.booleanReturns true if the sale adjustments should be used.
-
Field Details
-
promotableOrderItem
-
promotableOrderItemPriceDetailAdjustments
-
promotionDiscounts
-
promotionQualifiers
-
quantity
protected int quantity -
useSaleAdjustments
protected boolean useSaleAdjustments -
adjustmentsFinalized
protected boolean adjustmentsFinalized -
adjustedTotal
protected org.broadleafcommerce.common.money.Money adjustedTotal
-
-
Constructor Details
-
PromotableOrderItemPriceDetailImpl
-
-
Method Details
-
isAdjustmentsFinalized
public boolean isAdjustmentsFinalized()- Specified by:
isAdjustmentsFinalizedin interfacePromotableOrderItemPriceDetail
-
setAdjustmentsFinalized
public void setAdjustmentsFinalized(boolean adjustmentsFinalized) - Specified by:
setAdjustmentsFinalizedin interfacePromotableOrderItemPriceDetail
-
addCandidateItemPriceDetailAdjustment
public void addCandidateItemPriceDetailAdjustment(PromotableOrderItemPriceDetailAdjustment itemAdjustment) Description copied from interface:PromotableOrderItemPriceDetailAdds the adjustment to the item's adjustment list and discounts the item's prices by the value of the adjustment.- Specified by:
addCandidateItemPriceDetailAdjustmentin interfacePromotableOrderItemPriceDetail
-
getCandidateItemAdjustments
- Specified by:
getCandidateItemAdjustmentsin interfacePromotableOrderItemPriceDetail- Returns:
-
hasNonCombinableAdjustments
public boolean hasNonCombinableAdjustments()Description copied from interface:PromotableOrderItemPriceDetailReturns true if this detail has nonCombinable adjustments. Used primarily with legacy offers (prior to 2.0)- Specified by:
hasNonCombinableAdjustmentsin interfacePromotableOrderItemPriceDetail- Returns:
-
hasOrderItemAdjustments
protected boolean hasOrderItemAdjustments() -
isTotalitarianOfferApplied
public boolean isTotalitarianOfferApplied()Description copied from interface:PromotableOrderItemPriceDetailReturns true if a notCombinableOffer or totalitarian offer was applied to this priceDetail.- Specified by:
isTotalitarianOfferAppliedin interfacePromotableOrderItemPriceDetail- Returns:
-
isNonCombinableOfferApplied
public boolean isNonCombinableOfferApplied()Description copied from interface:PromotableOrderItemPriceDetailReturns true if a non-combinable offer has been applied to this item.- Specified by:
isNonCombinableOfferAppliedin interfacePromotableOrderItemPriceDetail
-
calculateSaleAdjustmentUnitPrice
public org.broadleafcommerce.common.money.Money calculateSaleAdjustmentUnitPrice() -
calculateRetailAdjustmentUnitPrice
public org.broadleafcommerce.common.money.Money calculateRetailAdjustmentUnitPrice() -
buildPreciseMoneyFromAdjustment
protected org.broadleafcommerce.common.money.Money buildPreciseMoneyFromAdjustment(org.broadleafcommerce.common.money.Money original, org.broadleafcommerce.common.money.Money adjustment) -
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:
chooseSaleOrRetailAdjustmentsin interfacePromotableOrderItemPriceDetail
-
removeAllAdjustments
public void removeAllAdjustments()Description copied from interface:PromotableOrderItemPriceDetailRemoves all adjustments from this detail. Typically called when it has been determined that another "totalitarian" offer has been applied.- Specified by:
removeAllAdjustmentsin interfacePromotableOrderItemPriceDetail
-
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:
useSalePrice-
-
getPromotableOrderItem
Description copied from interface:PromotableOrderItemPriceDetailReturn the parent promotableOrderItem- Specified by:
getPromotableOrderItemin interfacePromotableOrderItemPriceDetail
-
getPromotionDiscounts
Description copied from interface:PromotableOrderItemPriceDetailReturns the promotion discounts applied to this detail object.- Specified by:
getPromotionDiscountsin interfacePromotableOrderItemPriceDetail- Returns:
-
getPromotionQualifiers
Description copied from interface:PromotableOrderItemPriceDetailReturns the times this item is being used as a promotionQualifier- Specified by:
getPromotionQualifiersin interfacePromotableOrderItemPriceDetail- Returns:
-
getQuantity
public int getQuantity()Description copied from interface:PromotableOrderItemPriceDetailReturns the quantity associated with this priceDetail.- Specified by:
getQuantityin interfacePromotableOrderItemPriceDetail- Returns:
-
setQuantity
public void setQuantity(int quantity) Description copied from interface:PromotableOrderItemPriceDetailSets the quantity for this price detail.- Specified by:
setQuantityin interfacePromotableOrderItemPriceDetail
-
restrictTarget
-
restrictQualifier
-
getQuantityAvailableToBeUsedAsTarget
Description copied from interface:PromotableOrderItemPriceDetailReturns the quantity of this item that can be used as a target for the passed in itemOffer- Specified by:
getQuantityAvailableToBeUsedAsTargetin interfacePromotableOrderItemPriceDetail- Returns:
-
lookupOrCreatePromotionQualifier
public PromotionQualifier lookupOrCreatePromotionQualifier(PromotableCandidateItemOffer candidatePromotion) -
lookupOrCreatePromotionDiscount
public PromotionDiscount lookupOrCreatePromotionDiscount(PromotableCandidateItemOffer candidatePromotion) -
addPromotionQualifier
public PromotionQualifier addPromotionQualifier(PromotableCandidateItemOffer itemOffer, OfferItemCriteria itemCriteria, int qtyToMarkAsQualifier) Description copied from interface:PromotableOrderItemPriceDetailAdds 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:
addPromotionQualifierin interfacePromotableOrderItemPriceDetail- Returns:
-
addPromotionDiscount
public void addPromotionDiscount(PromotableCandidateItemOffer itemOffer, OfferItemCriteria itemCriteria, int qtyToMarkAsTarget) Description copied from interface:PromotableOrderItemPriceDetailAdds 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:
addPromotionDiscountin interfacePromotableOrderItemPriceDetail
-
finalizeQuantities
public void finalizeQuantities()Description copied from interface:PromotableOrderItemPriceDetailUpdates the target and qualifier quantities to indicate the number that are being used.- Specified by:
finalizeQuantitiesin interfacePromotableOrderItemPriceDetail
-
clearAllNonFinalizedQuantities
public void clearAllNonFinalizedQuantities()Description copied from interface:PromotableOrderItemPriceDetailClears target and qualifier quantities that were marked for a promotion that did not have enough qualifiers or targets to get applied.- Specified by:
clearAllNonFinalizedQuantitiesin interfacePromotableOrderItemPriceDetail
-
getQuantityAvailableToBeUsedAsQualifier
Description copied from interface:PromotableOrderItemPriceDetailReturns the quantity of this item that can be used as a qualifier for the passed in itemOffer- Specified by:
getQuantityAvailableToBeUsedAsQualifierin interfacePromotableOrderItemPriceDetail- Returns:
-
calculateItemUnitPriceWithAdjustments
public org.broadleafcommerce.common.money.Money calculateItemUnitPriceWithAdjustments(boolean allowSalePrice) Description copied from interface:PromotableOrderItemPriceDetailReturns the price to be used for this priceDetail taking into account whether or not the sales price can be used.- Specified by:
calculateItemUnitPriceWithAdjustmentsin interfacePromotableOrderItemPriceDetail- Returns:
-
calculateAdjustmentsUnitValue
protected org.broadleafcommerce.common.money.Money calculateAdjustmentsUnitValue() -
buildDetailKey
Creates a key that represents a unique priceDetail- Specified by:
buildDetailKeyin interfacePromotableOrderItemPriceDetail- Returns:
-
getFinalizedTotalWithAdjustments
public org.broadleafcommerce.common.money.Money getFinalizedTotalWithAdjustments()Description copied from interface:PromotableOrderItemPriceDetailReturns the final total for this item taking into account the finalized adjustments. Intended to be called after the adjustments have been finalized with a callPromotableOrderItemPriceDetail.chooseSaleOrRetailAdjustments().- Specified by:
getFinalizedTotalWithAdjustmentsin interfacePromotableOrderItemPriceDetail
-
calculateTotalAdjustmentValue
public org.broadleafcommerce.common.money.Money calculateTotalAdjustmentValue()Description copied from interface:PromotableOrderItemPriceDetailReturns the total adjustment value as the sum of the adjustments times the quantity represented by this PriceDetail- Specified by:
calculateTotalAdjustmentValuein interfacePromotableOrderItemPriceDetail- Returns:
-
shallowCopy
Description copied from interface:PromotableOrderItemPriceDetailCopies thePromotableOrderItemPriceDetailwithout Qualifiers, Discounts, or Adjustments- Specified by:
shallowCopyin interfacePromotableOrderItemPriceDetail- Returns:
-
copyWithFinalizedData
Description copied from interface:PromotableOrderItemPriceDetailCopies thePromotableOrderItemPriceDetailwith all Finalized Qualifiers, Discounts, and Adjustments- Specified by:
copyWithFinalizedDatain interfacePromotableOrderItemPriceDetail- Returns:
-
split
protected PromotableOrderItemPriceDetail split(int discountQty, Long offerId, boolean hasQualifiers) -
splitIfNecessary
Description copied from interface:PromotableOrderItemPriceDetailChecks to see that the discount quantities match the target quantities. If not, splits this item into two.- Specified by:
splitIfNecessaryin interfacePromotableOrderItemPriceDetail- Returns:
-
useSaleAdjustments
public boolean useSaleAdjustments()Description copied from interface:PromotableOrderItemPriceDetailReturns true if the sale adjustments should be used.- Specified by:
useSaleAdjustmentsin interfacePromotableOrderItemPriceDetail- Returns:
-