atg.integrations.taxware
Class SalesTaxCaller

java.lang.Object
  extended by atg.integrations.taxware.SalesTaxCaller

public class SalesTaxCaller
extends java.lang.Object

SalesTaxCaller provides a higher level interface to TaxWare's sales calculation software. Since the shared library may not be re-entrant, synchronize a number of the methods here just to be safe.

Each TaxWare request is made up of an InputHeader and some number of individual records. This interface sends one request at a time.

Each TaxWare response is made up of an OutputHeader and some number of individual records (should be equal to the number of individual input records). The only function one should need to call directly is CalculateTax.

See Also:
TaxRequest, TaxResult

Nested Class Summary
protected static class SalesTaxCaller.InputHeaderRecordDef
           
protected static class SalesTaxCaller.OutputHeader
          Output header
 
Field Summary
static java.lang.String CLASS_VERSION
           
protected static boolean m_bOpen
          Whether TaxWare's files are open or not.
protected static atg.integrations.taxware.SalesTaxCaller.InputHeader m_inputHeader
          Input header re-used for each request.
protected static java.lang.reflect.Method m_methodCalculateTax
          Method for calculating tax.
protected static java.lang.Object[] m_rgobjArgs
          Argument array.
protected static java.lang.StringBuffer m_strbufInput
          StringBuffer re-used for each request.
 
Constructor Summary
SalesTaxCaller()
           
 
Method Summary
static TaxResult[] calculateTax(TaxRequest[] request)
          Calculate the SalesTax (and a myriad of additiona tax information when given a TaxRequest object).
static TaxResult[] calculateTax(TaxRequest[] request, java.util.Set pNonFatalCompCodes)
           
protected static SalesTaxCaller.OutputHeader calculateTaxInternal(TaxRequest[] request, java.lang.StringBuffer strbuf)
          Does all the stuff for calculating tax that needs to be synchronized.
protected static SalesTaxCaller.OutputHeader callCalculate(java.lang.String stringRequest, java.lang.StringBuffer strbuf, java.lang.StringBuffer intobj, boolean vzip)
          Do the dynamic call into the taxcommon class.
static void closeTaxWare()
          Close down taxware.
protected static java.lang.StringBuffer createBuffer(int header, int record, int cRequests)
          Create the InputString buffer
protected static void createInputHeader()
          Create our input header.
protected static void createInputStringBuffer(int cRequests)
          Create our static input string buffer to hold the input header + individual records.
protected static double getTotalTaxAmount(TaxResult taxresult)
           
static void main(java.lang.String[] args)
          Run some simple tests
protected static void openOrCloseTaxWare(boolean bOpen)
          Called to open or close taxware.
static void openTaxWare()
          Open taxware.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
See Also:
Constant Field Values

m_strbufInput

protected static java.lang.StringBuffer m_strbufInput
StringBuffer re-used for each request.


m_inputHeader

protected static atg.integrations.taxware.SalesTaxCaller.InputHeader m_inputHeader
Input header re-used for each request.


m_bOpen

protected static boolean m_bOpen
Whether TaxWare's files are open or not.


m_methodCalculateTax

protected static java.lang.reflect.Method m_methodCalculateTax
Method for calculating tax.


m_rgobjArgs

protected static java.lang.Object[] m_rgobjArgs
Argument array.

Constructor Detail

SalesTaxCaller

public SalesTaxCaller()
Method Detail

createInputStringBuffer

protected static void createInputStringBuffer(int cRequests)
Create our static input string buffer to hold the input header + individual records. This is created every time it is used. The input header is created only once, but some of the fields get set every time we call to Taxware, for example the number of records.


createBuffer

protected static java.lang.StringBuffer createBuffer(int header,
                                                     int record,
                                                     int cRequests)
Create the InputString buffer


createInputHeader

protected static void createInputHeader()
Create our input header. The inpute header is re-used for each call.


openOrCloseTaxWare

protected static void openOrCloseTaxWare(boolean bOpen)
                                  throws TaxwareCriticalException,
                                         TaxwareMinorException
Called to open or close taxware. Taxware has the option to load data files and keep them in memory. Open loads data into memory, and close flushes it properly. Called by SalesTaxService.

Throws:
TaxwareCriticalException - Thrown if installation problem.
TaxwareMinorException - Thrown if error returned from TaxWare.
See Also:
SalesTaxService

closeTaxWare

public static void closeTaxWare()
                         throws TaxwareCriticalException,
                                TaxwareMinorException
Close down taxware. Called by SalesTaxService.

Throws:
TaxwareCriticalException - Thrown if installation problem.
TaxwareMinorException - Thrown if error returned from TaxWare.

openTaxWare

public static void openTaxWare()
                        throws TaxwareCriticalException,
                               TaxwareMinorException
Open taxware. Called by SalesTaxService.

Throws:
TaxwareCriticalException - Thrown if installation problem.
TaxwareMinorException - Thrown if error returned from TaxWare.
See Also:
SalesTaxService

callCalculate

protected static SalesTaxCaller.OutputHeader callCalculate(java.lang.String stringRequest,
                                                           java.lang.StringBuffer strbuf,
                                                           java.lang.StringBuffer intobj,
                                                           boolean vzip)
                                                    throws TaxwareCriticalException,
                                                           TaxwareMinorException
Do the dynamic call into the taxcommon class.

Throws:
TaxwareMinorException - Thrown if installation problem.
TaxwareCriticalException - Thrown if error returned from TaxWare.

calculateTaxInternal

protected static SalesTaxCaller.OutputHeader calculateTaxInternal(TaxRequest[] request,
                                                                  java.lang.StringBuffer strbuf)
                                                           throws TaxwareMinorException,
                                                                  TaxwareCriticalException
Does all the stuff for calculating tax that needs to be synchronized.

Throws:
TaxwareCriticalException - Thrown if installation problem.
TaxwareMinorException - Thrown if error returned from TaxWare.

calculateTax

public static TaxResult[] calculateTax(TaxRequest[] request)
                                throws TaxwareMinorException,
                                       TaxwareCriticalException
Calculate the SalesTax (and a myriad of additiona tax information when given a TaxRequest object).

Parameters:
request - a TaxRequest object
Returns:
the TaxResult object representing the result
Throws:
TaxwareCriticalException - Thrown if installation problem.
TaxwareMinorException - Thrown if error returned from TaxWare.

calculateTax

public static TaxResult[] calculateTax(TaxRequest[] request,
                                       java.util.Set pNonFatalCompCodes)
                                throws TaxwareMinorException,
                                       TaxwareCriticalException
Throws:
TaxwareMinorException
TaxwareCriticalException

getTotalTaxAmount

protected static double getTotalTaxAmount(TaxResult taxresult)

main

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