| Quintiq file version 2.0 | 
| #parent: #root | 
| Method GetHasValidCapacityRange ( | 
|   output Strings feedback_o, | 
|   output Strings sanitycheckfeedback_o | 
| ) declarative remote as Boolean | 
| { | 
|   Description: 'Checks if the difference factor of the max and min capacity is within specified limits.' | 
|   TextBody: | 
|   [* | 
|     // Checks if the difference factor of the max and min capacity is within specified limits. | 
|     isvalid := true; | 
|     factorlimit := this.MacroPlan().GlobalParameters_MP().DifferenceFactor1e6(); | 
|      | 
|     //only check when not of transport type | 
|     if( ( this.HasCapacityTypeTransportBase() or this.HasCapacityTypeQuantity() ) | 
|         and this.MaxCapacity().IsFinite() | 
|         and this.MinCapacity().IsFinite() ) | 
|     { | 
|       differencefactor := guard( this.MaxCapacity() / this.MinCapacity(), this.MaxCapacity() ); | 
|       isvalid := differencefactor < factorlimit; | 
|     } | 
|      | 
|     // if not valid, we should provide feedback | 
|     if( not isnull( feedback_o ) and not isvalid ) | 
|     { | 
|       unitname := MacroPlan::GetSubstituteName( this.Name() ); | 
|       // format values, because translations does not support representations yet | 
|       formatfactorlimit := factorlimit.Format( "N(Dec(0), Thousands)" ); | 
|       formatmincapacity := this.MinCapacity().Format( "N(Dec(0), Thousands)" ); | 
|       formatmaxcapacity := this.MaxCapacity().Format( "N(Dec(0), Thousands)" ); | 
|       // the exact feedback depends on the capacity type at hand | 
|       if( this.HasCapacityTypeQuantity() ) | 
|       { | 
|         feedback_o.Add( SanityCheckMessage::GetFormattedMessage( Translations::MP_Unit_Instance( unitname ), | 
|                                                                  Translations::MP_Unit_ValidateInput_HasExtremeCapacityRange( formatmaxcapacity, formatmincapacity, formatfactorlimit  ) ) ); | 
|         sanitycheckfeedback_o.Add( SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning() ); | 
|       } | 
|       else if( this.HasCapacityTypeTransportBase() ) | 
|       { | 
|         feedback_o.Add( SanityCheckMessage::GetFormattedMessage( Translations::MP_Unit_Instance( unitname ), | 
|                                                                  Translations::MP_Unit_ValidateInput_HasExtremeTransportQuantityRange( formatmaxcapacity, formatmincapacity, formatfactorlimit  ) ) ); | 
|         sanitycheckfeedback_o.Add( SanityCheckCategoryLevel::GetSanityCheckCategoryDataWarning() ); | 
|       } | 
|     } | 
|      | 
|     return isvalid; | 
|   *] | 
| } |