lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  StockingPoint_MP stockingpoint,
  Date start,
  Real maxcapacity,
  StockingPointCapacity stockingpointcapacity,
  Boolean checkunique
) declarative remote as Boolean
{
  Description: 'Check for input obtained from UI'
  TextBody:
  [*
    // Validate input from UI
    feedback_o := '';
    sanitycheckfeedback_o := '';
    gp := guard( stockingpoint.MacroPlan().GlobalParameters_MP(), null( GlobalParameters_MP ) );
    
    // Check if the primary keys is unique
    if( checkunique
        and not StockingPointCapacity::IsPrimaryKeysUnique( stockingpoint, start, stockingpointcapacity ) )
    {
      feedback_o := Translations::MP_StockingPointCapacity_ValidateInput_IsNotUnique();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if max capacity is less than zero
    else if( maxcapacity < 0.0 )
    {
      feedback_o := Translations::MP_StockingPointCapacity_ValidateInput_IsNegativeMaxCapacity( maxcapacity );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if max capacity is within the allowed range
    else if( maxcapacity <> 0
             and not GlobalParameters_MP::GetIsValueWithinRange( maxcapacity,
                                                                 gp.AbsoluteUpperLimit(),
                                                                 gp.AbsoluteLowerLimit() ) )
    {
      feedback_o := Translations::MP_StockingPointCapacity_ValidateInput_InvalidMaxCapacity( maxcapacity,
                                                                                             gp.AbsoluteUpperLimit(),
                                                                                             gp.AbsoluteLowerLimit() );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Check if stocking point is null
    else if( isnull( stockingpoint ) )
    {
      feedback_o := Translations::MP_StockingPointCapacity_ValidateInput_IsNullStockingPoint();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning();
    }
    
    // Add instance text if any of the preconditions above are violated
    if( feedback_o <> '' )
    {
      spname := MacroPlan::GetSubstituteName( guard( stockingpoint.Name(), '' ) );
      feedback_o := SanityCheckMessage::GetFormattedMessage( Translations::MP_StockingPointCapacity_Instance( spname, start ),
                                                             feedback_o );
    }
    
    return feedback_o = '';
  *]
}