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
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  MacroPlan macroplan,
  Boolean isenabled,
  Boolean hasstart,
  Date start,
  Boolean hasend,
  Date end,
  Boolean hasuserleadtime,
  Duration leadtime,
  Real co2Emission,
  LaneLeg laneleg
) declarative remote as Boolean
{
  Description: 'Validate input, triggered when user create lane leg from the UI or edit it.'
  TextBody:
  [*
    feedback_o := '';
    str := '';
    
    // Validate inputs
    if( not Process_MP::ValidateInput( str,
                                       sanitycheckfeedback_o,
                                       macroplan,
                                       laneleg.Lane().Unit(),
                                       laneleg.Name(),
                                       hasstart,
                                       start,
                                       hasend,
                                       end,
                                       false, // HasUserLotSize
                                       0.0, // UserMinimumQuantity
                                       false, // HasUserMaximumQuantity
                                       0.0, // UserMaximumQuantity
                                       0.0, // UserLotSize
                                       co2Emission, // co2 emission
                                       laneleg.DefinitionName() ) ) // As we need to re-use the translation
    {
      feedback_o := str;
    }
    else
    {
      // If LaneLeg is enabled, check if lead time is valid
      if( isenabled
          and ( hasuserleadtime and leadtime = Duration::Zero() ) )
      {
        feedback_o := Translations::MP_LaneLeg_ValidateInput_InvalidLeadTime( laneleg.Lane().Name() );
        sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
      }
    
      // Add feedback text if any of the preconditions above are violated
      if( feedback_o <> '' )
      {
        instancetext := Translations::MP_Process_Instance( LaneLeg::GetDefinitionName(), MacroPlan::GetSubstituteName( laneleg.Name() ) )
        feedback_o := SanityCheckMessage::GetFormattedMessage( instancetext, feedback_o );
      }    
    }
    
    return feedback_o = '';
  *]
}