| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod ValidateInput ( | 
|   output String feedback_o, | 
|   Unit unit, | 
|   Product_MP product, | 
|   DateTime start, | 
|   DateTime end, | 
|   Real minquantity, | 
|   Real targetquantity, | 
|   Boolean hasmaxquantity, | 
|   Real maxquantity, | 
|   SupplySpecification supplyspec, | 
|   Boolean checkunique, | 
|   output String sanitycheckfb | 
| ) declarative remote as Boolean | 
| { | 
|   Description: 'Check for input obtained from UI' | 
|   TextBody: | 
|   [* | 
|     // Validate input for SupplySpecifications | 
|     feedback_o := ''; | 
|      | 
|     // Check if the supply specification can be created. | 
|     // Check if the unit and product are null | 
|     if( isnull( unit ) ) | 
|     {  | 
|       feedback_o := Translations::MP_SupplySpecification_ValidateInput_IsNullUnit(); | 
|       sanitycheckfb := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); | 
|     } | 
|     else if( isnull( product ) ) | 
|     { | 
|       feedback_o := Translations::MP_SupplySpecification_ValidateInput_IsNullProduct(); | 
|       sanitycheckfb := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); | 
|     } | 
|     // Check if the primary keys are unique | 
|     else if( checkunique | 
|              and not SupplySpecification::IsPrimaryKeysUnique( unit, product, start, end, supplyspec ) ) | 
|     { | 
|       feedback_o := Translations::MP_SupplySpecification_ValidateInput_IsSupplySpecificationExists(); | 
|       sanitycheckfb := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     else if ( not exists( unit, AllChildren.AsChildren.Process_MP.ProcessOutput.ProductInStockingPoint_MP.Product_MP.AllParent.AsParent, p, p = product )) | 
|     { | 
|       feedback_o := Translations::MP_SupplySpecification_ValidateInput_NoOutputProduct( unit.Name(), product.Name()); | 
|       sanitycheckfb := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|      | 
|     // Check if start is larger than equals to end | 
|     else if( start >= end ) | 
|     { | 
|       feedback_o := Translations::MP_SupplySpecification_ValidateInput_IsStartAfterEnd( end, start ); | 
|       sanitycheckfb := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|      | 
|     // Check if min quantity is less than zero | 
|     else if( minquantity < 0 ) | 
|     { | 
|       feedback_o := Translations::MP_SupplySpecification_ValidateInput_IsNegativeMinQuantity( minquantity ); | 
|       sanitycheckfb := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // Check if target quantity is less than zero | 
|     else if( targetquantity < 0 ) | 
|     { | 
|       feedback_o := Translations::MP_SupplySpecification_ValidateInput_IsNegativeTargetQuantity( targetquantity ); | 
|       sanitycheckfb := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // Check if has max quantity | 
|     else if( hasmaxquantity ) | 
|     { | 
|       // Check if max quantity is valid | 
|       if( maxquantity < minquantity ) | 
|       { | 
|         feedback_o := Translations::MP_SupplySpecification_ValidateInput_IsMaxQuantityLessThanMinQuantity( maxquantity, minquantity ); | 
|         sanitycheckfb := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|       } | 
|       else if( maxquantity < targetquantity ) | 
|       { | 
|         feedback_o := Translations::MP_SupplySpecification_ValidateInput_IsMaxQuantityLessThanTargetQuantity( maxquantity, targetquantity ); | 
|         sanitycheckfb := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|       } | 
|       | 
|     } | 
|      | 
|     // Add instance text if any of the preconditions above are violated | 
|     if( feedback_o <> '' ) | 
|     { | 
|       unitname := MacroPlan::GetSubstituteName( guard( unit.Name(), '' ) ); | 
|       productname := MacroPlan::GetSubstituteName( guard( product.Name(), '' ) ); | 
|       feedback_o := SanityCheckMessage::GetFormattedMessage( Translations::MP_SupplySpecification_Instance( productname, unitname, start, end ), | 
|                                                              feedback_o ); | 
|     } | 
|      | 
|     return feedback_o = ''; | 
|   *] | 
| } |