Thursday, April 16, 2015

Fiscal calendar period dates and status

Financial calendars can be created and accessed from General ledger > Setup > Financial calendars.

Fiscal calendar periods status (Open, On hold and Closed) can be changed from General ledger > Setup > Ledger > button.












Following job can be used to  get Start and End date of current Fiscal year

static void fiscalCalendarDates(Args _args)
{
    PeriodStart     periodStartDate;
    PeriodEnd       periodEndDate;

    periodStartDate = FiscalCalendarYear::findYearByCalendarDate(CompanyInfo::fiscalCalendarRecId(), systemDateGet()).StartDate;
    periodEndDate   = FiscalCalendarYear::findYearByCalendarDate(CompanyInfo::fiscalCalendarRecId(), systemDateGet()).EndDate;

    info(strFmt("%1", periodStartDate));
    info(strFmt("%1", periodEndDate));

    periodStartDate = FiscalCalendars::findFirstDayofYear(Ledger::find(Ledger::current()).FiscalCalendar, systemDateGet());
    periodEndDate   = FiscalCalendars::findLastDayofYear(Ledger::find(Ledger::current()).FiscalCalendar, systemDateGet());

    info(strFmt("%1", periodStartDate));
    info(strFmt("%1", periodEndDate));

}

Following job can be used to get the period status (Open, On hold and Closed)

static void checkFiscalCalendarPeriod(Args _args)
{
    TransDate               transDate = systemDateGet();
    RecId                   calendarRecId;
    FiscalCalendarPeriod    fiscalCalendarPeriod;

    calendarRecId = Ledger::fiscalCalendar(CompanyInfo::find().RecId);

    fiscalCalendarPeriod = FiscalCalendars::findPeriodByPeriodCodeDate(calendarRecId, transDate, FiscalPeriodType::Operating);


    if (transDate)
    {
        if (! fiscalCalendarPeriod)
        {
            checkFailed(strFmt("@SYS17614",date2StrUsr(transDate, DateFlags::FormatAll)));
        }

        if (fiscalCalendarPeriod.currentLedgerPeriodStatus() !=  FiscalPeriodStatus::Open)
        {
            checkFailed(strFmt("@SYS17615", date2StrUsr(transDate, DateFlags::FormatAll)));
        }
    }
}

4 comments:

  1. Very helpful for us and gained more knowledge from it. We are very greatful and thanks a lot.
    Microsoft Dynamics AX Training | Microsoft Dynamics CRM Online Training

    ReplyDelete
  2. nice post thanks given such helpful information more about MS Dynamics AX Microsoft Dynamics Online Tutorial

    ReplyDelete
  3. Great.
    Anyone that have tried to get the "mandatory" account/dimension set information from code ?

    ReplyDelete

I will appreciate your comments !

How to enable new Microsoft teams - Public Preview!

New Microsoft Teams is just AWESOME, quick but useful post below shows how you have this preview feature to make your life EASY!  Open Micr...