Class DefaultTaxService<F extends com.broadleafcommerce.cart.client.domain.FulfillmentGroup,TREQ extends com.broadleafcommerce.tax.domain.TaxRequest,TRES extends com.broadleafcommerce.tax.domain.TaxResponse,TI extends com.broadleafcommerce.tax.domain.TaxItem>
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.pricing.DefaultTaxService<F,TREQ,TRES,TI>
-
- All Implemented Interfaces:
TaxService
@Deprecated public class DefaultTaxService<F extends com.broadleafcommerce.cart.client.domain.FulfillmentGroup,TREQ extends com.broadleafcommerce.tax.domain.TaxRequest,TRES extends com.broadleafcommerce.tax.domain.TaxResponse,TI extends com.broadleafcommerce.tax.domain.TaxItem> extends Object implements TaxService
Deprecated.The defaultTaxService
which integrates withTaxProviders
. This service connects to anactualTaxProvider
for accurate actual tax amounts and an optionalestimatedTaxProvider
for quick estimated tax amounts. Callers of this class can choose to get taxes for either or both actual and estimated. A typical scenario would be to use a quick synchronous call for estimated taxes when performing cart operations and then get the actual taxes through a 3rd party provider once the cart is finalized in checkout and ready for the customer to review final pricing.- Author:
- Chad Harchar (charchar)
- See Also:
DefaultDelegatingTaxService
-
-
Constructor Summary
Constructors Constructor Description DefaultTaxService(com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> estimatedTaxProvider, com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> actualTaxProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
Deprecated.DefaultTaxService(com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> estimatedTaxProvider, com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> actualTaxProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, List<TaxAddressSourceHandler> handlers)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addFulfillmentItemTaxDetails(com.broadleafcommerce.tax.domain.TaxResponse taxResponse, com.broadleafcommerce.tax.domain.TaxInfo taxInfo, com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
Deprecated.AddFulfillmentItemTaxDetails
to the fulfillment item.void
applyTaxes(com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimated, boolean actual, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Calculates and applies taxes to a cart.protected void
applyTaxesForGroup(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, F fulfillmentGroup, @NonNull com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> taxProvider, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected void
applyTaxesForGroups(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull List<F> fulfillmentGroups, @NonNull com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> taxProvider, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Calculates and setsFulfillmentItem.getMerchandiseTotalTax()
andFulfillmentGroup.getTotalTax()
.protected void
applyTaxesInternal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> taxProvider, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Performs the bulk of the tax calculations and application for a givenTaxProvider
.protected void
applyTaxResponse(TRES taxResponse, F fulfillmentGroup, javax.money.CurrencyUnit expectedCurrency)
Deprecated.In favor ofapplyTaxResponses(List, List, CurrencyUnit)
protected void
applyTaxResponses(List<TRES> taxResponses, List<F> fulfillmentGroups, javax.money.CurrencyUnit expectedCurrency)
Deprecated.protected TI
buildTaxItemForFeeItem(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Deprecated.protected TI
buildTaxItemForLineItem(F fulfillmentGroup, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
Deprecated.Since 1.2.protected List<TI>
buildTaxItemsForFulfillment(F fulfillmentGroup)
Deprecated.protected List<TI>
buildTaxItemsForLineItems(F fulfillmentGroup)
Deprecated.Since 1.2.protected Collection<? extends TI>
buildTaxItemsForLineItems(F fulfillmentGroup, com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.protected void
calculateActualTaxesForCart(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected void
calculateEstimatedTaxesForCart(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected void
calculateIncludedTaxes(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, javax.money.CurrencyUnit expectedCurrency, List<TRES> taxResponse)
Deprecated.Set VAT properties onCartPricing
.boolean
canCalculateTaxes(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Whether the cart contains the information required to calculate taxes.protected TaxAddressSourceHandler
findTaxAddressSourceHandler(com.broadleafcommerce.cart.client.domain.Cart cart, F fulfillmentGroup, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected com.broadleafcommerce.tax.TaxProvider<TREQ,TRES>
getActualTaxProvider()
Deprecated.protected Optional<TaxAddressSourceHandler>
getAddressSourceForFeeTaxCalculation(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, F fulfillmentGroup, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
getAuthenticationUtils()
Deprecated.protected CustomerProvider
getCustomerProvider()
Deprecated.protected com.broadleafcommerce.tax.TaxProvider<TREQ,TRES>
getEstimatedTaxProvider()
Deprecated.protected Optional<F>
getFulfillmentGroupForCOD(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.protected List<F>
getFulfillmentGroups(com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.protected <T> T
getInstance(Class<?> clazz)
Deprecated.protected String
getProductDescription(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Deprecated.Retrieves the description of the product represented by theCartItem
.protected List<TaxAddressSourceHandler>
getTaxAddressSourceHandlers()
Deprecated.protected javax.money.MonetaryAmount
getTaxesForFeeItems(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> taxProvider, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected String
getTaxId(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected String
getTaxItemIdForFulfillment(F fulfillmentGroup)
Deprecated.Extension point to modify theTaxItem.getItemId()
for fulfillment tax items.protected String
getTaxItemIdForLineItem(F fulfillmentGroup, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
Deprecated.protected com.broadleafcommerce.tax.TaxProvider<TREQ,TRES>
getTaxProvider(com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimated, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Determine which tax provider to use for calculating taxes for the cartprotected TREQ
getTaxRequest(com.broadleafcommerce.cart.client.domain.Cart cart, F fulfillmentGroup, TaxAddressSourceHandler handler, List<TI> taxItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.protected Map<String,TRES>
getTaxResponseMap(List<TRES> taxResponses)
Deprecated.Returns a map of tax responses, with the key as theTaxResponse.getFulfillmentGroupReferenceNumber()
protected com.broadleafcommerce.common.extension.TypeFactory
getTypeFactory()
Deprecated.protected boolean
isEstimatedProvider(com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> taxProvider, com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Determine if the given provider calculates estimated taxes or actual taxes.protected void
setAllTaxToZero(com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.void
setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
Deprecated.void
setCustomerProvider(CustomerProvider customerProvider)
Deprecated.protected boolean
shouldCalculateItemTaxes(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.protected boolean
shouldTaxFulfillment(F fulfillmentGroup, javax.money.CurrencyUnit currencyUnit)
Deprecated.
-
-
-
Constructor Detail
-
DefaultTaxService
public DefaultTaxService(@Nullable com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> estimatedTaxProvider, com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> actualTaxProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, List<TaxAddressSourceHandler> handlers)
Deprecated.
-
-
Method Detail
-
setAuthenticationUtils
@Autowired public void setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
Deprecated.
-
setCustomerProvider
@Autowired public void setCustomerProvider(CustomerProvider customerProvider)
Deprecated.
-
canCalculateTaxes
public boolean canCalculateTaxes(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.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.
-
applyTaxes
public void applyTaxes(com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimated, boolean actual, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.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.estimated
- Whether to provide an estimateactual
- Whether to provide the actualcontextInfo
- Additional sandbox and tenant info
-
calculateActualTaxesForCart
protected void calculateActualTaxesForCart(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
-
calculateEstimatedTaxesForCart
protected void calculateEstimatedTaxesForCart(com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
-
applyTaxesInternal
protected void applyTaxesInternal(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> taxProvider, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Performs the bulk of the tax calculations and application for a givenTaxProvider
.- Parameters:
cart
- Cart to be taxedtaxProvider
- TheTaxProvider
to facilitate tax calculations
-
getTaxesForFeeItems
protected javax.money.MonetaryAmount getTaxesForFeeItems(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> taxProvider, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
-
buildTaxItemForFeeItem
protected TI buildTaxItemForFeeItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Deprecated.
-
getFulfillmentGroupForCOD
protected Optional<F> getFulfillmentGroupForCOD(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.
-
getAddressSourceForFeeTaxCalculation
protected Optional<TaxAddressSourceHandler> getAddressSourceForFeeTaxCalculation(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull F fulfillmentGroup, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
-
applyTaxesForGroups
protected void applyTaxesForGroups(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull List<F> fulfillmentGroups, @NonNull @NonNull com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> taxProvider, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Calculates and setsFulfillmentItem.getMerchandiseTotalTax()
andFulfillmentGroup.getTotalTax()
.- Parameters:
cart
- The cart with items to be taxedfulfillmentGroups
- The group to be taxed with items to be taxedtaxProvider
- TheTaxProvider
that calculates the tax
-
getTaxId
@Nullable protected String getTaxId(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
-
calculateIncludedTaxes
protected void calculateIncludedTaxes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, javax.money.CurrencyUnit expectedCurrency, List<TRES> taxResponse)
Deprecated.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.
-
buildTaxItemsForLineItems
protected Collection<? extends TI> buildTaxItemsForLineItems(F fulfillmentGroup, com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.
-
getProductDescription
protected String getProductDescription(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
Deprecated.Retrieves the description of the product represented by theCartItem
.- Parameters:
cartItem
- theCartItem
- Returns:
- The description of the product that was added to the cart.
-
getTaxRequest
protected TREQ getTaxRequest(com.broadleafcommerce.cart.client.domain.Cart cart, F fulfillmentGroup, TaxAddressSourceHandler handler, List<TI> taxItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
-
applyTaxResponses
protected void applyTaxResponses(List<TRES> taxResponses, List<F> fulfillmentGroups, javax.money.CurrencyUnit expectedCurrency)
Deprecated.
-
addFulfillmentItemTaxDetails
protected void addFulfillmentItemTaxDetails(com.broadleafcommerce.tax.domain.TaxResponse taxResponse, com.broadleafcommerce.tax.domain.TaxInfo taxInfo, com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
Deprecated.AddFulfillmentItemTaxDetails
to the fulfillment item.- Parameters:
taxResponse
- The tax responsetaxInfo
- The tax infofulfillmentItem
- The fulfillment item
-
getTaxResponseMap
protected Map<String,TRES> getTaxResponseMap(List<TRES> taxResponses)
Deprecated.Returns a map of tax responses, with the key as theTaxResponse.getFulfillmentGroupReferenceNumber()
- Parameters:
taxResponses
- A list of tax responses- Returns:
- A map of tax responses.
-
applyTaxesForGroup
@Deprecated protected void applyTaxesForGroup(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull F fulfillmentGroup, @NonNull @NonNull com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> taxProvider, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Calculates and setsFulfillmentItem.getMerchandiseTotalTax()
andFulfillmentGroup.getTotalTax()
.- Parameters:
cart
- The cart with items to be taxedfulfillmentGroup
- The group to be taxed with items to be taxedtaxProvider
- TheTaxProvider
that facilitates calculating the tax
-
getTaxItemIdForLineItem
protected String getTaxItemIdForLineItem(@NonNull F fulfillmentGroup, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
Deprecated.
-
buildTaxItemForLineItem
@Deprecated protected TI buildTaxItemForLineItem(@NonNull F fulfillmentGroup, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem)
Deprecated.Since 1.2. UsebuildTaxItemsForLineItems(FulfillmentGroup, Cart)
- Parameters:
fulfillmentGroup
-fulfillmentItem
-- Returns:
-
buildTaxItemsForFulfillment
protected List<TI> buildTaxItemsForFulfillment(@NonNull F fulfillmentGroup)
Deprecated.
-
getTaxItemIdForFulfillment
protected String getTaxItemIdForFulfillment(@NonNull F fulfillmentGroup)
Deprecated.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
-
applyTaxResponse
@Deprecated protected void applyTaxResponse(@NonNull TRES taxResponse, @NonNull F fulfillmentGroup, javax.money.CurrencyUnit expectedCurrency)
Deprecated.In favor ofapplyTaxResponses(List, List, CurrencyUnit)
Takes theTaxResponse
and applies the results to theFulfillmentGroup
and its items.- Parameters:
taxResponse
- Tax response to applyfulfillmentGroup
- Group to which to apply the response
-
setAllTaxToZero
protected void setAllTaxToZero(com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.
-
shouldCalculateItemTaxes
protected boolean shouldCalculateItemTaxes(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.
-
buildTaxItemsForLineItems
@Deprecated protected List<TI> buildTaxItemsForLineItems(F fulfillmentGroup)
Deprecated.Since 1.2. UsebuildTaxItemsForLineItems(FulfillmentGroup, Cart)
- Parameters:
fulfillmentGroup
-- Returns:
-
shouldTaxFulfillment
protected boolean shouldTaxFulfillment(F fulfillmentGroup, javax.money.CurrencyUnit currencyUnit)
Deprecated.
-
findTaxAddressSourceHandler
@Nullable protected TaxAddressSourceHandler findTaxAddressSourceHandler(com.broadleafcommerce.cart.client.domain.Cart cart, F fulfillmentGroup, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.
-
getInstance
protected <T> T getInstance(Class<?> clazz)
Deprecated.
-
getFulfillmentGroups
protected List<F> getFulfillmentGroups(com.broadleafcommerce.cart.client.domain.Cart cart)
Deprecated.
-
getTaxProvider
@Nullable protected com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> getTaxProvider(com.broadleafcommerce.cart.client.domain.Cart cart, boolean estimated, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Determine which tax provider to use for calculating taxes for the cart- Parameters:
cart
- The cart to be taxed.estimated
- Whether the calculated tax is an estimate.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- A
TaxProvider
that can be used to calculate taxes for the cart.
-
isEstimatedProvider
protected boolean isEstimatedProvider(com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> taxProvider, com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Deprecated.Determine if the given provider calculates estimated taxes or actual taxes.- Parameters:
taxProvider
- TheTaxProvider
used to calculate taxes for the cart.cart
- The cart to be taxed.contextInfo
- Context information around sandbox and multitenant state.- Returns:
- True if the given
TaxProvider
calculates estimated taxes.
-
getEstimatedTaxProvider
@Nullable protected com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> getEstimatedTaxProvider()
Deprecated.
-
getActualTaxProvider
protected com.broadleafcommerce.tax.TaxProvider<TREQ,TRES> getActualTaxProvider()
Deprecated.
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
Deprecated.
-
getTaxAddressSourceHandlers
protected List<TaxAddressSourceHandler> getTaxAddressSourceHandlers()
Deprecated.
-
getAuthenticationUtils
protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils()
Deprecated.
-
getCustomerProvider
protected CustomerProvider getCustomerProvider()
Deprecated.
-
-