Class DefaultFulfillmentPricingService
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.pricing.DefaultFulfillmentPricingService
-
- All Implemented Interfaces:
FulfillmentPricingService
public class DefaultFulfillmentPricingService extends Object implements FulfillmentPricingService
- Author:
- Chad Harchar (charchar)
-
-
Constructor Summary
Constructors Constructor Description DefaultFulfillmentPricingService(com.fasterxml.jackson.databind.ObjectMapper mapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartOperationServiceProperties cartOperationServiceProperties, ShippingProvider shippingProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyFulfillmentPricing(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Service for calculating and applying fulfillment pricing to aCart, typically by integrating with Shipping Services.protected voidapplyFulfillmentPricingForGroup(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)Sends a pricing request to the ShippingService that can calculate the cost for theFulfillmentGroup.getFulfillmentOption()and sets the group's pricing fields based on the response.protected voidapplyProductVariantAttributes(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, @NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem fulfillmentPricingItem, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)protected com.broadleafcommerce.shipping.domain.FulfillmentPricingItembuildFulfillmentPricingItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)protected com.broadleafcommerce.shipping.domain.FulfillmentPricingRequestbuildFulfillmentPricingRequest(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String fulfillmentGroupId)booleancanCalculateFulfillmentPricing(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Whether the cart contains the information required to calculate fulfillment pricing.protected com.broadleafcommerce.cart.client.domain.CartItemgetCartItemForFulfillmentItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fi)protected CartOperationServicePropertiesgetCartOperationServiceProperties()protected com.fasterxml.jackson.databind.ObjectMappergetMapper()List<com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponse>getOptions(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String referenceNumber)A list of all potential fulfillment options for the specified cart and fulfillment group.protected CartPricingRoundingHelpergetRoundingHelper()protected com.broadleafcommerce.shipping.domain.ShippingAddressgetShippingAddress(com.broadleafcommerce.order.common.domain.Address fgAddress)protected ShippingProvidergetShippingProvider()protected com.broadleafcommerce.common.extension.TypeFactorygetTypeFactory()protected voidprorateFulfillmentGroupAdjustments(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup group, @NonNull javax.money.CurrencyUnit currency)Prorates theFulfillmentGrouplevel adjustments down to the items.voidprorateFulfillmentGroupsAdjustments(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Prorates theFulfillmentGrouplevel adjustments down to the items for the entire cart.voidsetRoundingHelper(CartPricingRoundingHelper roundingHelper)
-
-
-
Constructor Detail
-
DefaultFulfillmentPricingService
public DefaultFulfillmentPricingService(com.fasterxml.jackson.databind.ObjectMapper mapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartOperationServiceProperties cartOperationServiceProperties, ShippingProvider shippingProvider)
-
-
Method Detail
-
setRoundingHelper
@Autowired public void setRoundingHelper(CartPricingRoundingHelper roundingHelper)
-
applyFulfillmentPricing
public void applyFulfillmentPricing(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Description copied from interface:FulfillmentPricingServiceService for calculating and applying fulfillment pricing to aCart, typically by integrating with Shipping Services. Options are expected to be unique across all providers, once a provider is found that can handle an option, it will be the one used for calculation.- Specified by:
applyFulfillmentPricingin interfaceFulfillmentPricingService- Parameters:
cart- The cart to apply fulfillment pricing against.
-
canCalculateFulfillmentPricing
public boolean canCalculateFulfillmentPricing(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Description copied from interface:FulfillmentPricingServiceWhether the cart contains the information required to calculate fulfillment pricing.- Specified by:
canCalculateFulfillmentPricingin interfaceFulfillmentPricingService- Parameters:
cart- The cart to determine whether fulfillment pricing can be calculated for.- Returns:
- Whether the cart contains the information required to calculate fulfillment pricing.
-
getOptions
public List<com.broadleafcommerce.shipping.domain.FulfillmentOptionPricedResponse> getOptions(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String referenceNumber)
Description copied from interface:FulfillmentPricingServiceA list of all potential fulfillment options for the specified cart and fulfillment group.- Specified by:
getOptionsin interfaceFulfillmentPricingService- Parameters:
cart- The cart to determine which fulfillment options can be chosen.referenceNumber- The id of the fulfillment group we are retrieving options for.- Returns:
- A list of all potential fulfillment options for the specified cart and fulfillment group.
-
prorateFulfillmentGroupsAdjustments
public void prorateFulfillmentGroupsAdjustments(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Prorates theFulfillmentGrouplevel adjustments down to the items for the entire cart. This is useful for downstream services for calculating partial captures and refunds.- Specified by:
prorateFulfillmentGroupsAdjustmentsin interfaceFulfillmentPricingService- Parameters:
cart- The parent cart
-
prorateFulfillmentGroupAdjustments
protected void prorateFulfillmentGroupAdjustments(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup group, @NonNull @NonNull javax.money.CurrencyUnit currency)Prorates theFulfillmentGrouplevel adjustments down to the items. This is useful for downstream services for calculating partial captures and refunds.- Parameters:
group- The group with adjustments to proratecurrency- The cart's currency
-
applyFulfillmentPricingForGroup
protected void applyFulfillmentPricingForGroup(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)Sends a pricing request to the ShippingService that can calculate the cost for theFulfillmentGroup.getFulfillmentOption()and sets the group's pricing fields based on the response.- Parameters:
cart- TheCartthat owns thefulfillmentGroupfulfillmentGroup- TheFulfillmentGroupto be priced
-
buildFulfillmentPricingRequest
protected com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest buildFulfillmentPricingRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull String fulfillmentGroupId)
-
buildFulfillmentPricingItem
protected com.broadleafcommerce.shipping.domain.FulfillmentPricingItem buildFulfillmentPricingItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
-
applyProductVariantAttributes
protected void applyProductVariantAttributes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, @NonNull @NonNull com.broadleafcommerce.shipping.domain.FulfillmentPricingItem fulfillmentPricingItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
-
getCartItemForFulfillmentItem
protected com.broadleafcommerce.cart.client.domain.CartItem getCartItemForFulfillmentItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fi)
-
getShippingAddress
@Nullable protected com.broadleafcommerce.shipping.domain.ShippingAddress getShippingAddress(@Nullable com.broadleafcommerce.order.common.domain.Address fgAddress)
-
getMapper
protected com.fasterxml.jackson.databind.ObjectMapper getMapper()
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-
getCartOperationServiceProperties
protected CartOperationServiceProperties getCartOperationServiceProperties()
-
getShippingProvider
protected ShippingProvider getShippingProvider()
-
getRoundingHelper
protected CartPricingRoundingHelper getRoundingHelper()
-
-