Overview
Variables are named placeholders in strings that are later replaced with actual values. For example, if you want to add an invoice note addressing the counterpart (customer) personally, you can use the{company_name} variable in the note text and Tesouro will automatically substitute it with the counterpart name associated with that invoice.
Variables can be used in any of the following ways:
- The
memoandfooterfields of accounts receivable invoices, quotes, and credit notes. - Email templates
- Text templates
- The email subject and body when sending documents via email by using the following endpoints:
Specifics of using variables in memo and footer fields
Variables inserted into the text of the memo and footer fields are immediately substituted with their values. That is, the replacement happens immediately during the document creation (POST) or update (PATCH), rather than later when the document gets issued.
Keep this in mind when repeatedly updating draft documents, as the memo text with earlier substitutions might no longer reflect the current values of the variables.
Example
Example
Consider a draft invoice created for a counterpart named Trustwave.If you add an invoice the returned But if you then change the
memo containing the {company_name} (counterpart name) variable:memo value will contain the hard-coded counterpart name:counterpart_id for this invoice, the memo will still contain the old counterpart name.To avoid issues, you can use these approaches:- Add
memoandfooteras the last update before issuing the document. - When calling
PATCH /receivables/{receivable_id}to update draft documents, provide thememoandfootervalues containing{variables}to ensure the resulting formatted strings remain up-to-date.
Retrieving variables
Certain variables are document-specific and can only be used on a particular document. You can retrieve variables depending on the document type. Tesouro provides separate endpoints to retrieve Payable, Purchase order, and Receivable document variables.Payables
To retrieve variables associated with Payables, callGET /payables/variables:
Purchase orders
To retrieve variables associated with Purchase order documents, callGET /payable-purchase-orders/variables:
Receivables
To retrieve variables associated with Accounts Receivable documents, callGET /receivables/variables:
Variable list
When retrieving document variables, their responses include anobject_type and object_subtype field that differentiates each document type.
The following table shows the object_type values and their corresponding possible object_subtype values and descriptions:
Common variables
These variables are available for all document types, unless noted otherwise:Additional variables for payables
In addition to the common variables, payables can use the following variables:Additional variables for purchase orders
In addition to the common variables, purchase orders can use the following variables:Additional variables for invoices
In addition to the common variables, outgoing invoices can use these variables:Additional variables for quotes
In addition to the common variables, quotes can use the following variables:Additional variables for credit notes
In addition to the common variables, credit notes can use these variables:Additional variables for invoice reminders
Variables for invoice reminders are available in the response from theGET /receivable/variables endpoint. These variables have an object_type value of reminder. The possible object_subtype value for these variables include discount_reminder, final_reminder, and overdue_reminder.