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 void
applyFulfillmentPricing(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Service for calculating and applying fulfillment pricing to aCart
, typically by integrating with Shipping Services.protected void
applyFulfillmentPricingForGroup(@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 void
applyProductVariantAttributes(@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.FulfillmentPricingItem
buildFulfillmentPricingItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
protected com.broadleafcommerce.shipping.domain.FulfillmentPricingRequest
buildFulfillmentPricingRequest(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull String fulfillmentGroupId)
boolean
canCalculateFulfillmentPricing(@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.CartItem
getCartItemForFulfillmentItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fi)
protected CartOperationServiceProperties
getCartOperationServiceProperties()
protected com.fasterxml.jackson.databind.ObjectMapper
getMapper()
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 CartPricingRoundingHelper
getRoundingHelper()
protected com.broadleafcommerce.shipping.domain.ShippingAddress
getShippingAddress(com.broadleafcommerce.order.common.domain.Address fgAddress)
protected ShippingProvider
getShippingProvider()
protected com.broadleafcommerce.common.extension.TypeFactory
getTypeFactory()
protected void
prorateFulfillmentGroupAdjustments(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup group, @NonNull javax.money.CurrencyUnit currency)
Prorates theFulfillmentGroup
level adjustments down to the items.void
prorateFulfillmentGroupsAdjustments(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Prorates theFulfillmentGroup
level adjustments down to the items for the entire cart.void
setRoundingHelper(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:FulfillmentPricingService
Service 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:
applyFulfillmentPricing
in 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:FulfillmentPricingService
Whether the cart contains the information required to calculate fulfillment pricing.- Specified by:
canCalculateFulfillmentPricing
in 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:FulfillmentPricingService
A list of all potential fulfillment options for the specified cart and fulfillment group.- Specified by:
getOptions
in 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 theFulfillmentGroup
level adjustments down to the items for the entire cart. This is useful for downstream services for calculating partial captures and refunds.- Specified by:
prorateFulfillmentGroupsAdjustments
in 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 theFulfillmentGroup
level 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
- TheCart
that owns thefulfillmentGroup
fulfillmentGroup
- TheFulfillmentGroup
to 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()
-
-