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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Quintiq file version 2.0
#parent: #root
Method GetHasValidQuantity (
  output Strings feedback_o,
  output Strings sanitycheckfeedback_o
) declarative remote as Boolean
{
  Description: 'Returns true if the operation link has valid quantity.'
  TextBody:
  [*
    message := '';
    sanitychecktype := '';
    
    // Check if OperationLink has valid quantities
    hasvalidsourceqty := this.SourceQuantity() > 0;
    hasvaliddestqty := this.DestQuantity() > 0;
    hasvaliddestminqty := this.DestMinQuantity() >= 0;
    hasvaliddestmaxqty := this.DestMaxQuantity() > 0;
    hasvaliddestrange := this.DestMaxQuantity() >= this.DestMinQuantity();
    hasvaliddestgroupqty := this.DestGroupQuantity() > 0;
    
    isvalid := hasvalidsourceqty
               and hasvaliddestqty
               and hasvaliddestminqty
               and hasvaliddestmaxqty
               and hasvaliddestrange
               and hasvaliddestgroupqty;
    
    // Add feedbacks if the OperationLink has invalid qunatities
    if( not isnull( feedback_o ) and not isvalid )
    {
      // Add feedback if OperationLink has invalid source quantity
      if( not hasvalidsourceqty )
      {
        message := Translations::MP_OperationLink_GetHasValidQuantity_InvalidSourceQuantity( this.SourceQuantity() );
        sanitychecktype :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
      }
      // Add feedback if OperationLink has invalid destination quantity
      else if( not hasvaliddestqty )
      {
        message := Translations::MP_OperationLink_GetHasValidQuantity_InvalidDestinationQuantity( this.DestQuantity() );
        sanitychecktype :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
      }
      // Add feedback if OperationLink has invalid destination min quantity
      else if( not hasvaliddestminqty )
      {
        message := Translations::MP_OperationLink_GetHasValidQuantity_InvalidDestinationMinQuantity( this.DestMinQuantity() );
        sanitychecktype :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
      }
      // Add feedback if OperationLink has invalid destination max quantity
      else if( not hasvaliddestmaxqty )
      {
        message := Translations::MP_OperationLink_GetHasValidQuantity_InvalidDestinationMaxQuantity( this.DestMaxQuantity() );
        sanitychecktype :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
      }
      // Add feedback if OperationLink has invalid range for destination min and max quantity combination
      else if( not hasvaliddestrange )
      {
        message := Translations::MP_OperationLink_GetHasValidQuantity_InvalidRange( this.DestMaxQuantity(),
                                                                                    this.DestMinQuantity() );
        sanitychecktype :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
      }
      // Add feedback if OperationLink has invalid destination group quantity
      else if( not hasvaliddestgroupqty )
      {
        message := Translations::MP_OperationLink_GetHasValidQuantity_InvalidDestinationGroupQuantity( this.DestGroupQuantity() );
        sanitychecktype :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
      }
    
      // Add feedback text
      instance := OperationLink::GetInstanceText( this );
      feedback_o.Add( SanityCheckMessage::GetFormattedMessage( instance, message ) );
      sanitycheckfeedback_o.Add( sanitychecktype );
    }
    
    return isvalid;
  *]
}