atg.integrations.taxware
Class TaxWareCalculateTax

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.integrations.taxware.TaxWareCalculateTax
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, TaxProcessor, java.util.EventListener

public class TaxWareCalculateTax
extends GenericService
implements TaxProcessor

Using the associated TaxService, this class calculates the sales/world tax for the items. This class implements the multiple items requests sent to Taxware, where items are represented by the shipping destination group objects passed in TaxRequestInfo. Also, it will use the VeraZip system to provide accurate means of verifying the city-state-zip address info. Using verazip can be triggered, the SalesUse system can verify address to some extent, but not as good as VeraZip.

See Also:
SalesTaxService, TaxRequest, TaxResult, TaxRequestInfo

Field Summary
static java.lang.String CLASS_VERSION
           
static int MAXIMUM_RECORD_SIZE
           
protected  boolean mSubmitShipping
          Whether or not to submit shipping cost to TaxWare as freight.
protected  TaxService mTaxService
          Reference to the sales tax service.
protected  boolean mUseVerazip
          Whether or not to attempt to use VeraZip.
protected  TaxWareVerifyZipInfo mVerifyZipInfo
           
protected  boolean mWritingAudit
          Whether or not to write this transaction to the TaxWare audit file.
protected  VeraZipOrderImpl zipInfo
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
TaxWareCalculateTax()
          Constructor for the service.
 
Method Summary
 TaxResult[] calculateProcess(TaxRequestInfo ccinfo)
           
 TaxStatus calculateTax(TaxRequestInfo ccinfo)
          Calculate tax on the information specified in TaxRequestInfo
 TaxStatus[] calculateTaxByShipping(TaxRequestInfo ccinfo)
          Calculate tax on the information specified in TaxRequestInfo.
 TaxResult[] calculateTaxes(TaxRequestInfo ccinfo, int index, int until)
           
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
static double DoubleFormat(double a)
           
protected  TaxService getAppropriateSalesTaxService(TaxRequestInfo pOrder)
          Returns the TaxService appropriate for the request.
 boolean getSubmitShipping()
          Get whether shipping cost from the order will be submitted to taxware as freight
 TaxService getTaxService()
          Get the TaxService used to generate the TaxRequest.
 boolean getUseVerazip()
          Get whether or not to attempt to use VeraZip.
 TaxWareVerifyZipInfo getVerifyZipInfo()
           
 boolean getWritingAudit()
          Returns whether we are writing this transaction to the TaxWare audit file.
static void main(java.lang.String[] args)
          Run some simple tests
protected  void modifyRequest(AddressVerificationInfo pOrder, TaxRequest request)
          Modifies the request before submitting it to TaxWare.
protected  TaxStatus recordResult(TaxResult[] taxresult)
          Adds up the taxresults' tax properties
protected  TaxStatus[] recordResultByShipping(TaxResult[] taxresult)
          Returns an array of taxStatus objects at the shipping level
protected  TaxStatus setErrorAndGetReturnValue(java.lang.String pKey, java.lang.String pMessage)
          Sets the error message and returns the TaxStatus object
 void setSubmitShipping(boolean pSubmitShipping)
          Set whether shipping cost from the order will be submitted to taxware as freight
 void setTaxService(TaxService pTaxService)
          Set the TaxService used to generate the TaxRequest.
 void setUseVerazip(boolean pUseVerazip)
          Set whether or not to attempt to use VeraZip.
 void setVerifyZipInfo(TaxWareVerifyZipInfo pVerifyZipInfo)
           
 void setWritingAudit(boolean pWritingAudit)
          Set whether to write this transaction to the TaxWare audit file.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

MAXIMUM_RECORD_SIZE

public static final int MAXIMUM_RECORD_SIZE
See Also:
Constant Field Values

mVerifyZipInfo

protected TaxWareVerifyZipInfo mVerifyZipInfo

zipInfo

protected VeraZipOrderImpl zipInfo

mTaxService

protected TaxService mTaxService
Reference to the sales tax service.


mSubmitShipping

protected boolean mSubmitShipping
Whether or not to submit shipping cost to TaxWare as freight.


mUseVerazip

protected boolean mUseVerazip
Whether or not to attempt to use VeraZip.


mWritingAudit

protected boolean mWritingAudit
Whether or not to write this transaction to the TaxWare audit file.

Constructor Detail

TaxWareCalculateTax

public TaxWareCalculateTax()
Constructor for the service.

Method Detail

getVerifyZipInfo

public TaxWareVerifyZipInfo getVerifyZipInfo()

setVerifyZipInfo

public void setVerifyZipInfo(TaxWareVerifyZipInfo pVerifyZipInfo)

setUseVerazip

public void setUseVerazip(boolean pUseVerazip)
Set whether or not to attempt to use VeraZip.


getUseVerazip

public boolean getUseVerazip()
Get whether or not to attempt to use VeraZip.


setSubmitShipping

public void setSubmitShipping(boolean pSubmitShipping)
Set whether shipping cost from the order will be submitted to taxware as freight


getSubmitShipping

public boolean getSubmitShipping()
Get whether shipping cost from the order will be submitted to taxware as freight


setWritingAudit

public void setWritingAudit(boolean pWritingAudit)
Set whether to write this transaction to the TaxWare audit file. The default is null.

Parameters:
boolean - whether or not to write

getWritingAudit

public boolean getWritingAudit()
Returns whether we are writing this transaction to the TaxWare audit file.


setTaxService

public void setTaxService(TaxService pTaxService)
Set the TaxService used to generate the TaxRequest.


getTaxService

public TaxService getTaxService()
Get the TaxService used to generate the TaxRequest.


getAppropriateSalesTaxService

protected TaxService getAppropriateSalesTaxService(TaxRequestInfo pOrder)
Returns the TaxService appropriate for the request. The default implementation simply returns the taxService property.


setErrorAndGetReturnValue

protected TaxStatus setErrorAndGetReturnValue(java.lang.String pKey,
                                              java.lang.String pMessage)
Sets the error message and returns the TaxStatus object


modifyRequest

protected void modifyRequest(AddressVerificationInfo pOrder,
                             TaxRequest request)
Modifies the request before submitting it to TaxWare.

In this version, adds GEOCODE information from verazip if available.

You may override this method to prevent calling verazip or to add addition information to the request, like a non standard tax rates.


calculateTax

public TaxStatus calculateTax(TaxRequestInfo ccinfo)
Description copied from interface: TaxProcessor
Calculate tax on the information specified in TaxRequestInfo

Specified by:
calculateTax in interface TaxProcessor
Parameters:
ccinfo - the TaxInfo reference which contains all the tax calculation data
Returns:
a TaxStatus object detailing the results of the tax calculation

calculateTaxByShipping

public TaxStatus[] calculateTaxByShipping(TaxRequestInfo ccinfo)
Description copied from interface: TaxProcessor
Calculate tax on the information specified in TaxRequestInfo. Unlike calculateTax, however, this method returns tax information on a per-shipping group basis. That is to say, it returns tax information for items grouped around their shipping address.

Specified by:
calculateTaxByShipping in interface TaxProcessor
Parameters:
ccinfo - the TaxInfo reference which contains all the tax calculation data
Returns:
an array of TaxStatus objects detailing the results of the tax calculation

calculateProcess

public TaxResult[] calculateProcess(TaxRequestInfo ccinfo)
                             throws TaxwareException
Throws:
TaxwareException

calculateTaxes

public TaxResult[] calculateTaxes(TaxRequestInfo ccinfo,
                                  int index,
                                  int until)
                           throws TaxwareException
Throws:
TaxwareException

recordResult

protected TaxStatus recordResult(TaxResult[] taxresult)
Adds up the taxresults' tax properties

Parameters:
An - array of taxResult objects
Returns:
TaxStatus that contains the results of the calculation
See Also:
TaxResult, TaxStatus

recordResultByShipping

protected TaxStatus[] recordResultByShipping(TaxResult[] taxresult)
Returns an array of taxStatus objects at the shipping level

Parameters:
An - array of taxResult objects
Returns:
An array of taxStatus that contains the results of the calculation
See Also:
TaxResult, TaxStatus

DoubleFormat

public static double DoubleFormat(double a)

doStartService

public void doStartService()
Description copied from class: GenericService
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. The Service should override this method to start any processes it requires.

Overrides:
doStartService in class GenericService

main

public static void main(java.lang.String[] args)
Run some simple tests