Package com.broadleafcommerce.tax
Interface TaxProvider<T1 extends TaxRequest,T2 extends TaxResponse>
- All Superinterfaces:
org.springframework.core.Ordered
,TaxAccessor<T1,
T2>
- All Known Implementing Classes:
SimpleTaxProvider
public interface TaxProvider<T1 extends TaxRequest,T2 extends TaxResponse>
extends TaxAccessor<T1,T2>, org.springframework.core.Ordered
Represents a component that is tasked with calculating taxes, or calling a 1st or 3rd party
service to calculate taxes.
- Author:
- Chad Harchar (charchar), Kelly Tisdell (ktisdell)
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Method Summary
Modifier and TypeMethodDescriptiondefault <R extends TaxCalculationRequest>
booleancanHandle
(R request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Indicates if thisTaxProvider
can handle requests for the givenTaxCalculationRequest
andContextInfo
, which can be null.default int
getOrder()
Allows for ordering of priority or precedence for variousTaxProvider
implementations.default String
This returns a string that is unique to identify eachTaxProvider
.default boolean
Indicates (or hints) if this provider estimates taxes.default void
validate
(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.Methods inherited from interface com.broadleafcommerce.tax.TaxAccessor
adjustTaxes, calculateTaxes, calculateTaxes, calculateTaxes, commitTaxes, commitTaxes, reverseTaxTransaction, voidTaxTransaction
-
Method Details
-
getProviderId
This returns a string that is unique to identify eachTaxProvider
. Broadleaf implementations will use "BLC_" as a prefix. Custom implementations should NOT use this prefix.- Returns:
-
isEstimator
default boolean isEstimator()Indicates (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.- Returns:
-
validate
default void validate(@Nullable 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. 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 aRuntimeException
should 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.- Parameters:
contextInfo
-
-
canHandle
default <R extends TaxCalculationRequest> boolean canHandle(@NonNull R request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Indicates if thisTaxProvider
can handle requests for the givenTaxCalculationRequest
andContextInfo
, which can be null.- Parameters:
request
- the tax request beingcontextInfo
-- Returns:
-
getOrder
default int getOrder()Allows for ordering of priority or precedence for variousTaxProvider
implementations. By default, this returns 0. Implementations that want to affect ordering, should return a value ' less than zero for higher priorities and greater than zero for lower priorities. Note that these are global orderings. Ordering only matters when you have multipleTaxProvider
implementations and more than one may be able to handle the request. Ordering ensures you select the the highest priority first. This is typically the case inDefaultTaxDelegate
, which attempts to resolve the bestTaxProvider
for a given request.- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
- Returns:
-