Class DefaultDelegatingTaxService
java.lang.Object
com.broadleafcommerce.cartoperation.service.pricing.DefaultDelegatingTaxService
- All Implemented Interfaces:
TaxService
This implementation of
TaxService
calls TaxDelegate
, which has a discovery
process to determine the best TaxProvider
implementation based on configured properties,
the provided TaxCalculationRequest
, and the ContextInfo
.- Author:
- Kelly Tisdell (ktisdell)
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefaultDelegatingTaxService
(@NonNull com.broadleafcommerce.tax.delegate.TaxDelegate<?, ?> taxDelegate, List<TaxAddressSourceHandler> taxAddressSourceHandlers, @NonNull com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addFeeItemsTaxCalculationGroup
(@NonNull com.broadleafcommerce.tax.domain.TaxCalculationRequest request, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Add aTaxCalculationGroup
for the cart's fee items to the givenTaxCalculationRequest
.protected void
addFulfillmentItemTaxDetails
(@NonNull com.broadleafcommerce.tax.domain.TaxInfo taxInfo, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This takes the total from theFulfillmentGroup.getFulfillmentTaxableAmount()
.protected void
addFulfillmentItemTaxDetails
(@NonNull com.broadleafcommerce.tax.domain.TaxInfo taxInfo, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) AddFulfillmentItemTaxDetails
to the fulfillment item.protected javax.money.MonetaryAmount
applyCODTaxResponse
(@NonNull com.broadleafcommerce.tax.domain.TaxCalculationResponse response, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull javax.money.CurrencyUnit expectedCurrency, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Applies theTaxCalculationResponse
for COD fees.void
applyTaxes
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimate, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Calculates and applies taxes to a cart.protected void
applyTaxResponses
(@NonNull com.broadleafcommerce.tax.domain.TaxCalculationResponse response, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull List<com.broadleafcommerce.cart.client.domain.FulfillmentGroup> fulfillmentGroups, @NonNull javax.money.CurrencyUnit expectedCurrency, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.tax.domain.TaxCalculationGroup
buildTaxCalculationGroup
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull TaxAddressSourceHandler handler, @NonNull List<com.broadleafcommerce.tax.domain.TaxItem> taxItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aTaxCalculationGroup
, which is used to calculate taxes for a group of items being shipped to or fulfilled at a particular Address.protected com.broadleafcommerce.tax.domain.TaxItem
buildTaxItemForFeeItem
(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Builds aTaxItem
based on the givenfee item
.protected com.broadleafcommerce.tax.domain.TaxItem
buildTaxItemForLineItem
(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, com.broadleafcommerce.cart.client.domain.CartItem cartItem) protected List<com.broadleafcommerce.tax.domain.TaxItem>
buildTaxItemsForFulfillment
(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) Deprecated.protected List<com.broadleafcommerce.tax.domain.TaxItem>
buildTaxItemsForFulfillment
(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected List<com.broadleafcommerce.tax.domain.TaxItem>
buildTaxItemsForLineItems
(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) protected void
calculateIncludedTaxes
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull javax.money.CurrencyUnit expectedCurrency, @NonNull com.broadleafcommerce.tax.domain.TaxCalculationResponse taxResponse) Set VAT properties onCartPricing
.boolean
canCalculateTaxes
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Whether the cart contains the information required to calculate taxes.protected com.broadleafcommerce.tax.domain.TaxCalculationRequest
createRequest
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull javax.money.CurrencyUnit expectedCurrency, boolean estimate, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected String
determineCartId
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) We require theCart.getId()
, in most cases.protected String
determinePreferredProviderId
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimate, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method returns the "preferred"Tax Provider ID
, which is determined byTaxProvider.getProviderId()
.protected String
determineTaxExemptionCode
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.tax.domain.TaxCalculationResponse
executeTaxCalculation
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.tax.domain.TaxCalculationRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected TaxAddressSourceHandler
findTaxAddressSourceHandler
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<TaxAddressSourceHandler>
findTaxAddressSourceHandlerForFeeTaxCalculation
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds theTaxAddressSourceHandler
for tax calculation for fees, e.g.protected boolean
fulfillmentGroupHasSufficientAddress
(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the givenFulfillmentGroup
has sufficient address to calculate taxes.protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
getCartItemMap
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) protected CustomerProvider
protected Optional<com.broadleafcommerce.cart.client.domain.FulfillmentGroup>
getFulfillmentGroupForCOD
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Gets theFulfillmentGroup
that has CollectOnDelivery selected from the givenCart
.protected List<com.broadleafcommerce.cart.client.domain.FulfillmentGroup>
getFulfillmentGroups
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) protected String
getProductDescription
(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Retrieves the description of the product represented by theCartItem
.protected List<TaxAddressSourceHandler>
protected com.broadleafcommerce.tax.delegate.TaxDelegate<?,
?> protected String
getTaxItemIdForFulfillment
(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) Extension point to modify theTaxItem.getItemId()
for fulfillment tax items.protected String
getTaxItemIdForLineItem
(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem) protected com.broadleafcommerce.common.extension.TypeFactory
protected boolean
isCODSelected
(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) protected void
setAllTaxToZero
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) void
setAuthenticationUtils
(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) void
setCustomerProvider
(CustomerProvider customerProvider) protected boolean
shouldCalculateItemTaxes
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected boolean
shouldTaxFulfillment
(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull javax.money.CurrencyUnit currencyUnit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) 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.TaxService
applyTaxes
-
Field Details
-
COD_REFERENCE_NUMBER
The reference number used for COD Fee Items'TaxCalculationRequest
.- See Also:
-
DEFAULT_FULFILLMENT_TAX_NAME
Default name for theTaxDetail
for taxes associated with fulfillment, shipping, and handling.- See Also:
-
-
Constructor Details
-
DefaultDelegatingTaxService
public DefaultDelegatingTaxService(@NonNull @NonNull com.broadleafcommerce.tax.delegate.TaxDelegate<?, ?> taxDelegate, @Nullable List<TaxAddressSourceHandler> taxAddressSourceHandlers, @NonNull @NonNull com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
setAuthenticationUtils
@Autowired public void setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) -
setCustomerProvider
-
applyTaxes
public void applyTaxes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimate, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TaxService
Calculates and applies taxes to a cart.- Specified by:
applyTaxes
in interfaceTaxService
- Parameters:
cart
- The cart to apply taxes against.estimate
- Hint indicating whether to try to provide only an estimate, possibly for better performancecontextInfo
- (Optional) Additional sandbox, tenant, and application info
-
canCalculateTaxes
public boolean canCalculateTaxes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TaxService
Whether the cart contains the information required to calculate taxes.- Specified by:
canCalculateTaxes
in interfaceTaxService
- Parameters:
cart
- The cart to determine whether taxes can be calculated for.contextInfo
- Additional sandbox and tenant info- Returns:
- Whether the cart contains the information required to calculate taxes.
-
fulfillmentGroupHasSufficientAddress
protected boolean fulfillmentGroupHasSufficientAddress(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the givenFulfillmentGroup
has sufficient address to calculate taxes.By default, for an address to be sufficient, it must have
TaxAddress.getCountry()
andTaxAddress.getStateProvinceRegion()
at the very least.For different address requirements, customization should be added here
- Parameters:
fg
- theFulfillmentGroup
to check the address forcart
- theCart
that theFulfillmentGroup
belongs tocontextInfo
- the contextInfo for this request- Returns:
- true if the given
FulfillmentGroup
has sufficient address to calculate taxes, otherwise false
-
executeTaxCalculation
protected com.broadleafcommerce.tax.domain.TaxCalculationResponse executeTaxCalculation(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.tax.domain.TaxCalculationRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getFulfillmentGroups
protected List<com.broadleafcommerce.cart.client.domain.FulfillmentGroup> getFulfillmentGroups(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) -
findTaxAddressSourceHandler
@Nullable protected TaxAddressSourceHandler findTaxAddressSourceHandler(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
createRequest
protected com.broadleafcommerce.tax.domain.TaxCalculationRequest createRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull javax.money.CurrencyUnit expectedCurrency, boolean estimate, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
addFeeItemsTaxCalculationGroup
protected void addFeeItemsTaxCalculationGroup(@NonNull @NonNull com.broadleafcommerce.tax.domain.TaxCalculationRequest request, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Add aTaxCalculationGroup
for the cart's fee items to the givenTaxCalculationRequest
.- Parameters:
request
- theTaxCalculationRequest
to add the fee items'TaxCalculationGroup
tocart
- theCart
containing fee itemscontextInfo
- Context information around sandbox and multitenant state
-
setAllTaxToZero
protected void setAllTaxToZero(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) -
buildTaxItemForFeeItem
protected com.broadleafcommerce.tax.domain.TaxItem buildTaxItemForFeeItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Builds aTaxItem
based on the givenfee item
.- Parameters:
cartItem
- the fee item- Returns:
- the
TaxItem
built from the given fee item
-
getFulfillmentGroupForCOD
protected Optional<com.broadleafcommerce.cart.client.domain.FulfillmentGroup> getFulfillmentGroupForCOD(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Gets theFulfillmentGroup
that has CollectOnDelivery selected from the givenCart
.- Parameters:
cart
- the cart that may contain a fulfillment group that has COD selected- Returns:
- an optional of COD fulfillment group
- See Also:
-
FulfillmentGroup.COD_STATUS_ATTR
-
isCODSelected
protected boolean isCODSelected(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) -
findTaxAddressSourceHandlerForFeeTaxCalculation
protected Optional<TaxAddressSourceHandler> findTaxAddressSourceHandlerForFeeTaxCalculation(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds theTaxAddressSourceHandler
for tax calculation for fees, e.g. COD feesBy default, it delegates to
findTaxAddressSourceHandler(Cart, FulfillmentGroup, ContextInfo)
.- Parameters:
cart
- theCart
containing fee itemsfulfillmentGroup
- theFulfillmentGroup
that has COD selectedcontextInfo
- context information surrounding multitenant state- Returns:
- an optional of
TaxAddressSourceHandler
for tax calculation for fees - See Also:
-
FulfillmentGroup.COD_STATUS_ATTR
-
buildTaxItemsForLineItems
protected List<com.broadleafcommerce.tax.domain.TaxItem> buildTaxItemsForLineItems(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) -
getCartItemMap
-
buildTaxItemForLineItem
protected com.broadleafcommerce.tax.domain.TaxItem buildTaxItemForLineItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, @Nullable com.broadleafcommerce.cart.client.domain.CartItem cartItem) -
getTaxItemIdForLineItem
protected String getTaxItemIdForLineItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem) -
getProductDescription
protected String getProductDescription(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Retrieves the description of the product represented by theCartItem
.- Parameters:
cartItem
- theCartItem
- Returns:
- The description of the product that was added to the cart.
-
shouldCalculateItemTaxes
protected boolean shouldCalculateItemTaxes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
shouldTaxFulfillment
protected boolean shouldTaxFulfillment(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull @NonNull javax.money.CurrencyUnit currencyUnit, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
determineTaxExemptionCode
@Nullable protected String determineTaxExemptionCode(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
applyTaxResponses
protected void applyTaxResponses(@NonNull @NonNull com.broadleafcommerce.tax.domain.TaxCalculationResponse response, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.FulfillmentGroup> fulfillmentGroups, @NonNull @NonNull javax.money.CurrencyUnit expectedCurrency, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
applyCODTaxResponse
protected javax.money.MonetaryAmount applyCODTaxResponse(@NonNull @NonNull com.broadleafcommerce.tax.domain.TaxCalculationResponse response, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull javax.money.CurrencyUnit expectedCurrency, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Applies theTaxCalculationResponse
for COD fees.- Parameters:
response
- theTaxCalculationResponse
that contains tax response for COD feescart
- theCart
that contains COD fee itemsexpectedCurrency
- the expected currencycontextInfo
- Context information around sandbox and multitenant state- Returns:
- the total COD fees tax
-
buildTaxItemsForFulfillment
@Deprecated protected List<com.broadleafcommerce.tax.domain.TaxItem> buildTaxItemsForFulfillment(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) Deprecated. -
buildTaxItemsForFulfillment
protected List<com.broadleafcommerce.tax.domain.TaxItem> buildTaxItemsForFulfillment(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getTaxItemIdForFulfillment
protected String getTaxItemIdForFulfillment(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) Extension point to modify theTaxItem.getItemId()
for fulfillment tax items. For someTaxProviders
, there may be a affix likeFR
(for freight) to add to theFulfillmentGroup.getReferenceNumber()
.- Parameters:
fulfillmentGroup
- Fulfillment group from which to derive an id- Returns:
TaxItem.getItemId()
for fulfillment tax items
-
calculateIncludedTaxes
protected void calculateIncludedTaxes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull javax.money.CurrencyUnit expectedCurrency, @NonNull @NonNull com.broadleafcommerce.tax.domain.TaxCalculationResponse taxResponse) Set VAT properties onCartPricing
. Determine how much of the total tax amount is included in the subtotal.- Parameters:
cart
- Cart to be taxedexpectedCurrency
- The currency to usetaxResponse
- TheTaxResponse
response containing calculated taxes.
-
addFulfillmentItemTaxDetails
protected void addFulfillmentItemTaxDetails(@NonNull @NonNull com.broadleafcommerce.tax.domain.TaxInfo taxInfo, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This takes the total from theFulfillmentGroup.getFulfillmentTaxableAmount()
. That should have generated aTaxInfo
. We createFulfillmentItemTaxDetails
for each item, distributing the fulfillment tax across all items, prorated based on merchandise value of each item, with the remainder arbitrarily going to the last item. The assumption is thatTaxInfo.getTaxCalculated()
is exactly equal to the sum of allTaxDetail.getTaxCalculated()
. This also assumes thatTaxInfo.getTaxableAmount()
is exactly equal to the sum of allTaxDetail.getTaxableAmount()
. By default, no rounding is performed in this method.- Parameters:
taxInfo
-fulfillmentGroup
-contextInfo
-
-
addFulfillmentItemTaxDetails
protected void addFulfillmentItemTaxDetails(@NonNull @NonNull com.broadleafcommerce.tax.domain.TaxInfo taxInfo, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) AddFulfillmentItemTaxDetails
to the fulfillment item.- Parameters:
taxInfo
- The tax infofulfillmentItem
- The fulfillment itemcontextInfo
- the contextInfo for this request
-
buildTaxCalculationGroup
protected com.broadleafcommerce.tax.domain.TaxCalculationGroup buildTaxCalculationGroup(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull @NonNull TaxAddressSourceHandler handler, @NonNull @NonNull List<com.broadleafcommerce.tax.domain.TaxItem> taxItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aTaxCalculationGroup
, which is used to calculate taxes for a group of items being shipped to or fulfilled at a particular Address.- Parameters:
cart
-fulfillmentGroup
-handler
-taxItems
-contextInfo
-- Returns:
-
determinePreferredProviderId
@Nullable protected String determinePreferredProviderId(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimate, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method returns the "preferred"Tax Provider ID
, which is determined byTaxProvider.getProviderId()
. By default, this will be null. This provides a hook point to allow someone to specify the Tax Provider that should be prioritized for use. For example, you may wish to returnSimpleTaxProvider.SIMPLE_TAX_PROVIDER_ID
for estimates. In this case you could override this method to do so if theestimate
argument is true, and return null otherwise. To be clear, this does not guarantee that theTaxProvider
specified will be used; only that it will be prioritized for use. If there is no TaxProvider registered with that ID, then it will be ignored. Or, if the TaxProvider exists with that ID, but it cannot handle the request, then it will be ignored.- Parameters:
cart
-estimate
-contextInfo
-- Returns:
-
determineCartId
protected String determineCartId(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) We require theCart.getId()
, in most cases. However, if, for some reason, there is no cart ID available in the cart, then we provide a UUID. The cart ID is generally used to tie requests together in someTax Provider systems
. By default, this uses theCart.getId()
. However, it generates aUUID
if no cart ID is available at the time this component is invoked.- Parameters:
cart
-contextInfo
-- Returns:
-
getTaxAddressSourceHandlers
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getTaxDelegate
protected com.broadleafcommerce.tax.delegate.TaxDelegate<?,?> getTaxDelegate() -
getAuthenticationUtils
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils() -
getCustomerProvider
-