function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Murali DittakaviMurali Dittakavi 

How is the Period object populated?

Hi All, 
our organisation is set to 'Standard Fiscal Year' configuration.
we are using PeriodObject inside an Apex to get  various fiscal year Quarter dates.  we found some gaps in the table same as asked here (https://developer.salesforce.com/forums/?id=906F00000009BJgIAM)

as the answer says 'date fields' on the records.    which date fields  and what record objects  effects Period Object.  we don't want to  switch custom fiscal year. our apex code
Map<String, List<Period>> typeToPeriod = new Map<String, List<Period>>();
            Map<Id, Order> orderMap;
            String billingFrequency;
            Order orderRecord;

            for(Period period : [SELECT Type,StartDate,EndDate FROM Period
                                WHERE (CALENDAR_YEAR(StartDate) IN:yearSet OR CALENDAR_YEAR(StartDate) IN:yearSetAdd)
                                AND (TYPE =:PERIOD_TYPE_YEAR OR TYPE =:PERIOD_TYPE_QUARTER)]){
                if(typeToPeriod.get(period.Type) == null) {
                    typeToPeriod.put(period.Type, new List<Period>());
                }
                    typeToPeriod.get(period.Type).add(period);
            }
            orderMap = new Map<Id, Order>([SELECT Id, Account.Billing_Frequency__c, Product_Category__c
                                        FROM Order WHERE Id IN :orderIds]);

            for (OrderItem orderItemRecord : orderItemUpdatedList){
                orderRecord = orderMap.get(orderItemRecord.OrderId);
                billingFrequency = (orderRecord.Account.Billing_Frequency__c == 'Annually')
                    ? PERIOD_TYPE_YEAR
                    : PERIOD_TYPE_QUARTER;
                for(Period periodlevel : typeToPeriod.get(billingFrequency)){
                    if (orderItemRecord.blng__NextChargeDate__c >= periodlevel.StartDate &&
                        orderItemRecord.blng__NextChargeDate__c <= periodlevel.EndDate){