Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Function CalcKPIUpperBound 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    value := Real::MaxReal();  
 | 
    if ( not this.KPIIsAccount() )  
 | 
    { 
 | 
      if ( this.KPIIsMaximize() )  
 | 
      { 
 | 
        if ( this.KPIName() = Translations::MP_GlobalParameters_KPIFulfillmentTargetName() )  
 | 
        { 
 | 
          value := sum( this, StrategyMacroPlan.MacroPlan.FulfillmentTarget, ft, ft.IsEnabled(), ft.TargetPercentage() * ft.TotalDemandQuantity() / 100 );  
 | 
        } 
 | 
        else if ( this.KPIName() = Translations::MP_GlobalParameters_KPIFulfillmentName() )  
 | 
        { 
 | 
          value := sum( this, StrategyMacroPlan.MacroPlan.SalesDemand, sd, true, sd.QuantityInDefaultUoM() );  
 | 
        } 
 | 
        else if ( this.KPIName() = Translations::MP_GlobalParameters_KPISalesDemandPriorityName() )  
 | 
        { 
 | 
          value := sum( this, StrategyMacroPlan.MacroPlan.SalesDemand, sd, sd.QuantityInDefaultUoM() * guard( sd.Priority().Weight(), 1.0 ) );  
 | 
        } 
 | 
         
 | 
        if ( this.KPIName() = Translations::MP_GlobalParameters_KPICampaignName() ) 
 | 
        { 
 | 
          value := ifexpr(  this.StrategyMacroPlan().UseCampaignSequenceOptimizer(), 0.0, Real::MaxReal() ) // non-sequencing campaign goal includes transition output, so we assume no a prior bound, seq optimizer computes penalties only 
 | 
        } 
 | 
      } 
 | 
      else 
 | 
      { 
 | 
        value := 0.0; // penalty KPI, know best score is 0 
 | 
      } 
 | 
    } 
 | 
    this.KPIUpperBound( value ); 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |