Node library to make requests to the Avalara Avatax API
npm install --save avatax
Supports these features of Avalara's Avatax REST API:
- Validate. Normalizes a single US or Canadian address, providing a non-ambiguous address match.
- GetTax. Calculates taxes on a document such as a sales order, sales invoice, purchase order, purchase invoice, or credit memo.
- EstimateTax. Retrieves tax rate details for the supplied geographic coordinates and sale amount.
var AvaTax = require("avatax");
var avatax = new AvaTax(username, password, [options]);
username
: String. Required. Typically your account number.password
: String. Required. Typically your license key.options
: Object. Optional.options.development
: Boolean. Defaults tofalse
avatax.validateAddress(address, callback);
address
:address
Object (see below). Required.callback
: Function. Called with two arguments:err
andvalidatedAddress
err
:null
orError
validatedAddress
: the validated and transformedaddress
data
avatax.getTax(taxObject, callback);
taxObject
: Object. Required. (See Avalara Documentation for full options)callback
: Function. Called with two arguments:err
andresult
err
:null
orError
result
: tax calculation object for thetaxObject
provided
avatax.estimateTax(latitude, longitude, amount, callback);
latitude
: Number. Required.longitude
: Number. Required.amount
: Number. Required.callback
: Function. Called with two arguments:err
andresult
err
:null
orError
result
: basic tax calculation object for the coordinates and amount provided.
An object representing an order with the following properties:
CustomerCode
: String. Required.DocDate
: String or Date. If String, format must be "YYYY-MM-DD". Defaults tonew Date()
.Commit
: Boolean. Defaults tofalse
.CurrencyCode
: String. 3 character ISO 4217 compliant currency code. Defaults to"USD"
Lines
: Array ofline
objects (see below). Required.Addresses
: Array ofaddress
objects (see below). Required.
See Avalara's documentation for a full list of fields.
An object representing address data with the following properties:
Line1
: String. Required unlessLatitude
andLongitude
, orTaxRegionId
is present.Line2
: String. Optional.Line3
: String. Optional.PostalCode
: String. Required unlessCity
andRegion
are present.City
: String. Required withRegion
unlessPostalCode
is present.Region
: String. Required withCity
unlessPostalCode
is present.Country
: String. Optional.Latitude
: Number. Must be accompanied byLongtitude
. Can be used ingetTax()
instead ofLine1
andPostalCode
orCity
plusRegion
.Longitude
: NumberTaxRegionId
: Number. Optional. If present, no other aboveaddress
field is required.AddressCode
: String. Required when used ingetTax()
. Used in conjunction withline
objects (see below).
See Avalara's documentation for full options and usage.
An object representing a line item in an order (e.g. product, shipping) with the following properties:
LineNo
: String. Required.Qty
: Number. Required.Amount
: Number. Required.ItemCode
: String.DestinationCode
: String. Required. Corresponds to LocationCode in Address objects. Seeaddress
above.OriginCode
: String. Required. Corresponds to LocationCode in Address objects. Seeaddress
above.
See Avalara's Documentation for full options.
- run
npm install
- copy and rename
authentication_template.json
toauthenticate.json
, and fill in your credentialsauthentication.json
is in.gitignore
, so therefore won't be added to the repo
- run
npm test
MIT