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
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  Operation owner,
  OperationInputSet operationinputset,
  String name,
  Real minquantity,
  Real maxquantity
) declarative remote as Boolean
{
  Description: 'Validate input, triggered when user creates operation input set or edits it.'
  TextBody:
  [*
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    // Check if name is unique
    if( exists( owner, OperationInputSet, ois,
                ois <> operationinputset,
                ois.Name() = name ) )
    {
      feedback_o := Translations::MP_OperationInputSet_ValidateInput_IsNotUnique();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    // Check if minquantity is valid
    else if( minquantity < 0 )
    {
      feedback_o := Translations::MP_OperationInputSet_Validate_IsNegativeMinQuantity( minquantity );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    // Check if minquantity and maxquantity combination is valid
    else if( maxquantity < minquantity )
    {
      feedback_o := Translations::MP_OperationInputSet_ValidateInput_IsMaxQtyLessThanMinQty( maxquantity, minquantity );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    
    // Add feedback text if any of the precondition above is violated
    if( feedback_o <> '' )
    {
      instance := Translations::MP_OperationInputSet_Instance( name, owner.Name() );
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance, feedback_o );
    }
    
    return feedback_o = '';
  *]
}