Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Function CalcTotalOpeningCost 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    value := 0.0; 
 | 
     
 | 
    if( not isnull( this.Previous() ) ) 
 | 
    { 
 | 
      nrpreviousunit := this.Previous().NrOfOpen() 
 | 
      nrcurrentunit := this.NrOfOpen() 
 | 
      if( nrpreviousunit < nrcurrentunit ) 
 | 
      { 
 | 
        //Open new 
 | 
        value := value + ( nrcurrentunit - nrpreviousunit ) * this.CostToOpenANewUnit(); 
 | 
      } 
 | 
    } 
 | 
    else 
 | 
    { 
 | 
      //value := value + nrofopen * this.CostToOpenANewUnit(); 
 | 
      nrofopen := this.NrOfOpen() 
 | 
     
 | 
      if( nrofopen > this.MacroPlan().GlobalParameters_MP().DefaultNumberOfUnits() ) 
 | 
      { 
 | 
        value := value + ( nrofopen - this.MacroPlan().GlobalParameters_MP().DefaultNumberOfUnits() ) * this.CostToOpenANewUnit(); 
 | 
      } 
 | 
    } 
 | 
     
 | 
    this.TotalOpeningCost( value ); 
 | 
  *] 
 | 
} 
 |