Introduction

Once Invoices are processed through PayThem v2, you can reference these exsiting requests on customer statements using the ''MVAR1...'' command.

This means that the customer information (billing adress etc) does not need to be provided on the statement as it is already held in the PayThem portal. If an invoice on a startement has not previously been processed using PayThem v2 it will not be included in any PayThem button for the statement.

Applies to

  • Spindle Document Management v10.3 and later
  • Spindle Document Distribution v10.3 and later
  • Spindle Document Distribution Cloud v10.3 and later


Required fields

Statments for PayThem v2 require only the following data fields (in addition to any required for the standard processing through Spindle Document Distribution):

  • ##ACCOUNTREF...##
  • ##DATASETID...##
  • ##COMPANY...## (all of the above in the statement header)
  • ##MVAR1....## (in the repeating detail section)
  • ##PAYTHEM## (at the position of the button)

Note: In the examples shown below, the commands are built using a large font size set to a visible colour for demonstration. On a customer site you would set the MVAR1 command to 2pt White text and close up the repeating invoice section.

Process

In the ERP report designer, check that the above commands are present in the report and add them if missing.

##ACCOUNTREF...### and ##COMPANY...## should contain the account number and customer company name respectively

##DATASEID...## needs to match the Company ID set in the PayThem portal :

Above: In this example we are setting up statements for Homestyle Kitchens, which has an ID of 3. 


Note that for Sage 200 companies, the Custom Host ID here should match the company number as set in Sage Adminstration and available in report designer as SysCompanies.CompanyNumber


Add the MVAR1 command

The MVAR1 command takes multiple values, a transactionID and an AmountToPay, which sets the outstanding amount left on a given invoice. Once rendered on the statement it will look as follows:

##MVAR1 [TransactionID=CustomerABB001InvoiceSI0012342024-03-20],[AmountToPay=100.00]##

That is: two Key=value pairs in square brackets, separated by a comma.

Establish the Custom Host ID format - see KBA-14-03-001 - About The Custom Host ID for details. In new implementations it will be as above (earlier implementations may have the date format as dd/MM/yyyy), we will set up the expression accordingly.


For Sage 200, the basic expression looks like this:

"##MVAR1 [TransactionID = Customer" + SLCustomerAccounts.CustomerAccountNumber + "Invoice" +SLPostedCustomerTrans.TransactionReference+ DateTimeToFormattedString(SLPostedCustomerTrans.TransactionDate,"yyyy-MM-dd")+ "],[AmountToPay=" + (SLPostedCustomerTrans.GoodsValueInAccountCurrency - SLPostedCustomerTrans.AllocatedValue)+ "]##"

Note that we calculate the amount remaining by subtracting the allocated amount from the initial amount. This gives the following output:



However we can see that this is adding the ##MVAR1...## command to all lines on the statement, including for credit notes, which we do not want. We have to place an IF.. statement around our expression so that it only appears if the statement line refers to an invoice. We can use the SLPostedCustomerTrans.TransactionTypeShortName field to identify these.


SLPostedCustomerTrans.TransactionTypeShortName="SI"?"##MVAR1 [TransactionID = Customer" + SLCustomerAccounts.CustomerAccountNumber + "Invoice" +SLPostedCustomerTrans.TransactionReference+ DateTimeToFormattedString(SLPostedCustomerTrans.TransactionDate,"yyyy-MM-dd")+ "],[AmounttoPay=" + (SLPostedCustomerTrans.GoodsValueInAccountCurrency - SLPostedCustomerTrans.AllocatedValue)+ "]##" : ""


(If the shortname is "SI", then put the MVAR command, otherwise put an empty string)


Which gives :



Above: Only Invoice lines show an MVAR1 command


With the expression behaving as we expect, we can now set its font size to 1pt, and its foregroung colour to white, tuck it up close to the detail line and narrow the detail band so as not to spoil the layout.:


For Sage 50, the process is as above, as Sage 50 shares the report designer with Sage 200, however the fieldnames will need to be amended.


In the Header, add (or confirm the presence of) the following commands:

"##ACCOUNTREF " + SALES_LEDGER.ACCOUNT_REF + "##
##DATASETID 3##
##COMPANY " + SALES_LEDGER.NAME + "##"

Note: Hard-code the DATASETID to match the company host ID in the PayThem portal.


In the HEADER_NUMBER details section, add the ##MVAR1...## command. We need to reference the outstanding amount in this expression, but this is specified using a Sum aggregate function of the AUDIT_SPLIT.FOREIGN_AGED_BALANCE field, and we cannot use this in our expression out of the box. To get around this, we will name the expression and reference its result in our ##MVAR1...## expression.

Select the expression containing the balance, then in the Properties panel, locate the Name field:


Give the Expression a name. In the example we use "SPOutstanding". We can now refer to SPOutstanding to get the aggregate value in our MVAR1 expression.

Add an expression into this section with the following:


AUDIT_SPLIT.TYPE="SI"?"##MVAR1 [TransactionID=Customer" + AUDIT_SPLIT.ACCOUNT_REF + "Invoice" + AUDIT_SPLIT.INV_REF + DateTimeToFormattedString(AUDIT_SPLIT.DATE,"yyyy-MM-dd")+ "],[AmountToPay=" + SPOutstanding  + "]##" : ""



Result:



For other ERPs, the above principle applies, build the ##MVAR...## string using the transaction reference, the account reference and the outstanding amount, then place it inside an IF statement such that only displays it if the line is an invoice.


Add the PayThem button to the layout

Place a text label with the text ##PAYTHEM## at the position on the document where the button is to be placed. The button is placed such that its upper left corner is at the upper left corner of the ##PAYTHEM## label:


Configure Spindle Document Distribution Tools

Create a new Payment Integration and name it appropriately

Set its document type to "Basic Statement"

Add this Integration to the Document Operation


If you select Ignore PayThem failures, then statements will be distributed even if there are errors with the PayThem integration (albeit without the PayThem button). 

If you are setting up Statements and Invoices for PayThem v2 at the same time, then statements will have errors until such time as the invoices listed on the statements have been issued through PayThem v2, this time will vary according to how old the invoices on a statement are. If required, you can configure an Archive only process for Invoices and reprint older invoies throiugh this to create the invoice payment requests.

Knowledge Base Article Details

Related ProductDraycir PayThem v2
Ref NumberKBA-14-02-007
Document Date22/03/2024
Original AuthorVince Hodgson
Document Versionv1.1
Last updated 05/04/20204
Update Author Vince Hodgson