Class SimpleTaxProvider
- All Implemented Interfaces:
org.broadleafcommerce.common.config.service.ModuleProvider,TaxProvider
Simple factor-based tax module that can be configured by adding rates for specific postalCodes, city, state, or country.
Through configuration, this module can be used to set a specific tax rate for items and shipping for a given postal code, city, state, or country.
Utilizes the fulfillment group's address to determine the tax location.
Useful for those with very simple tax needs that want to configure rates programmatically.
- Author:
- jfischer, brian polster, Phillip Verheyden (phillipuniverse)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyTaxFactor(List<TaxDetail> taxes, BigDecimal taxFactor, org.broadleafcommerce.common.money.Money taxMultiplier) calculateTaxForOrder(Order order, org.broadleafcommerce.common.config.domain.ModuleConfiguration config) Calculates taxes on an entire order.voidSome tax providers store tax details from an order on an external system for reporting and tax reconcilliation.booleancanRespond(org.broadleafcommerce.common.config.domain.ModuleConfiguration config) commitTaxForOrder(Order order, org.broadleafcommerce.common.config.domain.ModuleConfiguration config) This method provides the implementation an opportunity to finalize taxes on the order.determineItemTaxRate(org.broadleafcommerce.profile.core.domain.Address address) Uses the passed in address to determine if the item is taxable.determineTaxRateForFulfillmentGroup(FulfillmentGroup fulfillmentGroup) Uses the passed in address to determine if the item is taxable.protected TaxDetailfindExistingTaxDetail(List<TaxDetail> taxes) protected voidhandleFulfillmentGroupFeeTaxes(FulfillmentGroup fulfillmentGroup) protected voidhandleFulfillmentGroupItemTaxes(FulfillmentGroup fulfillmentGroup) protected voidhandleFulfillmentGroupTaxes(FulfillmentGroup fulfillmentGroup) protected booleanprotected booleanlookupCityRate(Map<String, Double> cityTaxRateMap, String city) Changes the city to upper case before checking the configuration.lookupCountryRate(Map<String, Double> countryTaxRateMap, org.broadleafcommerce.common.i18n.domain.ISOCountry isoCountry) Returns the taxAmount for the passed in country or null if no match is found.lookupCountryRate(Map<String, Double> countryTaxRateMap, org.broadleafcommerce.profile.core.domain.Country country) Returns the taxAmount for the passed in country or null if no match is found.lookupPostalCodeRate(Map<String, Double> postalCodeTaxRateMap, String postalCode) Returns the taxAmount for the passed in postal code or null if no match is found.lookupStateRate(Map<String, Double> stateTaxRateMap, String stateProvinceRegion) Returns the taxAmount for the passed in stateProvinceRegion or null if no match is found.voidsetDefaultFulfillmentGroupTaxRate(Double defaultFulfillmentGroupTaxRate) voidsetDefaultItemTaxRate(Double defaultItemTaxRate) voidsetFulfillmentGroupCityTaxRateMap(Map<String, Double> fulfillmentGroupCityTaxRateMap) voidsetFulfillmentGroupCountryTaxRateMap(Map<String, Double> fulfillmentGroupCountryTaxRateMap) voidsetFulfillmentGroupPostalCodeTaxRateMap(Map<String, Double> fulfillmentGroupPostalCodeTaxRateMap) voidsetFulfillmentGroupStateTaxRateMap(Map<String, Double> fulfillmentGroupStateTaxRateMap) voidsetItemCityTaxRateMap(Map<String, Double> itemCityTaxRateMap) voidsetItemCountryTaxRateMap(Map<String, Double> itemCountryTaxRateMap) voidsetItemPostalCodeTaxRateMap(Map<String, Double> itemPostalCodeTaxRateMap) voidsetItemStateTaxRateMap(Map<String, Double> itemStateTaxRateMap)
-
Field Details
-
itemPostalCodeTaxRateMap
-
itemCityTaxRateMap
-
itemStateTaxRateMap
-
itemCountryTaxRateMap
-
fulfillmentGroupPostalCodeTaxRateMap
-
fulfillmentGroupCityTaxRateMap
-
fulfillmentGroupStateTaxRateMap
-
fulfillmentGroupCountryTaxRateMap
-
defaultItemTaxRate
-
defaultFulfillmentGroupTaxRate
-
taxFees
protected boolean taxFees -
entityConfig
protected org.broadleafcommerce.common.persistence.EntityConfiguration entityConfig
-
-
Constructor Details
-
SimpleTaxProvider
public SimpleTaxProvider()
-
-
Method Details
-
canRespond
public boolean canRespond(org.broadleafcommerce.common.config.domain.ModuleConfiguration config) - Specified by:
canRespondin interfaceorg.broadleafcommerce.common.config.service.ModuleProvider
-
calculateTaxForOrder
public Order calculateTaxForOrder(Order order, org.broadleafcommerce.common.config.domain.ModuleConfiguration config) throws TaxException Description copied from interface:TaxProviderCalculates taxes on an entire order. Returns the order with taxes included.- Specified by:
calculateTaxForOrderin interfaceTaxProvider- Returns:
- Throws:
TaxException
-
handleFulfillmentGroupItemTaxes
-
handleFulfillmentGroupFeeTaxes
-
handleFulfillmentGroupTaxes
-
applyTaxFactor
protected void applyTaxFactor(List<TaxDetail> taxes, BigDecimal taxFactor, org.broadleafcommerce.common.money.Money taxMultiplier) -
findExistingTaxDetail
-
commitTaxForOrder
public Order commitTaxForOrder(Order order, org.broadleafcommerce.common.config.domain.ModuleConfiguration config) throws TaxException Description copied from interface:TaxProviderThis method provides the implementation an opportunity to finalize taxes on the order. This is often required when tax sub systems require tax documents to be created on checkout. This method will typically be called by the checkout workflow, rather than by the pricing workflow. Some implementations may wish to do nothing in this method, except perhaps recalculate taxes.- Specified by:
commitTaxForOrderin interfaceTaxProvider- Returns:
- Throws:
TaxException
-
cancelTax
public void cancelTax(Order order, org.broadleafcommerce.common.config.domain.ModuleConfiguration config) throws TaxException Description copied from interface:TaxProviderSome tax providers store tax details from an order on an external system for reporting and tax reconcilliation. This allows one to cancel or undo tax recording in an external system. Typically, this will be called to offset a call to commitTaxForOrder. This might be called, for example, in a rollback handler for a checkout workflow activity that calls commitTaxForOrder. Many implementations may wish to do nothing in this method.- Specified by:
cancelTaxin interfaceTaxProvider- Throws:
TaxException
-
lookupPostalCodeRate
Returns the taxAmount for the passed in postal code or null if no match is found.- Parameters:
postalCode-- Returns:
-
lookupCityRate
Changes the city to upper case before checking the configuration.Return null if no match is found.
- Parameters:
cityTaxRateMap- , city- Returns:
-
lookupStateRate
Returns the taxAmount for the passed in stateProvinceRegion or null if no match is found.First checks the abbreviation (uppercase) followed by the name (uppercase).
- Parameters:
stateTaxRateMap- , stateProvinceRegion- Returns:
-
lookupCountryRate
public Double lookupCountryRate(Map<String, Double> countryTaxRateMap, org.broadleafcommerce.profile.core.domain.Country country) Returns the taxAmount for the passed in country or null if no match is found.First checks the abbreviation (uppercase) followed by the name (uppercase).
- Parameters:
countryTaxRateMap- , country- Returns:
-
lookupCountryRate
public Double lookupCountryRate(Map<String, Double> countryTaxRateMap, org.broadleafcommerce.common.i18n.domain.ISOCountry isoCountry) Returns the taxAmount for the passed in country or null if no match is found.First checks the alpha2 (uppercase) followed by the name (uppercase).
- Parameters:
countryTaxRateMap- , isoCountry- Returns:
-
isItemTaxable
-
isFeeTaxable
-
determineItemTaxRate
Uses the passed in address to determine if the item is taxable.Checks the configured maps in order - (postal code, city, state, country)
- Parameters:
address-- Returns:
-
determineTaxRateForFulfillmentGroup
Uses the passed in address to determine if the item is taxable.Checks the configured maps in order - (postal code, city, state, country)
- Parameters:
fulfillmentGroup-- Returns:
-
getItemPostalCodeTaxRateMap
-
setItemPostalCodeTaxRateMap
-
getItemCityTaxRateMap
-
setItemCityTaxRateMap
-
getItemStateTaxRateMap
-
setItemStateTaxRateMap
-
getItemCountryTaxRateMap
-
setItemCountryTaxRateMap
-
getFulfillmentGroupPostalCodeTaxRateMap
-
setFulfillmentGroupPostalCodeTaxRateMap
-
getFulfillmentGroupCityTaxRateMap
-
setFulfillmentGroupCityTaxRateMap
-
getFulfillmentGroupStateTaxRateMap
-
setFulfillmentGroupStateTaxRateMap
-
getFulfillmentGroupCountryTaxRateMap
-
setFulfillmentGroupCountryTaxRateMap
-
getDefaultItemTaxRate
-
setDefaultItemTaxRate
-
getDefaultFulfillmentGroupTaxRate
-
setDefaultFulfillmentGroupTaxRate
-