Interface PotentialSavingsCalculator
- All Known Implementing Classes:
DefaultPotentialSavingsCalculator
public interface PotentialSavingsCalculator
This service is responsible for calculating the potential savings for
Offer
target items
if that offer is was the only offer applied. It is typically used by
ItemOfferProcessor#calculatePotentialSavings(EnhancedOrder, CandidateOffers)
because of
how complex the calculation process is for EnhancedLineItem
discounts.- Author:
- Nathan Moore (nathanmoore).
-
Method Summary
Modifier and TypeMethodDescriptionjavax.money.MonetaryAmount
calculateDiscountForItem
(CandidateItemOffer itemOffer, EnhancedLineItem item, int quantityToReceiveDiscount) Calculates the potential discount of aCandidateItemOffer
for anEnhancedLineItem
.calculatePotentialSavingsForOffer
(EnhancedOrder order, CandidateItemOffer itemOffer, boolean isForFulfillment) Calculates theTotalPotentialSavings
for all of the givenEnhancedOrder.getOrderLineItems()
order's order line items} if the givenCandidateItemOffer
was applied.javax.money.MonetaryAmount
computeAdjustmentValue
(javax.money.MonetaryAmount currentPrice, CandidateItemOffer itemOffer) CallscomputeAdjustmentValue(javax.money.MonetaryAmount, com.broadleafcommerce.promotion.offer.service.dto.CandidateItemOffer, double)
with a proration amount of 1 meaning no proration.}javax.money.MonetaryAmount
computeAdjustmentValue
(javax.money.MonetaryAmount currentPrice, CandidateItemOffer itemOffer, double prorationAmount) Computes the adjustment value of aCandidateItemOffer
for a targetedEnhancedLineItem
.void
finalizePotentialSavingsOnOffer
(CandidateItemOffer itemOffer, TotalPotentialSavings totalPotentialSavings) Saves the finalBaseCandidateOffer.getPotentialSavings()
andCandidateItemOffer.getWeightedPercentSaved()
for all of anEnhancedOrder.getOrderLineItems()
order's order items} if the givenCandidateItemOffer
was applied.
-
Method Details
-
calculatePotentialSavingsForOffer
@NonNull TotalPotentialSavings calculatePotentialSavingsForOffer(@NonNull EnhancedOrder order, @NonNull CandidateItemOffer itemOffer, boolean isForFulfillment) Calculates theTotalPotentialSavings
for all of the givenEnhancedOrder.getOrderLineItems()
order's order line items} if the givenCandidateItemOffer
was applied.- Parameters:
order
- TheEnhancedOrder
for whose items to calculate potential savings provided byCandidateItemOffer
itemOffer
- TheCandidateItemOffer
whose discount will be used to calculate potential savingsisForFulfillment
- whether this calculation should useEnhancedOrder.getFulfillmentLineItems()
instead ofEnhancedOrder.getOrderLineItems()
- Returns:
TotalPotentialSavings
DTO containing the total savings info for all of theEnhancedOrder.getOrderLineItems()
order's order items}
-
finalizePotentialSavingsOnOffer
void finalizePotentialSavingsOnOffer(@NonNull CandidateItemOffer itemOffer, @NonNull TotalPotentialSavings totalPotentialSavings) Saves the finalBaseCandidateOffer.getPotentialSavings()
andCandidateItemOffer.getWeightedPercentSaved()
for all of anEnhancedOrder.getOrderLineItems()
order's order items} if the givenCandidateItemOffer
was applied.- Parameters:
itemOffer
- TheCandidateItemOffer
whose discount was used to calculate the potential savingstotalPotentialSavings
-TotalPotentialSavings
DTO containing the total savings info for all of anEnhancedOrder.getOrderLineItems()
order's order items}
-
calculateDiscountForItem
@NonNull javax.money.MonetaryAmount calculateDiscountForItem(@NonNull CandidateItemOffer itemOffer, @NonNull EnhancedLineItem item, int quantityToReceiveDiscount) Calculates the potential discount of aCandidateItemOffer
for anEnhancedLineItem
.- Parameters:
itemOffer
- TheCandidateItemOffer
for which to find a potential discount.item
- TheEnhancedLineItem
to discount.quantityToReceiveDiscount
- The quantity of items in theEnhancedLineItem
that can receive a discount from the offer- Returns:
- the discount amount of a
CandidateItemOffer
for anEnhancedLineItem
.
-
computeAdjustmentValue
@NonNull javax.money.MonetaryAmount computeAdjustmentValue(@NonNull javax.money.MonetaryAmount currentPrice, @NonNull CandidateItemOffer itemOffer, double prorationAmount) Computes the adjustment value of aCandidateItemOffer
for a targetedEnhancedLineItem
. If the adjusted value is greater than the targetorder item's current price
, then the current price is returned.- Parameters:
currentPrice
- Current price of theEnhancedLineItem
(may include previous orderAdjustments)itemOffer
- TheCandidateItemOffer
for which to find an adjustment value.prorationAmount
- For Offers withOffer.isDistributeOfferAmountToTargets()
, the relative amount for the item being priced.- Returns:
- the adjustment value of a
CandidateItemOffer
for a targetedEnhancedLineItem
-
computeAdjustmentValue
@NonNull javax.money.MonetaryAmount computeAdjustmentValue(@NonNull javax.money.MonetaryAmount currentPrice, @NonNull CandidateItemOffer itemOffer) CallscomputeAdjustmentValue(javax.money.MonetaryAmount, com.broadleafcommerce.promotion.offer.service.dto.CandidateItemOffer, double)
with a proration amount of 1 meaning no proration.}- Returns:
- the adjustment value of a
CandidateItemOffer
for a targetedEnhancedLineItem
-