From acffa3d576342b2d24001d8410d53e6972eeb9e5 Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期三, 16 十月 2024 19:16:28 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev

---
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelExport_369_ButtonExport696_OnClick.def |    2 
 _Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl                                                          |   33 ++--
 _Main/BL/Type_FinancialProductionSource/Method_AfterImport.qbl                                                           |   42 ++--
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelHeader.def                            |    1 
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Component_PanelHeader.def                                 |    1 
 _Main/UI/MacroPlannerWebApp/Component_FormInventorySummaryReport/Response_PanelExport_ButtonSummaryExport_OnClick.def    |    2 
 _Main/BL/Type_NewAssemblyOnlinePlanCell/StaticMethod_RefreshData.qbl                                                     |   88 +++++-----
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Response_PanelExport_ButtonExport570_OnClick.def          |    2 
 _Main/BL/Type_ChangeLossSettingExcel/StaticMethod_Import.qbl                                                             |    4 
 _Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Response_pHeader_ddslFactorySelection_OnCreated.def              |   16 ++
 _Main/BL/Type_FinancialProductionReport/Method_ImportVerification.qbl                                                    |   18 +-
 _Main/BL/Type_FinancialSalesReport/Method_ImportVerification.qbl                                                         |   22 +-
 _Main/BL/Type_FinancialSalesSource/StaticMethod_Download.qbl                                                             |   62 +++++++
 _Main/BL/Type_InventorySummarySource/StaticMethod_Download.qbl                                                           |   82 ++++++++++
 _Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Component_pHeader.def                                            |    1 
 _Main/BL/Type_FinancialSalesSource/Method_AfterImport.qbl                                                                |   41 ++--
 _Main/BL/Type_FinancialProductionSource/StaticMethod_Download.qbl                                                        |   63 +++++++
 17 files changed, 353 insertions(+), 127 deletions(-)

diff --git a/_Main/BL/Type_ChangeLossSettingExcel/StaticMethod_Import.qbl b/_Main/BL/Type_ChangeLossSettingExcel/StaticMethod_Import.qbl
index 7332ee9..6fbaedf 100644
--- a/_Main/BL/Type_ChangeLossSettingExcel/StaticMethod_Import.qbl
+++ b/_Main/BL/Type_ChangeLossSettingExcel/StaticMethod_Import.qbl
@@ -35,7 +35,7 @@
         unit            := selectobject( macroplan, Unit, unit, unit.ID() = excel.Unit() );
         feedback        := '';
         if( ChangeLossSetting::ValidateInput( feedback, macroplan, null( ChangeLossSetting ), unit, product1, product2, excel.StartDate(), excel.EndDate(), excel.ChangeLossNumber() ) ){
-          cls             := macroplan.ChangeLossSetting( relnew, ChangeLossNumber := [Real]excel.ChangeLossNumber() );
+          cls             := macroplan.ChangeLossSetting( relnew, ChangeLossNumber := [Real]excel.ChangeLossNumber(), StartDate := excel.StartDate(), EndDate := excel.EndDate()  );
           
           cls.ProductFirst( relset, product1 );
           cls.ProductSecond( relset, product2 );
@@ -48,6 +48,8 @@
           error( feedback );
         }
       }else {
+        cls.StartDate( excel.StartDate() );
+        cls.EndDate( excel.EndDate() );
         cls.ChangeLossNumber( [Real]excel.ChangeLossNumber() );
       }
       info( '-------------------', cls.ChangeLossNumber() );
diff --git a/_Main/BL/Type_FinancialProductionReport/Method_ImportVerification.qbl b/_Main/BL/Type_FinancialProductionReport/Method_ImportVerification.qbl
index f7b6a58..9460bca 100644
--- a/_Main/BL/Type_FinancialProductionReport/Method_ImportVerification.qbl
+++ b/_Main/BL/Type_FinancialProductionReport/Method_ImportVerification.qbl
@@ -6,8 +6,8 @@
   [*
     // 鐢勫叞楦� Jun-27-2024 (created)
     owner           := this.FinancialProductionSource().MacroPlan();
-    startofthisyear := owner.StartOfPlanning().StartOfYear().Date();
-    startofnextyear := owner.StartOfPlanning().StartOfNextYear().Date();
+    //startofthisyear := owner.StartOfPlanning().StartOfYear().Date();
+    //startofnextyear := owner.StartOfPlanning().StartOfNextYear().Date();
     
     if ( exists( this, FinancialProductionColumn, column, ( column.Index() = 0 and column.Name() <> "Product" )             or 
                                                       ( column.Index() = 1 and column.Name() <> "Unit" )  ) ){
@@ -20,18 +20,18 @@
     } else {
       cnv2 := StringToDate::StandardConverter();
       cnv2.SetCustomConversion();
-      cnv2.CustomFormatString( "dd/MM/yyyy" );
+      cnv2.CustomFormatString( "MM/dd/yyyy");
     
       while ( not isnull( indexcolumn ) ) {
         if ( not cnv2.CanConvert( indexcolumn.Name() ) ) {
           error( Translations::MP_FinancialProductionReport_ImportIndetifyIllegalTime() );
         }
-        period := cnv2.Convert( indexcolumn.Name() );
-    
-        // 鍒ゆ柇鏄惁鍦ㄨ鍒掑懆鏈熷唴
-        if ( period < startofthisyear or period > startofnextyear ) {
-          error( Translations::MP_FinancialProductionReport_ImportIndetifyOverPeriod() );
-        }
+    //    period := cnv2.Convert( indexcolumn.Name() );
+    //
+    //    // 鍒ゆ柇鏄惁鍦ㄨ鍒掑懆鏈熷唴
+    //    if ( period < startofthisyear or period > startofnextyear ) {
+    //      error( Translations::MP_FinancialProductionReport_ImportIndetifyOverPeriod() );
+    //    }
         indexcolumn := indexcolumn.NextColumn();
       }
     }
diff --git a/_Main/BL/Type_FinancialProductionSource/Method_AfterImport.qbl b/_Main/BL/Type_FinancialProductionSource/Method_AfterImport.qbl
index 310a91b..8c5cef4 100644
--- a/_Main/BL/Type_FinancialProductionSource/Method_AfterImport.qbl
+++ b/_Main/BL/Type_FinancialProductionSource/Method_AfterImport.qbl
@@ -35,21 +35,13 @@
         }
         
         //璇诲彇姣忎竴琛岀殑鍗曞厓鏍�
-        traverse( row, FinancialProductionCell, cell, cell.FinancialProductionColumn() <> productcolumn and cell.FinancialProductionColumn() <> unitcolumn ){
+        traverse( row, FinancialProductionCell, cell, cell.FinancialProductionColumn() <> productcolumn and cell.FinancialProductionColumn() <> unitcolumn and cnv2.Convert( cell.FinancialProductionColumn().Name() ) <> beforeyearday ){
           period            := cnv2.Convert( cell.FinancialProductionColumn().Name() )
-          tablecolumn       := construct( FinancialProductionColumn );
-          if( period = beforeyearday ){
-            periodname      := yearday.Format( "M2/D2/Y" );
-            //鑾峰彇琚鍏ユ姤琛ㄧ殑鏃ユ湡鍒�
-            tablecolumn     := selectobject( table, FinancialProductionColumn, column, not column.IsDay() and column.Name() = periodname );
-            if( isnull( tablecolumn ) ){
-              tablecolumn   := table.FinancialProductionColumn( relnew, Name := periodname, Period := yearday.Date() );
-            }
-          }else{
-            tablecolumn     := selectobject( table, FinancialProductionColumn, column, not column.IsDay() and column.Name() = cell.FinancialProductionColumn().Name() );
-            if( isnull( tablecolumn ) ){
-              tablecolumn   := table.FinancialProductionColumn( relnew, Name := cell.FinancialProductionColumn().Name(), Period := cnv2.Convert( cell.FinancialProductionColumn().Name() ) );
-            }
+          periodname      := yearday.Format( "M2/D2/Y" );
+          //鑾峰彇琚鍏ユ姤琛ㄧ殑鏃ユ湡鍒�
+          tablecolumn     := selectobject( table, FinancialProductionColumn, column, not column.IsDay() and column.Name() = periodname );
+          if( isnull( tablecolumn ) ){
+            tablecolumn   := table.FinancialProductionColumn( relnew, Name := periodname, Period := yearday.Date() );
           }
           //鑾峰彇琚鍏ユ姤琛ㄧ殑鍗曞厓鏍�
           unitcell          := selectobject( unitrow, FinancialProductionCell, unitcell, unitcell.FinancialProductionColumn() = tablecolumn );
@@ -57,9 +49,14 @@
             unitcell        := tablecolumn.FinancialProductionCell( relnew, Quantity := [Real]cell.Value(), Value := cell.Value() );
             unitrow.FinancialProductionCell( relinsert, unitcell );
           }else{
-            if( unitcell.Quantity() <> [Real]cell.Value() ){
-              unitcell.Quantity( [Real]cell.Value() );
-              unitcell.IsUpdate( true );
+            previouscolumn  := cell.FinancialProductionColumn().PreviousColumn();
+            if( period = yearday.Date() and not isnull( previouscolumn ) and beforeyearday = cnv2.Convert( previouscolumn.Name() ) ){
+              previouscell  := selectobject( row, FinancialProductionCell, previouscell, previouscell.FinancialProductionColumn() = previouscolumn );
+              quantity      := [Real]cell.Value() + [Real]previouscell.Value();
+              if( unitcell.Quantity() <> quantity ){
+                unitcell.Quantity( quantity );
+                unitcell.IsUpdate( true );
+              }
             }
           }
           allcell           := selectobject( allrow, FinancialProductionCell, allcell, allcell.FinancialProductionColumn() = tablecolumn );
@@ -67,9 +64,14 @@
             allcell         := tablecolumn.FinancialProductionCell( relnew, Quantity := [Real]cell.Value(), Value := cell.Value() );
             allrow.FinancialProductionCell( relinsert, allcell );
           }else{
-            if( allcell.Quantity() <> [Real]cell.Value() ){
-              allcell.Quantity( [Real]cell.Value() );
-              allcell.IsUpdate( true );
+            previouscolumn  := cell.FinancialProductionColumn().PreviousColumn();
+            if( period = yearday.Date() and not isnull( previouscolumn ) and beforeyearday = cnv2.Convert( previouscolumn.Name() ) ){
+              previouscell  := selectobject( row, FinancialProductionCell, previouscell, previouscell.FinancialProductionColumn() = previouscolumn );
+              quantity      := [Real]cell.Value() + [Real]previouscell.Value();
+              if( unitcell.Quantity() <> quantity ){
+                allcell.Quantity( [Real]cell.Value() );
+                allcell.IsUpdate( true );
+              }
             }
           }
         }
diff --git a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Download.qbl b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Download.qbl
index ed8f090..ac8db97 100644
--- a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Download.qbl
+++ b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Download.qbl
@@ -1,7 +1,11 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod Download (
-  MacroPlan macroPlan
+  MacroPlan macroPlan,
+  Factorys factorys,
+  ProductGenerations generations,
+  ProductPowers powers,
+  ProductMLBMQBs mlbmqls
 ) as BinaryValue
 {
   Description: '涓嬭浇璐㈠姟鎶ヨ〃鏁版嵁'
@@ -14,6 +18,14 @@
     xmlDOM  := xmlDOMI.CreateDocumentFromString( '<?xml version="1.0" encoding="UTF-16"?><table><name>' + table.Name() + '</name></table>' );
     
     tableElement := xmlDOM.GetElementByTagName( "table", 0 );
+    //Search
+    searchcolumnelement := xmlDOM.CreateElement( "column" );
+    searchnameelement   := xmlDOM.CreateElement( "name" );
+    searchtypeelement   := xmlDOM.CreateElement( "type" );
+    searchnameelement.TextContent( 'Search' );
+    searchtypeelement.TextContent( "String" );
+    searchcolumnelement.AppendChild( searchnameelement );
+    searchcolumnelement.AppendChild( searchtypeelement );
     //Product
     productcolumnelement := xmlDOM.CreateElement( "column" );
     productnameelement   := xmlDOM.CreateElement( "name" );
@@ -31,8 +43,43 @@
     unitcolumnelement.AppendChild( unitnameelement );
     unitcolumnelement.AppendChild( unittypeelement );
     
+    tableElement.AppendChild( searchcolumnelement ); 
     tableElement.AppendChild( productcolumnelement ); 
     tableElement.AppendChild( unitcolumnelement ); 
+    searchtotal     := factorys.Size() + generations.Size() + powers.Size() + mlbmqls.Size() + 4 ;
+    searchunitElement := xmlDOM.CreateElement( "cell" );
+    searchunitElement.SetAttribute( "value", 'Unit' );
+    searchcolumnelement.AppendChild( searchunitElement );
+    traverse( factorys, Elements, factory ){
+      searchunitcellElement := xmlDOM.CreateElement( "cell" );
+      searchunitcellElement.SetAttribute( "value", factory.Name() );
+      searchcolumnelement.AppendChild( searchunitcellElement );
+    }
+    searchgenerationElement := xmlDOM.CreateElement( "cell" );
+    searchgenerationElement.SetAttribute( "value", 'Generation' );
+    searchcolumnelement.AppendChild( searchgenerationElement );
+    traverse( generations, Elements, generation ){
+      generationcellElement := xmlDOM.CreateElement( "cell" );
+      generationcellElement.SetAttribute( "value", generation.Generation() );
+      searchcolumnelement.AppendChild( generationcellElement );
+    }
+    searchpowerElement := xmlDOM.CreateElement( "cell" );
+    searchpowerElement.SetAttribute( "value", 'Power' );
+    searchcolumnelement.AppendChild( searchpowerElement );
+    traverse( powers, Elements, power ){
+      searchpowercellElement := xmlDOM.CreateElement( "cell" );
+      searchpowercellElement.SetAttribute( "value", power.Power() );
+      searchcolumnelement.AppendChild( searchpowercellElement );
+    }
+    searchmlbmqlElement := xmlDOM.CreateElement( "cell" );
+    searchmlbmqlElement.SetAttribute( "value", 'MQBMLB' );
+    searchcolumnelement.AppendChild( searchmlbmqlElement );
+    traverse( mlbmqls, Elements, mlbmql ){
+      searchmlbmqlcellElement := xmlDOM.CreateElement( "cell" );
+      searchmlbmqlcellElement.SetAttribute( "value", mlbmql.MLBMQB() );
+      searchcolumnelement.AppendChild( searchmlbmqlcellElement );
+    }
+    
     minindex        := min( table, FinancialProductionColumn, column, not column.IsDay(), column.Index() );
     traverse ( table, FinancialProductionColumn, column, not column.IsDay() ) {
       columnelement := xmlDOM.CreateElement( "column" );
@@ -56,11 +103,25 @@
           unitcellElement := xmlDOM.CreateElement( "cell" );
           unitcellElement.SetAttribute( "value", row.Unit() );
           unitcolumnelement.AppendChild( unitcellElement );
+          if( cells.Size() > searchtotal ){
+            for( i := searchtotal; i < cells.Size(); i := i + 1 ){
+              searchcellElement1 := xmlDOM.CreateElement( "cell" );
+              searchcellElement1.SetAttribute( "value", '' );
+              searchcolumnelement.AppendChild( searchcellElement1 );
+            }
+          }
         }
         cellElement := xmlDOM.CreateElement( "cell" );
         cellElement.SetAttribute( "value", c.Value() ); 
         columnelement.AppendChild( cellElement );
       }
+      if( cells.Size() < searchtotal ){
+        for( i := cells.Size(); i < searchtotal; i := i + 1 ){
+          searchcellElement1 := xmlDOM.CreateElement( "cell" );
+          searchcellElement1.SetAttribute( "value", '' );
+          searchcolumnelement.AppendChild( searchcellElement1 );
+        }
+      }
       tableElement.AppendChild( columnelement );  
     }
     
diff --git a/_Main/BL/Type_FinancialSalesReport/Method_ImportVerification.qbl b/_Main/BL/Type_FinancialSalesReport/Method_ImportVerification.qbl
index b39339e..3afd388 100644
--- a/_Main/BL/Type_FinancialSalesReport/Method_ImportVerification.qbl
+++ b/_Main/BL/Type_FinancialSalesReport/Method_ImportVerification.qbl
@@ -6,8 +6,8 @@
   [*
     // 鐢勫叞楦� Jun-27-2024 (created)
     owner           := this.FinancialSalesSource().MacroPlan();
-    startofthisyear := owner.StartOfPlanning().StartOfYear().Date();
-    startofnextyear := owner.StartOfPlanning().StartOfNextYear().Date();
+    //startofthisyear := owner.StartOfPlanning().StartOfYear().Date();
+    //startofnextyear := owner.StartOfPlanning().StartOfNextYear().Date();
     
     if ( exists( this, FinancialSalesColumn, column, ( column.Index() = 0 and column.Name() <> "Product" )             or 
                                                       ( column.Index() = 1 and column.Name() <> "Unit" )  ) ){
@@ -20,20 +20,20 @@
     } else {
       cnv2 := StringToDate::StandardConverter();
       cnv2.SetCustomConversion();
-      cnv2.CustomFormatString( "dd/MM/yyyy" );
+      cnv2.CustomFormatString( "MM/dd/yyyy" );
     
       while ( not isnull( indexcolumn ) ) {
         if ( not cnv2.CanConvert( indexcolumn.Name() ) ) {
           error( Translations::MP_FinancialProductionReport_ImportIndetifyIllegalTime() );
         }
-        period := cnv2.Convert( indexcolumn.Name() );
-      //  info( "寮�濮嬫椂闂达細", this.SalesForecastInputSource().PlanningStartDate().Format( "Y-M2-D2" ),
-      //        "缁撴潫鏃堕棿锛�", this.SalesForecastInputSource().PlanningEndDate().Format( "Y-M2-D2" ),
-      //        "鍒楁椂闂达細", cnv2.Convert( indexColumn.name() ).Format( "Y-M2-D2" ) );
-        // 鍒ゆ柇鏄惁鍦ㄨ鍒掑懆鏈熷唴
-        if ( period < startofthisyear or period > startofnextyear ) {
-          error( Translations::MP_FinancialProductionReport_ImportIndetifyOverPeriod() );
-        }
+    //    period := cnv2.Convert( indexcolumn.Name() );
+    //  //  info( "寮�濮嬫椂闂达細", this.SalesForecastInputSource().PlanningStartDate().Format( "Y-M2-D2" ),
+    //  //        "缁撴潫鏃堕棿锛�", this.SalesForecastInputSource().PlanningEndDate().Format( "Y-M2-D2" ),
+    //  //        "鍒楁椂闂达細", cnv2.Convert( indexColumn.name() ).Format( "Y-M2-D2" ) );
+    //    // 鍒ゆ柇鏄惁鍦ㄨ鍒掑懆鏈熷唴
+    //    if ( period < startofthisyear or period > startofnextyear ) {
+    //      error( Translations::MP_FinancialProductionReport_ImportIndetifyOverPeriod() );
+    //    }
         indexcolumn := indexcolumn.NextColumn();
       }
     }
diff --git a/_Main/BL/Type_FinancialSalesSource/Method_AfterImport.qbl b/_Main/BL/Type_FinancialSalesSource/Method_AfterImport.qbl
index bfd3c4c..36d1094 100644
--- a/_Main/BL/Type_FinancialSalesSource/Method_AfterImport.qbl
+++ b/_Main/BL/Type_FinancialSalesSource/Method_AfterImport.qbl
@@ -30,32 +30,30 @@
           allrow            := table.FinancialSalesRow( relnew, Name := product.Value(), Unit := allunit );
         }
         
-        traverse( row, FinancialSalesCell, cell, cell.FinancialSalesColumn() <> productcolumn and cell.FinancialSalesColumn() <> unitcolumn ){
+        traverse( row, FinancialSalesCell, cell, cell.FinancialSalesColumn() <> productcolumn and cell.FinancialSalesColumn() <> unitcolumn and cnv2.Convert( cell.FinancialSalesColumn().Name() ) <> beforeyearday  ){
           column            := cell.FinancialSalesColumn();
           period            := cnv2.Convert( column.Name() )
+          periodname        := period.Format( "M2/D2/Y" )
           
           tablecolumn       := construct( FinancialSalesColumn );
-          if( period = beforeyearday ){
-            periodname      := yearday.Format( "M2/D2/Y" );
-            //鑾峰彇琚鍏ユ姤琛ㄧ殑鏃ユ湡鍒�
-            tablecolumn     := selectobject( table, FinancialSalesColumn, fscolumn, not fscolumn.IsDay() and fscolumn.Name() = periodname );
-            if( isnull( tablecolumn ) ){
-              tablecolumn   := table.FinancialSalesColumn( relnew, Name := periodname, Period := yearday.Date() );
-            }
-          }else{
-            tablecolumn     := selectobject( table, FinancialSalesColumn, fscolumn, not fscolumn.IsDay() and fscolumn.Name() = column.Name() );
-            if( isnull( tablecolumn ) ){
-              tablecolumn   := table.FinancialSalesColumn( relnew, Name := column.Name(), Period := cnv2.Convert( column.Name() ) );
-            }
+          //鑾峰彇琚鍏ユ姤琛ㄧ殑鏃ユ湡鍒�
+          tablecolumn     := selectobject( table, FinancialSalesColumn, fscolumn, not fscolumn.IsDay() and fscolumn.Name() = periodname );
+          if( isnull( tablecolumn ) ){
+            tablecolumn   := table.FinancialSalesColumn( relnew, Name := periodname, Period := yearday.Date() );
           }
           unitcell := selectobject( unitrow, FinancialSalesCell, unitcell, unitcell.FinancialSalesColumn().Name() = column.Name() );
           if( isnull( unitcell ) ){
             unitcell        := tablecolumn.FinancialSalesCell( relnew, Value := cell.Value() );
             unitrow.FinancialSalesCell( relinsert, unitcell );
           }else{
-            if( unitcell.Value() <> cell.Value() ){
-              unitcell.Value( cell.Value() );
-              unitcell.IsUpdate( true );
+            previouscolumn  := cell.FinancialSalesColumn().PreviousColumn();
+            if( period = yearday.Date() and not isnull( previouscolumn ) and beforeyearday = cnv2.Convert( previouscolumn.Name() ) ){
+              previouscell  := selectobject( row, FinancialSalesCell, previouscell, previouscell.FinancialSalesColumn() = previouscolumn );
+              quantity      := [Real]cell.Value() + [Real]previouscell.Value();
+              if( [Real]unitcell.Value() <> quantity ){
+                unitcell.Value( [String]( [Number]cell.Value() ) );
+                unitcell.IsUpdate( true );
+              }
             }
           }
           allcell  := selectobject( allrow, FinancialSalesCell, allcell, allcell.FinancialSalesColumn().Name() = column.Name() );
@@ -63,9 +61,14 @@
             allcell         := tablecolumn.FinancialSalesCell( relnew, Value := cell.Value() );
             allrow.FinancialSalesCell( relinsert, allcell );
           }else{
-            if( allcell.Value() <> cell.Value() ){
-              allcell.Value( cell.Value() );
-              allcell.IsUpdate( true );
+            previouscolumn  := cell.FinancialSalesColumn().PreviousColumn();
+            if( period = yearday.Date() and not isnull( previouscolumn ) and beforeyearday = cnv2.Convert( previouscolumn.Name() ) ){
+              previouscell  := selectobject( row, FinancialSalesCell, previouscell, previouscell.FinancialSalesColumn() = previouscolumn );
+              quantity      := [Real]cell.Value() + [Real]previouscell.Value();
+              if( [Real]allcell.Value() <> quantity ){
+                allcell.Value( [String]( [Number]cell.Value() ) );
+                allcell.IsUpdate( true );
+              }
             }
           }
         }
diff --git a/_Main/BL/Type_FinancialSalesSource/StaticMethod_Download.qbl b/_Main/BL/Type_FinancialSalesSource/StaticMethod_Download.qbl
index fcbd81e..1bdd2e2 100644
--- a/_Main/BL/Type_FinancialSalesSource/StaticMethod_Download.qbl
+++ b/_Main/BL/Type_FinancialSalesSource/StaticMethod_Download.qbl
@@ -1,7 +1,11 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod Download (
-  MacroPlan macroPlan
+  MacroPlan macroPlan,
+  Factorys factorys,
+  ProductGenerations generations,
+  ProductPowers powers,
+  ProductMLBMQBs mlbmqls
 ) as BinaryValue
 {
   Description: '涓嬭浇璐㈠姟鎶ヨ〃鏁版嵁'
@@ -14,6 +18,14 @@
     xmlDOM  := xmlDOMI.CreateDocumentFromString( '<?xml version="1.0" encoding="UTF-16"?><table><name>' + table.Name() + '</name></table>' );
     
     tableElement := xmlDOM.GetElementByTagName( "table", 0 );
+    //Search
+    searchcolumnelement := xmlDOM.CreateElement( "column" );
+    searchnameelement   := xmlDOM.CreateElement( "name" );
+    searchtypeelement   := xmlDOM.CreateElement( "type" );
+    searchnameelement.TextContent( 'Search' );
+    searchtypeelement.TextContent( "String" );
+    searchcolumnelement.AppendChild( searchnameelement );
+    searchcolumnelement.AppendChild( searchtypeelement );
     //Product
     productcolumnelement := xmlDOM.CreateElement( "column" );
     productnameelement   := xmlDOM.CreateElement( "name" );
@@ -31,8 +43,42 @@
     unitcolumnelement.AppendChild( unitnameelement );
     unitcolumnelement.AppendChild( unittypeelement );
     
+    tableElement.AppendChild( searchcolumnelement ); 
     tableElement.AppendChild( productcolumnelement ); 
     tableElement.AppendChild( unitcolumnelement ); 
+    searchtotal     := factorys.Size() + generations.Size() + powers.Size() + mlbmqls.Size() + 4 ;
+    searchunitElement := xmlDOM.CreateElement( "cell" );
+    searchunitElement.SetAttribute( "value", 'Unit' );
+    searchcolumnelement.AppendChild( searchunitElement );
+    traverse( factorys, Elements, factory ){
+      searchunitcellElement := xmlDOM.CreateElement( "cell" );
+      searchunitcellElement.SetAttribute( "value", factory.Name() );
+      searchcolumnelement.AppendChild( searchunitcellElement );
+    }
+    searchgenerationElement := xmlDOM.CreateElement( "cell" );
+    searchgenerationElement.SetAttribute( "value", 'Generation' );
+    searchcolumnelement.AppendChild( searchgenerationElement );
+    traverse( generations, Elements, generation ){
+      generationcellElement := xmlDOM.CreateElement( "cell" );
+      generationcellElement.SetAttribute( "value", generation.Generation() );
+      searchcolumnelement.AppendChild( generationcellElement );
+    }
+    searchpowerElement := xmlDOM.CreateElement( "cell" );
+    searchpowerElement.SetAttribute( "value", 'Power' );
+    searchcolumnelement.AppendChild( searchpowerElement );
+    traverse( powers, Elements, power ){
+      searchpowercellElement := xmlDOM.CreateElement( "cell" );
+      searchpowercellElement.SetAttribute( "value", power.Power() );
+      searchcolumnelement.AppendChild( searchpowercellElement );
+    }
+    searchmlbmqlElement := xmlDOM.CreateElement( "cell" );
+    searchmlbmqlElement.SetAttribute( "value", 'MQBMLB' );
+    searchcolumnelement.AppendChild( searchmlbmqlElement );
+    traverse( mlbmqls, Elements, mlbmql ){
+      searchmlbmqlcellElement := xmlDOM.CreateElement( "cell" );
+      searchmlbmqlcellElement.SetAttribute( "value", mlbmql.MLBMQB() );
+      searchcolumnelement.AppendChild( searchmlbmqlcellElement );
+    }
     minindex        := min( table, FinancialSalesColumn, column, not column.IsDay(), column.Index() );
     traverse ( table, FinancialSalesColumn, column, not column.IsDay() ) {
       columnelement := xmlDOM.CreateElement( "column" );
@@ -56,11 +102,25 @@
           unitcellElement := xmlDOM.CreateElement( "cell" );
           unitcellElement.SetAttribute( "value", row.Unit() );
           unitcolumnelement.AppendChild( unitcellElement );
+          if( cells.Size() > searchtotal ){
+            for( i := searchtotal; i < cells.Size(); i := i + 1 ){
+              searchcellElement1 := xmlDOM.CreateElement( "cell" );
+              searchcellElement1.SetAttribute( "value", '' );
+              searchcolumnelement.AppendChild( searchcellElement1 );
+            }
+          }
         }
         cellElement := xmlDOM.CreateElement( "cell" );
         cellElement.SetAttribute( "value", c.Value() ); 
         columnelement.AppendChild( cellElement );
       }
+      if( cells.Size() < searchtotal ){
+        for( i := cells.Size(); i < searchtotal; i := i + 1 ){
+          searchcellElement1 := xmlDOM.CreateElement( "cell" );
+          searchcellElement1.SetAttribute( "value", '' );
+          searchcolumnelement.AppendChild( searchcellElement1 );
+        }
+      }
       tableElement.AppendChild( columnelement );  
     }
     
diff --git a/_Main/BL/Type_InventorySummarySource/StaticMethod_Download.qbl b/_Main/BL/Type_InventorySummarySource/StaticMethod_Download.qbl
index 1bba790..06cfb30 100644
--- a/_Main/BL/Type_InventorySummarySource/StaticMethod_Download.qbl
+++ b/_Main/BL/Type_InventorySummarySource/StaticMethod_Download.qbl
@@ -1,7 +1,12 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod Download (
-  MacroPlan macroPlan
+  MacroPlan macroPlan,
+  Factorys factorys,
+  ProductGenerations generations,
+  ProductPowers powers,
+  ProductMLBMQBs mlbmqls,
+  InventorySummarySearch search
 ) as BinaryValue
 {
   Description: '涓嬭浇璐㈠姟鎶ヨ〃鏁版嵁'
@@ -14,6 +19,14 @@
     xmlDOM  := xmlDOMI.CreateDocumentFromString( '<?xml version="1.0" encoding="UTF-16"?><table><name>' + table.Name() + '</name></table>' );
     
     tableElement := xmlDOM.GetElementByTagName( "table", 0 );
+    //Search
+    searchcolumnelement := xmlDOM.CreateElement( "column" );
+    searchnameelement   := xmlDOM.CreateElement( "name" );
+    searchtypeelement   := xmlDOM.CreateElement( "type" );
+    searchnameelement.TextContent( 'Search' );
+    searchtypeelement.TextContent( "String" );
+    searchcolumnelement.AppendChild( searchnameelement );
+    searchcolumnelement.AppendChild( searchtypeelement );
     //Product
     productcolumnelement := xmlDOM.CreateElement( "column" );
     productnameelement   := xmlDOM.CreateElement( "name" );
@@ -39,9 +52,61 @@
     attricolumnelement.AppendChild( attrinameelement );
     attricolumnelement.AppendChild( attritypeelement );
     
+    tableElement.AppendChild( searchcolumnelement ); 
     tableElement.AppendChild( productcolumnelement ); 
     tableElement.AppendChild( unitcolumnelement ); 
     tableElement.AppendChild( attricolumnelement );
+    searchtotal     := factorys.Size() + generations.Size() + powers.Size() + mlbmqls.Size() + 10 ;
+    searchunitElement := xmlDOM.CreateElement( "cell" );
+    searchunitElement.SetAttribute( "value", 'Unit' );
+    searchcolumnelement.AppendChild( searchunitElement );
+    traverse( factorys, Elements, factory ){
+      searchunitcellElement := xmlDOM.CreateElement( "cell" );
+      searchunitcellElement.SetAttribute( "value", factory.Name() );
+      searchcolumnelement.AppendChild( searchunitcellElement );
+    }
+    searchgenerationElement := xmlDOM.CreateElement( "cell" );
+    searchgenerationElement.SetAttribute( "value", 'Generation' );
+    searchcolumnelement.AppendChild( searchgenerationElement );
+    traverse( generations, Elements, generation ){
+      generationcellElement := xmlDOM.CreateElement( "cell" );
+      generationcellElement.SetAttribute( "value", generation.Generation() );
+      searchcolumnelement.AppendChild( generationcellElement );
+    }
+    searchpowerElement := xmlDOM.CreateElement( "cell" );
+    searchpowerElement.SetAttribute( "value", 'Power' );
+    searchcolumnelement.AppendChild( searchpowerElement );
+    traverse( powers, Elements, power ){
+      searchpowercellElement := xmlDOM.CreateElement( "cell" );
+      searchpowercellElement.SetAttribute( "value", power.Power() );
+      searchcolumnelement.AppendChild( searchpowercellElement );
+    }
+    searchmlbmqlElement := xmlDOM.CreateElement( "cell" );
+    searchmlbmqlElement.SetAttribute( "value", 'MQBMLB' );
+    searchcolumnelement.AppendChild( searchmlbmqlElement );
+    traverse( mlbmqls, Elements, mlbmql ){
+      searchmlbmqlcellElement := xmlDOM.CreateElement( "cell" );
+      searchmlbmqlcellElement.SetAttribute( "value", mlbmql.MLBMQB() );
+      searchcolumnelement.AppendChild( searchmlbmqlcellElement );
+    }
+    searchstartdateElement := xmlDOM.CreateElement( "cell" );
+    searchstartdateElement.SetAttribute( "value", 'Start date' );
+    searchcolumnelement.AppendChild( searchstartdateElement );
+    searchstartdatecellElement := xmlDOM.CreateElement( "cell" );
+    searchstartdatecellElement.SetAttribute( "value", search.StartDate().Format( 'M2/D2/Y' ) );
+    searchcolumnelement.AppendChild( searchstartdatecellElement );
+    searchenddateElement := xmlDOM.CreateElement( "cell" );
+    searchenddateElement.SetAttribute( "value", 'End date' );
+    searchcolumnelement.AppendChild( searchenddateElement );
+    searchenddatecellElement := xmlDOM.CreateElement( "cell" );
+    searchenddatecellElement.SetAttribute( "value", search.EndDate().Format( 'M2/D2/Y' ) );
+    searchcolumnelement.AppendChild( searchenddatecellElement );
+    searchcellElement1 := xmlDOM.CreateElement( "cell" );
+    searchcellElement1.SetAttribute( "value", 'Periods' );
+    searchcolumnelement.AppendChild( searchcellElement1 );
+    searchcellElement1 := xmlDOM.CreateElement( "cell" );
+    searchcellElement1.SetAttribute( "value", search.Category() );
+    searchcolumnelement.AppendChild( searchcellElement1 );
     traverse ( table, InventorySummaryColumn, column ) {
       columnelement := xmlDOM.CreateElement( "column" );
       nameelement   := xmlDOM.CreateElement( "name" );
@@ -99,6 +164,14 @@
           avecellElement := xmlDOM.CreateElement( "cell" );
           avecellElement.SetAttribute( "value", '骞冲潎搴撳瓨' );//AverageInventory
           attricolumnelement.AppendChild( avecellElement );
+          
+          if( cells.Size() > searchtotal ){
+            for( i := searchtotal; i < cells.Size(); i := i + 1 ){
+              searchcellElement1 := xmlDOM.CreateElement( "cell" );
+              searchcellElement1.SetAttribute( "value", '' );
+              searchcolumnelement.AppendChild( searchcellElement1 );
+            }
+          }
         }
         //鏈熸湯搴撳瓨
         endcellElement := xmlDOM.CreateElement( "cell" );
@@ -117,6 +190,13 @@
         avecellElement.SetAttribute( "value", [String]c.AverageInventory() );
         columnelement.AppendChild( avecellElement );
       }
+      if( cells.Size() < searchtotal ){
+        for( i := cells.Size(); i < searchtotal; i := i + 1 ){
+          searchcellElement1 := xmlDOM.CreateElement( "cell" );
+          searchcellElement1.SetAttribute( "value", '' );
+          searchcolumnelement.AppendChild( searchcellElement1 );
+        }
+      }
       tableElement.AppendChild( columnelement );  
     }
     
diff --git a/_Main/BL/Type_NewAssemblyOnlinePlanCell/StaticMethod_RefreshData.qbl b/_Main/BL/Type_NewAssemblyOnlinePlanCell/StaticMethod_RefreshData.qbl
index a8a7fcc..fad645a 100644
--- a/_Main/BL/Type_NewAssemblyOnlinePlanCell/StaticMethod_RefreshData.qbl
+++ b/_Main/BL/Type_NewAssemblyOnlinePlanCell/StaticMethod_RefreshData.qbl
@@ -54,51 +54,51 @@
     }
     
     // 澶勭悊鏃ュ巻浜嬩欢
-    //pls := selectuniquevalues( macroPlan, AssemblyOnlinePlanRow, tempAOPR, true, tempAOPR.ProductionLine() );
-    //traverse ( pls, Elements, pl ) {
-    //  targetQuantity := ifexpr( pl = "CC MoMo", guard( macroPlan.AssemblyOnlineQuantity().CCMoMo(), 0 ),
-    //                            ifexpr( pl = "DL MoMo", guard( macroPlan.AssemblyOnlineQuantity().DLMoMo(), 0 ), guard( macroPlan.AssemblyOnlineQuantity().DLZKM(), 0 ) )
-    //                           );
-    //  
-    //  u           := select( macroPlan, Unit, tempU, tempU.ID() = pl );
-    //  drainPs     := selectset( u, UnitCalendar.Participation, tempP, guard( tempP.Event().Subject().Regex( "鎷夌┖" ), false ) );
-    //  lineLyingPs := selectset( u, UnitCalendar.Participation, tempP, guard( tempP.Event().Subject().Regex( "閾虹嚎" ), false ) );
-    //  
-    //  // 澶勭悊鎺掔┖
+    pls := selectuniquevalues( macroPlan, NewAssemblyOnlinePlanRow, tempNAOPR, true, tempNAOPR.ProductionLine() );
+    traverse ( pls, Elements, pl ) {
+      targetQuantity := ifexpr( pl = "CC MoMo", guard( macroPlan.AssemblyOnlineQuantity().CCMoMo(), 0 ),
+                                ifexpr( pl = "DL MoMo", guard( macroPlan.AssemblyOnlineQuantity().DLMoMo(), 0 ), guard( macroPlan.AssemblyOnlineQuantity().DLZKM(), 0 ) )
+                               );
+      
+      u           := select( macroPlan, Unit, tempU, tempU.ID() = pl );
+      drainPs     := selectset( u, UnitCalendar.Participation, tempP, guard( tempP.Event().Subject().Regex( "鎷夌┖" ), false ) );
+      lineLyingPs := selectset( u, UnitCalendar.Participation, tempP, guard( tempP.Event().Subject().Regex( "閾虹嚎" ), false ) );
+      
+      // 澶勭悊鎷夌┖
     //  info( "褰撳墠浜х嚎锛�", pl, "    澶勭悊鎷夌┖--------------------------" );
-    //  traverse ( drainPs, Elements, p ) {
-    //    traverse ( p, ExplicitTimeInterval, eti ) {
+      traverse ( drainPs, Elements, p ) {
+        traverse ( p, ExplicitTimeInterval, eti ) {
     //      info( "寮�濮嬫椂闂达細", eti.Start().Format( "Y-M2-D2" ), "    缁撴潫鏃堕棿锛�", eti.End().Format( "Y-M2-D2" ) );
-    //      // 鍓嶄竴澶╂棩鍘�
-    //      aopc := select( macroPlan, AssemblyOnlinePlanColumn, tempAOPC, tempAOPC.ColumnDate() = ( eti.Start().Date() - 1 ) );
-    //      info( "闇�瑕佹媺绌虹殑涓婄嚎璁″垝鏃堕棿锛�", aopc.ColumnDate().Format( "Y-M2-D2" ) );
-    //      aoprs := selectset( macroPlan, AssemblyOnlinePlanRow, tempAOPR, tempAOPR.ProductionLine() = pl and tempAOPR.Type() = "2" and
-    //                          exists( tempAOPR, AssemblyOnlinePlanCell, tempAOPC, tempAOPC.AssemblyOnlinePlanColumn() = aopc and tempAOPC.Value() <> "" ) );
-    //      aopr  := maxselect( aoprs, Elements.AssemblyOnlinePlanCell, tempAOPC, tempAOPC.AssemblyOnlinePlanColumn() = aopc,
-    //                          [Number]tempAOPC.Value().ReplaceAll( "#0", "" ) );
-    //      cell  := select( macroPlan, AssemblyOnlinePlanRow.AssemblyOnlinePlanCell, tempAOPC, tempAOPC.AssemblyOnlinePlanRow().ProductionLine() = pl and tempAOPC.AssemblyOnlinePlanColumn() = aopc and
-    //                       tempAOPC.AssemblyOnlinePlanRow().Type() = "1" and tempAOPC.AssemblyOnlinePlanRow().ProductID() = aopr.AssemblyOnlinePlanRow().ProductID() ); 
-    //      
-    //      cell.Value( [String] ( [Number]cell.Value() - targetQuantity ) );
-    //    }
-    //  }
-    //  
-    //  info( "褰撳墠浜х嚎锛�", pl, "    澶勭悊閾虹嚎--------------------------" );
-    //  // 澶勭悊閾虹嚎
-    //  traverse ( lineLyingPs, Elements, p ) {
-    //    traverse ( p, ExplicitTimeInterval, eti ) {
-    //      info( "寮�濮嬫椂闂达細", eti.Start().Format( "Y-M2-D2" ), "    缁撴潫鏃堕棿锛�", eti.End().Format( "Y-M2-D2" ) );
-    //      info( "闇�瑕侀摵绾跨殑涓婄嚎璁″垝鏃堕棿锛�", eti.Start().Format( "Y-M2-D2" ) );
-    //      aopc  := select( macroPlan, AssemblyOnlinePlanColumn, tempAOPC, tempAOPC.ColumnDate() = eti.Start().Date() );
-    //      aoprs := selectset( macroPlan, AssemblyOnlinePlanRow, tempAOPR, tempAOPR.ProductionLine() = pl and tempAOPR.Type() = "2" and
-    //                          exists( tempAOPR, AssemblyOnlinePlanCell, tempAOPC, tempAOPC.AssemblyOnlinePlanColumn() = aopc and tempAOPC.Value() <> "" ) );
-    //      aopr  := minselect( aoprs, Elements.AssemblyOnlinePlanCell, tempAOPC, tempAOPC.AssemblyOnlinePlanColumn() = aopc,
-    //                          [Number]tempAOPC.Value().ReplaceAll( "#0", "" ) );
-    //      cell  := select( macroPlan, AssemblyOnlinePlanRow.AssemblyOnlinePlanCell, tempAOPC, tempAOPC.AssemblyOnlinePlanRow().ProductionLine() = pl and tempAOPC.AssemblyOnlinePlanColumn() = aopc and
-    //                       tempAOPC.AssemblyOnlinePlanRow().Type() = "1" and tempAOPC.AssemblyOnlinePlanRow().ProductID() = aopr.AssemblyOnlinePlanRow().ProductID() );
-    //      cell.Value( [String] ( [Number]cell.Value() + targetQuantity ) );
-    //    }
-    //  }
-    //}
+          
+          cell  := maxselect( macroPlan, NewAssemblyOnlinePlanRow.NewAssemblyOnlinePlanCell, tempNAOPCell, 
+                              tempNAOPCell.NewAssemblyOnlinePlanRow().ProductionLine() = pl                         and 
+                              tempNAOPCell.NewAssemblyOnlinePlanColumn().StartDate()   = ( eti.Start().Date() - 1 ) and
+                              tempNAOPCell.NewAssemblyOnlinePlanRow().Type()           = "1",
+                              tempNAOPCell.OrderNr() ); 
+          
+          if ( not isnull( cell ) ) {
+            cell.Quantity( cell.Quantity() - targetQuantity );
+          }
+        }
+      }
+      
+      info( "褰撳墠浜х嚎锛�", pl, "    澶勭悊閾虹嚎--------------------------" );
+      // 澶勭悊閾虹嚎
+      traverse ( lineLyingPs, Elements, p ) {
+        traverse ( p, ExplicitTimeInterval, eti ) {
+          info( "寮�濮嬫椂闂达細", eti.Start().Format( "Y-M2-D2" ), "    缁撴潫鏃堕棿锛�", eti.End().Format( "Y-M2-D2" ) );
+          
+          cell  := minselect( macroPlan, NewAssemblyOnlinePlanRow.NewAssemblyOnlinePlanCell, tempNAOPCell, 
+                              tempNAOPCell.NewAssemblyOnlinePlanRow().ProductionLine() = pl                 and 
+                              tempNAOPCell.NewAssemblyOnlinePlanColumn().StartDate()   = eti.Start().Date() and
+                              tempNAOPCell.NewAssemblyOnlinePlanRow().Type()           = "1"                and
+                              tempNAOPCell.OrderNr()                                   > 0,
+                              tempNAOPCell.OrderNr() );
+          if ( not isnull( cell ) ) {
+            cell.Quantity( cell.Quantity() + targetQuantity );
+          }
+        }
+      }
+    }
   *]
 }
diff --git a/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl b/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
index 9eb8dff..8a41f88 100644
--- a/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
+++ b/_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
@@ -22,15 +22,8 @@
       // 鍒涘缓琛�
       ppr := select( macroPlan, PackagingPlanRow, tempPPR, tempPPR.ProductID() = pisp.ProductID() and tempPPR.Factory() = factory );
       if ( isnull( ppr ) ) {
-        ppr := macroPlan.PackagingPlanRow( relnew, ProductID := pisp.ProductID(), StockingPointID := pisp.StockingPointID(), Factory := factory, Category := guard( pisp.Product_MP().ParentID(), "" ) );
+        ppr := macroPlan.PackagingPlanRow( relnew, ProductID := pisp.ProductID(), Factory := factory, Category := guard( pisp.Product_MP().ParentID(), "" ) );
       }
-      
-      // 鍑哄彂鍦板簱瀛樼偣Trip
-      originTrips      := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation )      and
-                                     TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() ) );
-      // 鐩殑鍦板簱瀛樼偣Trip
-      destinationTrips := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation ) and
-                                     TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() ) );  
       
       // 寰幆pispippl
       traverse ( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispipl, not pispipl.IsPeriodFrozen() ) {
@@ -44,24 +37,32 @@
         cell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = ppc );
         if ( isnull( cell ) ) {
           cell := ppr.PackagingPlanCell( relnew );
-          cell.NetDemand( pispipl.DependentDemandAndSalesDemandQuantity() - pispipl.NewSupplyQuantity() );
+          cell.NetDemand( pispipl.InventoryLevelEnd() + pispipl.NewSupplyQuantity() - pispipl.DependentDemandAndSalesDemandQuantity() );
           cell.EndingInventory( pispipl.InventoryLevelEnd() );
           cell.PackagingPlanColumn( relset, ppc );
         } else {
-          cell.NetDemand( cell.NetDemand() + ( pispipl.DependentDemandAndSalesDemandQuantity() - pispipl.NewSupplyQuantity() ) );
+          cell.NetDemand( cell.NetDemand() + ( pispipl.InventoryLevelEnd() + pispipl.NewSupplyQuantity() - pispipl.DependentDemandAndSalesDemandQuantity() ) );
           cell.EndingInventory( cell.EndingInventory() + pispipl.InventoryLevelEnd() );
         }
         
         // 璁剧疆璋冨嚭
-        outs := selectset( originTrips, Elements, tempT, tempT.Departure().Date() = pispipl.Start().Date() );
-        traverse ( outs, Elements.ProductInTrip, outPIT, outPIT.ProductID() = pisp.ProductID() ) {
-          cell.Out( cell.Out() + outPIT.Quantity() );
+        traverse ( pispipl, AsDeparturePISPIP, pit,
+                   pit.Quantity()                > 0                                                                         and
+                   pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation )      and
+                   TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() )
+                  ) 
+        {
+          cell.Out( cell.Out() + pit.Quantity() );
         }
         
         // 璁剧疆璋冭繘
-        transferIns := selectset( destinationTrips, Elements, tempT, tempT.Arrival().Date() = pispipl.Start().Date() );
-        traverse ( transferIns, Elements.ProductInTrip, tiPIT, tiPIT.ProductID() = pisp.ProductID() ) {
-          cell.TransferIn( cell.TransferIn() + tiPIT.Quantity() );
+        traverse ( pispipl, AsArrivalPISPIP, pit,
+                   pit.Quantity()              > 0                                                                           and
+                   pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( factoryAbbreviation ) and
+                   TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP() ) <> TransferPlanRow::IdentifyTheFactory( pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP() )
+                  ) 
+        {
+          cell.TransferIn( cell.TransferIn() + pit.Quantity() );
         }
         
         // 闀挎槬宸ュ巶鐗规畩鎯呭喌璁剧疆鍖呰搴撳瓨鍜岄潪鍖呰搴撳瓨
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelHeader.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelHeader.def
index dcef188..d747539 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelHeader.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelHeader.def
@@ -10,6 +10,7 @@
   ]
   Properties:
   [
+    FixedSize: true
     Orientation: 'horizontal'
     Taborder: 0
   ]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelExport_369_ButtonExport696_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelExport_369_ButtonExport696_OnClick.def
index 2ad8c4d..3ee2cc5 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelExport_369_ButtonExport696_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelExport_369_ButtonExport696_OnClick.def
@@ -13,7 +13,7 @@
   {
     Body:
     [*
-      binaryValue := FinancialProductionSource::Download( MacroPlan );
+      binaryValue := FinancialProductionSource::Download( MacroPlan, dhFactorys.Data(), dhGenerations.Data(), dhPowers.Data(), dhMQBMLBs.Data() );
       
       Application.Download( FinancialProductionReport::GetDefaultName() + '.xlsx', binaryValue.AsBinaryData() );
     *]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Component_PanelHeader.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Component_PanelHeader.def
index 0570d30..5dbb1ce 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Component_PanelHeader.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Component_PanelHeader.def
@@ -10,6 +10,7 @@
   ]
   Properties:
   [
+    FixedSize: true
     Orientation: 'horizontal'
     Taborder: 0
   ]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Response_PanelExport_ButtonExport570_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Response_PanelExport_ButtonExport570_OnClick.def
index 96fa9ae..a198312 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Response_PanelExport_ButtonExport570_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Response_PanelExport_ButtonExport570_OnClick.def
@@ -13,7 +13,7 @@
   {
     Body:
     [*
-      binaryValue := FinancialSalesSource::Download( MacroPlan );
+      binaryValue := FinancialSalesSource::Download( MacroPlan, dhFactorys.Data(), dhGenerations.Data(), dhPowers.Data(), dhMQBMLBs.Data() );
       
       Application.Download( FinancialSalesReport::GetDefaultName() + '.xlsx', binaryValue.AsBinaryData() );
       //owner.FinancialSalesSource( relflush );
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormInventorySummaryReport/Response_PanelExport_ButtonSummaryExport_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormInventorySummaryReport/Response_PanelExport_ButtonSummaryExport_OnClick.def
index b3d157a..e049eb6 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormInventorySummaryReport/Response_PanelExport_ButtonSummaryExport_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormInventorySummaryReport/Response_PanelExport_ButtonSummaryExport_OnClick.def
@@ -13,7 +13,7 @@
   {
     Body:
     [*
-      binaryValue := InventorySummarySource::Download( MacroPlan );
+      binaryValue := InventorySummarySource::Download( MacroPlan, dhFactorys.Data(), dhGenerations.Data(), dhPowers.Data(), dhMQBMLBs.Data(), dhSearch.Data() );
       
       Application.Download( InventorySummaryReport::GetDefaultName() + '.xlsx', binaryValue.AsBinaryData() );
     *]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Component_pHeader.def b/_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Component_pHeader.def
index f81dab7..9200e4d 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Component_pHeader.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Component_pHeader.def
@@ -61,7 +61,6 @@
       BaseType: 'WebDropDownStringList'
       Properties:
       [
-        InitialValue: '澶ц繛宸ュ巶'
         Label: '宸ュ巶'
         Sorting: 'none'
         Strings: '澶ц繛宸ュ巶;闀挎槬宸ュ巶'
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Response_pHeader_ddslFactorySelection_OnCreated.def b/_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Response_pHeader_ddslFactorySelection_OnCreated.def
new file mode 100644
index 0000000..a956c23
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Response_pHeader_ddslFactorySelection_OnCreated.def
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: pHeader/ddslFactorySelection
+Response OnCreated () id:Response_pHeader_ddslFactorySelection_OnCreated
+{
+  #keys: '[413988.1.1602019]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebComponent_OnCreated'
+  QuillAction
+  {
+    Body:
+    [*
+      this.Text( dhSelectedFactory.Data() );
+    *]
+    GroupServerCalls: false
+  }
+}

--
Gitblit v1.9.3