Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method Update ( 
 | 
  DateTime startofplanning, 
 | 
  PeriodSpecification_MP periodspecification, 
 | 
  Boolean iscleanupactuals, 
 | 
  Boolean isfromdb 
 | 
) 
 | 
{ 
 | 
  Description: 'Update method' 
 | 
  TextBody: 
 | 
  [* 
 | 
    this.StartOfPlanning( startofplanning ); 
 | 
    this.IsManuallyConfigured( not isfromdb ); 
 | 
    // We will roll the period by sequnce with the one have the earlsiest start. 
 | 
    sortedperiodspec := selectsortedset( this, MacroPlan.PeriodSpecification_MP, pspec,  
 | 
                                         not pspec.IsDummyPlanningPeriod(),  
 | 
                                         pspec.FirstInPeriodSpecification().Start() ); 
 | 
     
 | 
    traverse( sortedperiodspec, Elements, spec ) 
 | 
    { 
 | 
      // Only update alignment for the other period spec except the one being selected in the period form. (Period Roll) 
 | 
      updatealignment := spec <> periodspecification; 
 | 
      spec.SynchronizePeriodAlignment( startofplanning, updatealignment, isnull( periodspecification ), isfromdb ); 
 | 
    } 
 | 
     
 | 
    traverse( this, MacroPlan.PeriodSpecification_MP, pp ) 
 | 
    { 
 | 
      pp.SynchronizePeriods(); 
 | 
    } 
 | 
     
 | 
    this.MacroPlan().SynchronizeBasePeriods(); 
 | 
    this.MacroPlan().SynchronizeGapPlanningPeriods(); 
 | 
    if( iscleanupactuals ) 
 | 
    { 
 | 
      this.MacroPlan().CleanUpActuals(); 
 | 
    } 
 | 
     
 | 
    // We need to create pispips for new base periods 
 | 
    // Now that pispip has different subclasses, we need to 
 | 
    // recreate them whenever the following attributes change 
 | 
    // Product.IsLeaf, Period.IsBase and Period.IsPlanning 
 | 
    periods := selectset( this, MacroPlan.Period_MP, period, true ) 
 | 
    pisps := selectset( this.MacroPlan(), Product_MP.ProductInStockingPoint_MP, pisp, true ) 
 | 
    this.MacroPlan().CreateProductInStockingPointInPeriod( pisps, periods, false /*isondelete*/ ); 
 | 
     
 | 
    //Update unit calendar window when the period horizon changes 
 | 
    this.MacroPlan().UpdateUnitCalendar(); 
 | 
     
 | 
    //Set Campaign and its Transition history 
 | 
    this.MacroPlan().SetHistoricalCampaignAndTransition(); 
 | 
  *] 
 | 
} 
 |