From bcd7eb876bff759f6aef96f1014b0bca7a3322ff Mon Sep 17 00:00:00 2001
From: rislai <risheng.lai@capgemini.com>
Date: 星期五, 16 八月 2024 15:53:14 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev

---
 _Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl |   51 +++++++++++++++++++++++++++++----------------------
 1 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl b/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl
index cf1176e..31f6bcd 100644
--- a/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl
@@ -32,7 +32,8 @@
     table.GenerateColumn( owner );
     
     //棣栧厛鍦╢orecast鐣岄潰鏌ユ壘sales segment涓洪暱鏄ョ殑鎵�鏈夐渶姹傦紝璇嗗埆鍑篗LB鐨勬墍鏈変骇鍝侊紝姣忎釜浜у搧鎸夋湀姹囨�婚渶姹傛暟閲�
-    traverse( owner, SalesDemand.astype( Forecast ), forecast, forecast.StartDate() < startofnextyear ){
+    traverse( owner, SalesDemand.astype( Forecast ), forecast, not isnull( forecast.SalesSegment_MP() ) and forecast.StartDate() < startofnextyear and forecast.Quantity() <> 0 
+              and exists( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() <> 0 ) ){
       salessegment            := forecast.SalesSegment_MP();
       parentsalessegments     := salessegment.GetAllParent();
       //鏄惁灞炰簬闀挎槬
@@ -46,20 +47,18 @@
       if( ( iscc and forecast.Product_MP().MQBMLB() = 'MLB' ) or isdl ){
         product              := forecast.Product_MP();
         //鑾峰彇鍚堣琛�
-        allrow               := table.GetRow( allunit, product.ID() );
+        allrow               := table.GetRow( allunit, product );
         //鑾峰彇宸ュ巶琛�
-        factoryrow           := table.GetRow( ifexpr( iscc and forecast.Product_MP().MQBMLB() = 'MLB', ccunit, dlunit ), product.ID() );
+        factoryrow           := table.GetRow( ifexpr( iscc and forecast.Product_MP().MQBMLB() = 'MLB', ccunit, dlunit ), product );
       
-        if( products.Find( product ) < 0 ){
-          products.Add( product );
-        }
-        traverse( forecast, PlanningSalesDemandInPeriod, psdip ){
+        products.Add( product );
+        traverse( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() <> 0 ){
           periodtime         := psdip.StartDate().StartOfMonth();
           periodname         := periodtime.Format( "M2/D2/Y" );
     //      info( '-------------------------', periodname, periodtime );
           column             := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime );
     //      info( '-------------------------', column.Name() );
-          quantity   := ceil( psdip.Quantity() );//鍚戜笂鍙栨暣
+          quantity   := [Number]psdip.Quantity();//鍥涜垗浜斿叆
           
           factoryrow.Initialize( column, quantity );
           allrow.Initialize( column, quantity );
@@ -73,14 +72,17 @@
       //鏄惁灞炰簬闀挎槬瑁呴厤绾�
     //  iscc                  := unit.ID() = ccspline or exists( parentunits, Elements, punit, punit.ID() = ccspline );
       if( table.IsInUnit( stockingpoint, ccspline ) ){
-        traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() and pisp.Product_MP().MQBMLB() = 'MQB' ){//浜у搧涓篗QB
-          allrow            := table.GetRow( allunit, pisp.ProductID() );
-          ccrow             := table.GetRow( ccunit, pisp.ProductID() );
-          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear ){
+        traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() and pisp.Product_MP().MQBMLB() = 'MQB' 
+                  and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.DependentDemandAndSalesDemandQuantity() <> 0 ) ){//浜у搧涓篗QB
+          product           := pisp.Product_MP();
+          allrow            := table.GetRow( allunit, product );
+          ccrow             := table.GetRow( ccunit, product );
+          products.Add( product );
+          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.DependentDemandAndSalesDemandQuantity() <> 0 ){
             periodtime      := pispip.Start().StartOfMonth().Date();
             periodname      := periodtime.Format( "M2/D2/Y" );
             column          := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime );
-            quantity        := ceil( pispip.DependentDemandAndSalesDemandQuantity() );//鍚戜笂鍙栨暣
+            quantity        := [Number]pispip.DependentDemandAndSalesDemandQuantity();//鍥涜垗浜斿叆
             
             ccrow.Initialize( column, quantity );//鍙朤otal Demand瀛楁鎸夋湀姹囨�婚渶姹傛暟閲�
             allrow.Initialize( column, quantity );
@@ -98,18 +100,23 @@
       destisp               := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.DestinationStockingPointID() );
       isccrent              := table.IsInUnit( destisp, ccrent );
       if( isdlspline and isccrent ){
-        traverse( laneleg, Trip, trip, trip.Arrival() < startofnextyearlead ){
-          periodtime        := ( trip.Arrival() - FinancialSalesReport::GetDefaultTripLeadingTime() ).StartOfMonth().Date();
+        traverse( laneleg, Trip, trip, trip.Arrival() < startofnextyearlead and exists( trip, ProductInTrip, pit, pit.Quantity() <> 0 ) ){
+    //      periodtime        := ( trip.Arrival() - FinancialSalesReport::GetDefaultTripLeadingTime() ).StartOfMonth().Date();
+          periodtime        := trip.Departure().StartOfMonth().Date();
           periodname        := periodtime.Format( "M2/D2/Y" );
           
           column            := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime );
-          traverse( trip, ProductInTrip, pit ){
-            quantity        := ceil( pit.Quantity() );//鍚戜笂鍙栨暣
-            dlrow           := table.GetRow( dlunit, pit.ProductID() );
-            dlrow.Initialize( column, quantity );//姹囨�绘暟閲�
-            
-            allrow          := table.GetRow( allunit, pit.ProductID() );
-            allrow.Initialize( column, quantity );
+          if( not isnull( column ) ){
+            traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
+              product       := pit.Product_MP();
+              products.Add( product );
+              quantity      := [Number]pit.Quantity();//鍥涜垗浜斿叆
+              dlrow         := table.GetRow( dlunit, pit.Product_MP() );
+              dlrow.Initialize( column, quantity );//姹囨�绘暟閲�
+              
+              allrow        := table.GetRow( allunit, pit.Product_MP() );
+              allrow.Initialize( column, quantity );
+            }
           }
         }
       }

--
Gitblit v1.9.3