Package com.broadleafcommerce.tax.simple
Class SimpleTaxProvider<T1 extends TaxRequest,T2 extends TaxResponse>
java.lang.Object
com.broadleafcommerce.tax.simple.SimpleTaxProvider<T1,T2>
- All Implemented Interfaces:
TaxAccessor<T1,,T2> TaxProvider<T1,,T2> org.springframework.core.Ordered
public class SimpleTaxProvider<T1 extends TaxRequest,T2 extends TaxResponse>
extends Object
implements TaxProvider<T1,T2>
Simple implementation of
TaxProvider primarily used for estimating taxes, but can be used
for providing full taxes for implementors without complex tax needs. Otherwise, a
TaxProvider integrated with a 3rd party, such as Avalara, is preferred. If this simple
provider is intended to be used in a live production environment, the implementor must be aware
that they own the consequences of tax law and must maintain the tax configuration details.
This TaxProvider can also act as a fallback tax provider when used with Circuit Breaker
functionality as is the case with DefaultTaxDelegate.- Author:
- Chad Harchar (charchar), Kelly Tisdell (ktisdell)
-
Field Summary
FieldsFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionSimpleTaxProvider(@NonNull com.fasterxml.jackson.databind.ObjectMapper objectMapper, @NonNull com.broadleafcommerce.common.extension.TypeFactory typeFactory, @NonNull SimpleTaxProperties properties) SimpleTaxProvider(@NonNull com.fasterxml.jackson.databind.ObjectMapper objectMapper, @NonNull com.broadleafcommerce.common.extension.TypeFactory typeFactory, @NonNull SimpleTaxProperties properties, org.springframework.core.io.ResourceLoader resourceLoader) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddTaxDetail(SimpleTaxRecord chosenConfig, TaxItem item, TaxInfo taxInfo, BigDecimal rate, boolean taxExempt) adjustTaxes(AdjustTaxTransactionRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) ForTax Accessorsthat support "commitTaxes", this allows for adjustments after taxes have been committed.protected StringbuildCacheKey(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidcalculateExcludedTax(javax.money.MonetaryAmount subtotal, BigDecimal rate, TaxInfo taxInfo, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Calculate tax and taxable amounts for excluded taxes.protected voidcalculateIncludedTax(javax.money.MonetaryAmount subtotal, BigDecimal rate, TaxInfo taxInfo, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Calculate tax and taxable amounts for included taxes.calculateTaxes(TaxCalculationRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Takes theTaxCalculationRequestand computes sales tax.calculateTaxes(List<T1> taxRequests, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.calculateTaxes(T1 taxRequest) Deprecated.<R extends TaxCalculationRequest>
booleancanHandle(R request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Indicates if thisTaxProvidercan handle requests for the givenTaxCalculationRequestandContextInfo, which can be null.commitTaxes(CommitTaxRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) SomeTaxAccessorinstances allow clients to "commit" taxes, which essentially marks them as being collected and owed to a jurisdiction or tax authority.protected Map<String,SimpleTaxConfig> Creates aLRUMapto containSimpleTaxConfiginstances for different applications and / or tenants.protected SimpleTaxConfigprotected SimpleTaxConfigcreateSimpleTaxConfigFromResourcePath(String resourcePath) protected SimpleTaxRecorddefaultIfNoneFound(SimpleTaxConfig simpleTaxConfig) protected booleandetermineIsTaxIncluded(Boolean isTaxIncludedInItemPrice, Boolean isVATTaxAccordingToConfig) Deprecated.protected booleandetermineIsTaxIncluded(Boolean isTaxIncludedInItemPrice, Boolean isVATTaxAccordingToConfig, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns true if either of theTaxItem.getTaxIncluded()andSimpleTaxRecord.getVat()flags are true.protected BigDecimaldetermineRate(TaxItem item, SimpleTaxRecord chosenConfig) Deprecated.protected BigDecimaldetermineRate(TaxItem item, SimpleTaxRecord chosenConfig, boolean taxExempt) protected Optional<SimpleTaxRecord>findByCountry(List<SimpleTaxRecord> taxTable, TaxAddress toAddress) protected Optional<SimpleTaxRecord>findByPostalCode(List<SimpleTaxRecord> taxTable, TaxAddress toAddress) protected Optional<SimpleTaxRecord>findBySubdivision(List<SimpleTaxRecord> taxTable, TaxAddress toAddress) protected Optional<SimpleTaxRecord>findBySubdivisionAndCity(List<SimpleTaxRecord> taxTable, TaxAddress toAddress) protected SimpleTaxConfiggetConfigFromCache(String key) Fetches theSimpleTaxConfigfrom cache so that it does not have to be deserialized every time.protected Map<String,SimpleTaxConfig> protected SimpleTaxConfigprotected SimpleTaxConfigprotected SimpleTaxRecordprotected com.fasterxml.jackson.databind.ObjectMapperintgetOrder()Order this component with a low precedence.final StringThis returns a string that is unique to identify eachTaxProvider.protected org.springframework.core.io.ResourceLoaderprotected SimpleTaxPropertiesprotected SimpleTaxRecordgetTaxConfig(T1 taxRequest, TaxItem item) Deprecated.useresolveSimpleTaxConfigprotected TaxInfogetTaxInfo(SimpleTaxRecord chosenConfig, TaxItem item, boolean taxExempt, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected TaxInfogetTaxInfo(SimpleTaxRecord chosenConfig, TaxItem item, javax.money.CurrencyUnit currencyUnit) Deprecated.UsegetTaxInfo(TaxCalculationRequest, SimpleTaxRecord, TaxItem, CurrencyUnit, ContextInfo)to consider tax-exemption for items.protected TaxInfogetTaxInfo(BigDecimal rate, TaxItem item, javax.money.CurrencyUnit currencyUnit) Deprecated.since 1.7.protected <R extends TaxCalculationRequest>
TaxInfogetTaxInfo(R request, SimpleTaxRecord chosenConfig, TaxItem item, javax.money.CurrencyUnit currencyUnit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected SimpleTaxRecordgetTaxRecord(TaxCalculationGroup group, TaxItem item, SimpleTaxConfig config) protected SimpleTaxRecordgetTaxRecord(T1 taxRequest, TaxItem item, SimpleTaxConfig config) Deprecated.protected T2getTaxResponse(T1 taxRequest) Deprecated.protected T2getTaxResponse(T1 taxRequest, SimpleTaxConfig config) Deprecated.protected com.broadleafcommerce.common.extension.TypeFactorybooleanIndicates (or hints) if this provider estimates taxes.protected booleanisSubdivisionMatch(TaxAddress address, SimpleTaxRecord taxRecord) protected <R extends TaxCalculationRequest>
booleanisTaxExempt(R request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<SimpleTaxRecord>lookupTaxConfig(SimpleTaxConfig simpleTaxConfig, TaxAddress toAddress) protected Optional<SimpleTaxRecord>lookupTaxConfig(SimpleTaxConfig simpleTaxConfig, TaxAddress toAddress, String lookupKey) protected voidpopulateTaxResponse(@NonNull TaxCalculationRequest request, @NonNull TaxCalculationResponse response, @NonNull SimpleTaxConfig config, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected <R extends TaxCalculationRequest>
voidpopulateTaxResponseGroup(@NonNull TaxResponseGroup taxResponseGroup, R request, @NonNull TaxCalculationGroup calculationGroup, @NonNull SimpleTaxConfig config, @NonNull javax.money.CurrencyUnit currency, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidputConfigInCache(@NonNull String key, @NonNull SimpleTaxConfig config) Puts theSimpleTaxConfigin a cache so that it does not have to be deserialized every time.protected SimpleTaxConfigresolveSimpleTaxConfig(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) reverseTaxTransaction(ReverseTaxTransactionRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) ForTax Accessorsthat support "commitTaxes", this allows for reversal after taxes have been committed.voidvalidate(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This can be used to determine if configurations, credential, and connections are correct and working properly together.voidvoidTaxTransaction(VoidTransactionRequest voidTransactionRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Typically used in the case of full order cancellations.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.tax.TaxAccessor
commitTaxes
-
Field Details
-
SIMPLE_TAX_PROVIDER_ID
- See Also:
-
-
Constructor Details
-
SimpleTaxProvider
public SimpleTaxProvider(@NonNull @NonNull com.fasterxml.jackson.databind.ObjectMapper objectMapper, @NonNull @NonNull com.broadleafcommerce.common.extension.TypeFactory typeFactory, @NonNull @NonNull SimpleTaxProperties properties) -
SimpleTaxProvider
public SimpleTaxProvider(@NonNull @NonNull com.fasterxml.jackson.databind.ObjectMapper objectMapper, @NonNull @NonNull com.broadleafcommerce.common.extension.TypeFactory typeFactory, @NonNull @NonNull SimpleTaxProperties properties, @Nullable org.springframework.core.io.ResourceLoader resourceLoader)
-
-
Method Details
-
calculateTaxes
Deprecated.Description copied from interface:TaxAccessorCalculate taxes for a request that includes a list of items and address(es).- Specified by:
calculateTaxesin interfaceTaxAccessor<T1 extends TaxRequest,T2 extends TaxResponse> - Parameters:
taxRequest- The request for which to calculate taxes.
-
getTaxResponse
Deprecated. -
isEstimator
public boolean isEstimator()Description copied from interface:TaxProviderIndicates (or hints) if this provider estimates taxes. This is similar to (or could be the same as) calculating taxes. This is usually a consideration where a provider prefers not to make a remote call, or where the provider can operate on limited info (e.g. just a state or province or country and not a full address). The default is false.- Specified by:
isEstimatorin interfaceTaxProvider<T1 extends TaxRequest,T2 extends TaxResponse> - Returns:
-
calculateTaxes
@Deprecated public List<T2> calculateTaxes(List<T1> taxRequests, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.The simple tax provider determines tax rates by looking atSimpleTaxProperties.getConfigPath(ContextInfo)orSimpleTaxProperties.getConfigJsonString(ContextInfo)and mapping it into the data structureSimpleTaxConfig. This is then used to determine the most accurate correspondingSimpleTaxRecordby the following priority, moving to the next item if no matching tax record is found:- Postal code
- City and subdivision (i.e. state, province, or region)
- Subdivision (i.e. state, province, or region)
- Country
- Specified by:
calculateTaxesin interfaceTaxAccessor<T1 extends TaxRequest,T2 extends TaxResponse> - Parameters:
taxRequests- The request for which to calculate taxes.contextInfo- Context information. May be null.- Returns:
- The
TaxResponseresponse containing calculated taxes.
-
getTaxConfig
Deprecated.useresolveSimpleTaxConfigDetermines the key to use for looking up tax records. This will use the tax code from the item if available. Otherwise, it will use the country code from the taxRequest address. If there is no configuration for the tax code, it will try the country code before returning the default configuration.- Parameters:
taxRequest- Represents a fulfillment group for tax calculations.item- The item to be taxed.- Returns:
- A
SimpleTaxRecordwith a tax rate.
-
calculateTaxes
public TaxCalculationResponse calculateTaxes(TaxCalculationRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TaxAccessorTakes theTaxCalculationRequestand computes sales tax. The details of the tax determination are returned via theTaxCalculationResponse.- Specified by:
calculateTaxesin interfaceTaxAccessor<T1 extends TaxRequest,T2 extends TaxResponse> - Parameters:
request- TaxCalculationRequest, or details about what needs to be taxescontextInfo- The ContextInfo that determines which tenant and application are making the request- Returns:
-
adjustTaxes
public TaxCalculationResponse adjustTaxes(AdjustTaxTransactionRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TaxAccessorForTax Accessorsthat support "commitTaxes", this allows for adjustments after taxes have been committed.- Specified by:
adjustTaxesin interfaceTaxAccessor<T1 extends TaxRequest,T2 extends TaxResponse> - Returns:
-
commitTaxes
public CommitTaxResponse commitTaxes(CommitTaxRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TaxAccessorSomeTaxAccessorinstances allow clients to "commit" taxes, which essentially marks them as being collected and owed to a jurisdiction or tax authority. This is basically a way of saying, "We collected this much taxes for these products... and therefore we are saving these details for reporting and remittance."- Specified by:
commitTaxesin interfaceTaxAccessor<T1 extends TaxRequest,T2 extends TaxResponse> - Returns:
-
reverseTaxTransaction
public ReverseTaxTransactionResponse reverseTaxTransaction(ReverseTaxTransactionRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TaxAccessorForTax Accessorsthat support "commitTaxes", this allows for reversal after taxes have been committed.- Specified by:
reverseTaxTransactionin interfaceTaxAccessor<T1 extends TaxRequest,T2 extends TaxResponse> - Returns:
-
voidTaxTransaction
public void voidTaxTransaction(VoidTransactionRequest voidTransactionRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TaxAccessorTypically used in the case of full order cancellations. Completely voids a committed tax transaction.- Specified by:
voidTaxTransactionin interfaceTaxAccessor<T1 extends TaxRequest,T2 extends TaxResponse> - Parameters:
voidTransactionRequest- The void transaction requestcontextInfo- The ContextInfo that determines which tenant and application are making the request
-
defaultIfNoneFound
-
getNoDefaultRateFound
-
populateTaxResponse
protected void populateTaxResponse(@NonNull @NonNull TaxCalculationRequest request, @NonNull @NonNull TaxCalculationResponse response, @NonNull @NonNull SimpleTaxConfig config, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
populateTaxResponseGroup
protected <R extends TaxCalculationRequest> void populateTaxResponseGroup(@NonNull @NonNull TaxResponseGroup taxResponseGroup, @NonNull R request, @NonNull @NonNull TaxCalculationGroup calculationGroup, @NonNull @NonNull SimpleTaxConfig config, @NonNull @NonNull javax.money.CurrencyUnit currency, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getTaxRecord
protected SimpleTaxRecord getTaxRecord(TaxCalculationGroup group, TaxItem item, SimpleTaxConfig config) -
getTaxResponse
Deprecated. -
getTaxRecord
@Deprecated protected SimpleTaxRecord getTaxRecord(T1 taxRequest, TaxItem item, SimpleTaxConfig config) Deprecated.Determines the key to use for looking up tax records. This will use the tax code from the item if available. Otherwise, it will use the country code from the taxRequest address. If there is no configuration for the tax code, it will try the country code before returning the default configuration.- Parameters:
taxRequest- Represents a fulfillment group for tax calculations.item- The item to be taxed.- Returns:
- A
SimpleTaxRecordwith a tax rate.
-
isTaxExempt
protected <R extends TaxCalculationRequest> boolean isTaxExempt(R request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getTaxInfo
protected <R extends TaxCalculationRequest> TaxInfo getTaxInfo(R request, SimpleTaxRecord chosenConfig, TaxItem item, javax.money.CurrencyUnit currencyUnit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Create and populate aTaxInfofor thisTaxItem. This form will determine if the item is tax-exempt based on the givenTaxCalculationRequest.- Type Parameters:
R-TaxCalculationRequestor a subclass.- Parameters:
request- TheTaxCalculationRequestto process.chosenConfig- TheSimpleTaxRecordthat will provide the tax rate.item- TheTaxItemwhose tax is being calculated.currencyUnit- TheCurrencyUnitof the tax calculation.contextInfo- TheContextInfoof the request.- Returns:
- A
TaxInfocalculated for the givenTaxItemwith the givenSimpleTaxRecord.
-
getTaxInfo
@Deprecated protected TaxInfo getTaxInfo(SimpleTaxRecord chosenConfig, TaxItem item, javax.money.CurrencyUnit currencyUnit) Deprecated.UsegetTaxInfo(TaxCalculationRequest, SimpleTaxRecord, TaxItem, CurrencyUnit, ContextInfo)to consider tax-exemption for items. -
getTaxInfo
protected TaxInfo getTaxInfo(SimpleTaxRecord chosenConfig, TaxItem item, boolean taxExempt, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Create and populate aTaxInfofor thisTaxItem. This overload accepts a boolean for tax-exempt status. UsegetTaxInfo(TaxCalculationRequest, SimpleTaxRecord, TaxItem, CurrencyUnit, ContextInfo)to determine tax-exemption for items from the TaxRequest.- Parameters:
chosenConfig- The tax config to use during calculations.item- The item to be taxed.taxExempt- Indicate if the item is tax-exempt.contextInfo- TheContextInfoof the request.- Returns:
- A
TaxInfocalculated for the givenTaxItemwith the givenSimpleTaxRecord.
-
calculateIncludedTax
protected void calculateIncludedTax(javax.money.MonetaryAmount subtotal, BigDecimal rate, TaxInfo taxInfo, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Calculate tax and taxable amounts for included taxes. Included taxes are taxes that are already included in the retail price of an item.For example, a $10 item with a 5% included tax will have a taxable amount of $9.52, a tax amount of $0.48, to total $10.00 at checkout.
- Parameters:
subtotal- The extended price of the item.rate- The tax ratetaxInfo- TheTaxInfoto hold the values calculatedcontextInfo- TheContextInfoof the request.
-
calculateExcludedTax
protected void calculateExcludedTax(javax.money.MonetaryAmount subtotal, BigDecimal rate, TaxInfo taxInfo, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Calculate tax and taxable amounts for excluded taxes. Excluded taxes should be added to the subtotal price of an item.For example, a $10 item with a 5% excluded tax will have a taxable amount of $10, a tax amount of $0.50, to total $10.50 at checkout.
- Parameters:
subtotal- The extended price of the item.rate- The tax ratetaxInfo- TheTaxInfoto hold the values calculatedcontextInfo- TheContextInfoof the request.
-
addTaxDetail
protected void addTaxDetail(SimpleTaxRecord chosenConfig, TaxItem item, TaxInfo taxInfo, BigDecimal rate, boolean taxExempt) -
determineRate
-
determineRate
Deprecated. -
getTaxInfo
@Deprecated protected TaxInfo getTaxInfo(BigDecimal rate, TaxItem item, javax.money.CurrencyUnit currencyUnit) Deprecated.since 1.7. UsegetTaxInfo(SimpleTaxRecord, TaxItem, CurrencyUnit).- Parameters:
rate- The tax rate to use during calculations.item- The item to be taxed.currencyUnit- The currency of the monetary amounts.
-
lookupTaxConfig
protected Optional<SimpleTaxRecord> lookupTaxConfig(SimpleTaxConfig simpleTaxConfig, TaxAddress toAddress) -
lookupTaxConfig
protected Optional<SimpleTaxRecord> lookupTaxConfig(SimpleTaxConfig simpleTaxConfig, TaxAddress toAddress, String lookupKey) -
findByCountry
protected Optional<SimpleTaxRecord> findByCountry(List<SimpleTaxRecord> taxTable, TaxAddress toAddress) -
findBySubdivision
protected Optional<SimpleTaxRecord> findBySubdivision(List<SimpleTaxRecord> taxTable, TaxAddress toAddress) -
findByPostalCode
protected Optional<SimpleTaxRecord> findByPostalCode(List<SimpleTaxRecord> taxTable, TaxAddress toAddress) -
findBySubdivisionAndCity
protected Optional<SimpleTaxRecord> findBySubdivisionAndCity(List<SimpleTaxRecord> taxTable, TaxAddress toAddress) -
isSubdivisionMatch
-
getProviderId
Description copied from interface:TaxProviderThis returns a string that is unique to identify eachTaxProvider. Broadleaf implementations will use "BLC_" as a prefix. Custom implementations should NOT use this prefix.- Specified by:
getProviderIdin interfaceTaxProvider<T1 extends TaxRequest,T2 extends TaxResponse> - Returns:
-
canHandle
public <R extends TaxCalculationRequest> boolean canHandle(R request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TaxProviderIndicates if thisTaxProvidercan handle requests for the givenTaxCalculationRequestandContextInfo, which can be null.- Specified by:
canHandlein interfaceTaxProvider<T1 extends TaxRequest,T2 extends TaxResponse> - Parameters:
request- the tax request being- Returns:
-
resolveSimpleTaxConfig
protected SimpleTaxConfig resolveSimpleTaxConfig(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
createSimpleTaxConfigFromJson
-
createSimpleTaxConfigFromResourcePath
-
determineIsTaxIncluded
@Deprecated protected boolean determineIsTaxIncluded(@Nullable Boolean isTaxIncludedInItemPrice, @Nullable Boolean isVATTaxAccordingToConfig) Deprecated.Use the overload that accepts a ContextInfo,determineIsTaxIncluded(Boolean, Boolean, ContextInfo).Returns true if either of theTaxItem.getTaxIncluded()andSimpleTaxRecord.getVat()flags are true.- Parameters:
isTaxIncludedInItemPrice- The isTaxIncludedInItemPrice tag of the givenTaxItemisVATTaxAccordingToConfig- The isVATTaxAccordingToConfig flag of thechosenConfig- Returns:
- Whether tax is included or not
-
determineIsTaxIncluded
protected boolean determineIsTaxIncluded(@Nullable Boolean isTaxIncludedInItemPrice, @Nullable Boolean isVATTaxAccordingToConfig, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns true if either of theTaxItem.getTaxIncluded()andSimpleTaxRecord.getVat()flags are true.- Parameters:
isTaxIncludedInItemPrice- The isTaxIncludedInItemPrice tag of the givenTaxItemisVATTaxAccordingToConfig- The isVATTaxAccordingToConfig flag of thechosenConfig- Returns:
- Whether tax is included or not
-
putConfigInCache
protected void putConfigInCache(@NonNull @NonNull String key, @NonNull @NonNull SimpleTaxConfig config) Puts theSimpleTaxConfigin a cache so that it does not have to be deserialized every time. This can be overridden to use a different cache implementation.- Parameters:
key- usually a combination of tenantId and applicationId or placeholdersconfig-- See Also:
-
getConfigFromCache
Fetches theSimpleTaxConfigfrom cache so that it does not have to be deserialized every time. This can be overridden to use a different cache implementation.- Parameters:
key-- Returns:
- See Also:
-
buildCacheKey
protected String buildCacheKey(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
createDefaultConfigCache
Creates aLRUMapto containSimpleTaxConfiginstances for different applications and / or tenants. Default max size of the cache is 5000. Default initial size is 10. Note that if you plan to use a different cache mechanism, you can optionally override this method to return null as it will no longer be used.- Returns:
- See Also:
-
getOrder
public int getOrder()Order this component with a low precedence. However, since we want to give others room to inject or order another component with lower precedence, this is defined asOrdered.LOWEST_PRECEDENCEminus 1000, which allows for 1000 spots to be lower precedence, if needed.- Specified by:
getOrderin interfaceorg.springframework.core.Ordered- Specified by:
getOrderin interfaceTaxProvider<T1 extends TaxRequest,T2 extends TaxResponse> - Returns:
-
validate
public void validate(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TaxProviderThis can be used to determine if configurations, credential, and connections are correct and working properly together. This should be called by the Admin UI or other methods to simply validate whether connection and credential details are correct. If everything is working, this is a pass-through method. If something is not working, then aRuntimeExceptionshould be thrown, typically anIllegalStateException,IllegalArgumentException, orUnsupportedOperationException. This method may be invoked by a call from the Admin or other systems to ensure that the configuration is correct.- Specified by:
validatein interfaceTaxProvider<T1 extends TaxRequest,T2 extends TaxResponse>
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getSimpleTaxProps
-
getResourceLoader
protected org.springframework.core.io.ResourceLoader getResourceLoader() -
getExampleSimpleTaxConfig
-
getDefaultSimpleTaxConfig
-
getDefaultConfigCache
-
determineIsTaxIncluded(Boolean, Boolean, ContextInfo).