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
Quintiq file version 2.0
#parent: #root
Method MPSyncShiftPattern (
  Boolean isoverwritemanualconfig,
  IOShiftPatterns ioshiftpatterns
)
{
  Description: 'Synchronization of ShiftPattern for MPSync'
  TextBody:
  [*
    
    existing := selectset( this, ShiftPattern, item, true );
    updates := construct( ShiftPatterns );
    
    traverse( ioshiftpatterns , Elements, io, io.IsValid() )
    {
      indexkey := io.Name();
      objectinstance := ShiftPattern::FindShiftPatternTypeIndex( indexkey );
      
      if( isnull( objectinstance ) )
      {
        objectinstance := ShiftPattern::Create( this, indexkey ,true );
      }
      if( guard( not objectinstance.IsManuallyConfigured() or isoverwritemanualconfig, false ) )
      {
        nrofdays := objectinstance.NumberOfDays();
        
        // Update shift pattern
        objectinstance.Update( indexkey,
                               nrofdays,
                               io.MinimumDuration(),
                               true );
        
        updates.Add( objectinstance );
      }
      if( not isnull( objectinstance ) )
      {
        objectinstance.CustomUpdate( io, isoverwritemanualconfig );
        this.MPSyncShiftDay( isoverwritemanualconfig, io, objectinstance );
      }
    }
    
    tobedeleteset := existing.Difference( updates );
    
    traverse( tobedeleteset, Elements, ele, not ele.IsManuallyConfigured() or isoverwritemanualconfig)
    {
      ele.Delete();
    }
  *]
}