Class DefaultDelegatingTaxService

java.lang.Object
com.broadleafcommerce.cartoperation.service.pricing.DefaultDelegatingTaxService
All Implemented Interfaces:
TaxService

public class DefaultDelegatingTaxService extends Object implements 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
    Modifier and Type
    Field
    Description
    static final String
    The reference number used for COD Fee Items' TaxCalculationRequest.
    static final String
    Default name for the TaxDetail for taxes associated with fulfillment, shipping, and handling.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultDelegatingTaxService(@NonNull com.broadleafcommerce.tax.delegate.TaxDelegate<?,?> taxDelegate, List<TaxAddressSourceHandler> taxAddressSourceHandlers, @NonNull com.broadleafcommerce.common.extension.TypeFactory typeFactory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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 a TaxCalculationGroup for the cart's fee items to the given TaxCalculationRequest.
    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 the FulfillmentGroup.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)
    Add FulfillmentItemTaxDetails 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 the TaxCalculationResponse 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 a TaxCalculationGroup, 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 a TaxItem based on the given fee 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 on CartPricing.
    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 the Cart.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 by TaxProvider.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)
     
    findTaxAddressSourceHandler(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    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 the TaxAddressSourceHandler 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 given FulfillmentGroup has sufficient address to calculate taxes.
    protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
     
    protected Map<String,com.broadleafcommerce.cart.client.domain.CartItem>
    getCartItemMap(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
     
     
    protected Optional<com.broadleafcommerce.cart.client.domain.FulfillmentGroup>
    getFulfillmentGroupForCOD(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
    Gets the FulfillmentGroup that has CollectOnDelivery selected from the given Cart.
    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 the CartItem.
     
    protected com.broadleafcommerce.tax.delegate.TaxDelegate<?,?>
     
    protected String
    getTaxItemIdForFulfillment(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)
    Extension point to modify the TaxItem.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
     
    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

      public static final String COD_REFERENCE_NUMBER
      The reference number used for COD Fee Items' TaxCalculationRequest.
      See Also:
    • DEFAULT_FULFILLMENT_TAX_NAME

      public static final String DEFAULT_FULFILLMENT_TAX_NAME
      Default name for the TaxDetail 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

      @Autowired public void setCustomerProvider(CustomerProvider customerProvider)
    • 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 interface TaxService
      Parameters:
      cart - The cart to apply taxes against.
      estimate - Hint indicating whether to try to provide only an estimate, possibly for better performance
      contextInfo - (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 interface TaxService
      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 given FulfillmentGroup has sufficient address to calculate taxes.

      By default, for an address to be sufficient, it must have TaxAddress.getCountry() and TaxAddress.getStateProvinceRegion() at the very least.

      For different address requirements, customization should be added here

      Parameters:
      fg - the FulfillmentGroup to check the address for
      cart - the Cart that the FulfillmentGroup belongs to
      contextInfo - 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 a TaxCalculationGroup for the cart's fee items to the given TaxCalculationRequest.
      Parameters:
      request - the TaxCalculationRequest to add the fee items' TaxCalculationGroup to
      cart - the Cart containing fee items
      contextInfo - 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 a TaxItem based on the given fee 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 the FulfillmentGroup that has CollectOnDelivery selected from the given Cart.
      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 the TaxAddressSourceHandler for tax calculation for fees, e.g. COD fees

      By default, it delegates to findTaxAddressSourceHandler(Cart, FulfillmentGroup, ContextInfo).

      Parameters:
      cart - the Cart containing fee items
      fulfillmentGroup - the FulfillmentGroup that has COD selected
      contextInfo - 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

      protected Map<String,com.broadleafcommerce.cart.client.domain.CartItem> getCartItemMap(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
    • 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 the CartItem.
      Parameters:
      cartItem - the CartItem
      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 the TaxCalculationResponse for COD fees.
      Parameters:
      response - the TaxCalculationResponse that contains tax response for COD fees
      cart - the Cart that contains COD fee items
      expectedCurrency - the expected currency
      contextInfo - 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 the TaxItem.getItemId() for fulfillment tax items. For some TaxProviders, there may be a affix like FR (for freight) to add to the FulfillmentGroup.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 on CartPricing. Determine how much of the total tax amount is included in the subtotal.
      Parameters:
      cart - Cart to be taxed
      expectedCurrency - The currency to use
      taxResponse - The TaxResponse 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 the FulfillmentGroup.getFulfillmentTaxableAmount(). That should have generated a TaxInfo. We create FulfillmentItemTaxDetails 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 that TaxInfo.getTaxCalculated() is exactly equal to the sum of all TaxDetail.getTaxCalculated(). This also assumes that TaxInfo.getTaxableAmount() is exactly equal to the sum of all TaxDetail.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)
      Add FulfillmentItemTaxDetails to the fulfillment item.
      Parameters:
      taxInfo - The tax info
      fulfillmentItem - The fulfillment item
      contextInfo - 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 a TaxCalculationGroup, 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 by TaxProvider.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 return SimpleTaxProvider.SIMPLE_TAX_PROVIDER_ID for estimates. In this case you could override this method to do so if the estimate argument is true, and return null otherwise. To be clear, this does not guarantee that the TaxProvider 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 the Cart.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 some Tax Provider systems. By default, this uses the Cart.getId(). However, it generates a UUID if no cart ID is available at the time this component is invoked.
      Parameters:
      cart -
      contextInfo -
      Returns:
    • getTaxAddressSourceHandlers

      protected List<TaxAddressSourceHandler> 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

      protected CustomerProvider getCustomerProvider()