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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Get total debit and credit against voucher in x++

(0) ShareShare
ReportReport
Posted on by 125

Hi any one please give me the query to get total debit and credit in X++ on the base of voucher #,not on the base of JounalNum,i am working on General ledger voucher report and i have to get debit and credit in single line and multiple line case,i am not getting one value say debit 100 and other value credit 0 in single line case from LedgerJournalTrans Table.(In Voucher credit is balanced by offset account).

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi Faran Baig!

    Something like this?

    static void Job203(Args _args)
    {
        GeneralJournalEntry         generalJournalEntry;    
        GeneralJournalAccountEntry  generalJournalAccountEntryCredit,
                                    generalJournalAccountEntryDebit;
        
        
        while select generalJournalEntry
            where generalJournalEntry.SubledgerVoucher == 'UNC-00000111'
        {
            select sum(AccountingCurrencyAmount) from generalJournalAccountEntryDebit
                where generalJournalAccountEntryDebit.IsCredit            == NoYes::No
                   && generalJournalAccountEntryDebit.GeneralJournalEntry == generalJournalEntry.RecId;
            
            select sum(AccountingCurrencyAmount) from generalJournalAccountEntryCredit
                where generalJournalAccountEntryCredit.IsCredit            == NoYes::Yes
                   && generalJournalAccountEntryCredit.GeneralJournalEntry == generalJournalEntry.RecId;
            
            
            info(strFmt("Voucher: %1. Debit: %2. Credit: %3.", generalJournalEntry.SubledgerVoucher, 
                                                               generalJournalAccountEntryDebit.AccountingCurrencyAmount,
                                                               generalJournalAccountEntryCredit.AccountingCurrencyAmount));
            
        }
            
    }


    
    

    Screenshot-2018_2D00_11_2D00_14-at-17.49.49.png

  • Faran Baig Profile Picture
    125 on at

    Thanks Rustem Galiamov ,it solved my problem

  • Faran Baig Profile Picture
    125 on at

    Hi Rustem,i m facing problem again,query is working fine in case of posted vouchers,but in case of open vouchers,it is not working.It is not giving credit and debit.Any help will be appreciated.

  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi Faran Baig!

    You can use AmountCurDebit and AmountCurCredit fields from LedgerJournalTrans table.

  • Faran Baig Profile Picture
    125 on at

    Issue is that,in single line case one of two amounts is zero either debit or credit,which is settled by offset account.I have already used it

  • Rustem Galiamov Profile Picture
    8,072 on at

    Sure. The records in GeneralJournalEntry and GeneralJournalAccountEntry tables are generates after voucher posting.

  • Faran Baig Profile Picture
    125 on at

    so is there any way to get it before voucher posting?

  • Rustem Galiamov Profile Picture
    8,072 on at

    Can you provide some template/screenshot of your report?

  • Faran Baig Profile Picture
    125 on at

    0488.image-_2800_1_2900_.png                    0488.image-_2800_1_2900_.png

    These are screenshots,first one is open voucher in General Ledger ,second is customized voucher report , i am not getting amount words field,because of open voucher.As in report showing debit and credit column,i tried,but not get pick the values from that column(issue in single and multi-line case also).

  • Verified answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Try to use LedgerJournalEngine class:

    static void Job203(Args _args)
    {
        
        LedgerJournalTrans  ledgerJournalTrans;
        ledgerJournalEngine ledgerJournalEngine = new ledgerJournalEngine();
        ledgerJournalTable  ledgerJournalTable;
        
        while select ledgerJournalTrans
            where ledgerJournalTrans.Voucher == 'UNC-00051795'
        {
            ledgerJournalTable = ledgerJournalTable::find(ledgerJournalTrans.JournalNum);
            ledgerJournalEngine.newJournalActive(ledgerJournalTable,true);
            info(strFmt("Voucher:%1 Debit: %2 Credit: %3",  ledgerJournalTrans.Voucher, ledgerJournalEngine.voucherDebit(ledgerJournalTrans), ledgerJournalEngine.voucherCredit(ledgerJournalTrans)));
        }
    }


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans