public class

AvalaraModule

extends Object
java.lang.Object
   ↳ org.mule.modules.avalara.AvalaraModule
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Avalara provides automated sales tax solutions to streamline cumbersome, error-prone tax compliance processes and reduce the risk of loss or penalty in case of an audit. Their automated solutions automatically perform address validation, jurisdiction research and rate calculation and allow you to manage even the most complicated tax issues, such as situs, nexus, tax tiers, tax holidays, exemptions, certificate management and product taxability rules.

Summary

Fields
private String addressServiceEndpoint Address Webservice endpoint
private AvalaraClient apiClient Avalara's application client.
private String batchServiceEndpoint Batch Webservice endpoint
private final MapObjectMapper mom
private String taxServiceEndpoint Tax Webservice endpoint
Public Constructors
AvalaraModule()
Public Methods
AdjustTaxResult adjustTax(int adjustmentReason, String adjustmentDescription, String companyCode, AvalaraDocumentType docType, String docCode, XMLGregorianCalendar docDate, String salespersonCode, String customerCode, String customerUsageType, String discount, String purchaseOrderNo, String exemptionNo, String originCode, String destinationCode, List<Map<String, Object>> baseAddresses, List<Map<String, Object>> lines, DetailLevelType detailLevel, String referenceCode, String locationCode, boolean commit, String batchCode, Map<String, Object> taxOverride, String currencyCode, ServiceModeType serviceMode, XMLGregorianCalendar paymentDate, String exchangeRate, XMLGregorianCalendar exchangeRateEffDate)
Adjust Tax processor.
CancelTaxResult cancelTax(String docId, String companyCode, AvalaraDocumentType docType, String docCode, CancelCodeType cancelCode)
Cancel tax, indicating the document that should be canceled and the reason for the operation.
CommitTaxResult commitTax(String docId, String companyCode, AvalaraDocumentType docType, String docCode, String newDocCode)
Commit Tax processor
synchronized void connect(String account, String avalaraClient, String license)
Connects to Avalara
synchronized void disconnect()
Destroys the session
Map<String, BatchFileFetchResult> fetchBatchFile(String batchId)
Batch Fetch processor.
String getAddressServiceEndpoint()
String getBatchServiceEndpoint()
String getConnectionIdentifier()
GetTaxResult getTax(String companyCode, AvalaraDocumentType docType, String docCode, XMLGregorianCalendar docDate, String salespersonCode, String customerCode, String customerUsageType, String discount, String purchaseOrderNo, String exemptionNo, String originCode, String destinationCode, List<Map<String, Object>> baseAddresses, List<Map<String, Object>> lines, DetailLevelType detailLevel, String referenceCode, String locationCode, boolean commit, String batchCode, Map<String, Object> taxOverride, String currencyCode, ServiceModeType serviceMode, XMLGregorianCalendar paymentDate, String exchangeRate, XMLGregorianCalendar exchangeRateEffDate)
Get Tax processor.
GetTaxHistoryResult getTaxHistory(String docId, String companyCode, AvalaraDocumentType docType, String docCode, DetailLevelType detailLevel)
Get Tax History processor
String getTaxServiceEndpoint()
boolean isBatchFinished(String batchId)
Has the Batch Processing finished

Fetches a Batch result

boolean isConnected()
PingResult ping(String message)
Ping Avalara to test connectivity and version of the service.
PingResult pingWithCredentials(String pingAccount, String pingAvalaraClient, String pingLicense, String message)
Ping Avalara to test connectivity and version of the service for a specific user.
PostTaxResult postTax(String docId, String companyCode, AvalaraDocumentType docType, String docCode, XMLGregorianCalendar docDate, String totalAmount, String totalTax, boolean commit, String newDocCode)
Post Tax processor
BatchSaveResult saveBatch(BatchType batchType, int companyId, String content, String batchName)
Batch Save processor.
void setAddressServiceEndpoint(String addressServiceEndpoint)
void setBatchServiceEndpoint(String batchServiceEndpoint)
void setClient(AvalaraClient apiClient)
Sets the apiClient.
void setTaxServiceEndpoint(String taxServiceEndpoint)
ValidateResult validateAddress(String line1, String line2, String line3, String city, String region, String country, String postalCode, String addressCode, Integer taxRegionId, String latitude, String longitude, TextCaseType textCase, boolean coordinates, boolean taxability, XMLGregorianCalendar date)
Validate Address processor.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private String addressServiceEndpoint

Address Webservice endpoint

private AvalaraClient apiClient

Avalara's application client. By default uses DefaultAvalaraClient class.

private String batchServiceEndpoint

Batch Webservice endpoint

private final MapObjectMapper mom

private String taxServiceEndpoint

Tax Webservice endpoint

Public Constructors

public AvalaraModule ()

Public Methods

public AdjustTaxResult adjustTax (int adjustmentReason, String adjustmentDescription, String companyCode, AvalaraDocumentType docType, String docCode, XMLGregorianCalendar docDate, String salespersonCode, String customerCode, String customerUsageType, String discount, String purchaseOrderNo, String exemptionNo, String originCode, String destinationCode, List<Map<String, Object>> baseAddresses, List<Map<String, Object>> lines, DetailLevelType detailLevel, String referenceCode, String locationCode, boolean commit, String batchCode, Map<String, Object> taxOverride, String currencyCode, ServiceModeType serviceMode, XMLGregorianCalendar paymentDate, String exchangeRate, XMLGregorianCalendar exchangeRateEffDate)

Adjust Tax processor.

The Get Tax operation calculates tax for one or more invoiced items and displays details describing the calculation of tax for each line item.

Parameters
adjustmentReason The reason for this tax adjustment.
adjustmentDescription A description of a tax adjustment.
companyCode Client application company reference code
docType The document type specifies the category of the document and affects how the document is treated after a tax calculation; see AvalaraDocumentType for more information about the specific document types.
docCode The internal reference code used by the client application.
docDate Date of invoice, purchase order, etc.
salespersonCode The client application salesperson reference code.
customerCode Client application customer reference code
customerUsageType Client application customer or usage type. CustomerUsageType determines the exempt status of the transaction based on the exemption tax rules for the jurisdictions involved. CustomerUsageType may also be set at the line item level.

The standard values for the CustomerUsageType (A-L).
A Federal Government
B State/Local Govt.
C Tribal Government
D Foreign Diplomat
E Charitable Organization
F Religious/Education
G Resale
H Agricultural Production
I Industrial Prod/Mfg.
J Direct Pay Permit
K Direct Mail
L - Other

discount The discount amount to apply to the document. The string represents a BigDecimal.
purchaseOrderNo Purchase order identifier. PurchaseOrderNo is required for single use exemption certificates to match the order and invoice with the certificate.
exemptionNo Exemption number used for this transaction
originCode Code that refers one of the address of the baseAddress collection. It has to be the same code of one of the address's addressCode. It represents the origin address.
destinationCode Code that refers one of the address of the baseAddress collection. It has to be the same code of one of the address's addressCode. It represents the destination address.
baseAddresses Collection of physical addresses that will be referred to as the destination or origination of 1 or more invoice line entries
lines Collection of invoice lines requiring tax calculation
detailLevel Specifies the level of tax detail to return
referenceCode For returns (see AvalaraDocumentType), refers to the AdjustTaxRequest of the original invoice.
locationCode Location Code value. It is Also referred to as a Store Location, Outlet Id, or Outlet code is a number assigned by the State which identifies a Store location. Some state returns require taxes are broken out separately for Store Locations.
commit Commit flag. If Commit is set to true, tax for the transaction is saved, posted and committed as tax document.
batchCode The batchCode value.
taxOverride Indicates to apply tax override to the document.
currencyCode It is 3 character ISO 4217 currency code.
serviceMode This is only supported by AvaLocal servers. It provides the ability to controls whether tax is calculated locally or remotely when using an AvaLocal server. The default is Automatic which calculates locally unless remote is necessary for non-local addresses.
paymentDate The date on which payment was made.
exchangeRate The exchange rate value. The string represents a BigDecimal
exchangeRateEffDate The exchange rate effective date value.
Returns

public CancelTaxResult cancelTax (String docId, String companyCode, AvalaraDocumentType docType, String docCode, CancelCodeType cancelCode)

Cancel tax, indicating the document that should be canceled and the reason for the operation.

Parameters
docId The original document's type, such as Sales Invoice or Purchase Invoice.
companyCode Client application company reference code. If docId is specified, this is not needed.
docType The document type specifies the category of the document and affects how the document is treated after a tax calculation; see AvalaraDocumentType for more information about the specific document types.
docCode The internal reference code used by the client application.
cancelCode A code indicating the reason the document is getting canceled.
Returns

public CommitTaxResult commitTax (String docId, String companyCode, AvalaraDocumentType docType, String docCode, String newDocCode)

Commit Tax processor

Parameters
docId The original document's type, such as Sales Invoice or Purchase Invoice.
companyCode Client application company reference code. If docId is specified, this is not needed.
docType The document type specifies the category of the document and affects how the document is treated after a tax calculation; see AvalaraDocumentType for more information about the specific document types.
docCode The internal reference code used by the client application.
newDocCode The new document code value.
Returns

public synchronized void connect (String account, String avalaraClient, String license)

Connects to Avalara

Parameters
account Registered Avalara account
avalaraClient Target client to which make the call
license The matching license for the account
Throws
ConnectionException

public synchronized void disconnect ()

Destroys the session

public Map<String, BatchFileFetchResult> fetchBatchFile (String batchId)

Batch Fetch processor.

Fetches a Batch result

Parameters
batchId The numerical identifier of the BatchFile.
Returns
  • The Map

public String getAddressServiceEndpoint ()

public String getBatchServiceEndpoint ()

public String getConnectionIdentifier ()

public GetTaxResult getTax (String companyCode, AvalaraDocumentType docType, String docCode, XMLGregorianCalendar docDate, String salespersonCode, String customerCode, String customerUsageType, String discount, String purchaseOrderNo, String exemptionNo, String originCode, String destinationCode, List<Map<String, Object>> baseAddresses, List<Map<String, Object>> lines, DetailLevelType detailLevel, String referenceCode, String locationCode, boolean commit, String batchCode, Map<String, Object> taxOverride, String currencyCode, ServiceModeType serviceMode, XMLGregorianCalendar paymentDate, String exchangeRate, XMLGregorianCalendar exchangeRateEffDate)

Get Tax processor.

The Get Tax operation calculates tax for one or more invoiced items and displays details describing the calculation of tax for each line item.

Parameters
companyCode Client application company reference code
docType The document type specifies the category of the document and affects how the document is treated after a tax calculation; see AvalaraDocumentType for more information about the specific document types.
docCode The internal reference code used by the client application.
docDate Date of invoice, purchase order, etc.
salespersonCode The client application salesperson reference code.
customerCode Client application customer reference code
customerUsageType Client application customer or usage type. CustomerUsageType determines the exempt status of the transaction based on the exemption tax rules for the jurisdictions involved. CustomerUsageType may also be set at the line item level.

The standard values for the CustomerUsageType (A-L).
A Federal Government
B State/Local Govt.
C Tribal Government
D Foreign Diplomat
E Charitable Organization
F Religious/Education
G Resale
H Agricultural Production
I Industrial Prod/Mfg.
J Direct Pay Permit
K Direct Mail
L - Other

discount The discount amount to apply to the document. The string represents a BigDecimal.
purchaseOrderNo Purchase order identifier. PurchaseOrderNo is required for single use exemption certificates to match the order and invoice with the certificate.
exemptionNo Exemption number used for this transaction
originCode Code that refers one of the address of the baseAddress collection. It has to be the same code of one of the address's addressCode. It represents the origin address.
destinationCode Code that refers one of the address of the baseAddress collection. It has to be the same code of one of the address's addressCode. It represents the destination address.
baseAddresses Collection of physical addresses that will be referred to as the destination or origination of 1 or more invoice line entries
lines Collection of invoice lines requiring tax calculation
detailLevel Specifies the level of tax detail to return
referenceCode For returns (see AvalaraDocumentType), refers to the getDocCode() of the original invoice.
locationCode Location Code value. It is Also referred to as a Store Location, Outlet Id, or Outlet code is a number assigned by the State which identifies a Store location. Some state returns require taxes are broken out separately for Store Locations.
commit Commit flag. If Commit is set to true, tax for the transaction is saved, posted and committed as tax document.
batchCode The batchCode value.
taxOverride Indicates to apply tax override to the document.
currencyCode It is 3 character ISO 4217 currency code.
serviceMode This is only supported by AvaLocal servers. It provides the ability to controls whether tax is calculated locally or remotely when using an AvaLocal server. The default is Automatic which calculates locally unless remote is necessary for non-local addresses.
paymentDate The date on which payment was made.
exchangeRate The exchange rate value. The string represents a BigDecimal
exchangeRateEffDate The exchange rate effective date value.
Returns

public GetTaxHistoryResult getTaxHistory (String docId, String companyCode, AvalaraDocumentType docType, String docCode, DetailLevelType detailLevel)

Get Tax History processor

Parameters
docId The original document's type, such as Sales Invoice or Purchase Invoice.
companyCode Client application company reference code. If docId is specified, this is not needed.
docType The document type specifies the category of the document and affects how the document is treated after a tax calculation; see AvalaraDocumentType for more information about the specific document types.
docCode The internal reference code used by the client application.
detailLevel Specifies the level of detail to return. See DetailLevelType.
Returns

public String getTaxServiceEndpoint ()

public boolean isBatchFinished (String batchId)

Has the Batch Processing finished

Fetches a Batch result

Parameters
batchId The numerical identifier of the BatchFile.
Returns
  • a boolean representing if the Batch finished or not

public boolean isConnected ()

public PingResult ping (String message)

Ping Avalara to test connectivity and version of the service.

Parameters
message Ping Message
Returns

public PingResult pingWithCredentials (String pingAccount, String pingAvalaraClient, String pingLicense, String message)

Ping Avalara to test connectivity and version of the service for a specific user. It is needed to specify the credentials for the user since this operation does not use the global connector configuration.

Parameters
pingAccount Avalara Account Number
pingAvalaraClient Avalara Client
pingLicense Avalara License
message Ping Message
Returns

public PostTaxResult postTax (String docId, String companyCode, AvalaraDocumentType docType, String docCode, XMLGregorianCalendar docDate, String totalAmount, String totalTax, boolean commit, String newDocCode)

Post Tax processor

Parameters
docId The original document's type, such as Sales Invoice or Purchase Invoice.
companyCode Client application company reference code. If docId is specified, this is not needed.
docType The document type specifies the category of the document and affects how the document is treated after a tax calculation; see AvalaraDocumentType for more information about the specific document types.
docCode The internal reference code used by the client application.
docDate The date on the invoice, purchase order, etc
totalAmount The total amount (not including tax) for the document. This is used for verification and reconciliation. This should be the TotalAmount returned by GetTaxResult when tax was calculated for this document; otherwise the web service will return an error. The string represents a BigDecimal
totalTax The total tax for the document. This is used for verification and reconciliation. This should be the TotalTax returned by GetTaxResult when tax was calculated for this document; otherwise the web service will return an error. The string represents a BigDecimal
commit The commit value. This has been defaulted to false. If this has been set to true AvaTax will commit the document on this call. Seller's system who wants to Post and Commit the document on one call should use this flag.
newDocCode The new document code value.
Returns

public BatchSaveResult saveBatch (BatchType batchType, int companyId, String content, String batchName)

Batch Save processor.

Saves a Batch. Note that you should pass-in your console credentials for this method, instead of the API ones

Parameters
batchType The kind of records to be imported.
companyId The id of the company. (Need to be retrived from address bar in Avalara after hitting the Organization Tab)
content The content of this import, usually a csv file.
batchName The name of the batch.
Returns

public void setAddressServiceEndpoint (String addressServiceEndpoint)

Parameters
addressServiceEndpoint

public void setBatchServiceEndpoint (String batchServiceEndpoint)

Parameters
batchServiceEndpoint

public void setClient (AvalaraClient apiClient)

Sets the apiClient.

Parameters
apiClient With the apiClient.

public void setTaxServiceEndpoint (String taxServiceEndpoint)

Parameters
taxServiceEndpoint

public ValidateResult validateAddress (String line1, String line2, String line3, String city, String region, String country, String postalCode, String addressCode, Integer taxRegionId, String latitude, String longitude, TextCaseType textCase, boolean coordinates, boolean taxability, XMLGregorianCalendar date)

Validate Address processor.

This operation validates the supplied address, returning canonical form and additional delivery details if successfully validated.

Parameters
line1 Address line 1
line2 Address line 2
line3 Address line 3
city City name. Required, when PostalCode is not specified.
region State or region name. Requirad, when PostalCode is not specified.
country Country code
postalCode Postal or ZIP code. Required, when City and Region are not specified
addressCode The address code.
taxRegionId The tax region id.
latitude Latitude.
longitude Longitude.
textCase The casing to apply to the validated address(es).
coordinates True, if you want in the result a not empty latitud and longitude.
taxability True, if you want the valid taxRegionId in the result.
date Date.
Returns