Class DefaultCartPricingService
- All Implemented Interfaces:
CartPricingService
- Author:
- Chad Harchar (charchar)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCartPricingService
(CartItemPricingUtils cartItemPricingUtils, CartProvider cartProvider, PricingProvider pricingProvider, OfferProvider offerProvider, CatalogProvider<? extends CatalogItem> catalogProvider, CartItemConfigurationService<? extends CatalogItem> cartItemConfigurationService, TaxService taxService, CommonFulfillmentPricingService commonFulfillmentPricingService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, CartTotalsCalculator cartTotalsCalculator, CartPricingRoundingHelper roundingHelper, CartOperationServiceProperties cartOperationServiceProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.context.MessageSource messageSource) DefaultCartPricingService
(CartItemPricingUtils cartItemPricingUtils, CartProvider cartProvider, PricingProvider pricingProvider, OfferProvider offerProvider, CatalogProvider<? extends CatalogItem> catalogProvider, TaxService taxService, CommonFulfillmentPricingService fulfillmentPricingService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, CartTotalsCalculator cartTotalsCalculator, CartPricingRoundingHelper roundingHelper, CartOperationServiceProperties cartOperationServiceProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.context.MessageSource messageSource) Constructor that does not require CartItemConfigurationService, as it has been deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.cart.client.domain.Cart
applyPricesToCart
(com.broadleafcommerce.cart.client.domain.Cart cart, CatalogItemList<? extends CatalogItem> catalogItemList) protected void
applyTaxes
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimate, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Applies taxes for the givenCart
.protected CatalogItemRequest
buildCatalogItemRequest
(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to create theCatalogItemRequest
and populate any additional attributes that should be passed to theCatalogProvider
when fetching the catalog representation for the cart item.protected Collection<CatalogItemRequest>
buildCatalogItemRequests
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PriceCartRequest
buildPriceCartRequest
(com.broadleafcommerce.cart.client.domain.Cart cart) protected BigDecimal
calculateFulfillmentChargeProportion
(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, com.broadleafcommerce.cart.client.domain.FulfillmentItem fi, Set<String> bandFields, BigDecimal sumFulfillmentItemWeightValue, javax.money.MonetaryAmount sumFulfillmentItemPriceValue) Calculates the proportion needed to determine eachFulfillmentItem.getProratedFulfillmentCharge()
from theFulfillmentGroup's
PricedFulfillmentOption.getPrice()
.protected boolean
calculateItemSubtotal
(boolean shouldPriceCart, com.broadleafcommerce.cart.client.domain.CartItem item, javax.money.CurrencyUnit expectedCurrency) Deprecated.protected boolean
calculateItemSubtotal
(com.broadleafcommerce.cart.client.domain.Cart cart, boolean shouldPriceCart, com.broadleafcommerce.cart.client.domain.CartItem item, javax.money.CurrencyUnit expectedCurrency) protected void
calculateProratedFulfillmentCharge
(com.broadleafcommerce.cart.client.domain.Cart cart) Calculates the prorated fulfillment charge for the givenFulfillmentItem
.protected void
calculateProratedFulfillmentPricing
(com.broadleafcommerce.cart.client.domain.Cart cart) Deprecated, for removal: This API element is subject to removal in a future version.protected void
calculateProratedOrderOfferAdjustments
(com.broadleafcommerce.cart.client.domain.Cart cart) This method aids in calculating prorated fulfillment pricing for the givenCart
, by populating theCartItem.getProratedOrderOfferAdjustments()
toFulfillmentItem.getProratedOrderAdjustments()
.void
calculateTotals
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Calculate the totals for the cart.protected boolean
catalogItemRequestAlreadyExist
(@NonNull Set<CatalogItemRequest> catalogItemRequests, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to prevent duplicateCatalogItemRequests
from being built based on theCartItem
.protected com.broadleafcommerce.pricing.client.domain.PriceInfo
cleanPriceInfo
(@NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) protected void
clearCartPrices
(com.broadleafcommerce.cart.client.domain.Cart cart) protected void
clearFulfillmentPricing
(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) protected void
clearItemPricing
(com.broadleafcommerce.cart.client.domain.CartItem ci) protected void
determineTaxableAmounts
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Determines and setsFulfillmentItem.getMerchandiseTaxableAmount()
andFulfillmentGroup.getFulfillmentTaxableAmount()
.protected String
determineTaxCalculationStrategy
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to determine theTaxCalculationStrategy
based on the givenCart
.protected BroadleafProductService<Product>
protected CartItemConfigurationService<? extends CatalogItem>
Deprecated.protected CartItemPricingUtils
protected CartOperationServiceProperties
protected CartOperationServiceOfferUtils
protected CartProvider
protected CartTotalsCalculator
protected String
getCatalogItemKeyFromCartItem
(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Hook point to determine what the catalog item is keyed on from theCartItem
.protected CatalogProvider<? extends CatalogItem>
protected CommonFulfillmentPricingService
protected FulfillmentPriceConfigurationProperties
protected javax.money.CurrencyUnit
getCurrencyFromCart
(com.broadleafcommerce.cart.client.domain.Cart cart) protected FulfillmentOptionRequestService
Deprecated.UsegetCommonFulfillmentPricingService()
instead.protected com.fasterxml.jackson.databind.ObjectMapper
protected org.springframework.context.MessageSource
protected com.fasterxml.jackson.databind.ObjectMapper
protected OfferProvider
protected com.broadleafcommerce.pricing.client.domain.context.PriceContext
getPriceContext
(Locale locale, javax.money.CurrencyUnit currency) protected String
getPricingKey
(CatalogItem catalogItem, com.broadleafcommerce.cart.client.domain.CartItem cartItem) Returns the catalog item's pricing key, if specified, otherwise retrieves it from the cart item or generates a new one.protected PricingProvider
protected BigDecimal
getProportionByLineItem
(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, com.broadleafcommerce.cart.client.domain.FulfillmentItem fi) Default method to get the splitting proportion for the fulfillment item.protected BigDecimal
getProportionByQuantity
(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, com.broadleafcommerce.cart.client.domain.FulfillmentItem fi) Default method to get the splitting proportion for the fulfillment item.protected CartPricingRoundingHelper
protected StaleCartItemsService
protected javax.money.MonetaryAmount
getTaxableItemFulfillmentTotal
(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, javax.money.CurrencyUnit currency) protected TaxService
protected BigDecimal
getTotalWeight
(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fi) protected com.broadleafcommerce.common.extension.TypeFactory
protected boolean
isCurrencyChange
(PriceCartRequest request, com.broadleafcommerce.cart.client.domain.Cart cart) protected boolean
isGroupFulfillmentTaxable
(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg) protected boolean
isLocaleChange
(PriceCartRequest request, com.broadleafcommerce.cart.client.domain.Cart cart) protected void
prepareCartForPricing
(com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) com.broadleafcommerce.cart.client.domain.Cart
priceCart
(com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest, boolean update, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Price the cart with the provided locale and currency.com.broadleafcommerce.cart.client.domain.Cart
priceCart
(com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Price the cart with the provided locale and currency.void
priceCartItems
(com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) com.broadleafcommerce.cart.client.domain.Cart
priceCartWithCatalogPriceUpdates
(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reprice the cart, including applying the latest catalog-based prices for each of its itemsprotected void
prorateOrderAdjustments
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.FulfillmentItem> fulfillmentItems, @NonNull javax.money.MonetaryAmount adjustmentsTotal) Deprecated, for removal: This API element is subject to removal in a future version.since 1.7.2, adjustment prorations are now done in OfferServicesvoid
setBroadleafProductService
(BroadleafProductService<Product> broadleafProductService) void
setCartOpsServiceOfferUtils
(CartOperationServiceOfferUtils cartOpsServiceOfferUtils) void
setConfigurationProperties
(FulfillmentPriceConfigurationProperties configurationProperties) protected void
setDefaultsForPriceCartRequest
(com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest) void
setFulfillmentOptionRequestService
(FulfillmentOptionRequestService fulfillmentOptionRequestService) void
setMapper
(com.fasterxml.jackson.databind.ObjectMapper mapper) void
setStaleCartItemsService
(StaleCartItemsService staleCartItemsService) protected boolean
updateCartItemPricing
(com.broadleafcommerce.cart.client.domain.Cart cart, Locale locale, javax.money.CurrencyUnit expectedCurrency, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected boolean
updateCartItemPricing
(List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems, Locale locale, javax.money.CurrencyUnit expectedCurrency, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.protected com.broadleafcommerce.cart.client.domain.Cart
updateCatalogPricesForCartItems
(com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.cart.client.domain.Cart
updateCatalogPricesForCartItems
(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version.protected <T extends com.broadleafcommerce.cart.client.domain.CartItem>
voidupdateTaxableAmounts
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.FulfillmentGroup> fulfillmentGroups, @NonNull Collection<T> cartItems) Updates the taxable amount fields onFulfillmentItem
.protected final javax.money.MonetaryAmount
zeroIfNull
(javax.money.MonetaryAmount amount, javax.money.CurrencyUnit currency) Defaults theamount
to zero if null.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.cartoperation.service.pricing.CartPricingService
priceCart, priceCartItems
-
Constructor Details
-
DefaultCartPricingService
public DefaultCartPricingService(CartItemPricingUtils cartItemPricingUtils, CartProvider cartProvider, PricingProvider pricingProvider, OfferProvider offerProvider, CatalogProvider<? extends CatalogItem> catalogProvider, TaxService taxService, CommonFulfillmentPricingService fulfillmentPricingService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, CartTotalsCalculator cartTotalsCalculator, CartPricingRoundingHelper roundingHelper, CartOperationServiceProperties cartOperationServiceProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.context.MessageSource messageSource) Constructor that does not require CartItemConfigurationService, as it has been deprecated. -
DefaultCartPricingService
public DefaultCartPricingService(CartItemPricingUtils cartItemPricingUtils, CartProvider cartProvider, PricingProvider pricingProvider, OfferProvider offerProvider, CatalogProvider<? extends CatalogItem> catalogProvider, CartItemConfigurationService<? extends CatalogItem> cartItemConfigurationService, TaxService taxService, CommonFulfillmentPricingService commonFulfillmentPricingService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, CartTotalsCalculator cartTotalsCalculator, CartPricingRoundingHelper roundingHelper, CartOperationServiceProperties cartOperationServiceProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.context.MessageSource messageSource)
-
-
Method Details
-
priceCart
public com.broadleafcommerce.cart.client.domain.Cart priceCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable PriceCartRequest priceCartRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartPricingService
Price the cart with the provided locale and currency.- Specified by:
priceCart
in interfaceCartPricingService
- Parameters:
cart
- The cart on which to perform the operation.priceCartRequest
- optional info to be used when deciding how to price the cartcontextInfo
- the context info- Returns:
- the priced cart
-
priceCartWithCatalogPriceUpdates
public com.broadleafcommerce.cart.client.domain.Cart priceCartWithCatalogPriceUpdates(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartPricingService
Reprice the cart, including applying the latest catalog-based prices for each of its items- Specified by:
priceCartWithCatalogPriceUpdates
in interfaceCartPricingService
- Parameters:
cart
- The cart on which to perform the operation.contextInfo
- the context info- Returns:
- the priced cart
-
calculateProratedFulfillmentPricing
@Deprecated(forRemoval=true, since="1.8.7") protected void calculateProratedFulfillmentPricing(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Deprecated, for removal: This API element is subject to removal in a future version.in favor ofcalculateProratedOrderOfferAdjustments(Cart)
-
calculateProratedOrderOfferAdjustments
protected void calculateProratedOrderOfferAdjustments(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) This method aids in calculating prorated fulfillment pricing for the givenCart
, by populating theCartItem.getProratedOrderOfferAdjustments()
toFulfillmentItem.getProratedOrderAdjustments()
.If there are multiple
FulfillmentItems
for one singleCartItem
, the prorated order offer adjustments are split across all theFulfillmentItems
based onFulfillmentItem.getQuantity()
.- Parameters:
cart
- theCart
to calculate the prorated fulfillment pricing for
-
calculateProratedFulfillmentCharge
protected void calculateProratedFulfillmentCharge(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Calculates the prorated fulfillment charge for the givenFulfillmentItem
.- Parameters:
cart
- theCart
whoseFulfillmentItems'
prorated fulfillment charges are to be calculated.
-
calculateFulfillmentChargeProportion
protected BigDecimal calculateFulfillmentChargeProportion(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, com.broadleafcommerce.cart.client.domain.FulfillmentItem fi, Set<String> bandFields, BigDecimal sumFulfillmentItemWeightValue, javax.money.MonetaryAmount sumFulfillmentItemPriceValue) Calculates the proportion needed to determine eachFulfillmentItem.getProratedFulfillmentCharge()
from theFulfillmentGroup's
PricedFulfillmentOption.getPrice()
. This method will derive a proportion by price and/or weight based on the availablePricedFulfillmentOption.getBandFields()
. When no band data is available, the fallback method denoted byFulfillmentPriceConfigurationProperties.getFulfillmentPriceProportionMethod()
will be used.- Parameters:
fg
- theFulfillmentGroup
whose fulfillment option price to prorate.fi
- theFulfillmentItem
whose proportion to calculatebandFields
- the set ofBandFields
used to calculate the fulfillment price.sumFulfillmentItemWeightValue
- the total sum of allFulfillmentItems'
weight.sumFulfillmentItemPriceValue
- the total sum of allFulfillmentItems'
price.- Returns:
- the calculated proportion
-
getProportionByQuantity
protected BigDecimal getProportionByQuantity(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, com.broadleafcommerce.cart.client.domain.FulfillmentItem fi) Default method to get the splitting proportion for the fulfillment item. This method returns the proportion based on quantity.- Returns:
- the proportion by quantity
-
getProportionByLineItem
protected BigDecimal getProportionByLineItem(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, com.broadleafcommerce.cart.client.domain.FulfillmentItem fi) Default method to get the splitting proportion for the fulfillment item. This method returns equal proportions for each line item.- Returns:
- the proportion by line item
-
getTotalWeight
protected BigDecimal getTotalWeight(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fi) -
updateCatalogPricesForCartItems
@Deprecated(forRemoval=true) protected com.broadleafcommerce.cart.client.domain.Cart updateCatalogPricesForCartItems(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version. -
updateCatalogPricesForCartItems
protected com.broadleafcommerce.cart.client.domain.Cart updateCatalogPricesForCartItems(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable PriceCartRequest priceCartRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
applyPricesToCart
protected com.broadleafcommerce.cart.client.domain.Cart applyPricesToCart(com.broadleafcommerce.cart.client.domain.Cart cart, CatalogItemList<? extends CatalogItem> catalogItemList) -
cleanPriceInfo
protected com.broadleafcommerce.pricing.client.domain.PriceInfo cleanPriceInfo(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) -
getPricingKey
protected String getPricingKey(CatalogItem catalogItem, com.broadleafcommerce.cart.client.domain.CartItem cartItem) Returns the catalog item's pricing key, if specified, otherwise retrieves it from the cart item or generates a new one. This in general only needed for theDefaultProductType.MERCHANDISING_PRODUCT
as it doesn't have the SKU and pricing key.- Parameters:
catalogItem
- the catalog item to get the pricing key fromcartItem
- the cart item to get the pricing key from- Returns:
- the pricing key
-
priceCart
public com.broadleafcommerce.cart.client.domain.Cart priceCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable PriceCartRequest priceCartRequest, boolean update, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartPricingService
Price the cart with the provided locale and currency.- Initialize pricing request
- Clear current pricing information from cart
- Update cart item pricing
- Retrieve prices from the pricing provider
- Calculate each item's subtotal
- Record whether each item was priced
- If the items were all priced, continue, otherwise mark the cart as un-priced, update, and return
- Calculate fulfillment pricing by calling the fulfillment pricing provider
- Apply adjustments by calling the offer provider
- Calculate the cart totals
- Record the cart as priced, update (if specified), and return
- Specified by:
priceCart
in interfaceCartPricingService
- Parameters:
cart
- The cart on which to perform the operation.priceCartRequest
- optional info to be used when deciding how to price the cartupdate
- whether to update (save) the cart after pricingcontextInfo
- the context info- Returns:
- the priced cart
-
priceCartItems
public void priceCartItems(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable PriceCartRequest priceCartRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
priceCartItems
in interfaceCartPricingService
-
calculateTotals
public void calculateTotals(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartPricingService
Calculate the totals for the cart. This assumes pricing such as item amount, adjustments, and taxes have been determined already.- Specified by:
calculateTotals
in interfaceCartPricingService
- Parameters:
cart
- The cart to calculate totals for.
-
determineTaxCalculationStrategy
protected String determineTaxCalculationStrategy(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to determine theTaxCalculationStrategy
based on the givenCart
.By default,
DefaultTaxCalculationStrategies.ACTUAL
is used when taxes can be calculated, otherwiseDefaultTaxCalculationStrategies.SKIP
is used.For different requirements for actual vs. estimated taxes, customization should be added here.
- Parameters:
cart
- theCart
to determine theTaxCalculationStrategy
forcontextInfo
- additional sandbox and multitenant info- Returns:
- the
TaxCalculationStrategy
for the givenCart
- See Also:
-
applyTaxes
protected void applyTaxes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimate, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Applies taxes for the givenCart
.- Parameters:
cart
- theCart
to calculate the taxes forestimate
- whether or not to apply estimated taxes, typically used when there's only a partial address associated with the cart.contextInfo
- additional sandbox and multitenant info
-
determineTaxableAmounts
protected void determineTaxableAmounts(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Determines and setsFulfillmentItem.getMerchandiseTaxableAmount()
andFulfillmentGroup.getFulfillmentTaxableAmount()
. This will by default prorate theCartPricing.getAdjustmentsTotal()
acrossFulfillmentItem.getMerchandiseTotalAmount()
.By default, a tax item is created for each group as a whole when calculating fulfillment tax, therefore no proration is necessary. To also prorate fulfillment-group adjustments across its items, extend this to add that proration.
- Parameters:
cart
- Cart with items to be taxed
-
prorateOrderAdjustments
@Deprecated(since="1.7.2", forRemoval=true) protected void prorateOrderAdjustments(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.FulfillmentItem> fulfillmentItems, @NonNull @NonNull javax.money.MonetaryAmount adjustmentsTotal) Deprecated, for removal: This API element is subject to removal in a future version.since 1.7.2, adjustment prorations are now done in OfferServicesDistributes the order-level adjustments to all of the items for tax purposes.- Parameters:
fulfillmentItems
-FulfillmentItems
onto which to distribute theadjustmentsTotal
adjustmentsTotal
- Total amount of the order-level adjustments to be distributed usually fromCartPricing.getAdjustmentsTotal()
.
-
updateTaxableAmounts
protected <T extends com.broadleafcommerce.cart.client.domain.CartItem> void updateTaxableAmounts(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Collection<? extends com.broadleafcommerce.cart.client.domain.FulfillmentGroup> fulfillmentGroups, @NonNull @NonNull Collection<T> cartItems) Updates the taxable amount fields onFulfillmentItem
. This should run after applying offers to ensure discounts are properly accounted for.By default, fulfillment taxable amounts are calculated at the fulfillment group level, and not the fulfillment item level. To calculate fulfillment taxes at the item level, extend this to calculate fulfillment taxable amounts for each fulfillment item.
- Parameters:
fulfillmentGroups
- All of the fulfillment groups in a cart to be taxed.cartItems
- All of the cart items from a cart to checkCartItem.isTaxable()
-
isGroupFulfillmentTaxable
protected boolean isGroupFulfillmentTaxable(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg) -
getTaxableItemFulfillmentTotal
protected javax.money.MonetaryAmount getTaxableItemFulfillmentTotal(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, javax.money.CurrencyUnit currency) -
calculateItemSubtotal
protected boolean calculateItemSubtotal(com.broadleafcommerce.cart.client.domain.Cart cart, boolean shouldPriceCart, com.broadleafcommerce.cart.client.domain.CartItem item, javax.money.CurrencyUnit expectedCurrency) -
calculateItemSubtotal
@Deprecated protected boolean calculateItemSubtotal(boolean shouldPriceCart, com.broadleafcommerce.cart.client.domain.CartItem item, javax.money.CurrencyUnit expectedCurrency) Deprecated. -
updateCartItemPricing
protected boolean updateCartItemPricing(com.broadleafcommerce.cart.client.domain.Cart cart, Locale locale, javax.money.CurrencyUnit expectedCurrency, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
updateCartItemPricing
@Deprecated(forRemoval=true) protected boolean updateCartItemPricing(List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems, Locale locale, javax.money.CurrencyUnit expectedCurrency, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated, for removal: This API element is subject to removal in a future version. -
buildPriceCartRequest
protected PriceCartRequest buildPriceCartRequest(com.broadleafcommerce.cart.client.domain.Cart cart) -
setDefaultsForPriceCartRequest
protected void setDefaultsForPriceCartRequest(com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest) -
isLocaleChange
protected boolean isLocaleChange(PriceCartRequest request, com.broadleafcommerce.cart.client.domain.Cart cart) -
isCurrencyChange
protected boolean isCurrencyChange(PriceCartRequest request, com.broadleafcommerce.cart.client.domain.Cart cart) -
getCurrencyFromCart
protected javax.money.CurrencyUnit getCurrencyFromCart(com.broadleafcommerce.cart.client.domain.Cart cart) -
prepareCartForPricing
protected void prepareCartForPricing(com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
clearCartPrices
protected void clearCartPrices(com.broadleafcommerce.cart.client.domain.Cart cart) -
clearFulfillmentPricing
protected void clearFulfillmentPricing(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) -
clearItemPricing
protected void clearItemPricing(com.broadleafcommerce.cart.client.domain.CartItem ci) -
zeroIfNull
protected final javax.money.MonetaryAmount zeroIfNull(@Nullable javax.money.MonetaryAmount amount, @Nullable javax.money.CurrencyUnit currency) Defaults theamount
to zero if null.- Parameters:
amount
- TheMonetaryAmount
to default to zerocurrency
- Theamount's
CurrencyUnit
- Returns:
- The
amount
or zero if null.
-
buildCatalogItemRequests
protected Collection<CatalogItemRequest> buildCatalogItemRequests(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
catalogItemRequestAlreadyExist
protected boolean catalogItemRequestAlreadyExist(@NonNull @NonNull Set<CatalogItemRequest> catalogItemRequests, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to prevent duplicateCatalogItemRequests
from being built based on theCartItem
.By default, we filter on the product ID.
- Parameters:
catalogItemRequests
- the list of requests to pass to theCatalogProvider
cartItem
- theCartItem
to build theCatalogItemRequest
contextInfo
- context information around sandbox and multitenant state- Returns:
- true if building a new
CatalogItemRequest
would be a duplicate of an existing request incatalogItemRequests
-
buildCatalogItemRequest
protected CatalogItemRequest buildCatalogItemRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to create theCatalogItemRequest
and populate any additional attributes that should be passed to theCatalogProvider
when fetching the catalog representation for the cart item.- Parameters:
cartItem
- theCartItem
to build theCatalogItemRequest
contextInfo
- context information around sandbox and multitenant state- Returns:
- the populated
CatalogItemRequest
for theCartItem
-
getCatalogItemKeyFromCartItem
protected String getCatalogItemKeyFromCartItem(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Hook point to determine what the catalog item is keyed on from theCartItem
.By default, this is set to the product ID.
- Parameters:
cartItem
- the cart item to identify a catalog item key from- Returns:
- the key for the catalog item
-
getPriceContext
@Nullable protected com.broadleafcommerce.pricing.client.domain.context.PriceContext getPriceContext(@Nullable Locale locale, @Nullable javax.money.CurrencyUnit currency) -
getFulfillmentPricingService
@Deprecated(forRemoval=false, since="1.9") public FulfillmentPricingService getFulfillmentPricingService()Deprecated.UsegetCommonFulfillmentPricingService()
instead.Backward-compatible getter forFulfillmentPricingService
. This should only be used if the shipping libraries (shipping-common and shipping-services) are in use. In 1.9, the shipping libraries have been replaced with fulfillment-common and fulfillment-services. ACommonFulfillmentPricingService
bean is configured by default in CartOps in 1.9. UsegetCommonFulfillmentPricingService()
instead.- Returns:
- The
CommonFulfillmentPricingService
field cast toFulfillmentPricingService
.
-
getCartItemPricingUtils
-
getCartProvider
-
getPricingProvider
-
getOfferProvider
-
getCatalogProvider
-
getCartItemConfigurationService
@Deprecated protected CartItemConfigurationService<? extends CatalogItem> getCartItemConfigurationService()Deprecated. -
getTaxService
-
getCommonFulfillmentPricingService
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getCartTotalsCalculator
-
getRoundingHelper
-
getCartOperationServiceProperties
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getMessageSource
protected org.springframework.context.MessageSource getMessageSource() -
getCartOpsServiceOfferUtils
-
setCartOpsServiceOfferUtils
@Autowired public void setCartOpsServiceOfferUtils(CartOperationServiceOfferUtils cartOpsServiceOfferUtils) -
setStaleCartItemsService
-
getStaleCartItemsService
-
setBroadleafProductService
@Autowired public void setBroadleafProductService(BroadleafProductService<Product> broadleafProductService) -
getBroadleafProductService
-
setFulfillmentOptionRequestService
@Autowired @Lazy public void setFulfillmentOptionRequestService(FulfillmentOptionRequestService fulfillmentOptionRequestService) -
getFulfillmentOptionRequestService
-
setMapper
@Autowired public void setMapper(com.fasterxml.jackson.databind.ObjectMapper mapper) -
getMapper
protected com.fasterxml.jackson.databind.ObjectMapper getMapper() -
setConfigurationProperties
@Autowired public void setConfigurationProperties(FulfillmentPriceConfigurationProperties configurationProperties) -
getConfigurationProperties
-
calculateProratedOrderOfferAdjustments(Cart)