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
Quintiq file version 2.0
#parent: #root
StaticMethod CanAddStockingPoint (
  output String feedback_o,
  StockingPointNodes stockingpointnodes,
  Lane lane,
  Boolean isorigin
) declarative remote as Boolean
{
  Description: 'Indicates if the stocking point(s) can be added to the lane.'
  TextBody:
  [*
    isvalid := true;
    
    // Check if any of the selected stocking point(s) is already added to the specific lane
    traverse( stockingpointnodes, Elements, stockingpointnode )
    {
      // Check if the stocking point(s) can be added as origin of the lane
      if( isorigin )
      {
        if( exists( lane, Origin.StockingPoint_MP, sp, sp = stockingpointnode.StockingPoint_MP() ) )
        {
          isvalid := false;
          feedback_o := Translations::MP_StockingPointInLane_CanAdd();
        }
      }
      // Check if the stocking point(s) can be added as destination of the lane
      else 
      {
        if( exists( lane, Destination.StockingPoint_MP, sp, sp = stockingpointnode.StockingPoint_MP() ) )
        {
          isvalid := false;
          feedback_o := Translations::MP_StockingPointInLane_CanAdd();
        }
      }
    }
    
    return isvalid;
  *]
}