In Microsoft Dynamics 365 for Finance and Operations and Microsoft Dynamics AX 2012, it is really difficult to get total debit and credit against voucher of payment journal shown as follows:
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: moeenahmedsultan@gmail.com
//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)));
Comments
Post a Comment