| Quintiq file version 2.0 | 
| #parent: #root | 
| Method CalcEngineCost ( | 
|   ProductInStockingPointInPeriods pispips, | 
|   LogisticsCostEngines enginecosts, | 
|   LogisticsCostTransports transcosts, | 
|   String factory, | 
|   output Real entercost, | 
|   output Real othercost, | 
|   output Real outcost, | 
|   output Real storecost, | 
|   output Real transcost | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     // 甄兰鸽 Nov-14-2024 (created)  | 
|     enginecost       := selectobject( enginecosts, Elements, engine, engine.StartDate() <= this.StartDate() and engine.EndDate() >= this.EndDate() and engine.Factory() = factory ); | 
|     if( isnull( enginecost ) ){ | 
|       fenginecost    := selectobject( enginecosts, Elements, engine, engine.EndDate() > this.StartDate() and engine.EndDate() <= this.EndDate() and engine.StartDate() < this.StartDate() and engine.Factory() = factory ); | 
|       if( not isnull( fenginecost ) ){ | 
|         fpispips     := selectset( pispips, Elements, pispip, pispip.Start().Date() >= fenginecost.StartDate() and pispip.Start().Date() <= fenginecost.EndDate() ); | 
|         if( not entercost.IsMaxInfinity() ){ | 
|           newsqty    := sum( fpispips, Elements, e, e.NewSupplyQuantity() ); | 
|           entercost  := entercost + ceil( newsqty / fenginecost.PackagingCapacity() ) * fenginecost.WarehousingPrice(); | 
|         } | 
|         if( not othercost.IsMaxInfinity() ){ | 
|           newsqty    := sum( fpispips, Elements, e, e.NewSupplyQuantity() ); | 
|           othercost  := othercost + ceil( newsqty / fenginecost.PackagingCapacity() ) * fenginecost.OtherPrice(); | 
|         } | 
|         if( not outcost.IsMaxInfinity() ){ | 
|           newsqty    := sum( fpispips, Elements, e, e.NewSupplyQuantity() ); | 
|           outcost    := outcost + ceil( newsqty / fenginecost.PackagingCapacity() ) * fenginecost.OutboundPrice(); | 
|         } | 
|         if( not storecost.IsMaxInfinity() ){ | 
|           pinvqty    := sum( fpispips, Elements, e, e.PlannedInventoryLevelEnd() ); | 
|           storecost  := storecost + ceil( pinvqty / fenginecost.PackagingCapacity() ) * fenginecost.StoragePrice();//四舍五入 | 
|         } | 
|         if( not transcost.IsMaxInfinity() ){ | 
|           this.CalcTransCost( fpispips, transcosts, fenginecost, transcost ); | 
|         } | 
|       } | 
|       menginecost    := selectobject( enginecosts, Elements, engine, engine.StartDate() > this.StartDate() and engine.EndDate() < this.EndDate() and engine.Factory() = factory ); | 
|       if( not isnull( menginecost ) ){ | 
|         mpispips     := selectset( pispips, Elements, pispip, pispip.Start().Date() >= menginecost.StartDate() and pispip.Start().Date() <= menginecost.EndDate() ); | 
|         if( not entercost.IsMaxInfinity() ){ | 
|           newsqty    := sum( mpispips, Elements, e, e.NewSupplyQuantity() ); | 
|           entercost  := entercost + ceil( newsqty / menginecost.PackagingCapacity() ) * menginecost.WarehousingPrice(); | 
|         } | 
|         if( not othercost.IsMaxInfinity() ){ | 
|           newsqty    := sum( mpispips, Elements, e, e.NewSupplyQuantity() ); | 
|           othercost  := othercost + ceil( newsqty / menginecost.PackagingCapacity() ) * menginecost.OtherPrice(); | 
|         } | 
|         if( not outcost.IsMaxInfinity() ){ | 
|           newsqty    := sum( mpispips, Elements, e, e.NewSupplyQuantity() ); | 
|           outcost    := outcost + ceil( newsqty / menginecost.PackagingCapacity() ) * menginecost.OutboundPrice(); | 
|         } | 
|         if( not storecost.IsMaxInfinity() ){ | 
|           pinvqty    := sum( mpispips, Elements, e, e.PlannedInventoryLevelEnd() ); | 
|           storecost  := storecost + ceil( pinvqty / menginecost.PackagingCapacity() ) * menginecost.StoragePrice();//四舍五入 | 
|         } | 
|         if( not transcost.IsMaxInfinity() ){ | 
|           this.CalcTransCost( mpispips, transcosts, menginecost, transcost ); | 
|         } | 
|       } | 
|       benginecost    := selectobject( enginecosts, Elements, engine, engine.StartDate() > this.StartDate() and engine.StartDate() <= this.EndDate() and engine.EndDate() > this.EndDate() and engine.Factory() = factory ); | 
|       if( not isnull( benginecost ) ){ | 
|         bpispips     := selectset( pispips, Elements, pispip, pispip.Start().Date() >= benginecost.StartDate() and pispip.Start().Date() <= benginecost.EndDate() ) | 
|         if( not entercost.IsMaxInfinity() ){ | 
|           newsqty    := sum( bpispips, Elements, e, e.NewSupplyQuantity() ); | 
|           entercost  := entercost + ceil( newsqty / benginecost.PackagingCapacity() ) * benginecost.WarehousingPrice(); | 
|         } | 
|         if( not othercost.IsMaxInfinity() ){ | 
|           newsqty    := sum( bpispips, Elements, e, e.NewSupplyQuantity() ); | 
|           othercost  := othercost + ceil( newsqty / benginecost.PackagingCapacity() ) * benginecost.OtherPrice(); | 
|         } | 
|         if( not outcost.IsMaxInfinity() ){ | 
|           newsqty    := sum( bpispips, Elements, e, e.NewSupplyQuantity() ); | 
|           outcost    := outcost + ceil( newsqty / benginecost.PackagingCapacity() ) * benginecost.OutboundPrice(); | 
|         } | 
|         if( not storecost.IsMaxInfinity() ){ | 
|           pinvqty    := sum( bpispips, Elements, e, e.PlannedInventoryLevelEnd() ); | 
|           storecost  := storecost + ceil( pinvqty / benginecost.PackagingCapacity() ) * benginecost.StoragePrice();//四舍五入 | 
|         } | 
|         if( not transcost.IsMaxInfinity() ){ | 
|           this.CalcTransCost( bpispips, transcosts, benginecost, transcost ); | 
|         } | 
|       } | 
|     }else{ | 
|       if( not entercost.IsMaxInfinity() ){ | 
|         newsqty      := sum( pispips, Elements, pispip, pispip.NewSupplyQuantity() ); | 
|         entercost    := entercost + ceil( newsqty / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice(); | 
|       } | 
|       if( not othercost.IsMaxInfinity() ){ | 
|         newsqty      := sum( pispips, Elements, pispip, pispip.NewSupplyQuantity() ); | 
|         othercost    := othercost + ceil( newsqty / enginecost.PackagingCapacity() ) * enginecost.OtherPrice(); | 
|       } | 
|       if( not outcost.IsMaxInfinity() ){ | 
|         newsqty      := sum( pispips, Elements, pispip, pispip.NewSupplyQuantity() ); | 
|         outcost      := outcost + ceil( newsqty / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice(); | 
|       } | 
|       if( not storecost.IsMaxInfinity() ){ | 
|         pinvqty      := sum( pispips, Elements, pispip, pispip.PlannedInventoryLevelEnd() ); | 
|         storecost    := storecost + ceil( pinvqty / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//四舍五入 | 
|       } | 
|       if( not transcost.IsMaxInfinity() ){ | 
|         this.CalcTransCost( pispips, transcosts, enginecost, transcost ); | 
|       } | 
|     } | 
|   *] | 
| } |