| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod ValidateInput ( | 
|   output String feedback_o, | 
|   Unit unit, | 
|   DateTime start, | 
|   String timeunit, | 
|   Number nrofunit, | 
|   Real lotsize, | 
|   Real minimumperlot, | 
|   Real maximumquantity, | 
|   ShiftPattern shiftpattern, | 
|   TransportAvailability transportavailability, | 
|   Boolean checkunique, | 
|   output String sanitycheckfb_o | 
| ) declarative remote as Boolean | 
| { | 
|   Description: 'Check for input obtained from UI.' | 
|   TextBody: | 
|   [* | 
|     // Validate input for TransportAvailability | 
|     feedback_o := ''; | 
|     sanitycheckfb_o := ''; | 
|     gp := guard( unit.MacroPlan().GlobalParameters_MP(), null( GlobalParameters_MP ) ); | 
|      | 
|     // Check if the unit availability has unique primary keys | 
|     if( checkunique | 
|         and not TransportAvailability::IsPrimaryKeysUnique( unit, start, transportavailability ) ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_IsNotUnique(); | 
|       sanitycheckfb_o :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue() ; | 
|     } | 
|     // Check if shift pattern is provided | 
|     else if( isnull( shiftpattern ) ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_IsNullShiftPattern(); | 
|       sanitycheckfb_o :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue() ; | 
|     } | 
|     // Check if number of unit is larger than 0 | 
|     else if( nrofunit < 0 ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_IsNegativeNrOfUnits( nrofunit ); | 
|       sanitycheckfb_o :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue() ; | 
|     } | 
|     // Check if lot size is larger than 0 | 
|     else if( lotsize < 0 ) | 
|     { | 
|       feedback_o := Translations::MP_ValidateInput_IsNegativeLotSize( lotsize ); | 
|       sanitycheckfb_o :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue() ; | 
|     } | 
|     // Check if minimum per lot is larger than 0 | 
|     else if( minimumperlot < 0 ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_IsNegativeMinimumPerLot( minimumperlot ); | 
|       sanitycheckfb_o :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue() ; | 
|     } | 
|     // Check if lot size is larger than minimum per lot | 
|     else if( lotsize < minimumperlot ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_IsLotSizeLessThanMinPerLot( lotsize, minimumperlot ); | 
|       sanitycheckfb_o :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue() ; | 
|     } | 
|     // Check if max quantity is larger than 0 | 
|     else if( maximumquantity < 0.0 ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_IsNegativeMaxCapacity( maximumquantity ); | 
|       sanitycheckfb_o :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue() ; | 
|     } | 
|     // Check if max quantity is larger than lot size | 
|     else if( maximumquantity < lotsize ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_IsMaxCapacityLessThanLotSize( maximumquantity, lotsize ); | 
|       sanitycheckfb_o :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue() ; | 
|     } | 
|     // Check if max quantity is within the allowed range | 
|     else if( not isnull( gp ) and maximumquantity <> 0 | 
|              and not GlobalParameters_MP::GetIsValueWithinRange( maximumquantity, | 
|                                                                  gp.AbsoluteUpperLimit(), | 
|                                                                  gp.AbsoluteLowerLimit() ) ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_InvalidMaxCapacity( maximumquantity, | 
|                                                                                              gp.AbsoluteUpperLimit(), | 
|                                                                                              gp.AbsoluteLowerLimit() ); | 
|       sanitycheckfb_o :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue() ;                                                                                      | 
|     } | 
|     // Check if unit is provided | 
|     else if( isnull( unit ) ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_IsNullUnit(); | 
|       sanitycheckfb_o :=  SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning() ; | 
|     } | 
|      | 
|     // Add instance text if any of the preconditions above are violated | 
|     if( feedback_o <> '' ) | 
|     { | 
|       unitname := MacroPlan::GetSubstituteName( guard( unit.Name(), '' ) ); | 
|       feedback_o :=  SanityCheckMessage::GetFormattedMessage( Translations::MP_TransportAvailability_Instance( unitname, start ), | 
|                                                               feedback_o ); | 
|     } | 
|      | 
|     return feedback_o = ''; | 
|   *] | 
| } |