| Quintiq file version 2.0 | 
| #parent: #root | 
| Method Update ( | 
|   String id, | 
|   String timeunit, | 
|   Number nroftimeunit, | 
|   DateTime startofcurrentperiod, | 
|   Number nrofhistoricalperiod, | 
|   Number nroffutureperiod, | 
|   Boolean synchronize, | 
|   Boolean isfromdb, | 
|   Boolean isusedforplanning, | 
|   Boolean iscleanupactuals | 
| ) | 
| { | 
|   Description: 'Update this period definition' | 
|   TextBody: | 
|   [* | 
|      // DWE2 Apr-25-2016 (modified) | 
|     this.UpdateTypeIndex( id ); | 
|      | 
|     this.TimeUnit( timeunit ); | 
|     this.NrOfTimeUnit( nroftimeunit ); | 
|     this.PeriodAlignment( startofcurrentperiod ); | 
|     this.NrOfHistoricalPeriod( nrofhistoricalperiod ); | 
|     this.NrOfFuturePeriod( nroffutureperiod ); | 
|     this.IsManuallyConfigured( not isfromdb ); | 
|     this.IsUsedForPlanning( isusedforplanning ); | 
|     isupdateforshelflifeoptimizer := this.MacroPlan().GetIsPeriodUpdateForShelfLifeOptimizer();  | 
|      | 
|     if( synchronize ) | 
|     { | 
|       this.SynchronizePeriodsAndBasePeriods(); | 
|      | 
|       // 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,  | 
|                           not isupdateforshelflifeoptimizer or ( pisp.Product_MP().HasShelfLifeOrMaturation() ) );  | 
|      | 
|       this.MacroPlan().CreateProductInStockingPointInPeriod( pisps, periods, false /*isondelete*/ ); | 
|      | 
|       // Update sales demand | 
|       if ( not isupdateforshelflifeoptimizer )  | 
|       { | 
|         Forecast::SynchronizeSalesDemand( this.MacroPlan(), false ); | 
|       } | 
|     } | 
|      | 
|     if( iscleanupactuals ) | 
|     { | 
|       this.MacroPlan().CleanUpActuals(); | 
|     } | 
|      | 
|     //Update unit calendar window when the period horizon changes | 
|     if ( not isupdateforshelflifeoptimizer )  | 
|     { | 
|       this.MacroPlan().UpdateUnitCalendar(); | 
|     } | 
|   *] | 
| } |