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:addressObject (see below). Required.callback: Function. Called with two arguments:errandvalidatedAddresserr:nullorErrorvalidatedAddress: the validated and transformedaddressdata
avatax.getTax(taxObject, callback);taxObject: Object. Required. (See Avalara Documentation for full options)callback: Function. Called with two arguments:errandresulterr:nullorErrorresult: tax calculation object for thetaxObjectprovided
avatax.estimateTax(latitude, longitude, amount, callback);latitude: Number. Required.longitude: Number. Required.amount: Number. Required.callback: Function. Called with two arguments:errandresulterr:nullorErrorresult: 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 oflineobjects (see below). Required.Addresses: Array ofaddressobjects (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 unlessLatitudeandLongitude, orTaxRegionIdis present.Line2: String. Optional.Line3: String. Optional.PostalCode: String. Required unlessCityandRegionare present.City: String. Required withRegionunlessPostalCodeis present.Region: String. Required withCityunlessPostalCodeis present.Country: String. Optional.Latitude: Number. Must be accompanied byLongtitude. Can be used ingetTax()instead ofLine1andPostalCodeorCityplusRegion.Longitude: NumberTaxRegionId: Number. Optional. If present, no other aboveaddressfield is required.AddressCode: String. Required when used ingetTax(). Used in conjunction withlineobjects (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. Seeaddressabove.OriginCode: String. Required. Corresponds to LocationCode in Address objects. Seeaddressabove.
See Avalara's Documentation for full options.
- run
npm install - copy and rename
authentication_template.jsontoauthenticate.json, and fill in your credentialsauthentication.jsonis in.gitignore, so therefore won't be added to the repo
- run
npm test
MIT