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();
    }
  *]
}
