How is the script organised?

Your script must implement whatever logic is necessary to export information to and import information from your accounting system. The specifics of that are beyond this topic. To achieve the interface your script must provide a number of standard functions with standard names. These functions are called by Match-IT when an import or export action is required. The action required is implied by the function called. If your interface does not provide an action, just do not implement that function and do not publish the capability (see GetCapability below).

The full set of standard functions is given below. You must define the functions with EXACTLY the name given below, including the case (e.g. Setup is not the same as setup). All these functions take as their first parameter an object that provides access to the generic management facilities. This parameter is conventionally named: Interface. Depending on the function, there may be other parameters as well. The functions must return a numeric result code that is non-zero to indicate success, or 0 to indicate failure. Alternatively, failure can be indicated by raising an error (by using the Lua error or assert functions). See the Reference section for a description of the helper facilities available to these functions. Depending on the function, a second string result can be returned.

function setup(Interface)

This is called when the user requests to setup the interface. It typically asks questions about the configuration and saves the results as qualifiers attached to the accounts centre record. Such qualifiers are available as properties of the interface (see Interface:GetProperties).

function exportCUS(Interface,RecNoQ)

This is called when the user has requested that new customer accounts be sent to your accounting system. The RecNoQ parameter will contain a list of customer records to be exported. It is an object of type RecNoQ containing entries of type Customer.

The function's responsibility is to traverse this list (using m.members), extract the required information and export it. On a success return from this function all the entries in the RecNoQ are automatically tagged within Match-IT as having been exported. If you do not want a particular record to be so tagged, remove it from the list before returning (using m.exclude).

function exportSUP(Interface,RecNoQ)

This is the same as exportCUS except it is dealing with suppliers (Q entry type is Supplier).

function exportSI(Interface,RecNoQ)

This is called when the user has requested that new sales invoices be sent to your accounting system. The RecNoQ parameter will contain a list of invoices to be exported. It's an object of type RecNoQ containing entries of type SInvoice.

The function's responsibility is to traverse this list, collate all the invoice lines as appropriate (use m.sdGetInvoiceLines to get the lines associated with any invoice), and export them.

On a success return from this function all the entries in the RecNoQ are automatically tagged within Match-IT as having been exported. If you do not want a particular record to be so tagged, remove it from the list before returning (using m.exclude).

function exportPI(Interface,RecNoQ)

This is the same as exportSI except it is dealing with purchase invoices (Q entry type is PInvoice, use m.poGetInvoiceLines to get purchase invoice lines).

function importCUS(Interface)

This is called when the user has requested that customer account details be imported into Match-IT.

The function's responsibility is to extract all account information from your accounting system and either create new records or update existing records in Match-IT as appropriate.

function importSUP(Interface)

This is the same as importCUS except the user has requested supplier account details.

function importCBAL(Interface)

This is called when the user has requested that customer credit balances be imported into Match-IT.

The function's responsibility is to extract all account credit information from your accounting system and update records in Match-IT as appropriate.

function importSBAL(Interface)

This is the same as importCBAL except the user has requested supplier credit balances.

function exportMAT(Interface,RecNoQ)

This function is called when the user has requested that new stock codes be sent to your accounting system. The RecNoQ parameter will contain a list of stock codes to be exported. It's an object of type RecNoQ containing entries of type Material.

The function's responsibility is to traverse this list (using m.members), extract the required information and export it. On a success return from this function all the entries in the RecNoQ are automatically tagged within Match-IT as having been exported. If you do not want a particular record to be so tagged, remove it from the list before returning (using m.exclude).

function exportMOVE(Interface,RecNoQ)

This function is called when the user has requested that new stock movements be sent to your accounting system. The RecNoQ parameter will contain a list of stock movements to be exported. It's an object of type RecNoQ containing entries of type Movement.

The function's responsibility is to traverse this list, extract the appropriate information from Match-IT and send it to your accounting system. On a success return from this function all the entries in the RecNoQ are automatically tagged within Match-IT as having been exported. If you do not want a particular record to be so tagged, remove it from the list before returning (using m.exclude).

function MakeAccountRef(Interface,Ignore,CusSup)

This function is called when either Match-IT itself, or the user, wants to create a new account reference for a customer or supplier record. The second parameter should be ignored. The third parameter may be missing or it may be an empty string. If present and not empty, it will be a string that should be used to create an initial code if possible. In either case the new account reference should be created to be consistent with the current contents of the CSH file buffer (i.e. do not open the file, just reference its fields as m.csh.<field>).

The function's responsibility is to populate the csh.AccountRef field with a code that is unique and conforms to the conventions of your accounting system.

function GetCapability(Interface)

This function is called when Match-IT needs to know what functions are implemented by the interface. The function must return two results, a non-zero number (to indicate success) and a string of concatenated capability codes. The capability codes have mnemonics of the form csAccCan…; they are all listed in the Reference section under Constants. E.g. if your interface just implements the exporting of customer accounts and sales invoices then the function return statement would look like this:

 return 1,m.csAccCanExportCustomers..m.csAccCanExportSalesInvoices

function GetDescription(Interface)

This function is called when you ask to see the description of an interface from the Accounts Centre form. The function must return two results, a non-zero number (to indicate success) and a string describing the interface sufficiently for anyone probing the interfaces to recognise they have selected the one they want. A typical response would be this:

return 1,’This interface exports information to the ’..
 ‘XXXX accounts package’