Hi guys,
I need to create customer payment journal in X which will settle customer invoices. My question is can we settle or mark 1 invoice in two different payment journal line ?
So the issue is in my payment journal creation, since I have 2 different payment mode, lets say 1 Cash 1 Giro, so I inserted in Payment journal (Ledgerjournaltrans) two line for each. But when settling the invoice which is same (1 invoice), after succeeded to mark 1 invoice, at the 2nd line I'm hit this error :
This transaction has been marked for settlement by Customer Payment Tst-000000407 in company xxx.
I assumed this error happened because it is found out that I already mark the invoice in the 1st row. Lets say the invoice is 1,000 and the payment is 200 Cash and 800 Giro, I want these two payment settle it.
Is this possible ? may I know how the code looks like ?
To settle the invoice now, I'm using this code :
void AutosettlePayment(TempTable _tmp, LedgerJournalTrans _paymLedgerJournalTrans)
{
custvendopentransmanager manager;
CustTransOpen CustTransOpen;
CustTrans CustTransExt;
ExchangeRateHelper exchangeRateHelper;
AmountCur totalSettlement;
CompanyInfo companyInfo;
select firstOnly AccountNum, RefRecId, AmountCur from CustTransopen
where CustTransOpen.AccountNum == _tmp.CustAccount
join Invoice, RecId, AccountNum from CustTransExt
where CustTransExt.Invoice == _tmp.InvoicetobeMarked
&& CustTransExt.RecId == CustTransopen.RefRecId
&& CustTransExt.AccountNum == CustTransOpen.AccountNum;
if(CustTransopen && CustTransOpen.AmountCur >= _tmp.PaymentAmount)
{
manager = custvendopentransmanager::construct(ledgerJournalTrans);
manager.updateTransMarked(CustTransOpen,true);
select firstonly RecId from companyInfo
where companyInfo.DataArea == ledgerJournalTrans.Company;
exchangeRateHelpe = ExchangeRateHelper::newCurrency(Ledger::primaryLedger(companyInfo.RecId),ledgerJournalTrans.CurrencyCode);
totalSettlement = SpecTransManager::getTotalSettleAmountForSpecReference(
ledgerJournalTrans.Company,
ledgerJournalTrans.TableId,
ledgerJournalTrans.RecId,
ledgerJournalTrans.CurrencyCode,
ledgerJournalTrans.Company,
ledgerJournalTrans.TransDate,
exchangeRateHelper.prepareExchangeRateForStorage(ledgerJournalTrans.crossrate()));
//To update in ledgerJournal trans
ttsBegin;
ledgerJournalTrans.selectForUpdate(true);
ledgerJournalTrans.AmountCurCredit = _tmp.PaymentAmount <= abs(totalSettlement) ? _tmp.PaymentAmount : 0;
ledgerJournalTrans.SettleVoucher = SettlementType::SelectedTransact;
ledgerJournalTrans.MarkedInvoice = _tmp.InvoicetobeMarked;
ledgerJournalTrans.doupdate();
ttsCommit;
}
}
Jut to informed, as in those code, I have a temptable contain the 2 payment, something like this:
| CUSTACCOUNT |
INVOICETOBEMARKED |
CUSTPAYMMODE |
INVOICEAMOUNT |
PAYMENTAMOUNT |
| BB5 |
I00000289 |
GIRO |
1000 |
800 |
| BB5 |
I00000289 |
CASH |
1000 |
200 |
As mentioned, these 2 records are the one inserted in Payment Journal Lines (LedgerJournalTrans) with at each line inserted I will call this AutoSettlePayment method to mark the invoice. It is throw that error while "ledgerJournalTrans.doUpdate()" for the 2nd time, which mean while processing the 2nd line of Journal lines (the 2nd payment mode)
Thanks,