admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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();
  *]
}