public class DefaultCartPricingService extends Object implements CartPricingService
Constructor and Description |
---|
DefaultCartPricingService(CartItemPricingUtils cartItemPricingUtils,
CartProvider cartProvider,
PricingProvider pricingProvider,
OfferProvider offerProvider,
CatalogProvider catalogProvider,
CartItemConfigurationService cartItemConfigurationService,
TaxService taxService,
FulfillmentPricingService fulfillmentPricingService,
com.fasterxml.jackson.databind.ObjectMapper objectMapper,
CartTotalsCalculator cartTotalsCalculator,
CartPricingRoundingHelper roundingHelper,
CartOperationServiceProperties cartOperationServiceProperties,
com.broadleafcommerce.common.extension.TypeFactory typeFactory,
org.springframework.context.MessageSource messageSource) |
Modifier and Type | Method and Description |
---|---|
protected void |
allocateCartTotalToPayment(com.broadleafcommerce.order.common.domain.Payment payment,
javax.money.MonetaryAmount cartTotal)
Hook point to automatically reallocate the cart total to the cart's single
payment . |
protected com.broadleafcommerce.cart.client.domain.Cart |
applyPricesToCart(com.broadleafcommerce.cart.client.domain.Cart cart,
ProductList productList) |
protected void |
applyTaxes(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
protected PriceCartRequest |
buildPriceCartRequest(com.broadleafcommerce.cart.client.domain.Cart cart) |
protected Set<String> |
buildProductIdList(List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems) |
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) |
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 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 sets
FulfillmentItem.getMerchandiseTaxableAmount() and
FulfillmentGroup.getFulfillmentTaxableAmount() . |
protected CartItemConfigurationService |
getCartItemConfigurationService() |
protected CartItemPricingUtils |
getCartItemPricingUtils() |
protected CartOperationServiceProperties |
getCartOperationServiceProperties() |
protected CartOperationServiceOfferUtils |
getCartOpsServiceOfferUtils() |
protected CartProvider |
getCartProvider() |
protected CartTotalsCalculator |
getCartTotalsCalculator() |
protected CatalogProvider |
getCatalogProvider() |
protected javax.money.CurrencyUnit |
getCurrencyFromCart(com.broadleafcommerce.cart.client.domain.Cart cart) |
protected FulfillmentPricingService |
getFulfillmentPricingService() |
protected org.springframework.context.MessageSource |
getMessageSource() |
protected com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper() |
protected OfferProvider |
getOfferProvider() |
protected String |
getPricingKey(Product product,
com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Returns the product price key, if specified, otherwise retrieves it from the cart item or
generates a new one.
|
protected PricingProvider |
getPricingProvider() |
protected CartPricingRoundingHelper |
getRoundingHelper() |
protected TaxService |
getTaxService() |
protected com.broadleafcommerce.common.extension.TypeFactory |
getTypeFactory() |
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 items
|
protected 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)
Distributes the order-level adjustments to all of the items for tax purposes.
|
protected void |
reallocateCartTotalAmongstPayments(List<com.broadleafcommerce.order.common.domain.Payment> cartPayments,
javax.money.MonetaryAmount cartTotal)
Hook point to automatically reallocate the cart total amongst the cart's
payments . |
void |
setCartOpsServiceOfferUtils(CartOperationServiceOfferUtils cartOpsServiceOfferUtils) |
protected void |
setDefaultsForPriceCartRequest(com.broadleafcommerce.cart.client.domain.Cart cart,
PriceCartRequest priceCartRequest) |
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.
|
protected com.broadleafcommerce.cart.client.domain.Cart |
updateCatalogPricesForCartItems(com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) |
protected <T extends com.broadleafcommerce.cart.client.domain.CartItem> |
updateTaxableAmounts(@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 on
FulfillmentItem . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
priceCart, priceCartItems
public DefaultCartPricingService(CartItemPricingUtils cartItemPricingUtils, CartProvider cartProvider, PricingProvider pricingProvider, OfferProvider offerProvider, CatalogProvider catalogProvider, CartItemConfigurationService cartItemConfigurationService, TaxService taxService, FulfillmentPricingService fulfillmentPricingService, com.fasterxml.jackson.databind.ObjectMapper objectMapper, CartTotalsCalculator cartTotalsCalculator, CartPricingRoundingHelper roundingHelper, CartOperationServiceProperties cartOperationServiceProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.context.MessageSource messageSource)
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)
CartPricingService
priceCart
in interface CartPricingService
cart
- The cart on which to perform the operation.priceCartRequest
- optional info to be used when deciding how to price the cartcontextInfo
- the context infopublic com.broadleafcommerce.cart.client.domain.Cart priceCartWithCatalogPriceUpdates(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartPricingService
priceCartWithCatalogPriceUpdates
in interface CartPricingService
cart
- The cart on which to perform the operation.contextInfo
- the context infoprotected com.broadleafcommerce.cart.client.domain.Cart updateCatalogPricesForCartItems(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected Set<String> buildProductIdList(List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems)
protected com.broadleafcommerce.cart.client.domain.Cart applyPricesToCart(com.broadleafcommerce.cart.client.domain.Cart cart, ProductList productList)
protected com.broadleafcommerce.pricing.client.domain.PriceInfo cleanPriceInfo(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo)
protected String getPricingKey(Product product, com.broadleafcommerce.cart.client.domain.CartItem cartItem)
DefaultProductType.MERCHANDISING_PRODUCT
as it doesn't have the SKU and pricing key.product
- the product to get the pricing key fromcartItem
- the cart item to get the pricing key frompublic 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)
CartPricingService
priceCart
in interface CartPricingService
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 infopublic void priceCartItems(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable PriceCartRequest priceCartRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
priceCartItems
in interface CartPricingService
public void calculateTotals(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartPricingService
calculateTotals
in interface CartPricingService
cart
- The cart to calculate totals for.protected void allocateCartTotalToPayment(com.broadleafcommerce.order.common.domain.Payment payment, javax.money.MonetaryAmount cartTotal)
payment
. Note: if a payment makes use of a single-use token and a successful transaction has
already been executed, then the amount cannot be changed. In that case, the payment will need
to be redefined.payment
- The cart's single paymentcartTotal
- The total price of the cartprotected void reallocateCartTotalAmongstPayments(List<com.broadleafcommerce.order.common.domain.Payment> cartPayments, javax.money.MonetaryAmount cartTotal)
payments
. Note: if a payment makes use of a single-use token and a successful transaction
has already been executed, then the amount cannot be changed. In that case, the payment will
need to be redefined.cartPayments
- The cart's paymentscartTotal
- The total price of the cartprotected void applyTaxes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected void determineTaxableAmounts(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
FulfillmentItem.getMerchandiseTaxableAmount()
and
FulfillmentGroup.getFulfillmentTaxableAmount()
. This will by default prorate the
CartPricing.getAdjustmentsTotal()
across
FulfillmentItem.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.
cart
- Cart with items to be taxedprotected 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)
fulfillmentItems
- FulfillmentItems
onto which to distribute the
adjustmentsTotal
adjustmentsTotal
- Total amount of the order-level adjustments to be distributed usually
from CartPricing.getAdjustmentsTotal()
.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)
FulfillmentItem
. This should be run after
prorateOrderAdjustments(com.broadleafcommerce.cart.client.domain.Cart, java.util.Collection<? extends com.broadleafcommerce.cart.client.domain.FulfillmentItem>, javax.money.MonetaryAmount)
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.
fulfillmentGroups
- All of the fulfillment groups in a cart to be taxed.cartItems
- All of the cart items from a cart to check CartItem.isTaxable()
protected boolean calculateItemSubtotal(com.broadleafcommerce.cart.client.domain.Cart cart, boolean shouldPriceCart, com.broadleafcommerce.cart.client.domain.CartItem item, javax.money.CurrencyUnit expectedCurrency)
@Deprecated protected boolean calculateItemSubtotal(boolean shouldPriceCart, com.broadleafcommerce.cart.client.domain.CartItem item, javax.money.CurrencyUnit expectedCurrency)
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)
@Deprecated 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)
protected PriceCartRequest buildPriceCartRequest(com.broadleafcommerce.cart.client.domain.Cart cart)
protected void setDefaultsForPriceCartRequest(com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest)
protected javax.money.CurrencyUnit getCurrencyFromCart(com.broadleafcommerce.cart.client.domain.Cart cart)
protected void prepareCartForPricing(com.broadleafcommerce.cart.client.domain.Cart cart, PriceCartRequest priceCartRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
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 CartItemPricingUtils getCartItemPricingUtils()
protected CartProvider getCartProvider()
protected PricingProvider getPricingProvider()
protected OfferProvider getOfferProvider()
protected CatalogProvider getCatalogProvider()
protected CartItemConfigurationService getCartItemConfigurationService()
protected TaxService getTaxService()
protected FulfillmentPricingService getFulfillmentPricingService()
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
protected CartTotalsCalculator getCartTotalsCalculator()
protected CartPricingRoundingHelper getRoundingHelper()
protected CartOperationServiceProperties getCartOperationServiceProperties()
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
protected org.springframework.context.MessageSource getMessageSource()
protected CartOperationServiceOfferUtils getCartOpsServiceOfferUtils()
@Autowired public void setCartOpsServiceOfferUtils(CartOperationServiceOfferUtils cartOpsServiceOfferUtils)
Copyright © 2021. All rights reserved.