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.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) 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, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
calculateIncludedTaxes
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull javax.money.CurrencyUnit expectedCurrency, @NonNull com.broadleafcommerce.tax.domain.TaxCalculationResponse taxResponse) In some situations, taxes are included in the price of the item.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 void
debugLogTrimmedTaxResponse
(@NotNull com.broadleafcommerce.tax.domain.TaxCalculationResponse response) 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) Deprecated.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 DelegatingTaxServiceProperties
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 com.fasterxml.jackson.databind.ObjectMapper
protected String
getProductDescription
(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Retrieves the description of the product represented by theCartItem
.protected javax.money.MonetaryAmount
getTaxableItemFulfillmentTotal
(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, javax.money.CurrencyUnit currency) 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
hasNoTaxItems
(com.broadleafcommerce.tax.domain.TaxCalculationRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determine if there are tax items on the given request.protected boolean
isCODSelected
(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) protected boolean
isGroupFulfillmentTaxable
(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg) protected boolean
isItemIncludesTaxes
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) In some situations, especially in European countries, for example, merchants are required to display all prices including tax.protected void
persistTaxResponseOnCart
(@NotNull com.broadleafcommerce.tax.domain.TaxCalculationResponse response, @NotNull com.broadleafcommerce.cart.client.domain.Cart cart) protected void
setAllTaxToZero
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) void
setAuthenticationUtils
(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) protected void
setCustomerAndAccountPropertiesOnRequest
(com.broadleafcommerce.tax.domain.TaxCalculationRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) void
setCustomerProvider
(CustomerProvider customerProvider) void
setDelegatingTaxServiceProperties
(DelegatingTaxServiceProperties delegatingTaxServiceProperties) void
setMapper
(com.fasterxml.jackson.databind.ObjectMapper mapper) 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) -
hasNoTaxItems
protected boolean hasNoTaxItems(com.broadleafcommerce.tax.domain.TaxCalculationRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determine if there are tax items on the given request.- Parameters:
request
- TheTaxCalculationRequest
to check.contextInfo
- The context of this request.- Returns:
- TRUE if there are no
Tax Items
on the request. FALSE if there are any present.
-
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, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getCartItemMap
-
buildTaxItemForLineItem
protected com.broadleafcommerce.tax.domain.TaxItem buildTaxItemForLineItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @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, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
isItemIncludesTaxes
protected boolean isItemIncludesTaxes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @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, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) In some situations, especially in European countries, for example, merchants are required to display all prices including tax. This is especially common with VAT. So, in some situations the price of a Product or Variant will include Value Added Taxes. Some providers (e.g. Avalara) will attempt to back-calculate the taxes from the price of the item if we indicate that tax is included in the price. While the customer does not need to pay additional taxes, this allows us to calculate taxes owed for this item, which we can store on the tax details for informational purposes and remediation. NOTE: By default, this method returns false. Broadleaf Commerce does not currently provide a mechanism to determine if tax is included because catalogs, products, variants, and even pricing can be shared across applications and countries. Implementors may wish to override this method to return true under certain circumstances. For example, if the destination country is a European country (e.g. GB or FR) and/or the currency is a European currency, then you may wish to return true. TheContextInfo
(i.e. the tenant or application) may also inform this decision.- Parameters:
fulfillmentGroup
-fulfillmentItem
-cartItem
-contextInfo
-- Returns:
-
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) -
isGroupFulfillmentTaxable
protected boolean isGroupFulfillmentTaxable(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg) -
getTaxableItemFulfillmentTotal
protected javax.money.MonetaryAmount getTaxableItemFulfillmentTotal(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, javax.money.CurrencyUnit currency) -
setCustomerAndAccountPropertiesOnRequest
protected void setCustomerAndAccountPropertiesOnRequest(com.broadleafcommerce.tax.domain.TaxCalculationRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
determineTaxExemptionCode
@Deprecated @Nullable protected String determineTaxExemptionCode(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated. -
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) -
persistTaxResponseOnCart
protected void persistTaxResponseOnCart(@NotNull @NotNull com.broadleafcommerce.tax.domain.TaxCalculationResponse response, @NotNull @NotNull com.broadleafcommerce.cart.client.domain.Cart cart) -
debugLogTrimmedTaxResponse
protected void debugLogTrimmedTaxResponse(@NotNull @NotNull com.broadleafcommerce.tax.domain.TaxCalculationResponse response) -
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) In some situations, taxes are included in the price of the item. This is most common with VAT, especially in European countries. This method determines whichTaxInfos
had taxes included prior to calling the TaxProvider. Then we set tax included properties onCartPricing
. This determines how much of the total tax amount is included in the subtotal vs how much has to be added to the subtotal. Note that it's common to confuse VAT with "included taxes" because VAT is usually included. However, these are separate properties or indicators, and VAT properties are for informational and remediation purposes, whiletaxIncluded
is for calculation purposes as well as informational and remediation purposes.- 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
-
getDelegatingTaxServiceProperties
-
setDelegatingTaxServiceProperties
@Autowired public void setDelegatingTaxServiceProperties(DelegatingTaxServiceProperties delegatingTaxServiceProperties) -
getMapper
protected com.fasterxml.jackson.databind.ObjectMapper getMapper() -
setMapper
@Autowired public void setMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
-