public class CartItemPricingUtils extends Object
CartItems.| Constructor and Description |
|---|
CartItemPricingUtils(CartItemPriceableTargetUtils cartItemPriceableTargetUtils,
com.fasterxml.jackson.databind.ObjectMapper mapper,
com.broadleafcommerce.common.extension.TypeFactory factory) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
attachBundleItemProratedPrices(List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems,
Map<String,javax.money.MonetaryAmount> roundedDependentItemProratedPrice,
javax.money.CurrencyUnit expectedCurrency) |
void |
calculateAndAttachBundleItemProratedPrices(com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Calculates the prorated prices for the dependent cart items based on the bundle item total
price.
|
protected void |
calculateAndAttachBundleItemProratedPrices(@NonNull com.broadleafcommerce.cart.client.domain.CartItem bundleCartItem,
@NonNull javax.money.CurrencyUnit expectedCurrency) |
protected Map<String,javax.money.MonetaryAmount> |
calculateBundleDependentItemPriceProration(com.broadleafcommerce.cart.client.domain.CartItem bundleCartItem,
javax.money.CurrencyUnit expectedCurrency,
javax.money.MonetaryAmount bundleTotalAmount) |
protected javax.money.MonetaryAmount |
calculateBundleDependentItemProratedPrice(com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem,
javax.money.MonetaryAmount bundleSubtotal,
javax.money.MonetaryAmount dependentItemsTotal,
javax.money.CurrencyUnit expectedCurrency) |
protected com.broadleafcommerce.order.common.domain.Adjustment |
createBundleDependentItemAdjustment(javax.money.MonetaryAmount adjustmentAmount) |
<P extends com.broadleafcommerce.pricing.client.domain.PriceInfo> |
determineMatchingPriceInfo(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
@NonNull Collection<P> priceInfos)
Determines the matching
PriceInfo for a CartItem from among the given
priceInfos. |
protected CartItemPriceableTargetUtils |
getCartItemPriceableTargetUtils() |
protected com.broadleafcommerce.common.extension.TypeFactory |
getFactory() |
protected com.broadleafcommerce.pricing.client.domain.PriceableTarget |
getItemChoiceTarget(com.broadleafcommerce.cart.client.domain.DependentItemDetails details,
String vendorRef,
int quantity)
Builds a
PriceableTarget for the parent ItemChoice of a dependent
CartItem representing a SpecificItemChoice. |
protected <P extends com.broadleafcommerce.pricing.client.domain.PriceInfo> |
getItemPriceInfo(com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem) |
protected com.fasterxml.jackson.databind.ObjectMapper |
getMapper() |
Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget> |
getPriceableTargets(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
Map<String,Integer> totalQuantityForTargetId)
Builds the
PriceableTargets for the given CartItem and its
dependents. |
protected <P extends com.broadleafcommerce.pricing.client.domain.PriceInfo> |
getPriceInfoForDependentItem(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
@NonNull Collection<P> priceInfos)
Determines the matching
PriceInfo for a dependent CartItem. |
protected <P extends com.broadleafcommerce.pricing.client.domain.PriceInfo> |
getPriceInfos(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) |
protected Object |
getProductType(com.broadleafcommerce.cart.client.domain.CartItem cartItem) |
protected CartPricingRoundingHelper |
getRoundingHelper() |
protected com.broadleafcommerce.pricing.client.domain.PriceableTarget |
getSpecificChoiceTarget(com.broadleafcommerce.cart.client.domain.DependentItemDetails details,
String vendorRef,
int quantity)
Builds a
PriceableTarget for a dependent CartItem. |
protected List<com.broadleafcommerce.pricing.client.domain.PriceableTarget> |
getTargetsForDependentItem(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
Map<String,Integer> totalQuantityForTargetId)
Builds the list of
PriceableTargets for the given dependent
CartItem. |
void |
setRoundingHelper(CartPricingRoundingHelper roundingHelper) |
public CartItemPricingUtils(CartItemPriceableTargetUtils cartItemPriceableTargetUtils, com.fasterxml.jackson.databind.ObjectMapper mapper, com.broadleafcommerce.common.extension.TypeFactory factory)
public Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget> getPriceableTargets(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, Map<String,Integer> totalQuantityForTargetId)
PriceableTargets for the given CartItem and its
dependents.cartItem - CartItem for which to build PriceableTargetsPriceableTargets for cartItem and its
dependents.public <P extends com.broadleafcommerce.pricing.client.domain.PriceInfo> Optional<P> determineMatchingPriceInfo(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Collection<P> priceInfos)
PriceInfo for a CartItem from among the given
priceInfos.P - The type of the PriceInfo in the collectioncartItem - The CartItem for which to determine a PriceInfopriceInfos - Collection of PriceInfos from which to choose a matchPriceInfo for cartItem.public void calculateAndAttachBundleItemProratedPrices(com.broadleafcommerce.cart.client.domain.Cart cart,
@Nullable
com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
CartPricingRoundingHelper.roundListOfMonetaryAmounts(java.util.Map, javax.money.MonetaryAmount, javax.money.CurrencyUnit)
to the bundle total to add the remainder unit amounts. This prevents the situation e.g when
the bundle total is $40 but the sum of the prorated item prices is $39.99.cart - the cart that contains the bundle products to calculate the prorated price@Nullable protected Object getProductType(com.broadleafcommerce.cart.client.domain.CartItem cartItem)
protected void calculateAndAttachBundleItemProratedPrices(@NonNull
@NonNull com.broadleafcommerce.cart.client.domain.CartItem bundleCartItem,
@NonNull
@NonNull javax.money.CurrencyUnit expectedCurrency)
protected Map<String,javax.money.MonetaryAmount> calculateBundleDependentItemPriceProration(com.broadleafcommerce.cart.client.domain.CartItem bundleCartItem, javax.money.CurrencyUnit expectedCurrency, javax.money.MonetaryAmount bundleTotalAmount)
protected void attachBundleItemProratedPrices(List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, Map<String,javax.money.MonetaryAmount> roundedDependentItemProratedPrice, javax.money.CurrencyUnit expectedCurrency)
protected com.broadleafcommerce.order.common.domain.Adjustment createBundleDependentItemAdjustment(javax.money.MonetaryAmount adjustmentAmount)
protected <P extends com.broadleafcommerce.pricing.client.domain.PriceInfo> Optional<P> getItemPriceInfo(com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem)
protected <P extends com.broadleafcommerce.pricing.client.domain.PriceInfo> Map<String,P> getPriceInfos(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
protected javax.money.MonetaryAmount calculateBundleDependentItemProratedPrice(com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem,
javax.money.MonetaryAmount bundleSubtotal,
javax.money.MonetaryAmount dependentItemsTotal,
javax.money.CurrencyUnit expectedCurrency)
protected <P extends com.broadleafcommerce.pricing.client.domain.PriceInfo> Optional<P> getPriceInfoForDependentItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Collection<P> priceInfos)
PriceInfo for a dependent CartItem. First is checks
based on its AdditionalItemPricing from among the given priceInfos. Then, it
checks based on its parent ItemChoice's pricing in the
DependentItemDetails.P - The type of the PriceInfo in the collectioncartItem - The dependent CartItem for which to determine a PriceInfopriceInfos - Collection of PriceInfos from which to choose a matchPriceInfo for cartItem.protected List<com.broadleafcommerce.pricing.client.domain.PriceableTarget> getTargetsForDependentItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, Map<String,Integer> totalQuantityForTargetId)
PriceableTargets for the given dependent
CartItem.cartItem - CartItem for which to build PriceableTargetsPriceableTargets for cartItemprotected com.broadleafcommerce.pricing.client.domain.PriceableTarget getItemChoiceTarget(com.broadleafcommerce.cart.client.domain.DependentItemDetails details,
String vendorRef,
int quantity)
PriceableTarget for the parent ItemChoice of a dependent
CartItem representing a SpecificItemChoice.details - The DependentItemDetails of the dependent CartItemvendorRef - The vendorRefquantity - The quantity of the dependent CartItemPriceableTarget for the parent ItemChoice of a dependent
CartItem representing a SpecificItemChoice.protected com.broadleafcommerce.pricing.client.domain.PriceableTarget getSpecificChoiceTarget(com.broadleafcommerce.cart.client.domain.DependentItemDetails details,
String vendorRef,
int quantity)
PriceableTarget for a dependent CartItem.details - The DependentItemDetails of the dependent CartItemvendorRef - The vendorRefquantity - The quantity of the dependent CartItemPriceableTarget for a dependent CartItem.protected CartItemPriceableTargetUtils getCartItemPriceableTargetUtils()
protected com.fasterxml.jackson.databind.ObjectMapper getMapper()
protected com.broadleafcommerce.common.extension.TypeFactory getFactory()
protected CartPricingRoundingHelper getRoundingHelper()
@Autowired public void setRoundingHelper(CartPricingRoundingHelper roundingHelper)
Copyright © 2021. All rights reserved.