LedgerPeriod - Commentaries Question

I currently use the following method to identify the relevant financial period name (which is stored in the ledgerperiod.Commentaries field:

void period()
{
ledgerperiod lperiod;

while select lperiod
where ledgertrans_1.TransDate >= lperiod.PeriodStart
&& ledgertrans_1.TransDate <= lperiod.PeriodEnd
&& lperiod.PeriodCode == 1
{
PeriodNo = lperiod.Commentaries;
break;
}
}

PeriodStart,PeriodEnd,PeriodCode columns in the ledgerPeriod is used to identify the correct record (in this case the relevant financial period). Ledger periods are recorded in the set of date ranges like

PeriodStart= March 1 … PeriodEnd = March 30 …PeriodCode= Normal, … Commentaries = Period 3 (name of period for example )

Now if your transaction “LedgerTrans” recorded in the range of March1 to March 30, then LedgerPeriod will always give you “period 3”. it just simply matches the date of transaction in the ledgerPeriod record.

My Question


I would appreciate it if anyone could confirm how AX works this out. How does AX understand that when looking at the transdate of for example March 1st, that it should return period 3.

I’m very keen on understanding this and if there are any other tables that use this type of logic. As a programmer how would you know AX has this type of logic. Are they books or case studies available describing this? If so I would appreciate feedback on this as well.

Thanks and kind regards,

Tom

When I add a break point to my period method and run in debug mode. I can see that AX knows that the ledgerperiod.periodstart >= 01/03/2011 and that the ledgerperiod.periodend <= 31/03/2011 when the transdate equals 01/03/2011.

How does AX know the correct periodstart and periodend date???

For example, why is it not picking out ledgerperiod.periodstart >= 01/04/2011 abd <= 30/04/2011 (April) instead??

Would appreciate your feedback regarding this top of interest.

Kind regards,
Tom

The periods will be created based on your selection of Length and Units during the creation of a Fiscal Year.

The transaction date should belong to any one of these created periods. So the system picks up the period - in which the transaction date lies…

It depends how you have created the periods…