Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method GetBaseCostPerQuantityForHour ( 
 | 
  const AccountAssignment aa, 
 | 
  const UnitPeriod unitperiod, 
 | 
  Real reqcapacity 
 | 
) const declarative remote as Real 
 | 
{ 
 | 
  Description: 'Calculate cost per hour. Table methods cannot be remote, therefore this method is created to cater the usage in remote and non-remote scope.' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // soh yee Jan-21-2015 (moved) 
 | 
    value := 0.0; 
 | 
    if( this.AsProcess_MP().HasCapacityTypeTimeBase() ) 
 | 
    { 
 | 
     
 | 
      accountcost := this.GetCost( aa, unitperiod ); 
 | 
     
 | 
      // we still need a null check because there is a chance that no accountcost is found 
 | 
      if( not isnull( accountcost ) ) 
 | 
      { 
 | 
        cost := accountcost.Cost(); 
 | 
     
 | 
        //convert cost per time unit into cost per quantity 
 | 
        if( reqcapacity > 0 and cost > 0 ) 
 | 
        { 
 | 
          ratio := PeriodSpecification_MP::GetLengthOfTimeAndTimeUnitRatio( unitperiod, accountcost ) 
 | 
          pfactor := guard( ratio / unitperiod.Duration().HoursAsReal(), 0 ); 
 | 
     
 | 
          value :=  ( 1 / reqcapacity * cost ) 
 | 
                    * guard( unitperiod.CurrencyInPeriod().Rate(), 1.0 ) 
 | 
                    * pfactor; 
 | 
        } 
 | 
      } 
 | 
    } 
 | 
     
 | 
    return value; 
 | 
  *] 
 | 
} 
 |