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)

How can i get Fiscal year (Period) on the ledgerjournal report?

(0) ShareShare
ReportReport
Posted on by 335

How can i get Fiscal year (Period) on the ledgerjournal report?

- i want to get fiscal year (Period) on the basis of journal date or voucher date.

for example

date is 09-01-2015 then fiscal year is 1-2015

date is 09-01-2015 then fiscal year is Period 0

Need code please....

thanks

zeeshan

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    It should depend if your journal is posted or still open

    If (Journal Is Not posted)

    {

     // generalJournalEntry.FiscalCalendarPeriod

    }

    Else

    {

       generalJournalEntry.FiscalCalendarPeriod

    }

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    above is wrong here goes correction for case of non-posted journal

    FiscalCalendars::findYearEndClosingPeriodByDate(CompanyInfo::fiscalCalendarRecId(),_transdate).RecId

  • Zeeshan Adeel Profile Picture
    335 on at

    not working :(

    thanks for reply.

  • André Arnaud de Calavon Profile Picture
    301,119 Super User 2025 Season 2 on at

    Hi Zeeshan,

    Can you please clarify the difference between:

    - date is 09-01-2015 then fiscal year is 1-2015

    - date is 09-01-2015 then fiscal year is Period 0

  • Zeeshan Adeel Profile Picture
    335 on at

    this is same.

    consider 2nd line

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    I provided you some hint to resolve that, expecting you would do some effort; anyway her you go again, some hint and sample code again. if below code can give you dates, it should not be difficult to get period

    Make sure to replace Recid(s) that I am using in below example. replace your own values.

    static void sampleFinePostingDates(Args _args)
    {
        LedgerJournalTrans  LedgerJournalTransNPosted;
        PeriodStart         periodStartDate;
        PeriodEnd           periodEndDate;
        
        
        LedgerJournalTrans          ledgerJournalTrans;
        GeneralJournalAccountEntry  generalJournalAccountEntry, localGeneralJournalAccountEntry;
        GeneralJournalEntry         generalJournalEntry, localGeneralJournalEntry,GeneralJournalEntryFin;    
        SubledgerVoucherGeneralJournalEntry subledgerVoucherGeneralJournalEntry;
        FiscalCalendarPeriod        FiscalCalendarPeriod;
        
        ;
        
        setPrefix('Output');
        //<Case 1: open journals>
            LedgerJournalTransNPosted.clear();
            LedgerJournalTransNPosted = LedgerJournalTrans::findRecId(35637315938,false);
        
            periodStartDate = FiscalCalendarYear::findYearByCalendarDate(CompanyInfo::fiscalCalendarRecId(), LedgerJournalTransNPosted.TransDate).StartDate;
            periodEndDate   = FiscalCalendarYear::findYearByCalendarDate(CompanyInfo::fiscalCalendarRecId(), LedgerJournalTransNPosted.TransDate).EndDate;
            //note that i am using LedgerJournalTrans.TransDate for case of open journals
            setPrefix('Case of open journal');
            info(strFmt("Period start date: %1", periodStartDate));
            info(strFmt("Period end date: %1", periodEndDate));
        //</Case 1: open journals>
    
        //<Case 2: posted journals>
        ledgerJournalTrans.clear();
        ledgerJournalTrans = LedgerJournalTrans::findRecId(5637194509,false);
        
        select firstonly generalJournalAccountEntry
        join RecId from subledgerVoucherGeneralJournalEntry
            where subledgerVoucherGeneralJournalEntry.GeneralJournalEntry == generalJournalAccountEntry.GeneralJournalEntry &&
                  subledgerVoucherGeneralJournalEntry.Voucher == ledgerJournalTrans.Voucher &&
                  subledgerVoucherGeneralJournalEntry.AccountingDate == ledgerJournalTrans.TransDate &&
                  subledgerVoucherGeneralJournalEntry.VoucherDataAreaId == ledgerJournalTrans.DataAreaId
        join RecId,FiscalCalendarPeriod from generalJournalEntry
            where generalJournalEntry.RecId == subledgerVoucherGeneralJournalEntry.GeneralJournalEntry ;
                  
        
         
        
        FiscalCalendarPeriod.clear();
        FiscalCalendarPeriod = FiscalCalendarPeriod::find(generalJournalEntry.FiscalCalendarPeriod);
        
        periodStartDate = FiscalCalendarPeriod.StartDate;
        periodEndDate = FiscalCalendarPeriod.EndDate;
        
        setPrefix('Case of posted journal');
        info(strFmt("Period start date: %1", periodStartDate));
        info(strFmt("Period end date: %1", periodEndDate));
        
    }


  • Zeeshan Adeel Profile Picture
    335 on at

    Bundle of thanks brother.

    exactly matches my requirement.

    you are a true champ and such a nice buddy. very helpful.

    regards

    zeeshan

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