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 ?