| 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 = ''; | 
|   *] | 
| } |