11 May 2021

X++ code to check Fiscal calendar period in AX 2012 and D365FO

X++ code to check Fiscal calendar period in AX 2012 and D365FO 

used to get the period status (Open, On hold and Closed)

  public static boolean checkFiscalCalendarPeriod(TransDate _transDate)

    {

        RecId calendarRecId;

        FiscalCalendarPeriod fiscalCalendarPeriod;


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


        fiscalCalendarPeriod = FiscalCalendarPeriod::findPeriodByCalendarDate(calendarRecId, _transDate, FiscalPeriodType::Operating);


        if (_transDate)

        {

            if (!fiscalCalendarPeriod)

            {

                return checkFailed(strFmt("@SYS17614",date2StrUsr(_transDate, DateFlags::FormatAll)));

            }


            if (fiscalCalendarPeriod.currentLedgerPeriodStatus() != FiscalPeriodStatus::Open)

            {

                return checkFailed(strFmt("@SYS17615", date2StrUsr(_transDate, DateFlags::FormatAll)));

            }

        }


        return true;

    }

1 comment:

Give me the commetns and solutions

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension-...