Get total debit and credit against voucher in x++
Voucher debit and credit fields on the form are not having the permanent table in back-end. Moreover, these fields are using display methods written in the data source. And, these display methods are using LedgerJournalEngine class to get these values. So, I am sharing the following code for all of you:
//Author: Moeen Ahmed Sultan //Email: firstname.lastname@example.org //Tel: +92 321 458 9595 LedgerJournalEngine ledgerJournalEngine; LedgerJournalTrans ledgerJournalTrans; LedgerJournalTable ledgerJournalTable; ledgerJournalTable.clear(); ledgerJournalTrans.clear(); select ledgerJournalTrans where ledgerJournalTrans.Voucher == "VOUCHER NUMBER"; //Add voucher number in the double quotes against which you want to get total debit and credit. ledgerJournalEngine = new ledgerJournalEngine(); ledgerJournalTable = ledgerJournalTable::find(ledgerJournalTrans.JournalNum); ledgerJournalEngine.newJournalActive(ledgerJournalTable,true); info(strFmt("%1 - %2", ledgerJournalEngine.voucherDebit(ledgerJournalTrans), ledgerJournalEngine.voucherCredit(ledgerJournalTrans)));
In this way you can get voucher debit and voucher credit values using x++. Moreover, if this helps you, please Like, Comment and Share to help other people.
If you found any ambiguity or a better solution, please feel free to ask.
Download code: Click here
Blog: Click here
YouTube: Click here
GitHub: Click here
I have got a dream that’s worth more than my sleep. – Eric Thomas