Friday, March 21, 2014

To Fetch Ledger transaction in x++

// To Fetch Ledger transaction

static void findLedgerTransactions(Args _args)
{
    MainAccount                         mainAccount; //Holds the main accounts
    GeneralJournalEntry                 generalJournalEntry; //Used to hold Ledger transactions
    GeneralJournalAccountEntry          generalJournalAccountEntry; //Used to hold Ledger transactions
    SubledgerJournalEntry               subLedgerJournalEntry; //Used to hold sub Ledger transactions (Like sales/purch invoice etc.)
    SubledgerJournalAccountEntry        subLedgerJournalAccountEntry;  //Used to hold sub Ledger transactions (Like sales/purch invoice etc.)
    DimensionAttributeValueCombination  dimAttrValueComb; //Used to store the combination of main accounts and dimensions

    while select AccountingCurrencyAmount, TransactionCurrencyAmount,  TransactionCurrencyCode
            from generalJournalAccountEntry
            join dimAttrValueComb
                where dimAttrValueComb.RecId == generalJournalAccountEntry.LedgerDimension
            join AccountingDate, JournalNumber from generalJournalEntry
                where generalJournalAccountEntry.GeneralJournalEntry == generalJournalEntry.RecId
                   && generalJournalEntry.AccountingDate == 017\2010
                   && generalJournalEntry.PostingLayer == OperationsTax::Current
                   && generalJournalEntry.Ledger == Ledger::current()
                join MainAccountId, Name from mainAccount
                    where mainAccount.RecId == dimAttrValueComb.MainAccount
                        && mainAccount.MainAccountId == ’130100'
            join subLedgerJournalAccountEntry
                where subLedgerJournalAccountEntry.GeneralJournalAccountEntry == generalJournalAccountEntry.RecId
                   && subLedgerJournalAccountEntry.LedgerDimension == generalJournalAccountEntry.LedgerDimension
                join Voucher from subLedgerJournalEntry
                    where subLedgerJournalAccountEntry.SubledgerJournalEntry == subLedgerJournalEntry.RecId
                       //&& subLedgerJournalEntry.Ledger == Ledger::current()

    {
        info(strFmt("%1-%2, %3, %4, %5, %6, %7, %8", mainAccount.MainAccountId, mainAccount.Name,
                    generalJournalEntry.AccountingDate, subLedgerJournalEntry.Voucher,
                    generalJournalAccountEntry.TransactionCurrencyCode, generalJournalAccountEntry.TransactionCurrencyAmount,
                    generalJournalAccountEntry.AccountingCurrencyAmount,
                    generalJournalEntry.JournalNumber));
    }
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...