admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;
  *]
}