yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
MultiTransaction ExecutePeriodRoll (
  DateTime rollto,
  PeriodSpecification_MP periodspecification
)
{
  Description: 'Roll to the given date. Using multitransaction to break down the transaction such that it consume lesser memory.'
  ExecuteContinuous: true
  FreeMemory: true
  OnFailureText:
  [*
    debuginfo( "Period roll failed!", errormessage );
    this.IsRollingPeriod( false ); // Set IsRollingPeriod to false if fails
    this.UpdateLastPlanningAction( false, false, true, false ); // isReset, isPlan, isRoll, isLockUnlock
  *]
  Priority: 'Default'
  ReleaseHistory: true
  Text:
  [*
    /* IMPORTANT NOTE
    The period roll goes by this sequence:
    1) Set MP.IsRollingPeriod to true
    2) Synchronize periods, in this synchronize, no instance will be deleted, they will be set to IsDeleted to assume is deleted
    3) Aggregation/Disaggregation
    4) Delete all obsolte instances
    5) Set MP.IsRollingPeriod to false
    */
    stopcondition := false;
    
    if ( step = 0 )
    {
      // Synchronize all periods
      this.PeriodParameter_MP().Update( rollto, periodspecification, false, false );
    }
    else if ( step = 1 )
    {
      this.HandlePostPeriodRollPeriodTaskOperations();
    }
    else if ( step = 2 )
    {
     this.HandlePostPeriodRollSalesDemands();
     this.HandlePostPeriodRollGlobalParameters();
    }
    else if ( step = 3 )
    {
      // Clean up
      this.DeleteObsoletePeriodAndCleanObsoletePeriodTasks();
      this.IsRollingPeriod( false );
      this.CleanUpActuals();
    }
    this.UpdateLastPlanningAction( false, false, true, false ); // isReset, isPlan, isRoll, isLockUnlock
    return step = 3 or stopcondition;
  *]
}