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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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 );
      }
    }
  *]
}