| Quintiq file version 2.0 | 
| #parent: #root | 
| Method GetBaseCostForHour ( | 
|   UnitAccount unitaccount | 
| ) declarative remote as Real | 
| { | 
|   Description: | 
|   [* | 
|     The cost calculated base on time. | 
|     e.g: 100/Day,trip duration 5 days, cost = 100 * 5 = 500 | 
|   *] | 
|   TextBody: | 
|   [* | 
|     // desmondt Jun-1-2015 (created) | 
|     value := 0.0; | 
|      | 
|     if( this.HasValidDeparture() ) | 
|     { | 
|       accountcost := this.LaneLeg().GetCost( unitaccount, this.DepartureUnitPeriod() ); | 
|       // 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( cost > 0 ) | 
|         { | 
|           ratio := PeriodSpecification_MP::GetLengthOfTimeAndTimeUnitRatio( this.DepartureUnitPeriod(), accountcost ) | 
|           pfactor := guard( ratio / this.DepartureUnitPeriod().Duration().HoursAsReal(), 0 ); | 
|      | 
|           value := cost | 
|                    * pfactor | 
|                    * guard( this.DepartureUnitPeriod().CurrencyInPeriod().Rate(), 1.0 ) | 
|                    * this.LeadTime().HoursAsReal(); | 
|         } | 
|       } | 
|     } | 
|      | 
|     return value; | 
|   *] | 
| } |