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
Quintiq file version 2.0
#parent: #root
StaticMethod Delete (
  PeriodSpecification_MPs perioddefinitions
)
{
  Description: 'Delete multiple period definitions'
  TextBody:
  [*
    // Cannot use MacroPlan::DeleteObjects because the logic is different.
    
    macroplan := guard( perioddefinitions.Element( 0 ).MacroPlan(), null( MacroPlan ) );
    
    traverse( perioddefinitions, Elements, pdef )
    {
      pdef.Delete();
    }
    
    //Synchronize periods
    traverse( macroplan, PeriodSpecification_MP, periodspec )
    {
      periodspec.SynchronizePeriods();
    }
    
    if( not isnull( macroplan ) )
    {
      macroplan.SynchronizeBasePeriods();
      macroplan.SynchronizeGapPlanningPeriods();
    
      // 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( macroplan, Period_MP, period, true )
      pisps := selectset( macroplan, Product_MP.ProductInStockingPoint_MP, pisp, true )
      macroplan.CreateProductInStockingPointInPeriod( pisps, periods, false /*isondelete*/ );
    
      // when period spec is deleted, planning is not changed so just pass in false
      Forecast::SynchronizeSalesDemand( macroplan, false );
    }
  *]
}