Class EnhancedLineItem
- java.lang.Object
-
- com.broadleafcommerce.promotion.offer.web.context.EnhancedLineItem
-
- All Implemented Interfaces:
com.broadleafcommerce.promotion.offer.client.web.context.LineItem,Serializable
- Direct Known Subclasses:
EnhancedFulfillmentLineItem,EnhancedOrderLineItem
public class EnhancedLineItem extends Object implements com.broadleafcommerce.promotion.offer.client.web.context.LineItem, Serializable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description EnhancedLineItem()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.money.MonetaryAmountcalculateTotalAdjustmentValue(boolean useSaleAdjustments)javax.money.MonetaryAmountcalculateTotalWithAdjustments()protected booleancanEqual(Object other)LineItemOfferDetailcreateNewDetail(com.broadleafcommerce.common.extension.TypeFactory offerFactory, int quantity)Creates a newLineItemOfferDetailfor this item.booleanequals(Object o)voidfinalizePrice()SetsgetFinalPrice()to theaverage priceof each item, which includes adjustments.javax.money.MonetaryAmountgetAdjustedTotalWithoutFutureCredits()Map<String,Object>getAttributes()javax.money.MonetaryAmountgetAveragePrice()javax.money.CurrencyUnitgetCurrency()javax.money.MonetaryAmountgetFinalPrice()The final price, including adjustments, for a single merchandising item represented by this order line item.javax.money.MonetaryAmountgetFinalTotalAdjustmentValue()javax.money.MonetaryAmountgetFutureCreditAdjustmentValue()javax.money.MonetaryAmountgetFutureCredits()StringgetId()StringgetLineNumber()List<LineItemOfferDetail>getOfferDetails()DTOs containing information aboutoffersapplicable to this item.javax.money.MonetaryAmountgetPrice(boolean useSalePrice)Convenience method to get either thegetSalePrice()orgetStandardPrice()depending on the flag.List<com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedOfferAdjustment>getProratedAdjustments()Prorated offer adjustment information for this line item.intgetQuantity()javax.money.MonetaryAmountgetSalePrice()javax.money.MonetaryAmountgetStandardPrice()javax.money.MonetaryAmountgetTotalPrice()Gets the total combined price of this order item, including any adjustments.javax.money.MonetaryAmountgetTotalPriceWithoutAdjustments()javax.money.MonetaryAmountgetTotalStandardPrice()javax.money.MonetaryAmountgetUnadjustedSalePrice()booleanhasAdjustments()inthashCode()voidinitializePriceDetails(com.broadleafcommerce.common.extension.TypeFactory offerFactory)Ensures that anLineItemOfferDetailis present so that the offer engine engages correctly.booleanisDependent()Whether this item is an Add-on/dependant type, that is, an item that cannot be sold or fulfilled on its own but as a child of another item.booleanisDiscountable()booleanisOnSale()booleanisSubscription()protected voidmergeDetails(LineItemOfferDetail firstDetail, LineItemOfferDetail secondDetail)voidmergeLikeDetails()Merges any priceDetails that share the same orderAdjustments.voidresetOfferDetails()Removes allLineItemOfferDetailsexcept the first, which just gets reset.voidresetPriceDetails(com.broadleafcommerce.common.extension.TypeFactory offerFactory)Clears allofferDetailsand re-initializes them.voidsetAttributes(Map<String,Object> attributes)voidsetCurrency(javax.money.CurrencyUnit currency)voidsetDiscountable(boolean discountable)voidsetFinalPrice(javax.money.MonetaryAmount finalPrice)The final price, including adjustments, for a single merchandising item represented by this order line item.voidsetId(String id)Matches the line number unless the line number isn't available in which case it will represent a uuid.voidsetLineNumber(String lineNumber)voidsetOfferDetails(List<LineItemOfferDetail> offerDetails)DTOs containing information aboutoffersapplicable to this item.voidsetProratedAdjustments(List<com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedOfferAdjustment> proratedAdjustments)Prorated offer adjustment information for this line item.voidsetQuantity(int quantity)voidsetSalePrice(javax.money.MonetaryAmount salePrice)voidsetStandardPrice(javax.money.MonetaryAmount standardPrice)voidsetSubscription(boolean isSubscription)StringtoString()
-
-
-
Method Detail
-
getUnadjustedSalePrice
public javax.money.MonetaryAmount getUnadjustedSalePrice()
- Returns:
- the
getSalePrice()if present with no adjustments, otherwise thegetStandardPrice().
-
getTotalStandardPrice
public javax.money.MonetaryAmount getTotalStandardPrice()
- Returns:
getStandardPrice()multiplied bygetQuantity().
-
getPrice
public javax.money.MonetaryAmount getPrice(boolean useSalePrice)
Convenience method to get either thegetSalePrice()orgetStandardPrice()depending on the flag. IfsalePrice == null, then returnsgetStandardPrice()no matter the value of the flag.- Parameters:
useSalePrice- whether to returngetSalePrice()if it exists orgetStandardPrice()()}- Returns:
- either the
getSalePrice()orgetStandardPrice()depending on the flag
-
isDependent
public boolean isDependent()
Whether this item is an Add-on/dependant type, that is, an item that cannot be sold or fulfilled on its own but as a child of another item.- Returns:
- Whether this item is an Add-on/dependant type
-
calculateTotalWithAdjustments
public javax.money.MonetaryAmount calculateTotalWithAdjustments()
- Returns:
- the item total including all
LineItemOfferDetail.getAdjustments().
-
isOnSale
public boolean isOnSale()
- Returns:
- whether this item has a sale price and that it is less than the standard price
-
resetPriceDetails
public void resetPriceDetails(@NonNull com.broadleafcommerce.common.extension.TypeFactory offerFactory)Clears allofferDetailsand re-initializes them.- Parameters:
offerFactory- theTypeFactoryto use to create any newLineItemOfferDetailsduring re-initialization.
-
initializePriceDetails
public void initializePriceDetails(@NonNull com.broadleafcommerce.common.extension.TypeFactory offerFactory)Ensures that anLineItemOfferDetailis present so that the offer engine engages correctly.- Parameters:
offerFactory- theTypeFactoryto use to create a newLineItemOfferDetail
-
createNewDetail
public LineItemOfferDetail createNewDetail(@NonNull com.broadleafcommerce.common.extension.TypeFactory offerFactory, int quantity)
Creates a newLineItemOfferDetailfor this item.- Parameters:
offerFactory- theTypeFactoryto use to create any newLineItemOfferDetailsquantity- the item quantity to associate with the new detail- Returns:
- the new
LineItemOfferDetail
-
mergeLikeDetails
public void mergeLikeDetails()
Merges any priceDetails that share the same orderAdjustments.
-
getFinalTotalAdjustmentValue
public javax.money.MonetaryAmount getFinalTotalAdjustmentValue()
- Returns:
- the total of all
adjustmentsnot including dependent items
-
getFutureCreditAdjustmentValue
public javax.money.MonetaryAmount getFutureCreditAdjustmentValue()
-
calculateTotalAdjustmentValue
public javax.money.MonetaryAmount calculateTotalAdjustmentValue(boolean useSaleAdjustments)
-
resetOfferDetails
public void resetOfferDetails()
Removes allLineItemOfferDetailsexcept the first, which just gets reset.
-
finalizePrice
public void finalizePrice()
SetsgetFinalPrice()to theaverage priceof each item, which includes adjustments.
-
getAveragePrice
public javax.money.MonetaryAmount getAveragePrice()
- Returns:
- the total combined price of this order item, including any orderAdjustments but not
dependent items, divided by
getQuantity().
-
getTotalPriceWithoutAdjustments
public javax.money.MonetaryAmount getTotalPriceWithoutAdjustments()
- Returns:
- the price without adjustments multiplied by the quantity of items, using the sale price if present.
-
getTotalPrice
public javax.money.MonetaryAmount getTotalPrice()
Gets the total combined price of this order item, including any adjustments.- Returns:
- the total combined price of this order item, including any adjustments.
-
mergeDetails
protected void mergeDetails(LineItemOfferDetail firstDetail, LineItemOfferDetail secondDetail)
-
getFutureCredits
public javax.money.MonetaryAmount getFutureCredits()
-
getAdjustedTotalWithoutFutureCredits
public javax.money.MonetaryAmount getAdjustedTotalWithoutFutureCredits()
-
getId
public String getId()
-
hasAdjustments
public boolean hasAdjustments()
-
getCurrency
public javax.money.CurrencyUnit getCurrency()
-
getLineNumber
public String getLineNumber()
- Specified by:
getLineNumberin interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
getStandardPrice
public javax.money.MonetaryAmount getStandardPrice()
- Specified by:
getStandardPricein interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
getSalePrice
public javax.money.MonetaryAmount getSalePrice()
- Specified by:
getSalePricein interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
getQuantity
public int getQuantity()
- Specified by:
getQuantityin interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
isDiscountable
public boolean isDiscountable()
- Specified by:
isDiscountablein interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
isSubscription
public boolean isSubscription()
- Specified by:
isSubscriptionin interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
getAttributes
public Map<String,Object> getAttributes()
- Specified by:
getAttributesin interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
getFinalPrice
public javax.money.MonetaryAmount getFinalPrice()
The final price, including adjustments, for a single merchandising item represented by this order line item.- Returns:
- The final price, including adjustments, for a single merchandising item represented by this order line item.
-
getOfferDetails
public List<LineItemOfferDetail> getOfferDetails()
DTOs containing information aboutoffersapplicable to this item.- Returns:
- DTOs containing information about
offersapplicable to this item.
-
getProratedAdjustments
public List<com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedOfferAdjustment> getProratedAdjustments()
Prorated offer adjustment information for this line item.This is typically used to communicate the adjustments prorated to this item from order-level or fulfillment group-level offer adjustments.
- Returns:
- DTOs containing prorated offer adjustment information for this line item
-
setCurrency
public void setCurrency(javax.money.CurrencyUnit currency)
-
setLineNumber
public void setLineNumber(String lineNumber)
- Specified by:
setLineNumberin interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
setStandardPrice
public void setStandardPrice(javax.money.MonetaryAmount standardPrice)
- Specified by:
setStandardPricein interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
setSalePrice
public void setSalePrice(javax.money.MonetaryAmount salePrice)
- Specified by:
setSalePricein interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
setQuantity
public void setQuantity(int quantity)
- Specified by:
setQuantityin interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
setDiscountable
public void setDiscountable(boolean discountable)
- Specified by:
setDiscountablein interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
setSubscription
public void setSubscription(boolean isSubscription)
- Specified by:
setSubscriptionin interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
setAttributes
public void setAttributes(Map<String,Object> attributes)
- Specified by:
setAttributesin interfacecom.broadleafcommerce.promotion.offer.client.web.context.LineItem
-
setFinalPrice
public void setFinalPrice(javax.money.MonetaryAmount finalPrice)
The final price, including adjustments, for a single merchandising item represented by this order line item.- Parameters:
finalPrice- The final price, including adjustments, for a single merchandising item represented by this order line item.
-
setOfferDetails
public void setOfferDetails(List<LineItemOfferDetail> offerDetails)
DTOs containing information aboutoffersapplicable to this item.- Parameters:
offerDetails- DTOs containing information aboutoffersapplicable to this item.
-
setProratedAdjustments
public void setProratedAdjustments(List<com.broadleafcommerce.promotion.offer.client.web.context.info.ProratedOfferAdjustment> proratedAdjustments)
Prorated offer adjustment information for this line item.This is typically used to communicate the adjustments prorated to this item from order-level or fulfillment group-level offer adjustments.
- Parameters:
proratedAdjustments- DTOs containing prorated offer adjustment information for this line item
-
setId
public void setId(String id)
Matches the line number unless the line number isn't available in which case it will represent a uuid.
-
canEqual
protected boolean canEqual(Object other)
-
-