From b1a0a49947bc7c9806f4d3b6277375ef543dbccf Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期四, 14 十一月 2024 18:19:14 +0800
Subject: [PATCH] 物流报表部分费用支持跨月

---
 _Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl |   45 ++++++++++++++++++---------------------------
 1 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
index 6c8de34..493fd05 100644
--- a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
@@ -7,7 +7,7 @@
   TextBody:
   [*
     // 鐢勫叞楦� Aug-12-2024 (created)
-    owner.CCEngineLogisticsCostReport( relflush );
+    //owner.CCEngineLogisticsCostReport( relflush );
     produtparent              := CCEngineLogisticsCostReport::GetDefaultProductParent();
     name                      := CCEngineLogisticsCostReport::GetDefaultName();
     allunit                   := CCEngineLogisticsCostReport::GetDefaultAllUnit();
@@ -20,9 +20,17 @@
     //startofyear               := startofplanning.StartOfYear();
     startofnextyear           := startofplanning.StartOfNextYear();
     
-    table                     := owner.CCEngineLogisticsCostReport( relnew, ID := name, Name := name );
-    owner.CCEngineLogisticsCostReport( relnew, ID := name + 'Show', Name := name, IsShow := true );
-    owner.CCEngineLogisticsCostSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit );
+    table                     := selectobject(owner, CCEngineLogisticsCostReport, report, report.ID() = name );
+    if( isnull( table ) ){
+      owner.CCEngineLogisticsCostReport( relnew, ID := name, Name := name );
+    }
+    showname                  := name + 'Show';
+    if( exists( owner, CCEngineLogisticsCostReport, report, report.ID() = showname and report.IsShow() ) ){
+      owner.CCEngineLogisticsCostReport( relnew, ID := showname, Name := name, IsShow := true );
+    }
+    if( isnull( owner.CCEngineLogisticsCostSearch() ) ){
+      owner.CCEngineLogisticsCostSearch( relnew, Generation := allunit, MqbMlb := allunit, Power := allunit );
+    }
     
     products                  := construct( Product_MPs );
     
@@ -130,33 +138,16 @@
         if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
           row                := table.GetRow( pisp.ProductID() );
           products.Add( product );
-          //褰損roduct planning鐨勬棩鏈熷尯闂村湪闇�瑕佺殑鏃ユ湡鍖洪棿鍐� 
-    //      traverse( table, Column, column ){
-    //        pispips          := selectset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.PlannedInventoryLevelEnd() <> 0 
-    //                                       and pispip.Start().Date() < column.StartDate().StartOfNextMonth() and pispip.Start().Date() >= column.StartDate() );
+          traverse( table, Column, column ){
             
-          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.PlannedInventoryLevelEnd() <> 0 ){
-            enginecost     := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date() );
-            if( not isnull( enginecost ) ){
-              periodtime   := pispip.Start().StartOfMonth().Date();
-              periodname   := periodtime.Format( "M2/D2/Y" );
-              quantity     := ceil( pispip.PlannedInventoryLevelEnd() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
-                  
-              column       := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
-                  
-              row.SetRentStorageCost( column, quantity ); 
-            }
+            pispips          := selectset( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start().Date() >= column.StartDate() 
+                                            and pispip.Start().Date() < column.StartDate().StartOfNextMonth() 
+                                            and pispip.PlannedInventoryLevelEnd() <> 0 );
+            cost             := column.CalcEngineCost( pispips, enginecosts );
+            row.SetRentStorageCost( column, cost ); 
           }
         }
       }
     }
-    //rows := selectsortedset( table, Row, row, row.Name() );
-    //i    := 0;
-    //traverse( rows, Elements, e ){
-    //  e.RowNr( i );
-    //  i := i + 1;
-    //}
-    //
-    //showtable.Generate( search, products );
   *]
 }

--
Gitblit v1.9.3