| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod ValidateInput ( | 
|   output String feedback_o, | 
|   Unit unit, | 
|   DateTime start, | 
|   String timeunit, | 
|   Real lotsize, | 
|   Real minimumquantity, | 
|   Real maximumquantity, | 
|   Boolean hassecondarycapacity, | 
|   Real secondarylotsize, | 
|   Real secondarymincapacity, | 
|   Real secondarymaxcapacity, | 
|   UnitOfMeasure_MP secondaryuom, | 
|   TransportCapacity transportcapacity, | 
|   Boolean checkunique, | 
|   output String sanitycheckfb_o | 
| ) declarative remote as Boolean | 
| { | 
|   Description: 'Check for input obtained from UI.' | 
|   TextBody: | 
|   [* | 
|     // Validate input for TransportCapacity | 
|     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 TransportCapacity::IsPrimaryKeysUnique( unit, start, transportcapacity ) ) | 
|     { | 
|       feedback_o := Translations::MP_TransportCapacity_ValidateInput_IsNotUnique(); | 
|       sanitycheckfb_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // check if lot size is larger than zero | 
|     else if( lotsize < 0 ) | 
|     { | 
|       feedback_o := Translations::MP_ValidateInput_IsNegativeLotSize( lotsize ); | 
|       sanitycheckfb_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // check for user capacity | 
|     // check if min quantity is larger than zero | 
|     else if( minimumquantity < 0.0 ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_IsNegativeMinCapacity( minimumquantity ); | 
|       sanitycheckfb_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // check if max quantity is larger than zero | 
|     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 min quantity is within the allowed range | 
|     else if( not isnull( gp ) and  minimumquantity <> 0 | 
|              and not GlobalParameters_MP::GetIsValueWithinRange( minimumquantity, | 
|                                                                  gp.AbsoluteUpperLimit(), | 
|                                                                  gp.AbsoluteLowerLimit() ) ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_IsInvalidMinCapacity( minimumquantity, | 
|                                                                                            gp.AbsoluteUpperLimit(), | 
|                                                                                            gp.AbsoluteLowerLimit() ); | 
|       sanitycheckfb_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue();                                                                                        | 
|     } | 
|     // check if min & max quantity conbination is valid | 
|     else if( minimumquantity > maximumquantity ) | 
|     { | 
|       feedback_o := Translations::MP_TransportAvailability_ValidateInput_IsMaxCapacityLessThanMinCpacity( maximumquantity, minimumquantity ); | 
|       sanitycheckfb_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataIssue(); | 
|     } | 
|     // check if unit is provided | 
|     else if( isnull( unit ) ) | 
|     { | 
|       feedback_o := Translations::MP_TransportCapacity_ValidateInput_IsNullUnit(); | 
|       sanitycheckfb_o := SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning(); | 
|     } | 
|      | 
|     // if previous has no error and has secondary capacity is checked, we need to validate the secondary capacity field | 
|     if( feedback_o = '' and hassecondarycapacity ) | 
|     { | 
|       TransportCapacity::GetHasValidSecondaryCapacityFields( feedback_o,  | 
|                                                              sanitycheckfb_o,   | 
|                                                              secondarylotsize,  | 
|                                                              secondarymincapacity, | 
|                                                              secondarymaxcapacity, | 
|                                                              secondaryuom, | 
|                                                              unit.UnitOfMeasureName(), | 
|                                                              gp ); | 
|     } | 
|      | 
|     // 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_TransportCapacity_Instance( unitname, start ), | 
|                                                               feedback_o ); | 
|     } | 
|      | 
|     return feedback_o = ''; | 
|   *] | 
| } |