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
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
StaticMethod ValidateInput (
  output String feedback_o,
  MacroPlan macroplan,
  Unit unit,
  String name,
  Boolean hasstart,
  Date start,
  Boolean hasend,
  Date end,
  Boolean hasuserlotsize,
  Real userminimumquantity,
  Boolean hasusermaximumquantity,
  Real usermaximumquantity,
  Real userlotsize,
  String processtype
) declarative remote as Boolean
{
  Description: 'Validate input, triggered when user create operation from the UI or edit it.'
  TextBody:
  [*
    feedback_o := '';
    lengthlimit := GlobalParameters_MP::GetLengthOfNames();
    
    if( isnull( unit ) )
    {
      feedback_o := Translations::MP_Process_ValidateInput_IsNullUnit( processtype );
    }
    // name should not be blank and name length should not be more than length limit
    else if( name = '' or name.Length() > lengthlimit )
    {
      feedback_o := Translations::MP_Process_ValidateInput_IsNameEmpty( lengthlimit, processtype );
    }
    else if( hasend and hasstart and ( start >= end ) )
    {
      feedback_o := Translations::MP_Process_ValidateInput_IsStartDateAfterEndDate( end, start );
    }
    // if has user lot size, check the remaining
    else if( hasuserlotsize )
    {
      if( userminimumquantity < 0 )
      {
        feedback_o := Translations::MP_Process_ValidateInput_IsNegativeMinimumQuantity( userminimumquantity );
      }
      else if( hasusermaximumquantity
               and usermaximumquantity < 0 ) // check only when hasusermaxquantity is true
      {
        feedback_o := Translations::MP_Process_ValidateInput_IsNegativeMaximumQuantity( usermaximumquantity );
      }
      else if( userlotsize < 0 )
      {
        feedback_o := Translations::MP_ValidateInput_IsNegativeLotSize( userlotsize );
      }
      else if( hasusermaximumquantity
               and userminimumquantity > usermaximumquantity )
      {
        feedback_o := Translations::MP_Process_ValidateInput_IsMinimumQuantityGreaterThanMaximumQuantity( usermaximumquantity, userminimumquantity );
      }
    
      else if( hasusermaximumquantity
               and userlotsize > usermaximumquantity )
      {
        feedback_o := Translations::MP_Process_ValidateInput_IsLotSizeGreaterThanMaximumQuantity( usermaximumquantity, userlotsize );
      }
    }
    
    if( feedback_o <> '' )
    {
      processname := MacroPlan::GetSubstituteName( name );
      // add instance text
      feedback_o := SanityCheckMessage::GetFormattedMessage( Translations::MP_Process_Instance( processtype, processname ),
                                                             feedback_o );
    }
    
    return feedback_o = '';
  *]
}