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
Quintiq file version 2.0
#parent: #root
StaticMethod GetChangeOfPlanningPeriodsAtEdition (
  MacroPlan macroplan,
  PeriodSpecification_MP periodspecification,
  Boolean isusedforplanning,
  DateTime periodalignment,
  Number nroftimeunit,
  String timeunit,
  Number nrofhistoricalperiod,
  Number nroffutureperiod,
  Boolean isnew
) declarative remote as Boolean
{
  Description: 'Returns TRUE if period specification creation/edition would result in modifications on planning periods.'
  TextBody:
  [*
    /*
    Warn user at period specification creation/edition in the following cases:
    - Create a planning period spec
    - Edit a period specification and change its isusedforplanning value (false>true or true>false)
    - Change duration of a planning period specification
    - Change period alignment of a planning period specification
    Warning will only be raised if plan contains period tasks with qty > 0
    */
    
    value := false;
    
    if( isnew )
    {
      value := isusedforplanning;
    }
    else
    {     
      if( ( isusedforplanning <> periodspecification.IsUsedForPlanning() )
          or( isusedforplanning
              and( nroftimeunit <> periodspecification.NrOfTimeUnit()
                   or nroffutureperiod <> periodspecification.NrOfFuturePeriod()
                   or nrofhistoricalperiod <> periodspecification.NrOfHistoricalPeriod()
                   or timeunit <> periodspecification.TimeUnit() ) ) )
      {
        value := true;
      }
    }
    
    hasperiodtasks := exists( macroplan, Unit.UnitPeriod.PeriodTask_MP, pt, pt.Quantity() > 0 );
    
    return value and hasperiodtasks;
  *]
}