From 7edeca2ed3587a88d7f94cacf05e49c8db610fb0 Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期四, 10 十月 2024 17:54:26 +0800
Subject: [PATCH] 发动机物流成本部分bug处理

---
 _Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl
index 47d9f59..aa66e0d 100644
--- a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl
+++ b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_InitializeNew.qbl
@@ -35,11 +35,11 @@
     traverse( owner, StockingPoint_MP, stockingpoint, stockingpoint.ID().EndsWith( '澶栫搴�' ) ){
     //  unit                    := stockingpoint.Unit();
     //  parentunits             := unit.GetAllParent();
-      //鏄惁灞炰簬闀挎槬澶栫搴�
+      //鏄惁灞炰簬闀挎槬澶栫搴撶敤浜庨暱鏄ュ绉熷簱浠撳偍璐圭敤
       isccrent                := stockingpoint.ID().StartsWith( '闀挎槬' ) or stockingpoint.ID().StartsWith( 'CC' );
-      //鏄惁灞炰簬澶ц繛鍙戝姩鏈虹殑闀挎槬澶栫搴�
+      //鏄惁灞炰簬澶ц繛鍙戝姩鏈虹殑闀挎槬澶栫搴撶敤浜庨暱鏄ュ叆搴�/鍑哄簱璐圭敤
       isdltoccrent            := stockingpoint.ID().StartsWith( '澶ц繛鍙戝姩鏈虹殑闀挎槬' );
-      //鏄惁灞炰簬澶ц繛澶栫搴�
+      //鏄惁灞炰簬澶ц繛澶栫搴撶敤浜庡ぇ杩炲绉熷簱浠撳偍璐圭敤
       isdlrent                := stockingpoint.ID().StartsWith( '澶ц繛' ) or stockingpoint.ID().StartsWith( 'DL' );
       if( isccrent or isdlrent ){
         traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() 
@@ -63,16 +63,15 @@
                   enginecost  := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date()
                                                      and engine.Factory() = ccfactory );
                    if( not isnull( enginecost ) ){
-                     quantity :=   [Number]pispip.NewSupplyQuantity();
                      if( isccrent ){
-                       cost        := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
-                       cell.CCRentStorCost( cell.CCRentStorCost() + cost );
+                       cost        := ceil( pispip.PlannedInventoryLevelEnd() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
+                       cell.CCRentStorCost( cell.CCRentStorCost() + cost );//闀挎槬澶栫搴撲粨鍌ㄨ垂鐢�
                      }else{
-                       cell.CCRentQuantity( cell.CCRentQuantity() + quantity );
-                       //闀挎槬澶栫搴撳叆搴撹垂鐢細鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环
-                       entercost  := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                       cell.CCRentQty( cell.CCRentQty() + pispip.NewSupplyQuantity() );
+                       //闀挎槬澶栫搴撳叆搴撹垂鐢細鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环 
+                       entercost  := ceil( pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
                        //闀挎槬澶栫搴撳嚭搴撹垂鐢�: 鍑哄簱閲�/鍖呰瀹归噺*鍑哄簱鍗曚环
-                       outcost    := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice();
+                       outcost    := ceil( pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice();
                        cell.CCRentInCost( cell.CCRentInCost() + entercost );
                        cell.CCRentOutOfCost( cell.CCRentOutOfCost() + outcost );
                      }
@@ -82,8 +81,8 @@
                   enginecost     := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date()
                                                      and engine.Factory() = dlfactory  );
                    if( not isnull( enginecost ) ){
-                     cost        := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
-                     cell.DLRentStorCost( cell.DLRentStorCost() + cost );
+                     cost        := ceil( [Number]pispip.PlannedInventoryLevelEnd() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
+                     cell.DLRentStorCost( cell.DLRentStorCost() + cost );//澶ц繛澶栫搴撲粨鍌ㄨ垂鐢�
                    }
                 }
               }   
@@ -242,18 +241,23 @@
           enginecosts         := selectset( owner, LogisticsCostEngine, engine, engine.PackagingCapacity() <> 0 and engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
                                                  and engine.Factory() = ccfactory );
+          //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
+          transcosts           := selectset( owner, LogisticsCostTransport, trans, trans.LoadingCapacity() <> 0 and trans.Origin() = '闀挎槬澶栫搴�'
+                                                  and trans.Destination() = '瀹㈡埛搴�'
+                                                  and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent,  e.ID() = trans.Product() ) ) );
           if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
             products.Add( forecast.Product_MP() );
             row               := table.GetRow( forecast.ProductID() );
             traverse( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() > 0 ){
               enginecost      := selectobject( enginecosts, Elements, engine, engine.StartDate() <= psdip.StartDate() and engine.EndDate() >= psdip.StartDate() );
+              transcost       := selectobject( transcosts, Elements, trans, trans.StartDate() <= psdip.StartDate() and trans.EndDate() >= psdip.StartDate() );
               if( not isnull( enginecost ) ){
                 periodtime    := psdip.StartDate().StartOfMonth();
                 periodname    := periodtime.Format( "M2/D2/Y" );
           //      info( '-------------------------', periodname, periodtime );
                 column         := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
           //      info( '-------------------------', column.Name() );
-                cost           := ceil( [Number]psdip.Quantity() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                cost           := ceil( ceil( [Number]psdip.Quantity() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();
                 cell           := selectobject( row, Cell, cell, cell.Column() = column );
                 cell.CCShorTransCost( cell.CCShorTransCost() + cost );
               }
@@ -269,7 +273,7 @@
       e.RowNr( i );
       i := i + 1;
     }
-    info( '-------------------------------------end---------------------------------' );
+    info( '-------------------------------------end----------------------------------' );
     //
     showtable.Generate( search, products );
   *]

--
Gitblit v1.9.3