Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Payment Journals from Transactions

Kevin Reece edited this page Oct 12, 2017 · 2 revisions

Payment Journals from Transactions

Creating a payment journal from a Sales or Purchase Invoice has become a challenge when processing more than a few payments due to the governor limits of the Salesforce platform, so there was a new mechanism created using the batch system to asynchronously create and post the journals.

There is a new Data Transformation Object (DTO) created and made globally available that allows for usage outside of the Sage Live managed package and it is detailed below.

global with sharing class Sage_INV_API_PayRequest 
{
    global Sage_API_Reference_1_0 transactionReference;
    global Sage_API_Tag_1_0 paymentTypeTag;
    global Double amount;
    global Date paymentDate;
    global Sage_API_Tag_1_0 bankTag;
    global Sage_API_Tag_1_0 adjustmentTypeTag;
}

It is notable that the type of Journal that is created is driven from the Transaction Type configuration and that is discovered by the 'TransactionReference' field in the DTO.

The method accepts two parameters.

Parameter Type Description
payRequests List<s2cor.Sage_INV_API_PayRequest> The list of Transactions to convert to Payment Journals
companyReference Sage_API_Reference_1_0 A reference to the company for the payment journal

Example Code

This example is creating a 'Payments to Suppliers/Vendors' Journal Type.

List requests = new List();
        
s2cor.Sage_API_Reference_1_0 company = new s2cor.Sage_API_Reference_1_0(s2cor.Sage_COR_User_Company_Settings_Helper.GetUserCompanyID(), null, null);

// for each payment
for(var x in y)
{
	s2cor.Sage_INV_API_PayRequest payRequest = new s2cor.Sage_INV_API_PayRequest();
                
	s2cor.Sage_API_Tag_1_0 paymentTagReference = new s2cor.Sage_API_Tag_1_0();
	paymentTagReference.Reference = new s2cor.Sage_API_Reference_1_0(null, null, null); // Id, Name, UID --> Complete One
	paymentTagReference.Dimension = new s2cor.Sage_API_Reference_1_0(null,null,'PayInstrumentType');
                
	s2cor.Sage_API_Tag_1_0 bankTagReference = new s2cor.Sage_API_Tag_1_0();
	bankTagReference.Reference = new s2cor.Sage_API_Reference_1_0(null, null, null); // Id, Name, UID --> Complete One
	bankTagReference.Dimension = new s2cor.Sage_API_Reference_1_0(null, null, 'BankAccount');
                     
	payRequest.transactionReference = new s2cor.Sage_API_Reference_1_0(null, null, null); // Id, Name, UID --> Complete One
	payRequest.paymentTypeTag = paymentTagReference;
	payRequest.bankTag = bankTagReference;
	payRequest.amount = AMOUNT;
	payRequest.paymentDate = system.today();
                
	requests.add(payRequest);
}

if(!requests.isEmpty())
{
	s2cor.Sage_INV_API_doPayments.doPayments(requests, company);
}

Clone this wiki locally