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
36
Quintiq file version 2.0
#parent: #root
Method CalcTransCost (
  ProductInTrips pits,
  LogisticsCostTransports transcosts,
  LogisticsCostEngine enginecost
) as Real
{
  TextBody:
  [*
    // 甄兰鸽 Nov-14-2024 (created) 
    transcost        := 0.0
    tran             := selectobject( transcosts, Elements, trans, trans.StartDate() <= this.StartDate() and trans.EndDate() >= this.StartDate() );
    if( isnull( tran ) ){
      ftranscost     := selectobject( transcosts, Elements, trans, trans.EndDate() > this.StartDate() and this.EndDate() <= this.EndDate() and trans.StartDate() < this.StartDate() );
      if( not isnull( ftranscost ) ){
        newsqty      := sum( pits, Elements, pit, pit.Trip().Arrival().Date() >= ftranscost.StartDate() and pit.Trip().Arrival().Date() <= ftranscost.EndDate(), pit.Quantity() );
        transcost    := transcost + ceil( ceil( newsqty / enginecost.PackagingCapacity() ) / ftranscost.LoadingCapacity() ) * ftranscost.TransportPrice();
      }
      mtranscost     := selectobject( transcosts, Elements, trans, trans.StartDate() > this.StartDate() and trans.EndDate() < this.EndDate() );
      if( not isnull( mtranscost ) ){
        newsqty      := sum( pits, Elements, pit, pit.Trip().Arrival().Date() >= mtranscost.StartDate() and pit.Trip().Arrival().Date() <= mtranscost.EndDate(), pit.Quantity() );
        transcost    := transcost + ceil( ceil( newsqty / enginecost.PackagingCapacity() ) / mtranscost.LoadingCapacity() ) * mtranscost.TransportPrice();
      }
      btranscost    := selectobject( transcosts, Elements, trans, trans.StartDate() > this.StartDate() and trans.StartDate() <= this.EndDate() and trans.EndDate() > this.EndDate() );
      if( not isnull( btranscost ) ){
        newsqty      := sum( pits, Elements, pit, pit.Trip().Arrival().Date() >= btranscost.StartDate() and pit.Trip().Arrival().Date() <= btranscost.EndDate(), pit.Quantity() );
        transcost    := transcost + ceil( ceil( newsqty / enginecost.PackagingCapacity() ) / btranscost.LoadingCapacity() ) * btranscost.TransportPrice();
      }
    }else{
      newsqty        := sum( pits, Elements, pit, pit.Quantity() );
      transcost      := transcost + ceil( ceil( newsqty / enginecost.PackagingCapacity() ) / tran.LoadingCapacity() ) * tran.TransportPrice();
    }
    return transcost;
  *]
}