org.broadleafcommerce.core.pricing.service.module
Class SimpleTaxModule

java.lang.Object
  extended by org.broadleafcommerce.core.pricing.service.module.SimpleTaxModule
All Implemented Interfaces:
TaxModule

public class SimpleTaxModule
extends Object
implements TaxModule

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.

Author:
jfischer, brian polster

Field Summary
protected  Double defaultFulfillmentGroupTaxRate
           
protected  Double defaultItemTaxRate
           
protected  Map<String,Double> fulfillmentGroupCityTaxRateMap
           
protected  Map<String,Double> fulfillmentGroupCountryTaxRateMap
           
protected  Map<String,Double> fulfillmentGroupPostalCodeTaxRateMap
           
protected  Map<String,Double> fulfillmentGroupStateTaxRateMap
           
protected  Map<String,Double> itemCityTaxRateMap
           
protected  Map<String,Double> itemCountryTaxRateMap
           
protected  Map<String,Double> itemPostalCodeTaxRateMap
           
protected  Map<String,Double> itemStateTaxRateMap
           
static String MODULENAME
           
protected  String name
           
protected  boolean taxFees
           
 
Constructor Summary
SimpleTaxModule()
           
 
Method Summary
 Order calculateTaxForOrder(Order order)
           
 Double determineItemTaxRate(Address address)
          Uses the passed in address to determine if the item is taxable.
 Double determineTaxRateForFulfillmentGroup(FulfillmentGroup fulfillmentGroup)
          Uses the passed in address to determine if the item is taxable.
 Double getDefaultFulfillmentGroupTaxRate()
           
 Double getDefaultItemTaxRate()
           
 Double getFactor()
          Deprecated.  
 Map<String,Double> getFulfillmentGroupCityTaxRateMap()
           
 Map<String,Double> getFulfillmentGroupCountryTaxRateMap()
           
 Map<String,Double> getFulfillmentGroupPostalCodeTaxRateMap()
           
 Map<String,Double> getFulfillmentGroupStateTaxRateMap()
           
 Map<String,Double> getItemCityTaxRateMap()
           
 Map<String,Double> getItemCountryTaxRateMap()
           
 Map<String,Double> getItemPostalCodeTaxRateMap()
           
 Map<String,Double> getItemStateTaxRateMap()
           
 String getName()
           
protected  boolean isFeeTaxable(FulfillmentGroupFee fee)
           
protected  boolean isItemTaxable(FulfillmentGroupItem item)
           
 Double lookupCityRate(Map<String,Double> cityTaxRateMap, String city)
          Changes the city to upper case before checking the configuration.
 Double lookupCountryRate(Map<String,Double> countryTaxRateMap, Country country)
          Returns the taxAmount for the passed in country or null if no match is found.
 Double lookupPostalCodeRate(Map<String,Double> postalCodeTaxRateMap, String postalCode)
          Returns the taxAmount for the passed in postal code or null if no match is found.
 Double lookupStateRate(Map<String,Double> stateTaxRateMap, State state)
          Returns the taxAmount for the passed in state or null if no match is found.
 void setDefaultFulfillmentGroupTaxRate(Double defaultFulfillmentGroupTaxRate)
           
 void setDefaultItemTaxRate(Double defaultItemTaxRate)
           
 void setFactor(Double factor)
          Deprecated.  
 void setFulfillmentGroupCityTaxRateMap(Map<String,Double> fulfillmentGroupCityTaxRateMap)
           
 void setFulfillmentGroupCountryTaxRateMap(Map<String,Double> fulfillmentGroupCountryTaxRateMap)
           
 void setFulfillmentGroupPostalCodeTaxRateMap(Map<String,Double> fulfillmentGroupPostalCodeTaxRateMap)
           
 void setFulfillmentGroupStateTaxRateMap(Map<String,Double> fulfillmentGroupStateTaxRateMap)
           
 void setItemCityTaxRateMap(Map<String,Double> itemCityTaxRateMap)
           
 void setItemCountryTaxRateMap(Map<String,Double> itemCountryTaxRateMap)
           
 void setItemPostalCodeTaxRateMap(Map<String,Double> itemPostalCodeTaxRateMap)
           
 void setItemStateTaxRateMap(Map<String,Double> itemStateTaxRateMap)
           
 void setName(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODULENAME

public static final String MODULENAME
See Also:
Constant Field Values

name

protected String name

itemPostalCodeTaxRateMap

protected Map<String,Double> itemPostalCodeTaxRateMap

itemCityTaxRateMap

protected Map<String,Double> itemCityTaxRateMap

itemStateTaxRateMap

protected Map<String,Double> itemStateTaxRateMap

itemCountryTaxRateMap

protected Map<String,Double> itemCountryTaxRateMap

fulfillmentGroupPostalCodeTaxRateMap

protected Map<String,Double> fulfillmentGroupPostalCodeTaxRateMap

fulfillmentGroupCityTaxRateMap

protected Map<String,Double> fulfillmentGroupCityTaxRateMap

fulfillmentGroupStateTaxRateMap

protected Map<String,Double> fulfillmentGroupStateTaxRateMap

fulfillmentGroupCountryTaxRateMap

protected Map<String,Double> fulfillmentGroupCountryTaxRateMap

defaultItemTaxRate

protected Double defaultItemTaxRate

defaultFulfillmentGroupTaxRate

protected Double defaultFulfillmentGroupTaxRate

taxFees

protected boolean taxFees
Constructor Detail

SimpleTaxModule

public SimpleTaxModule()
Method Detail

calculateTaxForOrder

public Order calculateTaxForOrder(Order order)
                           throws TaxException
Specified by:
calculateTaxForOrder in interface TaxModule
Throws:
TaxException

getName

public String getName()
Specified by:
getName in interface TaxModule

setName

public void setName(String name)
Specified by:
setName in interface TaxModule

lookupPostalCodeRate

public Double lookupPostalCodeRate(Map<String,Double> postalCodeTaxRateMap,
                                   String postalCode)
Returns the taxAmount for the passed in postal code or null if no match is found.

Parameters:
postalCode -
Returns:

lookupCityRate

public Double lookupCityRate(Map<String,Double> cityTaxRateMap,
                             String city)
Changes the city to upper case before checking the configuration. Return null if no match is found.

Parameters:
cityTaxRateMap, - city
Returns:

lookupStateRate

public Double lookupStateRate(Map<String,Double> stateTaxRateMap,
                              State state)
Returns the taxAmount for the passed in state or null if no match is found. First checks the abbreviation (uppercase) followed by the name (uppercase).

Parameters:
stateTaxRateMap, - state
Returns:

lookupCountryRate

public Double lookupCountryRate(Map<String,Double> countryTaxRateMap,
                                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, - state
Returns:

isItemTaxable

protected boolean isItemTaxable(FulfillmentGroupItem item)

isFeeTaxable

protected boolean isFeeTaxable(FulfillmentGroupFee fee)

determineItemTaxRate

public Double determineItemTaxRate(Address address)
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

public Double determineTaxRateForFulfillmentGroup(FulfillmentGroup fulfillmentGroup)
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

public Map<String,Double> getItemPostalCodeTaxRateMap()

setItemPostalCodeTaxRateMap

public void setItemPostalCodeTaxRateMap(Map<String,Double> itemPostalCodeTaxRateMap)

getItemCityTaxRateMap

public Map<String,Double> getItemCityTaxRateMap()

setItemCityTaxRateMap

public void setItemCityTaxRateMap(Map<String,Double> itemCityTaxRateMap)

getItemStateTaxRateMap

public Map<String,Double> getItemStateTaxRateMap()

setItemStateTaxRateMap

public void setItemStateTaxRateMap(Map<String,Double> itemStateTaxRateMap)

getItemCountryTaxRateMap

public Map<String,Double> getItemCountryTaxRateMap()

setItemCountryTaxRateMap

public void setItemCountryTaxRateMap(Map<String,Double> itemCountryTaxRateMap)

getFulfillmentGroupPostalCodeTaxRateMap

public Map<String,Double> getFulfillmentGroupPostalCodeTaxRateMap()

setFulfillmentGroupPostalCodeTaxRateMap

public void setFulfillmentGroupPostalCodeTaxRateMap(Map<String,Double> fulfillmentGroupPostalCodeTaxRateMap)

getFulfillmentGroupCityTaxRateMap

public Map<String,Double> getFulfillmentGroupCityTaxRateMap()

setFulfillmentGroupCityTaxRateMap

public void setFulfillmentGroupCityTaxRateMap(Map<String,Double> fulfillmentGroupCityTaxRateMap)

getFulfillmentGroupStateTaxRateMap

public Map<String,Double> getFulfillmentGroupStateTaxRateMap()

setFulfillmentGroupStateTaxRateMap

public void setFulfillmentGroupStateTaxRateMap(Map<String,Double> fulfillmentGroupStateTaxRateMap)

getFulfillmentGroupCountryTaxRateMap

public Map<String,Double> getFulfillmentGroupCountryTaxRateMap()

setFulfillmentGroupCountryTaxRateMap

public void setFulfillmentGroupCountryTaxRateMap(Map<String,Double> fulfillmentGroupCountryTaxRateMap)

getDefaultItemTaxRate

public Double getDefaultItemTaxRate()

setDefaultItemTaxRate

public void setDefaultItemTaxRate(Double defaultItemTaxRate)

getDefaultFulfillmentGroupTaxRate

public Double getDefaultFulfillmentGroupTaxRate()

setDefaultFulfillmentGroupTaxRate

public void setDefaultFulfillmentGroupTaxRate(Double defaultFulfillmentGroupTaxRate)

getFactor

public Double getFactor()
Deprecated. 

Use getDefaultItemTaxRate instead.

Returns:

setFactor

public void setFactor(Double factor)
Deprecated. 

Use setDefaultItemTaxRate instead.



Copyright © 2013. All Rights Reserved.