com.konakart.bl
Class TaxMgr

java.lang.Object
  extended by com.konakart.bl.BaseMgr
      extended by com.konakart.bl.TaxMgr
All Implemented Interfaces:
TaxMgrIf

public class TaxMgr
extends BaseMgr
implements TaxMgrIf

TaxMgr class


Nested Class Summary
protected  class TaxMgr.StaticData
          Used to store the static data of this manager
 
Field Summary
protected static org.apache.commons.logging.Log log
          the log
protected static java.lang.String mutex
          mutex
protected static java.util.Map<java.lang.String,TaxMgr.StaticData> staticDataHM
          Hash Map that contains the static data
 
Fields inherited from class com.konakart.bl.BaseMgr
templateBaseDir
 
Constructor Summary
TaxMgr(KKEngIf eng)
          Constructor
 
Method Summary
 java.math.BigDecimal addStoreTax(java.math.BigDecimal cost, int taxClassId)
          This is a utility method to directly get the final cost.
 java.math.BigDecimal addStoreTax(java.math.BigDecimal cost, int taxClassId, int quantity)
          This is a utility method to directly get the final cost.
 java.math.BigDecimal addTax(java.math.BigDecimal cost, int countryId, int zoneId, int taxClassId)
          This is a utility method to directly get the final cost.
 java.math.BigDecimal addTax(java.math.BigDecimal cost, int countryId, int zoneId, int taxClassId, int quantity)
          This is a utility method to directly get the final cost.
 Country[] getAllCountries()
          Returns an array of all defined countries
 Country getCountryPerId(int countryId)
          Returns the country object for the country id, or Null if the country doesn't exist in the DB.
 Country getCountryPerName(java.lang.String countryName)
          Returns the country object for the country name, or Null if the country doesn't exist in the DB.
 GeoZone[] getGeoZonesPerZone(ZoneIf zone)
          Find the GeoZones that exist for a particular zone
 java.math.BigDecimal getStoreTax(java.math.BigDecimal cost, int taxClassId)
          This is a utility method to directly return the tax that needs to be applied for a defined item cost and a quantity of 1.
 java.math.BigDecimal getStoreTax(java.math.BigDecimal cost, int taxClassId, int quantity)
          This is a utility method to directly return the total tax that needs to be applied for a defined item cost and quantity.
 java.math.BigDecimal getStoreTaxRate(int taxClassId)
          Returns the tax rate for the store for a taxClassId.
 java.math.BigDecimal getTax(java.math.BigDecimal cost, int countryId, int zoneId, int taxClassId)
          This is a utility method to directly return the tax that needs to be applied for a defined item cost and a quantity of 1.
 java.math.BigDecimal getTax(java.math.BigDecimal cost, int countryId, int zoneId, int taxClassId, int quantity)
          This is a utility method to directly return the total tax that needs to be applied for a defined item cost and quantity.
 int getTaxQuantityRule()
          Returns the rule used to calculate tax for products with multiple quantities.
 java.math.BigDecimal getTaxRate(int countryId, int zoneId, int taxClassId)
          The tax rate can be calculated based on the country id, the zone id and the tax class id.
 TaxRate[] getTaxRateObjects(int countryId, int zoneId, int taxClassId)
          The tax rate can be calculated based on the country id, the zone id and the tax class id.
 int getTaxScale()
          Returns the precision use for calculating tax that matches the ADMIN_CURRENCY_DECIMAL_PLACES configuration variable.
 Zone getZonePerCountryAndCode(int countryId, java.lang.String zoneDesc)
          The zone name and zone code is compared with the zoneDesc parameter in order to determine whether a zone exists in the DB matching zoneDesc for the country defined by countryId.
 Zone getZonePerId(int zoneId)
          Get a zone for a zoneId
 Zone[] getZonesPerCountry(int countryId)
          Get all zones for a country.
 void refreshConfigs()
          Get the config variables needed to setup the tax mgr
 Zone[] searchForZones(ZoneSearchIf search)
          Search for zones using various search criteria
protected  void setZoneCriteriaWithStandardAttributes(org.apache.torque.util.Criteria c)
          Sets the criteria with the standard attributes so as not to have to repeat this code many times.
 
Methods inherited from class com.konakart.bl.BaseMgr
addInsertAttr, addInsertAttr, checkRequired, getAdminEngMgr, getBasketMgr, getBillingMgr, getBookableProductMgr, getCatMgr, getConfigMgr, getCookieMgr, getCurrMgr, getCustMgr, getCustomerIdFromSession, getCustomerStatsMgr, getCustomerTagMgr, getEmailMgr, getEng, getLangMgr, getManuMgr, getMiscItemMgr, getMode, getModeString, getMqMgr, getMultiStoreMgr, getNewCriteria, getNewCriteria, getOrderMgr, getOrderTotalMgr, getPaymentMgr, getProdMgr, getPromMgr, getRewardPointMgr, getSecMgr, getShippingMgr, getSolrMgr, getStoreId, getTaxMgr, getTemplate, getTemplateRoot, getVelocityContextMgr, getWishListMgr, init, isEnterprise, isMultiStoreShareCustomers, isMultiStoreShareProducts
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
the log


mutex

protected static java.lang.String mutex
mutex


staticDataHM

protected static java.util.Map<java.lang.String,TaxMgr.StaticData> staticDataHM
Hash Map that contains the static data

Constructor Detail

TaxMgr

public TaxMgr(KKEngIf eng)
       throws java.lang.Exception
Constructor

Parameters:
eng -
Throws:
java.lang.Exception
Method Detail

refreshConfigs

public void refreshConfigs()
                    throws java.lang.Exception
Get the config variables needed to setup the tax mgr

Specified by:
refreshConfigs in interface TaxMgrIf
Throws:
java.lang.Exception

getZonePerCountryAndCode

public Zone getZonePerCountryAndCode(int countryId,
                                     java.lang.String zoneDesc)
                              throws org.apache.torque.TorqueException,
                                     com.workingdogs.village.DataSetException,
                                     KKException
The zone name and zone code is compared with the zoneDesc parameter in order to determine whether a zone exists in the DB matching zoneDesc for the country defined by countryId. An example of this would be to compare the state of an address with FL or Florida.

Specified by:
getZonePerCountryAndCode in interface TaxMgrIf
Parameters:
countryId -
zoneDesc -
Returns:
the zoneif it exists, otherwise null
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKException

getZonesPerCountry

public Zone[] getZonesPerCountry(int countryId)
                          throws org.apache.torque.TorqueException,
                                 com.workingdogs.village.DataSetException,
                                 KKException
Get all zones for a country.

Specified by:
getZonesPerCountry in interface TaxMgrIf
Parameters:
countryId -
Returns:
the zoneif it exists, otherwise null
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKException

searchForZones

public Zone[] searchForZones(ZoneSearchIf search)
                      throws org.apache.torque.TorqueException,
                             com.workingdogs.village.DataSetException,
                             KKException
Search for zones using various search criteria

Specified by:
searchForZones in interface TaxMgrIf
Parameters:
search -
Returns:
Returns an array of Zone objects
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKException

getZonePerId

public Zone getZonePerId(int zoneId)
                  throws org.apache.torque.TorqueException,
                         com.workingdogs.village.DataSetException,
                         KKException
Description copied from interface: TaxMgrIf
Get a zone for a zoneId

Specified by:
getZonePerId in interface TaxMgrIf
Parameters:
zoneId -
Returns:
the zone if it exists, otherwise null
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKException

getStoreTaxRate

public java.math.BigDecimal getStoreTaxRate(int taxClassId)
                                     throws com.workingdogs.village.DataSetException,
                                            org.apache.torque.TorqueException,
                                            KKException
Description copied from interface: TaxMgrIf
Returns the tax rate for the store for a taxClassId.

Specified by:
getStoreTaxRate in interface TaxMgrIf
Parameters:
taxClassId -
Returns:
Returns The tax rate for the taxClassId and the store
Throws:
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
KKException

getTaxRate

public java.math.BigDecimal getTaxRate(int countryId,
                                       int zoneId,
                                       int taxClassId)
                                throws com.workingdogs.village.DataSetException,
                                       org.apache.torque.TorqueException,
                                       KKException
The tax rate can be calculated based on the country id, the zone id and the tax class id. There may be more than one tax rate. If this is the case the rates have to be applied starting from the first rate and then compounded. If there are multiple rates with the same priority, then these are added together and can be applied in a single calculation. If there are multiple rates with different priorities, then they are compounded. temp = (1+t1/100)*(1+t2/100)*(1+t3/100) etc. Compound rate = (temp-1)*100; i.e. for rates of 7% and 10% the return is 17.7%

Specified by:
getTaxRate in interface TaxMgrIf
Parameters:
countryId -
zoneId -
taxClassId -
Returns:
Returns the tax rates for the country, zone and tax class
Throws:
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
KKException

getTaxRateObjects

public TaxRate[] getTaxRateObjects(int countryId,
                                   int zoneId,
                                   int taxClassId)
                            throws com.workingdogs.village.DataSetException,
                                   org.apache.torque.TorqueException,
                                   KKException
The tax rate can be calculated based on the country id, the zone id and the tax class id. There may be more than one tax rate.

Specified by:
getTaxRateObjects in interface TaxMgrIf
Parameters:
countryId -
zoneId -
taxClassId -
Returns:
Returns the tax rate objects for the country, zone and tax class
Throws:
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
KKException

getTax

public java.math.BigDecimal getTax(java.math.BigDecimal cost,
                                   int countryId,
                                   int zoneId,
                                   int taxClassId)
                            throws KKException,
                                   org.apache.torque.TorqueException,
                                   com.workingdogs.village.DataSetException
This is a utility method to directly return the tax that needs to be applied for a defined item cost and a quantity of 1.

Specified by:
getTax in interface TaxMgrIf
Parameters:
cost -
countryId -
zoneId -
taxClassId -
Returns:
Returns the tax that needs to be applied
Throws:
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getTax

public java.math.BigDecimal getTax(java.math.BigDecimal cost,
                                   int countryId,
                                   int zoneId,
                                   int taxClassId,
                                   int quantity)
                            throws KKException,
                                   org.apache.torque.TorqueException,
                                   com.workingdogs.village.DataSetException
This is a utility method to directly return the total tax that needs to be applied for a defined item cost and quantity. When the quantity is greater than one, the tax amount may be calculated differently depending on the algorithm used. i.e. Could calculate tax on a single product before multiplying by the quantity or tax on the total.

Specified by:
getTax in interface TaxMgrIf
Parameters:
cost -
countryId -
zoneId -
taxClassId -
quantity -
Returns:
Returns the tax that needs to be applied
Throws:
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getStoreTax

public java.math.BigDecimal getStoreTax(java.math.BigDecimal cost,
                                        int taxClassId)
                                 throws KKException,
                                        org.apache.torque.TorqueException,
                                        com.workingdogs.village.DataSetException
This is a utility method to directly return the tax that needs to be applied for a defined item cost and a quantity of 1.

Specified by:
getStoreTax in interface TaxMgrIf
Parameters:
cost -
taxClassId -
Returns:
Returns the tax that needs to be applied
Throws:
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getStoreTax

public java.math.BigDecimal getStoreTax(java.math.BigDecimal cost,
                                        int taxClassId,
                                        int quantity)
                                 throws KKException,
                                        org.apache.torque.TorqueException,
                                        com.workingdogs.village.DataSetException
This is a utility method to directly return the total tax that needs to be applied for a defined item cost and quantity. When the quantity is greater than one, the tax amount may be calculated differently depending on the algorithm used. i.e. Could calculate tax on a single product before multiplying by the quantity or tax on the total.

Specified by:
getStoreTax in interface TaxMgrIf
Parameters:
cost -
taxClassId -
quantity -
Returns:
Returns the tax that needs to be applied
Throws:
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

addTax

public java.math.BigDecimal addTax(java.math.BigDecimal cost,
                                   int countryId,
                                   int zoneId,
                                   int taxClassId)
                            throws KKException,
                                   org.apache.torque.TorqueException,
                                   com.workingdogs.village.DataSetException
This is a utility method to directly get the final cost. The tax is added to the value of the cost parameter.

Specified by:
addTax in interface TaxMgrIf
Parameters:
cost -
countryId -
zoneId -
taxClassId -
Returns:
Returns the cost after tax has been applied
Throws:
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

addTax

public java.math.BigDecimal addTax(java.math.BigDecimal cost,
                                   int countryId,
                                   int zoneId,
                                   int taxClassId,
                                   int quantity)
                            throws KKException,
                                   org.apache.torque.TorqueException,
                                   com.workingdogs.village.DataSetException
This is a utility method to directly get the final cost. The tax is added to the value of the cost parameter. The cost parameter defines the total cost (item cost x quantity) before tax. When the quantity is greater than one, the tax amount may be calculated differently depending on the algorithm used. i.e. Could calculate tax on a single product before multiplying by the quantity or tax on the total.

Specified by:
addTax in interface TaxMgrIf
Parameters:
cost -
countryId -
zoneId -
taxClassId -
Returns:
Returns the cost after tax has been applied
Throws:
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

addStoreTax

public java.math.BigDecimal addStoreTax(java.math.BigDecimal cost,
                                        int taxClassId)
                                 throws KKException,
                                        org.apache.torque.TorqueException,
                                        com.workingdogs.village.DataSetException
This is a utility method to directly get the final cost. The tax is added to the value of the cost parameter.

Specified by:
addStoreTax in interface TaxMgrIf
Parameters:
cost -
taxClassId -
Returns:
Returns the cost after tax has been applied
Throws:
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

addStoreTax

public java.math.BigDecimal addStoreTax(java.math.BigDecimal cost,
                                        int taxClassId,
                                        int quantity)
                                 throws KKException,
                                        org.apache.torque.TorqueException,
                                        com.workingdogs.village.DataSetException
This is a utility method to directly get the final cost. The tax is added to the value of the cost parameter. The cost parameter defines the total cost (item cost x quantity) before tax. When the quantity is greater than one, the tax amount may be calculated differently depending on the algorithm used. i.e. Could calculate tax on a single product before multiplying by the quantity or tax on the total.

Specified by:
addStoreTax in interface TaxMgrIf
Parameters:
cost -
taxClassId -
quantity -
Returns:
Returns the cost after tax has been applied
Throws:
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getGeoZonesPerZone

public GeoZone[] getGeoZonesPerZone(ZoneIf zone)
                             throws org.apache.torque.TorqueException,
                                    com.workingdogs.village.DataSetException,
                                    KKException
Find the GeoZones that exist for a particular zone

Specified by:
getGeoZonesPerZone in interface TaxMgrIf
Parameters:
zone -
Returns:
An array of GeoZones or null if non exist
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKException

getAllCountries

public Country[] getAllCountries()
                          throws com.workingdogs.village.DataSetException,
                                 org.apache.torque.TorqueException,
                                 KKException
Description copied from interface: TaxMgrIf
Returns an array of all defined countries

Specified by:
getAllCountries in interface TaxMgrIf
Returns:
Returns an array of countries - it only returns the countries that are active
Throws:
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
KKException

getCountryPerName

public Country getCountryPerName(java.lang.String countryName)
                          throws KKException,
                                 org.apache.torque.TorqueException,
                                 com.workingdogs.village.DataSetException
Returns the country object for the country name, or Null if the country doesn't exist in the DB. If there is more than one country with the same name, we return the first one that we find.

Specified by:
getCountryPerName in interface TaxMgrIf
Parameters:
countryName -
Returns:
Returns a country object
Throws:
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getCountryPerId

public Country getCountryPerId(int countryId)
                        throws KKException,
                               org.apache.torque.TorqueException,
                               com.workingdogs.village.DataSetException
Returns the country object for the country id, or Null if the country doesn't exist in the DB.

Specified by:
getCountryPerId in interface TaxMgrIf
Parameters:
countryId -
Returns:
Returns a country object
Throws:
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getTaxQuantityRule

public int getTaxQuantityRule()
                       throws KKException
Returns the rule used to calculate tax for products with multiple quantities. The supported rules are:
    • TaxUtils.TAX_PER_ITEM : The tax is calculated for a single item, to the number of decimal places defined by scale. Then this value is multiplied by the quantity.
      TaxUtils.TAX_ON_TOTAL : The tax is calculated for the total amount (single item cost x quantity).
  • Specified by:
    getTaxQuantityRule in interface TaxMgrIf
    Returns:
    the taxQuantityRule
    Throws:
    KKException

    getTaxScale

    public int getTaxScale()
                    throws KKException
    Returns the precision use for calculating tax that matches the ADMIN_CURRENCY_DECIMAL_PLACES configuration variable.

    Specified by:
    getTaxScale in interface TaxMgrIf
    Returns:
    the taxScale
    Throws:
    KKException

    setZoneCriteriaWithStandardAttributes

    protected void setZoneCriteriaWithStandardAttributes(org.apache.torque.util.Criteria c)
    Sets the criteria with the standard attributes so as not to have to repeat this code many times.

    Parameters:
    c -


    Copyright © 2011 DS Data Systems UK Ltd.