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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultDelegatingTaxService(@NonNull com.broadleafcommerce.tax.delegate.TaxDelegate<?, ?> taxDelegate, List<TaxAddressSourceHandler> taxAddressSourceHandlers, @NonNull com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddFeeItemsTaxCalculationGroup(@NonNull com.broadleafcommerce.tax.domain.TaxCalculationRequest request, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Add aTaxCalculationGroupfor the cart's fee items to the givenTaxCalculationRequest.protected voidaddFulfillmentItemTaxDetails(@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 voidaddFulfillmentItemTaxDetails(@NonNull com.broadleafcommerce.tax.domain.TaxInfo taxInfo, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) AddFulfillmentItemTaxDetailsto the fulfillment item.protected javax.money.MonetaryAmountapplyCODTaxResponse(@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 theTaxCalculationResponsefor COD fees.voidapplyTaxes(@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 voidapplyTaxResponses(@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.TaxCalculationGroupbuildTaxCalculationGroup(@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.TaxItembuildTaxItemForFeeItem(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Builds aTaxItembased on the givenfee item.protected com.broadleafcommerce.tax.domain.TaxItembuildTaxItemForLineItem(@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 voidcalculateIncludedTaxes(@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.booleancanCalculateTaxes(@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.TaxCalculationRequestcreateRequest(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull javax.money.CurrencyUnit expectedCurrency, boolean estimate, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voiddebugLogTrimmedTaxResponse(@NotNull com.broadleafcommerce.tax.domain.TaxCalculationResponse response) protected StringdetermineCartId(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) We require theCart.getId(), in most cases.protected StringdeterminePreferredProviderId(@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 StringdetermineTaxExemptionCode(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.protected com.broadleafcommerce.tax.domain.TaxCalculationResponseexecuteTaxCalculation(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.tax.domain.TaxCalculationRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected TaxAddressSourceHandlerfindTaxAddressSourceHandler(@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 theTaxAddressSourceHandlerfor tax calculation for fees, e.g.protected booleanfulfillmentGroupHasSufficientAddress(@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 givenFulfillmentGrouphas sufficient address to calculate taxes.protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtilsgetCartItemMap(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) protected CustomerProviderprotected DelegatingTaxServicePropertiesprotected Optional<com.broadleafcommerce.cart.client.domain.FulfillmentGroup>getFulfillmentGroupForCOD(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Gets theFulfillmentGroupthat 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.ObjectMapperprotected StringgetProductDescription(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Retrieves the description of the product represented by theCartItem.protected javax.money.MonetaryAmountgetTaxableItemFulfillmentTotal(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg, javax.money.CurrencyUnit currency) protected List<TaxAddressSourceHandler>protected com.broadleafcommerce.tax.delegate.TaxDelegate<?,?> protected StringgetTaxItemIdForFulfillment(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) Extension point to modify theTaxItem.getItemId()for fulfillment tax items.protected StringgetTaxItemIdForLineItem(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem) protected com.broadleafcommerce.common.extension.TypeFactoryprotected booleanhasNoTaxItems(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 booleanisCODSelected(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup) protected booleanisGroupFulfillmentTaxable(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fg) protected booleanisItemIncludesTaxes(@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 voidpersistTaxResponseOnCart(@NotNull com.broadleafcommerce.tax.domain.TaxCalculationResponse response, @NotNull com.broadleafcommerce.cart.client.domain.Cart cart) protected voidsetAllTaxToZero(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) voidsetAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils) protected voidsetCustomerAndAccountPropertiesOnRequest(com.broadleafcommerce.tax.domain.TaxCalculationRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidsetCustomerProvider(CustomerProvider customerProvider) voidsetDelegatingTaxServiceProperties(DelegatingTaxServiceProperties delegatingTaxServiceProperties) voidsetMapper(com.fasterxml.jackson.databind.ObjectMapper mapper) protected booleanshouldCalculateItemTaxes(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanshouldTaxFulfillment(@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, waitMethods 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 theTaxDetailfor 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:TaxServiceCalculates and applies taxes to a cart.- Specified by:
applyTaxesin 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:TaxServiceWhether the cart contains the information required to calculate taxes.- Specified by:
canCalculateTaxesin 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 givenFulfillmentGrouphas 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- theFulfillmentGroupto check the address forcart- theCartthat theFulfillmentGroupbelongs tocontextInfo- the contextInfo for this request- Returns:
- true if the given
FulfillmentGrouphas 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- TheTaxCalculationRequestto check.contextInfo- The context of this request.- Returns:
- TRUE if there are no
Tax Itemson 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 aTaxCalculationGroupfor the cart's fee items to the givenTaxCalculationRequest.- Parameters:
request- theTaxCalculationRequestto add the fee items'TaxCalculationGrouptocart- theCartcontaining 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 aTaxItembased on the givenfee item.- Parameters:
cartItem- the fee item- Returns:
- the
TaxItembuilt 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 theFulfillmentGroupthat 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 theTaxAddressSourceHandlerfor tax calculation for fees, e.g. COD feesBy default, it delegates to
findTaxAddressSourceHandler(Cart, FulfillmentGroup, ContextInfo).- Parameters:
cart- theCartcontaining fee itemsfulfillmentGroup- theFulfillmentGroupthat has COD selectedcontextInfo- context information surrounding multitenant state- Returns:
- an optional of
TaxAddressSourceHandlerfor 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 theTaxCalculationResponsefor COD fees.- Parameters:
response- theTaxCalculationResponsethat contains tax response for COD feescart- theCartthat 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 whichTaxInfoshad 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, whiletaxIncludedis for calculation purposes as well as informational and remediation purposes.- Parameters:
cart- Cart to be taxedexpectedCurrency- The currency to usetaxResponse- TheTaxResponseresponse 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 createFulfillmentItemTaxDetailsfor 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) AddFulfillmentItemTaxDetailsto 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_IDfor estimates. In this case you could override this method to do so if theestimateargument is true, and return null otherwise. To be clear, this does not guarantee that theTaxProviderspecified 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 aUUIDif 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)
-