陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
54
55
56
57
58
59
60
61
62
63
64
65
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();
    }
  *]
}