Avalara Tax Integration

Started by roger@acsol.com, September 04, 2021, 03:44:27 PM

Previous topic - Next topic

roger@acsol.com

Has anyone integrated Avalara Tax into your application.

Loren Doornek

Yes.  Our implementation is done entirely within PXPlus using the Avalara SOAP/XML interface.  Avalara is one of the few API's that is very well documented, and they have a fully-functional test system that can be used during development.  Our implementation has been in use for years, since back when SOAP/XML was the only option.  We generate all of the SOAP data and then do the communication using [TCP] ports within PXPlus.  Avalara isn't really pushing the SOAP implementation any longer, since they prefer to use JSON.  That's even better and easier than SOAP, and building JSON with PXPlus is really easy.  We send all of the web calls using our own logic, but there are utilities within PXPlus to generate web service calls - others here on the forums are better able to address those questions.  Let me know if you have questions about integrating Avalara (or other tax software.  I've worked on a few.)

Patrick Denny

Does anyone have "sample code" or "routines" developed that you would be willing to share?
I have a customer looking to integrate with Avalara.  Any insights would be helpful.

Stéphane Devouard

#3
Hi

Not related in any way to the Avalara API interface but may help (or not...)

This is how I request the french postal service API to get all the cities/towns for a given postal code
The service uses a REST API with JSON data payloads - which is a breeze to generate and parse with PxPlus


0170 REQUEST$=FN_URL$+"/lines"
0180 REQUEST$+="?q="+STR(CCP:"00000")
0190 REQUEST$+="&select="+CVS("nom_de_la_commune,ligne_5","ascii:url")
0200 REQUEST$+="&size=99"
0210 CALL "*plus/web/request",ERR=*NEXT,REQUEST$,"",RESPONSE$,HEADERS$
0220 IF POS("200"=HEADERS$)=0 THEN ERRMSG$=TBL(TCB(2),"",MSG(ERR)); GOSUB USE_LOCAL
0230 DIM LOAD RESULT${ALL}=RESPONSE$,ERR=PROCESS_END
0240 BUREAUX$=""
0250 CITIES=TRY(NUM(RESULT$["total"]),0),CITY=0
0260 WHILE ++CITY<=CITIES
0270 COMMUNE$="",LIGNE_5$=""
0280 COMMUNE$=RESULT$["results."+STR(CITY)+".nom_de_la_commune"]
0290 LIGNE_5$=RESULT$["results."+STR(CITY)+".ligne_5"]
0300 CHOIX$=COMMUNE$
0310 IF POS(";"+CHOIX$+";"=";"+BUREAUX$)=0 THEN BUREAUX$+=CHOIX$+";"
0320 INFO$=PAD(COMMUNE$,INT(MXC(0)/3)); IF LIGNE_5$<>"" THEN INFO$+=PAD(" ancien nom : "+LIGNE_5$,INT(MXC(0)/3)); INFO$
0320:+=PAD(" --> "+CHOIX$,INT(MXC(0)/3))
0330 IF NOT(CALLED) THEN PRINT PAD(INFO$,MXC(0))
0340 WEND
...
0990 DEF FN_URL$="https://datanova.laposte.fr/data-fair/api/v1/datasets/laposte-hexasmal"



The request is built on statements 170-200
The request is sent using the PxPlus HTTP client on statement 210, getting back the response data and HTTP headers
Statement 210 checks the response status (should be 200 if everything went well)
Statement 230 parses the JSON response into a PxPlus associative array
The response JSON schema is :

{
  "total": 2
  "results": [
    { "nom_de_la_commune": "BRUNOY", "ligne5": "" },
    { "nom_de_la_commune": "BOUSSY SAINT ANTOINE", "ligne5": "" }
  ]
}

Which results in the following assoc array :

result$["total"]="2"
result$["results.1.nom_de_la_commune"]="BRUNOY"
result$["results.1.ligne5"]=""
result$["results.2.nom_de_la_commune"]="BOUSSY SAINT ANTOINE"
result$["results.2.ligne5"]=""


Making it very easy to iterate and get the required info

Hope this helps
Stéphane Devouard
Portfolio | Work

Patrick Denny

Thanks Stéphane for the sample code.  I'm sure that will be a help.