Lai,Risheng
2023-11-02 30c02e0c981b16be0918483543f4b812956c45d4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Quintiq file version 2.0
#parent: #root
Method UpdatePeriodSelections (
  PeriodSpecification_MP periodspec,
  Number past,
  Number future
) id:Method_ApplicationMacroPlanner_UpdatePeriodSelections
{
  #keys: '[138546.0.807232637]'
  Body:
  [*
    // Extract pastindex number of historical periods from start of planning
    // and futureindex number of future periods into data holder periods
    startofplanning := ifexpr( periodspec.IsDummyPlanningPeriod(), 
                               MacroPlan.StartOfPlanningPeriod(),
                               periodspec.StartOfPlanningPeriod() );
    if( not isnull( startofplanning ) )
    {
      periods := selectsortedset( periodspec, PeriodSpecificationPeriod.Period_MP, period, true, period.Start() );
      
      index := periods.Find( startofplanning );
      pastindex := index - past;
      futureindex := index + future;
      periods:= guard( periods.SelectRange( pastindex, futureindex ), &periods );
      
      DataHolderPeriods.Data( periods.Copy() );
    }
    else
    {
      DataHolderPeriods.Data().Flush();
    }
  *]
}