From 628700bb251d908486dd24dc225e5c9ac2cfada8 Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期二, 08 十月 2024 15:29:09 +0800
Subject: [PATCH] 财务产量/销量报表添加年汇总和往前串一天

---
 _Main/BL/Type_FinancialSalesReport/Method_Generate.qbl              |    8 ++++++++
 _Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl |   12 ++++++------
 _Main/BL/Type_FinancialSalesSource/StaticMethod_InitializeNew.qbl   |   14 +++++++-------
 _Main/BL/Type_FinancialProductionReport/Method_Generate.qbl         |    8 ++++++++
 4 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl b/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl
index 45e40f0..db27bd2 100644
--- a/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl
+++ b/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl
@@ -12,17 +12,23 @@
     allunit    := '<All>';
     //娓呯┖涔嬪墠瀛樺偍鐨勬樉绀烘暟鎹�
     this.Clear();
+    //骞存眹鎬�
+    yearcolumn := this.FinancialProductionColumn( relnew, Name := '姹囨��', Period := search.MacroPlan().StartOfPlanning().StartOfNextYear().Date() );
     //杩囨护鍚庣殑浜у搧id
     productids := selectuniquevalues( products, Elements, product, ( search.Generation() = allunit or product.Generation() = search.Generation() )
                                       and ( search.MqbMlb() = allunit or product.MQBMLB() = search.MqbMlb() )
                                       and ( search.Power() = allunit or product.Power() = search.Power() ), product.ID() );
     sumrow     := this.FinancialProductionRow( relnew, Name := 'SUM', Unit := search.Unit(), RowNr := table.FinancialProductionRow( relsize ) );
+    sumyearcell := yearcolumn.FinancialProductionCell( relnew, Quantity := 0 );
+    sumrow.FinancialProductionCell( relinsert, sumyearcell );
     traverse( table, FinancialProductionRow, row, row.Unit() = search.Unit() ){
       productid  := construct( Strings );
       productid.Add( row.Name() );
       
       if( productids.ContainsAll( productid ) ){
         showrow := this.FinancialProductionRow( relnew, Name := row.Name(), Unit := row.Unit(), RowNr := row.RowNr() );
+        yearcell := yearcolumn.FinancialProductionCell( relnew, Quantity := 0 );
+        showrow.FinancialProductionCell( relinsert, yearcell );
         
         traverse( row, FinancialProductionCell, cell, not cell.FinancialProductionColumn().IsDay() ){
           column   := selectobject( this, FinancialProductionColumn, column, column.Name() = cell.FinancialProductionColumn().Name() and not column.IsDay() );
@@ -35,6 +41,8 @@
           
           showcell := column.FinancialProductionCell( relnew, Quantity := cell.Quantity() );
           showrow.FinancialProductionCell( relinsert, showcell );
+          yearcell.Quantity( yearcell.Quantity() + cell.Quantity() );
+          sumyearcell.Quantity( sumyearcell.Quantity() + cell.Quantity() );
     //      value := [Real]cell.Value() + [Real]sumcell.Value();
           sumcell.Quantity( sumcell.Quantity() + cell.Quantity() );
         }
diff --git a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
index 0aa4ae5..541eafb 100644
--- a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
@@ -20,8 +20,8 @@
     table                     := source.FinancialProductionReport( relnew, ID := source.Name(), Name := source.Name(), IsImport := false );
     showtable                 := source.FinancialProductionReport( relnew, ID := source.Name() + 'Show', Name := source.Name(), IsImport := false, IsShow := true );
     startofplanning           := owner.StartOfPlanning().Date();
-    //startofnextmonth          := startofplanning.StartOfNextMonth();
-    startofnextyear           := startofplanning.StartOfNextYear();
+    startofyear               := ( startofplanning.StartOfYear() - Duration::Days( 1 ) ).Date();
+    startofnextyear           := ( startofplanning.StartOfNextYear() - Duration::Days( 1 ) ).Date();
     
     search                    := owner.FinancialProductionSearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit );
     
@@ -47,17 +47,17 @@
     //  isdl                    := unit.ID() = dlalienunit or unit.ID() = dlmplineunit  or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit );
       if( iscc or isdl ){
         traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() 
-                  and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ) ){
+                  and exists( pisp, ProductInStockingPointInPeriod, pispip, pispip.Period_MP().StartDate() >= startofyear and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ) ){
           //鑾峰彇宸ュ巶琛�
           factoryrow          := table.GetRowByUnit( pisp.Product_MP(), ifexpr( iscc, ccunit, dlunit ) );
           //鑾峰彇鍚堣琛�
           allrow              := table.GetRowByUnit( pisp.Product_MP(), allunit );
           products.Add( pisp.Product_MP() );
           //褰損roduct planning鐨勬棩鏈熷尯闂村湪闇�瑕佺殑鏃ユ湡鍖洪棿鍐� 
-          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ){
-            dayperiodtime     := pispip.Start().Date();
+          traverse( pisp, ProductInStockingPointInPeriod, pispip, pispip.Period_MP().StartDate() >= startofyear and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ){
+            dayperiodtime     := ( pispip.Start() + Duration::Days( 1 ) ).Date();
             dayperiodname     := dayperiodtime.Format( "M2/D2/Y" );
-            periodtime        := pispip.Start().StartOfMonth().Date();
+            periodtime        := dayperiodtime.StartOfMonth();
             periodname        := periodtime.Format( "M2/D2/Y" );
     //        quantity          := [Number]pispip.NewSupplyQuantity();//鍥涜垗浜斿叆
             daycolumn         := selectobject( table, FinancialProductionColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
diff --git a/_Main/BL/Type_FinancialSalesReport/Method_Generate.qbl b/_Main/BL/Type_FinancialSalesReport/Method_Generate.qbl
index 4c67240..d62492f 100644
--- a/_Main/BL/Type_FinancialSalesReport/Method_Generate.qbl
+++ b/_Main/BL/Type_FinancialSalesReport/Method_Generate.qbl
@@ -12,17 +12,23 @@
     allunit    := '<All>';
     //娓呯┖涔嬪墠瀛樺偍鐨勬樉绀烘暟鎹�
     this.Clear();
+    //骞存眹鎬�
+    yearcolumn := this.FinancialSalesColumn( relnew, Name := '姹囨��', Period := search.MacroPlan().StartOfPlanning().StartOfNextYear().Date() );
     //杩囨护鍚庣殑浜у搧id
     productids := selectuniquevalues( products, Elements, product, ( search.Generation() = allunit or product.Generation() = search.Generation() )
                                       and ( search.MqbMlb() = allunit or product.MQBMLB() = search.MqbMlb() )
                                       and ( search.Power() = allunit or product.Power() = search.Power() ), product.ID() );
     sumrow     := this.FinancialSalesRow( relnew, Name := 'SUM', Unit := search.Unit(), RowNr := table.FinancialSalesRow( relsize ) );
+    sumyearcell := yearcolumn.FinancialSalesCell( relnew, Value := '0' );
+    sumrow.FinancialSalesCell( relinsert, sumyearcell );
     traverse( table, FinancialSalesRow, row, row.Unit() = search.Unit() ){
       productid  := construct( Strings );
       productid.Add( row.Name() );
       
       if( productids.ContainsAll( productid ) ){
         showrow := this.FinancialSalesRow( relnew, Name := row.Name(), Unit := row.Unit(), RowNr := row.RowNr() );
+        yearcell := yearcolumn.FinancialSalesCell( relnew, Value := '0' );
+        showrow.FinancialSalesCell( relinsert, yearcell );
         
         traverse( row, FinancialSalesCell, cell, not cell.FinancialSalesColumn().IsDay() ){
           column   := selectobject( this, FinancialSalesColumn, column, column.Name() = cell.FinancialSalesColumn().Name() and not column.IsDay());
@@ -35,6 +41,8 @@
           
           showcell := column.FinancialSalesCell( relnew, Value := cell.Value() );
           showrow.FinancialSalesCell( relinsert, showcell );
+          yearcell.Value( [String]( [Real]yearcell.Value() + [Real]cell.Value() ) );
+          sumyearcell.Value( [String]( [Real]sumyearcell.Value() + [Real]cell.Value() ) );
           value := [Real]cell.Value() + [Real]sumcell.Value();
           sumcell.Value( [String]value );
         }
diff --git a/_Main/BL/Type_FinancialSalesSource/StaticMethod_InitializeNew.qbl b/_Main/BL/Type_FinancialSalesSource/StaticMethod_InitializeNew.qbl
index bfd4632..4afd265 100644
--- a/_Main/BL/Type_FinancialSalesSource/StaticMethod_InitializeNew.qbl
+++ b/_Main/BL/Type_FinancialSalesSource/StaticMethod_InitializeNew.qbl
@@ -24,15 +24,15 @@
     table                     := source.FinancialSalesReport( relnew, ID := source.Name(), Name := source.Name(), IsImport := false );
     showtable                 := source.FinancialSalesReport( relnew, ID := source.Name() + 'Show', Name := source.Name(), IsImport := false, IsShow := true );
     startofplanning           := owner.StartOfPlanning().Date();
-    //startofyear               := startofplanning.StartOfYear();
-    startofnextyear           := startofplanning.StartOfNextYear();
+    startofyear               := ( startofplanning.StartOfYear() - Duration::Days( 1 ) ).Date();
+    startofnextyear           := ( startofplanning.StartOfNextYear() - Duration::Days( 1 ) ).Date();
     
     search                    := owner.FinancialSalesSearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit );
     
     table.GenerateColumn( owner );
     
     //棣栧厛鍦╢orecast鐣岄潰鏌ユ壘sales segment涓洪暱鏄ョ殑鎵�鏈夐渶姹傦紝璇嗗埆鍑篗LB鐨勬墍鏈変骇鍝侊紝姣忎釜浜у搧鎸夋湀姹囨�婚渶姹傛暟閲�
-    traverse( owner, SalesDemand.astype( Forecast ), forecast, not isnull( forecast.SalesSegment_MP() ) and forecast.StartDate() < startofnextyear and forecast.Quantity() <> 0 
+    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();
@@ -74,18 +74,18 @@
     //浠嶱roduct planning鏌ユ壘搴撳瓨鐐逛负澶ц繛鍙戝姩鏈虹殑闀挎槬澶栫搴擄紝鍙朜ew supply瀛楁鎸夋湀姹囨�婚渶姹傛暟閲�
     traverse( owner, StockingPoint_MP, stockingpoint, stockingpoint.ID() = '澶ц繛鍙戝姩鏈虹殑闀挎槬澶栫搴�' ){
         traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf()
-                  and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear 
+                  and exists( pisp, ProductInStockingPointInPeriod, pispip, pispip.Period_MP().StartDate() >= startofyear and pispip.Period_MP().StartDate() < startofnextyear 
                               and ( pispip.DependentDemandAndSalesDemandQuantity() <> 0 or pispip.NewSupplyQuantity() <> 0 ) ) ){//浜у搧涓篗QB
           product           := pisp.Product_MP();
           allrow            := table.GetRow( allunit, product );
           factoryrow        := table.GetRow( dlunit, product );
           products.Add( product );
-          traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() 
+          traverse( pisp, ProductInStockingPointInPeriod, pispip, pispip.Period_MP().StartDate() >= startofyear
                     and pispip.Period_MP().StartDate() < startofnextyear 
                     and ( pispip.DependentDemandAndSalesDemandQuantity() <> 0 or pispip.NewSupplyQuantity() <> 0 ) ){
-            dayperiodtime   := pispip.Start().Date();
+            dayperiodtime   := ( pispip.Start() + Duration::Days( 1 ) ).Date();
             dayperiodname   := dayperiodtime.Format( "M2/D2/Y" );
-            periodtime      := pispip.Start().StartOfMonth().Date();
+            periodtime      := dayperiodtime.StartOfMonth();
             periodname      := periodtime.Format( "M2/D2/Y" );
             daycolumn       := selectobject( table, FinancialSalesColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
             column          := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime and not column.IsDay() );

--
Gitblit v1.9.3