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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
Quintiq file version 2.0
#parent: #root
StaticMethod ValidateInput (
  output String feedback_o,
  output String sanitycheckfeedback_o,
  Product_MP product,
  StockingPoint_MP stockingpoint,
  Date start,
  Boolean hasminlevelindays,
  Real minlevelindays,
  Real minlevelinquantity,
  Boolean hasmaxlevel,
  Boolean hasmaxlevelindays,
  Real maxlevelindays,
  Real maxlevelinquantity,
  InventorySpecification inventoryspecification,
  Boolean checkunique
) declarative remote as Boolean
{
  Description: 'Check for input obtained from UI'
  TextBody:
  [*
    feedback_o := '';
    sanitycheckfeedback_o := '';
    
    pisp := guard( select( product, ProductInStockingPoint_MP, ps, ps.StockingPoint_MP() = stockingpoint ), null( ProductInStockingPoint_MP ) );
    allownegativeinventory := guard( pisp.PISPSpecification().IsNegativeInventoryAllowed(), false );
    // Has product
    if( isnull( product ) )
    {
      feedback_o := Translations::MP_InventorySpecification_ValidateInput_IsNullProduct();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    
    // Has stocking point
    else if( isnull( stockingpoint ) )
    {
      feedback_o := Translations::MP_InventorySpecification_ValidateInput_IsNullStockingPoint();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Is unique
    else if( checkunique
             and not InventorySpecification::IsPrimaryKeysUnique( product, stockingpoint, start, inventoryspecification ) )
    {
      feedback_o := Translations::MP_InventorySpecification_ValidateInput_IsNotUnique();
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Has min level in day and value is empty
    else if( hasminlevelindays
             and ( minlevelindays.IsInfinite() or not allownegativeinventory and minlevelindays < 0.0 ) )
    {
      feedback_o := ifexpr( minlevelindays.IsFinite(),
                            Translations::MP_InventorySpecification_ValidateInput_IsNegativeMinLevelInDays( minlevelindays ),
                            Translations::MP_InventorySpecification_ValidateInput_IsEmptyInput( Translations::MP_InventorySpecification_FieldName( Translations::MP_WebDesigner_MinInventoryLevel(),
                                                                                                                                                   hasminlevelindays ) ) );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    // Has min quantity and value is empty
    else if( not hasminlevelindays
             and ( minlevelinquantity.IsInfinite() or ( not allownegativeinventory and minlevelinquantity < 0.0 ) ) )
    {
      feedback_o := ifexpr( minlevelinquantity.IsFinite(),
                            Translations::MP_InventorySpecification_ValidateInput_IsNegativeMinLevelInQuantity( minlevelinquantity ),
                            Translations::MP_InventorySpecification_ValidateInput_IsEmptyInput( Translations::MP_InventorySpecification_FieldName( Translations::MP_WebDesigner_MinInventoryLevel(),
                                                                                                                                                   hasminlevelindays ) ) );
      sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
    }
    else if( hasmaxlevel )
    {
      if( hasmaxlevelindays ) // has max in days
      {
        if( maxlevelindays < 0.0 )
        {
          feedback_o := ifexpr( maxlevelindays.IsFinite(), 
                                Translations::MP_InventorySpecification_ValidateInput_IsNegativeMaxLevelInDays( maxlevelindays ),
                                Translations::MP_InventorySpecification_ValidateInput_IsEmptyInput( Translations::MP_InventorySpecification_FieldName ( Translations::MP_WebDesigner_MaxInventoryLevel(),
                                                                                                                                                      hasmaxlevelindays ) ) );
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
        }
        /*else if( hastargetindays and maxlevelindays < targetindays ) // max in days < target in days
        {
          feedback_o := Translations::MP_InventorySpecification_ValidateInput_IsMaxLevelInDaysLessThanTargetInDays( maxlevelindays, targetindays );
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
        }*/
        else if( hasminlevelindays and maxlevelindays < minlevelindays ) // max in days < min in days
        {
          feedback_o := Translations::MP_InventorySpecification_ValidateInput_IsMaxLevelInDaysLessThanMinLevelInDays( maxlevelindays, minlevelindays );
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
        }
      }
      else // has max in quantity
      {
        if( maxlevelinquantity < 0.0 )
        {
          feedback_o := ifexpr( maxlevelinquantity.IsFinite(),
                                Translations::MP_InventorySpecification_ValidateInput_IsNegativeMaxLevelInQuantity( maxlevelinquantity ),
                                Translations::MP_InventorySpecification_ValidateInput_IsEmptyInput( Translations::MP_InventorySpecification_FieldName ( Translations::MP_WebDesigner_MaxInventoryLevel(),
                                                                                                                                                        hasmaxlevelindays ) ) );
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
        }
        /*else if( not hastargetindays and maxlevelinquantity < targetinquantity ) // max in quantity < target in quantity
        {
          feedback_o := Translations::MP_InventorySpecification_ValidateInput_IsMaxLevelInQuantityLessThanTargetInQuantity( maxlevelinquantity, targetinquantity );
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
        }*/
        else if( not hasminlevelindays and maxlevelinquantity < minlevelinquantity ) // max in quantity < min in quantity
        {
          feedback_o := Translations::MP_InventorySpecification_ValidateInput_IsMaxLevelInQuantityLessThanMinLevelInQuantity( maxlevelinquantity, minlevelinquantity );
          sanitycheckfeedback_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();
        }
      }
    }
    
    if( feedback_o <> '' )
    {
      name := MacroPlan::GetSubstituteName( guard( product.Name(), '' ) );
      instance := Translations::MP_InventorySpecification_Instance( name, start );
    
      feedback_o := SanityCheckMessage::GetFormattedMessage( instance, feedback_o );
    }
    
    return feedback_o = '';
  *]
}