I am looking for the best way to mass simulate the reverse button for a large batch of customer invoices and payments that need to be unsettled.
I am reviewed a few blogs on this site and I have tried using the following but even though the settlement was performed a month ago in an open period, the system is going back to the date of the transaction itself and giving the following error:
Reversal denied. The transaction is in a previous accounting year.
Here is the code sample:
CustTrans custTrans;
TransTxt txt;
Counter counter = 0;
boolean reversed;
Voucher voucher = 'SSCNV00796948';
TransactionReversal_Cust transsactionCust = new TransactionReversal_Cust();
Args args = new Args();
;
while select custTrans
where custTrans.Voucher == voucher
{
//Returns the reversed status
reversed = TransactionReversalTrans::findTransactionReversalTrans(tableNum(CustTrans), custTrans.RecId).Reversed;
if(!reversed)
{
args.record(custTrans);
transsactionCust.parmReversalDate(systemDateGet());
transsactionCust.run();
new MenuFunction(menuitemActionStr(TransactionReversal_Cust), MenuItemType::Action).run(args);
counter ;
}
}
info(strFmt('Transaction %1 reversed, transaction count %2',voucher,counter));
Can someone provide me with a quick sample script where I can provide invoiceID or voucher number that is settled and be able to reverse?
Thank you