From July 9th till 13th we will be at #MSInspire. See you there!

How to Make Ledger General Journal Entry in Dynamics AX

How to Make Ledger General Journal Entry in Dynamics AX
28 Apr 2017

Introduction of Ledger General Journal

The general ledger is used to define and manage a legal entity’s financial records. It is a formal ledger that contains a company’s accounting records, and is a register of debit and credit entries. These entries are classified by using the accounts that are listed in a chart of accounts.

LedgerJournalTable form shows ledger journal entries. We can navigate to this form by clicking General ledger > Journals > General journal or we can find this form in the AOT by clicking Forms > LedgerJournalTable. See screen shot below.

dynamics ax

Select any journal and click on Lines.

dynamics ax

 

Journal Document Intro

Journal Document enables external systems to create ledger general journals and retrieve general journal entries. This service supports only journal types of Daily and account types of Ledger.

This document exposes following operations of ledger journal service.

  • Create
  • Find
  • Read

We will discuss create operation of the service. Some of the data sources of create operation are that we will use in our code are:

  • Journal Name: To create a journal entry we need to specify the journal name.
  • Journal Number: We will get a journal number after creating journal entry. This number will be used to post the journal entry.
  • Ledger account type: This will be the main account from where given amount will be transferred to offset account
  • Ledger offset account type: This will be the account where given amount will be credited.
  • Amount Credit: The amount to be credited in offset account
  • Amount Debit: The amount credited in offset account must be debited from main account. Single amount value will be used for credit and debit in our example.
  • Voucher: Each journal has a voucher sequence. When transactions are manually entered in the ledger journal, the vouchers are typically allocated automatically by using a number sequence. We will generate this number sequence in our example using voucher sequence.
  • Offset Company: We need to specify offset company associated with offset account to create a journal entry

Create & Post Journal Example

We need to create a service class in Dynamics AX with a function. Here our function name is “createLJEntry()”. Later we can call function of this service in code of our external system.

public str createLJEntry ()
{
    LedgerGeneralJournalService             service;
    LedgerGeneralJournal                    ledgerGeneralJournal;
    LedgerGeneralJournal_LedgerJournalTable ledgerJournalTable;
    LedgerGeneralJournal_LedgerJournalTrans ledgerJournalTrans;

    AfStronglyTypedDataContainerList        list;
    AifMultiTypeAccount                     ledgerDimension;
    AifMultiTypeAccount                     offsetLedgerDimension;
    AifEntityKeyList                        keyList;

    NumberSeq                               numberSeq;
    NumberSequenceTable                     numberSequenceTable;

    LedgerJournalCheckPost                  ledgerJournalCheckPost;
    LedgerJournalTable                      postLedgerJournalTable;
    F3ComAxMagentoGiftCardRedeemMapping     magentoGiftCardRedeem;
    ;

    try {
        // Ledger General Journal
        ledgerGeneralJournal = new LedgerGeneralJournal();

        // Ledger Journal Table
        ledgerJournalTable = ledgerGeneralJournal.createLedgerJournalTable().addNew();        
        // give name of existing journal
        ledgerJournalTable.parmJournalName('GJ');
        list = ledgerJournalTable.createLedgerJournalTrans();
        
        ttsBegin;
        // Number Sequence for Voucher
        numberSequenceTable = NumberSequenceTable::find(LedgerJournalName::find(ledgerJournalTable.parmJournalName('GJ')).NumberSequenceTable);
        numberSeq = NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence);


        // Ledger Journal Transaction 1
        ledgerJournalTrans = new LedgerGeneralJournal_LedgerJournalTrans();
        ledgerJournalTrans.parmVoucher(numberSeq.voucher());
        // curext() function is used to get the active company in AX;
        ledgerJournalTrans.parmCompany(curext());
        ledgerJournalTrans.parmAccountType(LedgerJournalACType::Ledger);
        ledgerJournalTrans.parmAmountCurDebit(59.47);
        list.add(ledgerJournalTrans);

        // Ledger Dimension. Enter number and name of existing main account
        ledgerDimension = ledgerJournalTrans.createLedgerDimension();
        ledgerDimension.parmAccount('111999');
        ledgerDimension.parmDisplayValue('Deferred ABC Revenue');
        
        // Offset Ledger Dimension. Enter number, name and company of existing account
        offsetLedgerDimension = ledgerJournalTrans.createOffsetLedgerDimension();
        offsetLedgerDimension.parmAccount('222999');
        offsetLedgerDimension.parmDisplayValue('Deferred Revenue');
        ledgerJournalTrans.parmOffsetCompany(curext());

        // Service to create journal
        service = LedgerGeneralJournalService::construct();
        keyList = service.create(ledgerGeneralJournal);     

	 // Commit transaction before posting this entry.   
        ttsCommit;              

        // Post Journal using journal number of recently created journal entry.
        postLedgerJournalTable = LedgerJournalTable::findByRecId(keyList.getEntityKey(1).parmRecId());
        ledgerJournalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(
            postLedgerJournalTable, NoYes::Yes, NoYes::Yes);
        ledgerJournalCheckPost.run();

        return 'SUCCESS';        
    }
    catch(Exception::CLRError)
    {
        info(strfmt("At : %1",DateTimeUtil ::toStr(DateTimeUtil ::utcNow())));
        info("Exception occurred in Creating Ledger Journal Entry");

        return 'Error';
    }
}


Check Journal Entries in Dynamics AX

We can check recently created and posted journal entry in Dynamics AX by accessing General ledger > Journals > General journal and sorting the grid by “Journal batch number” column. See screen shot below.

dynamics ax

Click on “Lines” in menu bar to view line entries of this journal.

dynamics ax

 

Summary

Create operation of ledger journal service enables us to create a ledger journal entry with lines using external system. Steps to perform this task are:

  1. Write your own service, call create operation of ledger journal service.
  2. Post journal entry using LedgerJournalCheckPost class that is a built-in class in Dynamics AX
  3. Use your service in your external system to generate ledger journal entries.

This will be good for a programmer to understand the basic concept of ledger general journal, ledger general document and data sources of document.

Share

Zulqarnain Abdul Jabbar

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest From Our Blog
Difference between Dynamics CRM and the Dynamic...
Record a Purchase Invoice In Dynamics AX
November 28, 2019
A lot of people tend to get confused between the Microsoft Dynamics CRM and the Dynamics AX CRM, Read our detailed comparison between dynamics crm ...
Read more
7 Ways Dynamics 365 Finance and Operations Boos...
dynamics 365 finance
November 9, 2018
Introduction Launched by Microsoft, Dynamics 365 ERP is one of the most effective for businesses today. It is perfect to save the time, effort and ...
Read more
The Ultimate Guide to Dynamics 365 HR Payroll P...
dynamics hr payroll
October 30, 2018
For any business, irrespective of its size, payroll processing is one of the most important functions. Payroll processing is a method through which...
Read more