haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  StockingPoint_MP stockingpoint,
  Product_MP product,
  Date start,
  Real factor,
  DisaggregationFactor old_disaggregationfactor,
  Boolean checkunique
) declarative remote as Boolean
{
  Description: 'Validate input, called from designer'
  TextBody:
  [*
    feedback_o := '';
    
    // Get product name
    productname :=  MacroPlan::GetSubstituteName( guard( product.Name(), '' ) );
    // Get formatted identification of product instance
    instance := Translations::MP_DisaggregationFactor_Instance( productname, start );
    
    // Check if stocking point is null
    if( isnull( stockingpoint ) )
    {
      feedback_o := Translations::MP_DisaggregationFactor_ValidateInput_IsNullStockingPoint();
    }
    // Check if product is null
    else if( isnull( product ) )
    {
      feedback_o := Translations::MP_DisaggregationFactor_ValidateInput_IsNullProduct();
    }
    // Check if the inventory value can be created.
    // For editing of inventory value, exclude itself from the checking of the primary key.
    else if( checkunique
             and not DisaggregationFactor::IsPrimaryKeysUnique( product, stockingpoint, start, old_disaggregationfactor ) )
    {
      feedback_o := Translations::MP_DisaggregationFactor_ValidateInput_IsNotUnique();
    }
    // Check if factor is valid
    else if( factor < 0 or factor > 1 )
    {
      feedback_o := Translations::MP_DisaggregationFactor_ValidateInput_InvalidFactor( factor );
    }
    
    // Format feedback text if nay of the precondtiions above are violated
    if( feedback_o <> '' )
    {
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance, feedback_o );
    }
    
    return feedback_o = '';
  *]
}