
Hello guys,
Need some help to bring some light. In Customer Payment Journal, when we want to Settle Transactions using this button ->
When the Settle Transaction form open, we're able to change the value of Amount to settle, lets say the Invoice Id is INV001 with the invoice amount is 50, I can overwrite it to 20, so that if I understand correctly, it will split Customer Transaction from 1 record INV001 50, into 2 records INV001 with amount of 20 (which will be settled) and the other record is for the balance of 30.
This is the screen:
May I know what class (or probably event handler) that trigger this "split" split logic ?
Also, I was told that I can use this class custvendopentransmanager to split it, but currently I don't know how to use or whether it is correct or not ?
thanks,
My apologies, I am now not sure whether it is split or not, but if I try manually, the record still 1 but when open Settle transaction, we edit the Amount to settle, lets say the 1st journal line 20, close the form then mark the same invoice, again edit Amount to settle to 10, it is actually able to do so.
My intention is actually I want to create program (X ) to have this kind of situation. So in the Payment Journal creation there will be 2 journal line, but this two journal line will have to pay the same invoice, just like the simulation above.
However I'm not succeed in doing this and always have error with the 2nd line by saying : This transaction has been marked for settlement by Customer Payment XXX-000000431 in company xxx.
It is like my code cannot settle the same invoice (in 2nd line) since it is marked in the 1st line.
My code for handling the settlement when creating payment journal in X is like this :
void settlement(MY_Table _mytable, LedgerJournalTrans _paymLedgerJournalTrans)
{
custvendopentransmanager manager;
CustTransOpen custTransOpen;
AmountCur totalSettlement, amountToSettle;
select firstonly custTransOpen where custTransOpen.Invoice== _mytable.InvoicetobeMarked;
amountToSettle = _mytable.PaymentAmount;
manager = custvendopentransmanager::construct(_paymLedgerJournalTrans);
manager.updateTransMarked(CustTransOpen,true);
manager.updateSettleAmount(CustTransOpen, amountToSettle);
// total settlement
totalSettlement = SpecTransManager::getTotalSettleAmountForSpecReference(
_paymLedgerJournalTrans.Company,
_paymLedgerJournalTrans.TableId,
_paymLedgerJournalTrans.RecId,
_paymLedgerJournalTrans.CurrencyCode,
_paymLedgerJournalTrans.Company,
_paymLedgerJournalTrans.TransDate,
exchangeRateHelper.prepareExchangeRateForStorage(_paymLedgerJournalTrans.crossrate()));
//To update in ledgerJournal trans
ttsBegin;
_paymLedgerJournalTrans.selectForUpdate(true);
_paymLedgerJournalTrans.AmountCurCredit = amountToSettle <= abs(totalSettlement) ? amountToSettle: 0;
_paymLedgerJournalTrans.SettleVoucher = SettlementType::SelectedTransact;
_paymLedgerJournalTrans.MarkedInvoice = _mytable.InvoicetobeMarked;
_paymLedgerJournalTrans.doupdate();
ttsCommit;
}
Basically this is a void called within my payment journal creation, so when the LedgerJournalTrans filled in, then will call this void to do the settlement.
But as mentioned, for two rows of journal line (2 payments) wants to settle the same invoice, on the 2nd line it will hit that error. Unlike when doing manual through Settle Transaction button, all is fine.
Anyone can help to give me some idea ?