Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method CalcEngineCost ( 
 | 
  BaseSalesDemandInPeriods psdips, 
 | 
  LogisticsCostEngines enginecosts 
 | 
) as Real 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    // 甄兰鸽 Nov-14-2024 (created)  
 | 
    outcost          := 0.0; 
 | 
    enginecost       := selectobject( enginecosts, Elements, engine, engine.StartDate() <= this.StartDate() and engine.EndDate() >= this.EndDate() ); 
 | 
    if( isnull( enginecost ) ){ 
 | 
      fenginecost    := selectobject( enginecosts, Elements, engine, engine.EndDate() > this.StartDate() and engine.EndDate() <= this.EndDate() and engine.StartDate() < this.StartDate() ); 
 | 
      if( not isnull( fenginecost ) ){ 
 | 
        quantity     := sum( psdips, Elements, psdip, psdip.StartDate() >= fenginecost.StartDate() and psdip.StartDate() <= fenginecost.EndDate(), psdip.Quantity() ); 
 | 
        outcost      := outcost + ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice(); 
 | 
      } 
 | 
      menginecost    := selectobject( enginecosts, Elements, engine, engine.StartDate() > this.StartDate() and engine.EndDate() < this.EndDate() ); 
 | 
      if( not isnull( menginecost ) ){ 
 | 
        quantity     := sum( psdips, Elements, psdip, psdip.StartDate() >= menginecost.StartDate() and psdip.StartDate() <= menginecost.EndDate(), psdip.Quantity() ); 
 | 
        outcost      := outcost + ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice(); 
 | 
      } 
 | 
      benginecost    := selectobject( enginecosts, Elements, engine, engine.StartDate() > this.StartDate() and engine.StartDate() <= this.EndDate() and engine.EndDate() > this.EndDate() ); 
 | 
      if( not isnull( benginecost ) ){ 
 | 
        quantity     := sum( psdips, Elements, psdip, psdip.StartDate() >= benginecost.StartDate() and psdip.StartDate() <= benginecost.EndDate(), psdip.Quantity() ) 
 | 
        outcost      := outcost + ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice(); 
 | 
      } 
 | 
    }else{ 
 | 
      quantity       := sum( psdips, Elements, psdip, psdip.Quantity() ); 
 | 
      outcost        := outcost + ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice(); 
 | 
    } 
 | 
    return outcost; 
 | 
  *] 
 | 
} 
 |