xiaoding721
2023-11-13 e4edcfd0b987b239526f5375881b919789782dad
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
Quintiq file version 2.0
#parent: #root
Method SetDefaultValue (
  StockingPointInPeriod stockingpointinperiod
) id:Method_DialogCreateEditStockingPointCapacity_SetDefaultValue
{
  #keys: '[107528.0.125967459]'
  Body:
  [*
    // Set the default value for the fields in the dialog.
    
    data := Dialog.Data();
    
    start := MacroPlan.Start().Date();
    maxcapacity := 0.0;
    
    if( not isnull( stockingpointinperiod ) )
    {
      // To inherit the value from last sp capacity while creating a new sp capacity
      stockingpointcapacity := stockingpointinperiod.StockingPointCapacity();
      start := stockingpointinperiod.Start().Date();
    
      if( not isnull( stockingpointcapacity ) )
      {
        maxcapacity := stockingpointcapacity.MaxCapacity();
      }
      else
      {
        maxcapacity := stockingpointinperiod.MaxCapacity();
      }
    }
    
    // Assigning value to Read-Only attribute will result in runtime error.
    if( isnull( data.WrappedInstance() ) )
    {
      data.Start( start );
    }
    
    data.MaxCapacity( maxcapacity );
    
    // In the case that the default stocking point cannot be found in the list of available stocking points,
    // the UOM should use the the currently selected stocking point's UOM
    // In order to set the UOM, we need to set the Dialog.Data's stocking point during initialization of the dialog
    availablestockingpoints := DataHolderChildStockingPoints.Data();
    if( not exists( availablestockingpoints, Elements, sp,
                    sp = data.StockingPoint_MP() ) )
    {
      stockingpoint := availablestockingpoints.Element( 0 );
      data.StockingPoint_MP( relset, stockingpoint );
    }
  *]
}