Avalara Source Code Integration - AV API Call

Release Date: 11/16/21
Revised: 05/23/22

Version: 8.6 and Above

This article is intended for Elliott Business Software developers.  This API call will allow the programmer to pass a value to indicate which Avalara function is to be performed. The following functions are supported:

Screen-Parameters: AV,TC (Test Connection)
The TC option will call the AvaTaxClient and GetAccount Avalara APIs. 

CS2111   MOVE "AV,TC" TO SCREEN-PARAMETERS
CS2111   PERFORM SCREEN-ROUTINE

Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.

The result of the connection to the client is returned in SCREEN-LITERAL including the API version and the the start/end date of the Avalara subscription. Screen-Answer will be set to Y if the call was successful. If the call was not successful, Screen-Answer will be set to N and the exception will be passed back in Screen-Literal and written to the AVErrors log.

Screen-Parameters: AV,TM (Tax Code Maintenance)  
The TM option will call the maintenance application for the tax codes.

CS2204    MOVE "AV,TM" TO SCREEN-PARAMETERS
CS2204    PERFORM SCREEN-ROUTINE  

Screen-Parameters: AV,UM (Use Code Maintenance)  
The UM option will call the maintenance application for the use codes.

CS2204   MOVE "AV,UM" TO SCREEN-PARAMETERS
CS2204   PERFORM SCREEN-ROUTINE  

Screen-Parameters: AV,CM (Country Maintenance) 
The CM option will call the maintenance application for the country codes.

CS2204   MOVE "AV,CM" TO SCREEN-PARAMETERS
CS2204   PERFORM SCREEN-ROUTINE  

  
Screen-Parameters: AV,ZM (Zip Tax Maintenance)
The ZM option will call the maintenance application for the zip tax records.

CS2204   MOVE "AV,ZM" TO SCREEN-PARAMETERS
CS2204   PERFORM SCREEN-ROUTINE  

Screen-Parameters: AV,UT (Update Tax Codes)   
The UT option will retrieve the current Avalara tax codes and update AVGDSRVC.

CS2204   MOVE "AV,UT" TO SCREEN-PARAMETERS
CS2204   PERFORM SCREEN-ROUTINE  

Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.
  
Screen-Parameters: AV,UZ (Update Zip Tax Records)   
The UZ option will retrieve the current Avalara zip tax codes and update AVZIPTAX.

CS2204   MOVE "AV,UZ" TO SCREEN-PARAMETERS
CS2204   PERFORM SCREEN-ROUTINE

Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.
  
Screen-Parameters: AV,UC (Update Countries)   
The UC option will retrieve the current Avalara country codes and update SYCNTRY.

CS2204   MOVE "AV,UC" TO SCREEN-PARAMETERS
CS2204   PERFORM SCREEN-ROUTINE

  Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.  

Screen-Parameters: AV,UU (Update Use Codes)  
The UU option will retrieve the current Avalara use codes and update AVUSECDE.

CS2204   MOVE "AV,UU" TO SCREEN-PARAMETERS
CS2204   PERFORM SCREEN-ROUTINE

  Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.
  
Screen-Parameters: AV,TD (Get Tax Code Description)  
The TD option will retrieve the description from AVGDSRVC.

CS2204   MOVE "AV,TD" TO SCREEN-PARAMETERS
CS2203   Move Attr-Value(Attr-Ndx) To Screen-Alpha-Field
CS2204   PERFORM SCREEN-ROUTINE     

  Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.
  
The description is returned in Screen-Alpha-Field.

Screen-Parameters: AV,UD (Get Use Code Description)  
The UD option will retrieve the description from AVUSECDE.

CS2204   MOVE "AV,UD" TO SCREEN-PARAMETERS
CS2203  Move Attr-Value(Attr-Ndx) To Screen-Alpha-Field
CS2204   PERFORM SCREEN-ROUTINE    

  Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.
  
The description is returned in Screen-Alpha-Field.

Screen-Parameters: AV,GS (Get Service Type)


CS2205   MOVE "AV,GS" TO SCREEN-PARAMETERS
CS2205   PERFORM SCREEN-ROUTINE  

Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.  

The GS option will get the service type based upon the entry for the company in the EL860.CFG file.
if successful:
SCREEN-ALPHA-FIELD will contain and "S" for the sandbox environment or a "P" for production.
SCREEN-ANSWER will be set to Y  

If unsuccessful:
SCREEN-ANSWER will be set to N
SCREEN-LITERAL will contain the error message returned by the API.    

Screen-Parameters: AV,GU (Get Use Avalara)


CS2205   MOVE "AV,GU" TO SCREEN-PARAMETERS
CS2205   PERFORM SCREEN-ROUTINE
  
  Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.  

The GU option will determine is Avalara integration is in use based upon the entry for the company in the EL860.CFG file and the entry in Avalara Global Setup.
if both flags are set to Yes:
SCREEN-ANSWER will be set to Y  

If either flag is set to No:
SCREEN-ANSWER will be set to N

Screen-Parameters: AV,VA (Validate Address)  
The VA option will validate an address using the Avalara ResolveAddress API. Pass the table to be checked in SCREEN-LITERAL. The valid options are: ARCUSFIL, CPORDHDR, CPRECHDR, CPSHPFIL and IMLOCFIL. Pass the key field for the corresponding table in SCREEN-ALPHA-FIELD.

           MOVE CUSTOMER-NO TO SCREEN-ALPHA-FIELD.
          MOVE "ARCUSFIL" TO SCREEN-LITERAL.
          MOVE "AV,VA" TO SCREEN-PARAMETERS.
          PERFORM SCREEN-ROUTINE.

Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.  

if successful:
SCREEN-ANSWER will be set to Y  
SCREEN-AREA will contain the latitude, longitude, resolution quality and any message concerning the address. The fields are separated by "/".

If unsuccessful:
SCREEN-ANSWER will be set to N
SCREEN-AREA will contain the error message returned by the API.    

Screen-Parameters: AV,RA (Resolve Address)  
The VA option will validate an address using the Avalara ResolveAddressPost API. Pass the table to be checked in SCREEN-LITERAL. The valid options are: ARCUSFIL, CPORDHDR, CPRECHDR, CPSHPFIL and IMLOCFIL. Pass the key field for the corresponding table in SCREEN-ALPHA-FIELD.

           MOVE CUSTOMER-NO TO SCREEN-ALPHA-FIELD.
          MOVE "ARCUSFIL" TO SCREEN-LITERAL.
          MOVE "AV,VA" TO SCREEN-PARAMETERS.
          PERFORM SCREEN-ROUTINE.

Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.  

Screen-answer will be set to N if the user does not accept the address change.

if successful:
SCREEN-ANSWER will be set to Y  
SCREEN-AREA will contain the latitude, longitude, resolution quality and any message concerning the address. The fields are separated by "/".

If unsuccessful:
SCREEN-ANSWER will be set to N
SCREEN-AREA will contain the error message returned by the API. 

Screen-Parameters: AV,CT (Calculate Taxes Regular Orders)
The CT option will call the CreateTransaction Avalara API to calculate taxes for a regular order.

  Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.  

                 MOVE "AV,CT" TO SCREEN-PARAMETERS
                MOVE "SalesOrder" TO SCREEN-ALPHA-FIELD
                MOVE ORDER-NO TO SCREEN-ALPHA-FIELD(16:6)
                PERFORM SCREEN-ROUTINE
                IF SCREEN-ANSWER = "Y"
                    MOVE SPACES TO TAXAMT1
                                                    TAXAMT2
                                                    TAXAMT3
                    Move Zero             To Y
                    MOVE "A1" TO FIELD
                    Perform varying X from 1 by 1
                            until X > 80
                            or     SCREEN-ALPHA-FIELD(X:1) = X"09"
                        Evaluate SCREEN-ALPHA-FIELD(X:1)
                          when "/"
                            Evaluate FIELD
                              when "A1"
                                MOVE "A2" TO FIELD
                              when "A2"
                                MOVE "A3" TO FIELD
                            End-Evaluate
                            Move Zeroes   To Y
                          when other
                            Add 1         To Y
                            Evaluate FIELD
                              when "A1"
                                If Y not > 12
                                    Move SCREEN-ALPHA-FIELD(X:1)
                                                  To TAXAMT1(Y:1)
                                End-If
                              when "A2"
                                If Y not > 12
                                    Move SCREEN-ALPHA-FIELD(X:1)
                                            To TAXAMT2(Y:1)
                                End-If
                              when "A3"
                                If Y not > 12
                                    Move SCREEN-ALPHA-FIELD(X:1)
                                            To TAXAMT3(Y:1)
                                End-If
                            End-Evaluate
                        End-Evaluate
                    End-Perform
                    Move Zeroes       To ORDER-SALES-TAX-AMOUNT-1
                    IF TAXAMT1 NOT = SPACES
                        MOVE TAXAMT1 TO C18-ROWS
                        Perform RCM-CVT-C-TO-D
                        Move DECIMAL-VALUE to ORDER-SALES-TAX-AMOUNT-1
                    End-If

                    If TAXAMT2 Not = Spaces
                        Move TAXAMT2 To C18-ROWS
                        Perform RCM-CVT-C-TO-D
                        Move DECIMAL-VALUE to ORDER-SALES-TAX-AMOUNT-2
                    Else
                        Move Zeroes       To ORDER-SALES-TAX-AMOUNT-2
                    End-If

                    If TAXAMT3 Not = Spaces
                        Move TAXAMT3 To C18-ROWS
                        Perform RCM-CVT-C-TO-D
                        Move DECIMAL-VALUE to ORDER-SALES-TAX-AMOUNT-3
                    Else
                        Move Zeroes       To ORDER-SALES-TAX-AMOUNT-3
                    End-If

                END-IF
When calling the AV,CT API, Screen-Alpha Field should be sent using the following layout:

Position 1-15 - Either SalesOrder or SalesInvoice (SalesOrder will calculate taxes but will not record the transaction. SalesInvoice will calculate taxes and record the transaction.)
Position 16-21 - The order number
Position 22-27 - The invoice number

The tax amounts 1,2 and 3 are returned in Screen-Alpha-Field separated by "/" and the string ending in X"09".   If an error is encountered, the error message is returned in Screen-Alpha-Field. The error is also written to AVErrors log file.
  
Screen-Parameters: AV,CR (Calculated Taxes Recurring Orders)
  Move a "Y" to Screen-Answer to suppress any message encountered by the API. Errors will be logged in the AVErrors log file.  

The CR option will call the CreateTransaction Avalara API to calculate taxes for a recurring order.

                 MOVE "AV,CR" TO SCREEN-PARAMETERS
                MOVE "SalesOrder" TO SCREEN-ALPHA-FIELD
                MOVE ORDER-NO TO SCREEN-ALPHA-FIELD(16:6)
                PERFORM SCREEN-ROUTINE
                IF SCREEN-ANSWER = "Y"
                    MOVE SPACES TO TAXAMT1
                                  TAXAMT2
                                  TAXAMT3
                    Move Zero             To Y
                    MOVE "A1" TO FIELD
                    Perform varying X from 1 by 1
                            until X > 80
                            or     SCREEN-ALPHA-FIELD(X:1) = X"09"
                        Evaluate SCREEN-ALPHA-FIELD(X:1)
                          when "/"
                            Evaluate FIELD
                              when "A1"
                                MOVE "A2" TO FIELD
                              when "A2"
                                MOVE "A3" TO FIELD
                            End-Evaluate
                            Move Zeroes   To Y
                          when other
                            Add 1         To Y
                            Evaluate FIELD
                              when "A1"
                                If Y not > 12
                                    Move SCREEN-ALPHA-FIELD(X:1)
                                                  To TAXAMT1(Y:1)
                                End-If
                              when "A2"
                                If Y not > 12
                                    Move SCREEN-ALPHA-FIELD(X:1)
                                            To TAXAMT2(Y:1)
                                End-If
                              when "A3"
                                If Y not > 30
                                    Move SCREEN-ALPHA-FIELD(X:1)
                                            To TAXAMT3(Y:1)
                                End-If
                            End-Evaluate
                        End-Evaluate
                    End-Perform
                    Move Zeroes       To ORDER-SALES-TAX-AMOUNT-1
                    IF TAXAMT1 NOT = SPACES
                        MOVE TAXAMT1 TO C18-ROWS
                        Perform RCM-CVT-C-TO-D
                        Move DECIMAL-VALUE to ORDER-SALES-TAX-AMOUNT-1
                    End-If

                    If TAXAMT2 Not = Spaces
                        Move TAXAMT2 To C18-ROWS
                        Perform RCM-CVT-C-TO-D
                        Move DECIMAL-VALUE to ORDER-SALES-TAX-AMOUNT-2
                    Else
                        Move Zeroes       To ORDER-SALES-TAX-AMOUNT-2
                    End-If
                    If TAXAMT3 Not = Spaces
                        Move TAXAMT3 To C18-ROWS
                        Perform RCM-CVT-C-TO-D
                        Move DECIMAL-VALUE to ORDER-SALES-TAX-AMOUNT-3
                    Else
                        Move Zeroes       To ORDER-SALES-TAX-AMOUNT-3
                    End-If
                END-IF
When calling the AV,CT API, Screen-Alpha Field should be sent using the following layout:

Position 1-15 - SalesOrder (SalesOrder will calculate taxes but will not record the transaction.)
Position 16-21 - The order number

The tax amounts 1,2 and 3 are returned in Screen-Alpha-Field separated by "/" and the string ending in X"09". If an error is encountered, the error message is returned in Screen-Alpha-Field. The error is also written to AVErrors log file.
       
AV API: Avalara Function Call (8.5)
If the AV API is called from the 8.5 System Manager, this will be an error condition. The user will receive the following error message stating that they must be running version 8.6 to perform this function.

“Error in XXXXXXXX API supported in v8.6 and above. Please report this error to Netcellent: AV,XX”

This error message is added to detect applications that have not been changed to retrieve the Elliott version and stop the user from running the application if running an Elliott version below 8.6. 



Programs Modified: NWSMSCRN
Programs Added: SYAVATAX
CLS

Feedback and Knowledge Base