web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / NevoiTech AX Blog / Get total debit and credit ...

Get total debit and credit against voucher in x++

Moeen Ahmed Sultan Profile Picture Moeen Ahmed Sultan 1,402

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:

Total debit and credit against voucher

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)));

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.

Note: I have tested this code is tested in D365FO but not in AX 2012.

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

The post Get total debit and credit against voucher in x++ appeared first on NevoiTech Blog.

Comments

*This post is locked for comments