From 3e2cfc09d9d2affff07a75a654b03c635582a5e9 Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期二, 25 六月 2024 16:10:02 +0800
Subject: [PATCH] 财务产量报表(差筛选)

---
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelExport_ButtonExport_OnClick.def                                    |    2 
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelFinancialProductionReportOperation_ButtonProductionExport_OnCl.def |    2 
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_dhUnit_OnCreated.def                                          |   16 +
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/_ROOT_Component_FormFinancialProductionReport.def                                |   22 +
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_OnCreated.def                                                           |   23 ++
 _Main/BL/Type_FinancialProductionSource/Method_Filter.qbl                                                                                            |   18 +
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelFinancialProductionReportOperation_ButtonProductionImport_OnCl.def |    3 
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelPower.def                                                         |   10 
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelFinancialProductionReportHeader.def                               |    3 
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelGeneration_ddslGeneration_OnSelectionChanged.def                   |   16 +
 _Main/BL/Type_FinancialProductionRow/Method_Initialize#110.qbl                                                                                       |   15 +
 _Main/BL/Type_FinancialProductionSource/StaticMethod_Download.qbl                                                                                    |   46 +++
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_matrixEditorActionBarPageTable.def                                     |   10 
 _Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl                                                                                  |   79 +++++++
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_ddslUnit_OnCreated.def                                        |   19 +
 _Main/BL/Type_FinancialProductionSource/Method_AfterImport.qbl                                                                                       |   37 +++
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelGeneration.def                                                    |   10 
 _Main/BL/Type_FinancialProductionSource/StaticMethod_Upload.qbl                                                                                      |    1 
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelTable.def                                                         |   14 +
 _Main/BL/Type_FinancialProductionSource/Attribute_IsImport.qbl                                                                                       |    7 
 _Main/BL/Type_FinancialProductionSource/Method_ReadStructure.qbl                                                                                     |    5 
 /dev/null                                                                                                                                            |   10 
 _Main/BL/Type_FinancialProductionSource/StaticMethod_DownloadTemplate.qbl                                                                            |    4 
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Method_filter.def                                                                |   18 +
 _Main/BL/Type_FinancialProductionRow/Method_Initialize.qbl                                                                                           |   16 +
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_MatrixEditorTable.def                                                  |   99 +++++++++
 _Main/BL/Type_FinancialProductionRow/Method_Filter.qbl                                                                                               |   22 ++
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelPower_ddslPower_OnSelectionChanged.def                             |   16 +
 _Main/BL/Type_FinancialProductionReport/Attribute_IsImport.qbl                                                                                       |    2 
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelUnit.def                                                          |   11 
 _Main/BL/Type_FinancialProductionRow/Attribute_Unit.qbl                                                                                              |    8 
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelMQBMLB_ddslMQBMLB_OnSelectionChanged.def                           |   16 +
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_ddslUnit_OnSelectionChanged.def                               |   16 +
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelMQBMLB.def                                                        |   10 
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_matrixeditorContextMenuTable.def                                       |   10 
 35 files changed, 593 insertions(+), 23 deletions(-)

diff --git a/_Main/BL/Type_FinancialProductionReport/Attribute_IsImport.qbl b/_Main/BL/Type_FinancialProductionReport/Attribute_IsImport.qbl
index c8eb836..125eb9d 100644
--- a/_Main/BL/Type_FinancialProductionReport/Attribute_IsImport.qbl
+++ b/_Main/BL/Type_FinancialProductionReport/Attribute_IsImport.qbl
@@ -2,6 +2,6 @@
 #parent: #root
 Attribute IsImport
 {
-  #keys: '3[415136.0.834715063][415136.0.834715062][415136.0.834715064]'
+  #keys: '3[415136.0.842718583][415136.0.842718582][415136.0.842718584]'
   ValueType: Boolean
 }
diff --git a/_Main/BL/Type_FinancialProductionRow/Attribute_Unit.qbl b/_Main/BL/Type_FinancialProductionRow/Attribute_Unit.qbl
new file mode 100644
index 0000000..2131a22
--- /dev/null
+++ b/_Main/BL/Type_FinancialProductionRow/Attribute_Unit.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute Unit
+{
+  #keys: '3[415136.0.842400951][415136.0.842400950][415136.0.842400952]'
+  Description: '浜х嚎'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_FinancialProductionRow/Method_Filter.qbl b/_Main/BL/Type_FinancialProductionRow/Method_Filter.qbl
new file mode 100644
index 0000000..f09176c
--- /dev/null
+++ b/_Main/BL/Type_FinancialProductionRow/Method_Filter.qbl
@@ -0,0 +1,22 @@
+Quintiq file version 2.0
+#parent: #root
+Method Filter (
+  Product_MPs products,
+  String unit,
+  String generation,
+  String mqbmlb,
+  String power
+) declarative remote as Boolean
+{
+  TextBody:
+  [*
+    // 鐢勫叞楦� Jun-24-2024 (created)
+    //productids := selectuniquevalues( products, Elements, product, ( generation = '<All>' or product.Generation() = generation ) and 
+    //                                  ( mqbmlb = '<All>' or product.MQBMLB() = mqbmlb ) and 
+    //                                  ( power = '<All>' or product.Power() = power ), product.ID() );
+    //productid := construct( Strings );
+    //productid.Add( this.Name() );
+    //return productids.ContainsAll( productid ) and this.Unit() = unit;
+    return this.Name() = '92 kW Stator' and this.Unit() = '<All>';
+  *]
+}
diff --git "a/_Main/BL/Type_FinancialProductionRow/Method_Initialize\043110.qbl" "b/_Main/BL/Type_FinancialProductionRow/Method_Initialize\043110.qbl"
new file mode 100644
index 0000000..ca0352d
--- /dev/null
+++ "b/_Main/BL/Type_FinancialProductionRow/Method_Initialize\043110.qbl"
@@ -0,0 +1,15 @@
+Quintiq file version 2.0
+#parent: #root
+Method Initialize (
+  FinancialProductionColumn column,
+  String unit
+)
+{
+  TextBody:
+  [*
+    // 鐢勫叞楦� Jun-24-2024 (created)
+    cell := column.FinancialProductionCell( relnew, Value := '' );
+    
+    this.FinancialProductionCell( relinsert, cell );
+  *]
+}
diff --git a/_Main/BL/Type_FinancialProductionRow/Method_Initialize.qbl b/_Main/BL/Type_FinancialProductionRow/Method_Initialize.qbl
new file mode 100644
index 0000000..2bdcc0c
--- /dev/null
+++ b/_Main/BL/Type_FinancialProductionRow/Method_Initialize.qbl
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: #root
+Method Initialize (
+  FinancialProductionColumn column,
+  Real quantity
+)
+{
+  TextBody:
+  [*
+    // 鐢勫叞楦� Jun-24-2024 (created)
+    cell := selectobject( this, FinancialProductionCell, cell, cell.FinancialProductionColumn() = column );
+          
+    value := [Real]cell.Value() + quantity;
+    cell.Value( [String]value );
+  *]
+}
diff --git a/_Main/BL/Type_FinancialProductionSource/Attribute_IsImport.qbl b/_Main/BL/Type_FinancialProductionSource/Attribute_IsImport.qbl
new file mode 100644
index 0000000..cc83511
--- /dev/null
+++ b/_Main/BL/Type_FinancialProductionSource/Attribute_IsImport.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute IsImport
+{
+  #keys: '3[415136.0.842718587][415136.0.842718586][415136.0.842718588]'
+  ValueType: Boolean
+}
diff --git a/_Main/BL/Type_FinancialProductionSource/Method_AfterImport.qbl b/_Main/BL/Type_FinancialProductionSource/Method_AfterImport.qbl
new file mode 100644
index 0000000..61fce2d
--- /dev/null
+++ b/_Main/BL/Type_FinancialProductionSource/Method_AfterImport.qbl
@@ -0,0 +1,37 @@
+Quintiq file version 2.0
+#parent: #root
+Method AfterImport
+{
+  TextBody:
+  [*
+    // 鐢勫叞楦� Jun-24-2024 (created)
+    table := selectobject( this.MacroPlan(), FinancialProductionSource.FinancialProductionReport, table, not table.IsImport() );
+    //info( '--------------------------', table.Name() );
+    traverse( this, FinancialProductionReport, report ){
+      productcolumn := selectobject( report, FinancialProductionColumn, column, column.Name() = 'Product' );
+      unitcolumn    := selectobject( report, FinancialProductionColumn, column, column.Name() = 'Unit' );
+      
+      traverse( report, FinancialProductionRow, row ){
+        product := selectobject( row, FinancialProductionCell, cell, cell.FinancialProductionColumn() = productcolumn );
+        unit    := selectobject( row, FinancialProductionCell, cell, cell.FinancialProductionColumn() = unitcolumn );
+        
+        unitrow := selectobject( table, FinancialProductionRow, unitrow, unitrow.Name() = product.Value() and unitrow.Unit() = unit.Value() );
+        allrow  := selectobject( table, FinancialProductionRow, allrow, allrow.Name() = product.Value() and allrow.Unit() = '<All>' );
+        
+        traverse( row, FinancialProductionCell, cell, cell.FinancialProductionColumn() <> productcolumn and cell.FinancialProductionColumn() <> unitcolumn and product.Value() = '120 kW Rotor' and unit.Value() = 'Assembly Plant (Spain)' ){
+          column   := cell.FinancialProductionColumn();
+          unitcell := selectobject( unitrow, FinancialProductionCell, unitcell, unitcell.FinancialProductionColumn().Name() = column.Name() );
+          allcell  := selectobject( allrow, FinancialProductionCell, allcell, allcell.FinancialProductionColumn().Name() = column.Name() );
+          info( isnull( unitcell ), isnull( allcell ), cell.Value(), unitcell.Value(), allcell.Value() );
+          if( not isnull( unitcell ) ){
+            unitcell.Value( cell.Value() );
+          }
+          if( not isnull( allcell ) ){
+            value := [Real]cell.Value() + [Real]allcell.Value();
+            allcell.Value( [String]value );
+          }
+        }
+      }
+    }
+  *]
+}
diff --git a/_Main/BL/Type_FinancialProductionSource/Method_Filter.qbl b/_Main/BL/Type_FinancialProductionSource/Method_Filter.qbl
new file mode 100644
index 0000000..fa51b40
--- /dev/null
+++ b/_Main/BL/Type_FinancialProductionSource/Method_Filter.qbl
@@ -0,0 +1,18 @@
+Quintiq file version 2.0
+#parent: #root
+Method Filter (
+  String productids,
+  String unit
+) declarative remote
+{
+  TextBody:
+  [*
+    // 鐢勫叞楦� Jun-24-2024 (created)
+    info( '------------1-----------', unit, '-', productids );
+    traverse( this, FinancialProductionReport.FinancialProductionRow, row, row.Name() = '92 kW Stator' ){
+      productid := construct( Strings );
+      productid.Add( row.Name() );
+      info( '-----------------------', row.Name(), row.Unit(), productids.FindString( row.Name(), 0 ), row.Unit() = unit );
+    }
+  *]
+}
diff --git a/_Main/BL/Type_FinancialProductionSource/Method_ReadStructure.qbl b/_Main/BL/Type_FinancialProductionSource/Method_ReadStructure.qbl
index 23e15cb..9e66381 100644
--- a/_Main/BL/Type_FinancialProductionSource/Method_ReadStructure.qbl
+++ b/_Main/BL/Type_FinancialProductionSource/Method_ReadStructure.qbl
@@ -20,7 +20,12 @@
       xlstable.SyncRows();
       
       xlstable.Name( sheetName );
+      xlstable.IsImport( true );
       this.FinancialProductionReport( relinsert, &xlstable ); 
+      
+      Transaction::Transaction().Propagate( attribute( FinancialProductionColumn, Index ) );
     }
+    //瀵煎叆鍚庡鐞嗘暟鎹�
+    this.AfterImport();
   *]
 }
diff --git a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Download.qbl b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Download.qbl
index 5d56a54..a655636 100644
--- a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Download.qbl
+++ b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Download.qbl
@@ -1,19 +1,40 @@
 Quintiq file version 2.0
 #parent: #root
 StaticMethod Download (
-  MacroPlan macroPlan
+  MacroPlan macroPlan,
+  Boolean istemplate
 ) as BinaryValue
 {
+  Description: '涓嬭浇璐㈠姟鎶ヨ〃鏁版嵁'
   TextBody:
   [*
+    startofplanning := macroPlan.StartOfPlanning().Date();
     table := selectobject( macroPlan, FinancialProductionSource.FinancialProductionReport, table, not table.IsImport() );
     
     xmlDOMI := XMLDOMImplementation::Create();
     xmlDOM  := xmlDOMI.CreateDocumentFromString( '<?xml version="1.0" encoding="UTF-16"?><table><name>' + table.Name() + '</name></table>' );
     
     tableElement := xmlDOM.GetElementByTagName( "table", 0 );
+    //Product
+    productcolumnelement := xmlDOM.CreateElement( "column" );
+    productnameelement   := xmlDOM.CreateElement( "name" );
+    producttypeelement   := xmlDOM.CreateElement( "type" );
+    productnameelement.TextContent( 'Product' );
+    producttypeelement.TextContent( "String" );
+    productcolumnelement.AppendChild( productnameelement );
+    productcolumnelement.AppendChild( producttypeelement );
+    //Unit
+    unitcolumnelement := xmlDOM.CreateElement( "column" );
+    unitnameelement   := xmlDOM.CreateElement( "name" );
+    unittypeelement   := xmlDOM.CreateElement( "type" );
+    unitnameelement.TextContent( 'Unit' );
+    unittypeelement.TextContent( "String" );
+    unitcolumnelement.AppendChild( unitnameelement );
+    unitcolumnelement.AppendChild( unittypeelement );
     
-    traverse ( table, FinancialProductionColumn, column ) {
+    tableElement.AppendChild( productcolumnelement ); 
+    tableElement.AppendChild( unitcolumnelement ); 
+    traverse ( table, FinancialProductionColumn, column, not istemplate or column.Period() < startofplanning ) {
       columnelement := xmlDOM.CreateElement( "column" );
       nameelement   := xmlDOM.CreateElement( "name" );
       typeelement   := xmlDOM.CreateElement( "type" );
@@ -22,13 +43,28 @@
       columnelement.AppendChild( nameelement );
       columnelement.AppendChild( typeelement );
       
-      cells := selectsortedset( column, FinancialProductionCell, cell, true, cell.FinancialProductionRow().RowNr() );
+      cells := selectsortedset( column, FinancialProductionCell, cell, cell.FinancialProductionRow().Unit() <> '<All>', cell.FinancialProductionRow().Name() );
+    
       traverse ( cells, Elements, c ) {
+        if( column.Index() = 0 ){
+          row := c.FinancialProductionRow();
+          //Product
+          productcellElement := xmlDOM.CreateElement( "cell" );
+          productcellElement.SetAttribute( "value", row.Name() );
+          productcolumnelement.AppendChild( productcellElement );
+          //Unit
+          unitcellElement := xmlDOM.CreateElement( "cell" );
+          unitcellElement.SetAttribute( "value", row.Unit() );
+          unitcolumnelement.AppendChild( unitcellElement );
+        }
         cellElement := xmlDOM.CreateElement( "cell" );
-        cellElement.SetAttribute( "value", c.Value() );
+        if( istemplate ){
+          cellElement.SetAttribute( "value", '' );
+        }else{
+          cellElement.SetAttribute( "value", c.Value() ); 
+        }
         columnelement.AppendChild( cellElement );
       }
-      
       tableElement.AppendChild( columnelement );  
     }
     
diff --git a/_Main/BL/Type_FinancialProductionSource/StaticMethod_DownloadTemplate.qbl b/_Main/BL/Type_FinancialProductionSource/StaticMethod_DownloadTemplate.qbl
index 4e29ea7..3e744a6 100644
--- a/_Main/BL/Type_FinancialProductionSource/StaticMethod_DownloadTemplate.qbl
+++ b/_Main/BL/Type_FinancialProductionSource/StaticMethod_DownloadTemplate.qbl
@@ -12,9 +12,9 @@
     tableElement              := xmlDOM.GetElementByTagName( "table", 0 );
     
     startofyear               := macroPlan.StartOfPlanning().StartOfYear();
-    startofnextyear           := macroPlan.StartOfPlanning().StartOfNextYear();
+    startofplanning           := macroPlan.StartOfPlanning();
     
-    for( start := startofyear; start < startofnextyear; start := start.StartOfNextMonth() ){
+    for( start := startofyear; start < startofplanning; start := start.StartOfNextMonth() ){
       columnElement := xmlDOM.CreateElement( "column" );
       nameElement   := xmlDOM.CreateElement( "name" );
       typeElement   := xmlDOM.CreateElement( "type" );
diff --git a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
new file mode 100644
index 0000000..5aeeda4
--- /dev/null
+++ b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
@@ -0,0 +1,79 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod Initialize (
+  MacroPlan owner
+)
+{
+  TextBody:
+  [*
+    // 鐢勫叞楦� Jun-24-2024 (created)
+    owner.FinancialProductionSource( relflush );
+    ccunit                    := 'Assembly Plant (France)';
+    dlunit                    := 'Assembly Plant (Spain)';
+    source                    := owner.FinancialProductionSource( relnew, IsImport := false, Name := 'Financial productions' );
+    table                     := source.FinancialProductionReport( relnew, ID := source.Name(), Name := source.Name(), IsImport := false );
+    startofplanning           := owner.StartOfPlanning();
+    startofnextmonth          := owner.StartOfPlanning().StartOfNextMonth();
+    startofyear               := startofplanning.StartOfYear();
+    startofnextyear           := startofplanning.StartOfNextYear();
+    info( ccunit, dlunit, source.Name(), table.Name(), startofplanning );
+    //unitids := selectuniquevalues( owner, Product_MP.ProductInStockingPoint_MP, pisp, pisp.StockingPoint_MP().UnitID() );
+    //traverse( unitids, Elements, e ){
+    //  info( e );
+    //}
+    traverse( owner, Product_MP.ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() and ( pisp.StockingPoint_MP().UnitID() = ccunit or pisp.StockingPoint_MP().UnitID() = dlunit ) ){
+      unit := pisp.StockingPoint_MP().UnitID();
+      info( unit, pisp.ProductID() );
+      ccrow := null( FinancialProductionRow );
+      dlrow := null( FinancialProductionRow );
+      allrow := selectobject( table, FinancialProductionRow, row, row.Name() = pisp.ProductID() and row.Unit() = '<All>' );
+      if( unit = ccunit ){
+        ccrow := table.FinancialProductionRow( relnew, Name := pisp.ProductID(), Unit := unit );
+      }else{
+        dlrow := table.FinancialProductionRow( relnew, Name := pisp.ProductID(), Unit := unit );
+      }
+      if( isnull( allrow ) ){
+        allrow := table.FinancialProductionRow( relnew, Name := pisp.ProductID(), Unit := '<All>' );
+      }
+      
+      for( start := startofyear; start < startofnextyear; start := start.StartOfNextMonth() ){
+        periodtime := start.Date();
+        periodname := periodtime.Format( "M2/D2/Y" );
+        column := selectobject( table, FinancialProductionColumn, column, column.Name() = periodname and column.Period() = periodtime );
+        
+        if( isnull( column ) ){
+          column := table.FinancialProductionColumn( relnew, Name := periodname, Period := periodtime );
+        }
+        
+        if( not isnull( ccrow ) ){
+          ccrow.Initialize( column, ccunit );
+        }
+        if( not isnull( dlrow ) ){
+          dlrow.Initialize( column, dlunit );
+        }
+        if( not exists( allrow, FinancialProductionCell, allcell, allcell.FinancialProductionColumn() = column ) ){
+          allrow.Initialize( column, '<All>' );
+        }
+      }
+      
+      traverse( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start() >= startofplanning
+                and ( ( pispip.Start() < startofnextmonth and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() ) 
+                      or ( pispip.Start() < startofnextyear and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Month() ) ) ){
+        periodtime := pispip.Start().StartOfMonth().Date();
+        periodname := periodtime.Format( "M2/D2/Y" );
+        
+        column := selectobject( table, FinancialProductionColumn, column, column.Name() = periodname and column.Period() = periodtime );
+        
+        if( not isnull( ccrow ) ){
+          ccrow.Initialize( column, pispip.NewSupplyProductionQuantity() );
+        }
+        if( not isnull( dlrow ) ){
+          dlrow.Initialize( column, pispip.NewSupplyProductionQuantity() );
+        }
+        if( not exists( allrow, FinancialProductionCell, allcell, allcell.FinancialProductionColumn() = column ) ){
+          allrow.Initialize( column, pispip.NewSupplyProductionQuantity() );
+        }
+      }
+    }
+  *]
+}
diff --git a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Upload.qbl b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Upload.qbl
index 9ffca0d..2e3f777 100644
--- a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Upload.qbl
+++ b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Upload.qbl
@@ -13,6 +13,7 @@
     source := owner.FinancialProductionSource( relnew, FileBinaryValue := binaryValue,
                                                Name                    := fileName,
                                                IsXLSX                  := fileName.EndsWith( "xlsx" ),
+                                               IsImport                := true,
                                                UploadDateTime          := DateTime::ActualTime().Format( "Y-M2-D2 H:m:s" ),
                                                UploadUser              := guard( QuintiqUser::CurrentUser().Username(), "" ) );
     
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_MatrixEditorTable.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_MatrixEditorTable.def
new file mode 100644
index 0000000..cb22804
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_MatrixEditorTable.def
@@ -0,0 +1,99 @@
+Quintiq file version 2.0
+Component MatrixEditorTable
+{
+  #keys: '[415136.0.844701426]'
+  BaseType: 'WebMatrixEditor'
+  Children:
+  [
+    Component MatrixEditorCellTable
+    {
+      #keys: '[415136.0.844701427]'
+      BaseType: 'WebMatrixEditorCell'
+      Children:
+      [
+        Component DataExtractorCell
+        {
+          #keys: '[415136.0.844701428]'
+          BaseType: 'WebDataExtractor'
+          Properties:
+          [
+            DataType: 'FinancialProductionReport'
+            Source: 'DataHolderTable'
+            Taborder: 0
+            Transformation: 'FinancialProductionColumn.FinancialProductionCell'
+          ]
+        }
+      ]
+      Properties:
+      [
+        Attributes: 'Value'
+        Column: 'FinancialProductionColumn'
+        Row: 'FinancialProductionRow'
+        Taborder: 0
+      ]
+    }
+    Component MatrixEditorRowsTable
+    {
+      #keys: '[415136.0.844701431]'
+      BaseType: 'WebMatrixEditorHeaderLevel'
+      Children:
+      [
+        Component DataExtractorRow
+        {
+          #keys: '[415136.0.844701432]'
+          BaseType: 'WebDataExtractor'
+          Properties:
+          [
+            DataType: 'FinancialProductionReport'
+            Description: 'productids.FindString( object.Name(), 0 ) >= 0 and object.Unit() = unit'
+            FilterArguments: 'unit:QMacroPlanner::FormFinancialProductionReport.dhUnit;productids:QMacroPlanner::FormFinancialProductionReport.dhProductIDs'
+            Source: 'DataHolderTable'
+            Taborder: 0
+            Transformation: 'FinancialProductionRow'
+          ]
+        }
+      ]
+      Properties:
+      [
+        Legend: 'Name'
+        SortCriteria: 'Name'
+        Taborder: 1
+      ]
+    }
+    Component MatrixEditorColumnsTable
+    {
+      #keys: '[415136.0.844701435]'
+      BaseType: 'WebMatrixEditorHeaderLevel'
+      Children:
+      [
+        Component DataExtractorColumn
+        {
+          #keys: '[415136.0.844701436]'
+          BaseType: 'WebDataExtractor'
+          Properties:
+          [
+            DataType: 'FinancialProductionReport'
+            Source: 'DataHolderTable'
+            Taborder: 0
+            Transformation: 'FinancialProductionColumn'
+          ]
+        }
+      ]
+      Properties:
+      [
+        Legend: 'Name'
+        SortCriteria: 'Index'
+        Taborder: 2
+      ]
+    }
+    #child: matrixEditorActionBarPageTable
+    #child: matrixeditorContextMenuTable
+  ]
+  Properties:
+  [
+    Columns: 'MatrixEditorColumnsTable'
+    ContextMenu: 'matrixeditorContextMenuTable'
+    Rows: 'MatrixEditorRowsTable'
+    Taborder: 0
+  ]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelFinancialProductionReportHeader.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelFinancialProductionReportHeader.def
index 5779852..5527cd6 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelFinancialProductionReportHeader.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelFinancialProductionReportHeader.def
@@ -10,6 +10,7 @@
   ]
   Properties:
   [
-    Taborder: 0
+    FixedSize: true
+    Taborder: 2
   ]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelFinancialProductionReportTable.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelFinancialProductionReportTable.def
deleted file mode 100644
index 19a477e..0000000
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelFinancialProductionReportTable.def
+++ /dev/null
@@ -1,10 +0,0 @@
-Quintiq file version 2.0
-Component PanelFinancialProductionReportTable
-{
-  #keys: '[415136.0.834352365]'
-  BaseType: 'WebPanel'
-  Properties:
-  [
-    Taborder: 1
-  ]
-}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelGeneration.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelGeneration.def
index 3161a19..8e10c6d 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelGeneration.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelGeneration.def
@@ -15,6 +15,16 @@
         Taborder: 0
       ]
     }
+    Component dhGeneration
+    {
+      #keys: '[415136.0.840791740]'
+      BaseType: 'WebDataHolder'
+      Databinding: 'String'
+      Properties:
+      [
+        Taborder: 1
+      ]
+    }
   ]
   Properties:
   [
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelMQBMLB.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelMQBMLB.def
index 8bdd3ca..cdde840 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelMQBMLB.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelMQBMLB.def
@@ -15,6 +15,16 @@
         Taborder: 0
       ]
     }
+    Component dhMQBMLB
+    {
+      #keys: '[415136.0.842090347]'
+      BaseType: 'WebDataHolder'
+      Databinding: 'String'
+      Properties:
+      [
+        Taborder: 1
+      ]
+    }
   ]
   Properties:
   [
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelPower.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelPower.def
index d027e3a..4929267 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelPower.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelPower.def
@@ -15,6 +15,16 @@
         Taborder: 0
       ]
     }
+    Component dhPower
+    {
+      #keys: '[415136.0.842090452]'
+      BaseType: 'WebDataHolder'
+      Databinding: 'String'
+      Properties:
+      [
+        Taborder: 1
+      ]
+    }
   ]
   Properties:
   [
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelTable.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelTable.def
new file mode 100644
index 0000000..4cf2817
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelTable.def
@@ -0,0 +1,14 @@
+Quintiq file version 2.0
+Component PanelTable
+{
+  #keys: '[415136.0.834352365]'
+  BaseType: 'WebPanel'
+  Children:
+  [
+    #child: MatrixEditorTable
+  ]
+  Properties:
+  [
+    Taborder: 3
+  ]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelUnit.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelUnit.def
index 451f699..b331fcc 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelUnit.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_PanelUnit.def
@@ -12,10 +12,19 @@
       Properties:
       [
         Label: 'Unit'
-        Strings: '<All>;闀挎槬;澶ц繛'
         Taborder: 0
       ]
     }
+    Component dhUnit
+    {
+      #keys: '[415136.0.840791605]'
+      BaseType: 'WebDataHolder'
+      Databinding: 'String'
+      Properties:
+      [
+        Taborder: 1
+      ]
+    }
   ]
   Properties:
   [
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_matrixEditorActionBarPageTable.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_matrixEditorActionBarPageTable.def
new file mode 100644
index 0000000..16fafd3
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_matrixEditorActionBarPageTable.def
@@ -0,0 +1,10 @@
+Quintiq file version 2.0
+Component matrixEditorActionBarPageTable
+{
+  #keys: '[415136.0.844701439]'
+  BaseType: 'matrixEditorActionBarPage'
+  Properties:
+  [
+    Taborder: 3
+  ]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_matrixeditorContextMenuTable.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_matrixeditorContextMenuTable.def
new file mode 100644
index 0000000..5a4b184
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_matrixeditorContextMenuTable.def
@@ -0,0 +1,10 @@
+Quintiq file version 2.0
+Component matrixeditorContextMenuTable
+{
+  #keys: '[415136.0.844701442]'
+  BaseType: 'matrixeditorContextMenu'
+  Properties:
+  [
+    Taborder: 4
+  ]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Method_filter.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Method_filter.def
new file mode 100644
index 0000000..fe82ebc
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Method_filter.def
@@ -0,0 +1,18 @@
+Quintiq file version 2.0
+#parent: #root
+Method filter () id:Method_FormFinancialProductionReport_filter
+{
+  #keys: '[415136.0.849432122]'
+  Body:
+  [*
+    generation := ddslGeneration.Text();
+    mqbmlb     := ddslMQBMLB.Text();
+    power      := ddslPower.Text();
+    products   := DataHolderProduct.Data();
+    productids := selectuniquevalues( products, Elements, product, ( generation = '<All>' or product.Generation() = generation ) and 
+                                      ( mqbmlb = '<All>' or product.MQBMLB() = mqbmlb ) and 
+                                      ( power = '<All>' or product.Power() = power ), product.ID() );
+    
+    dhProductIDs.Data( productids.Concatenate( ';' ) );
+  *]
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_OnCreated.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_OnCreated.def
new file mode 100644
index 0000000..e6a840f
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_OnCreated.def
@@ -0,0 +1,23 @@
+Quintiq file version 2.0
+#parent: #root
+Response OnCreated () id:Response_FormFinancialProductionReport_OnCreated
+{
+  #keys: '[415136.0.842812649]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebComponent_OnCreated'
+  QuillAction
+  {
+    Body:
+    [*
+      //鍒濆鍖�
+      if( not exists( MacroPlan, FinancialProductionSource, source, not source.IsImport() ) ){
+        FinancialProductionSource::Initialize( MacroPlan );
+      }
+      //info( '------------------1----------------' );
+      table := selectobject( MacroPlan, FinancialProductionSource.FinancialProductionReport, table, not table.IsImport() );
+      //info( '------------------2----------------' );
+      DataHolderTable.Data( table );
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelExport_ButtonExport_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelExport_ButtonExport_OnClick.def
index 13d7fd4..174cd83 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelExport_ButtonExport_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelExport_ButtonExport_OnClick.def
@@ -13,7 +13,7 @@
   {
     Body:
     [*
-      binaryValue := FinancialProductionSource::Download( MacroPlan );
+      binaryValue := FinancialProductionSource::Download( MacroPlan, false );
       
       Application.Download( "Financial productions.xlsx", binaryValue.AsBinaryData() );
     *]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelFinancialProductionReportOperation_ButtonProductionExport_OnCl.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelFinancialProductionReportOperation_ButtonProductionExport_OnCl.def
index 176b03b..e78b4e0 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelFinancialProductionReportOperation_ButtonProductionExport_OnCl.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelFinancialProductionReportOperation_ButtonProductionExport_OnCl.def
@@ -13,7 +13,7 @@
   {
     Body:
     [*
-      binaryValue := FinancialProductionSource::DownloadTemplate( MacroPlan );
+      binaryValue := FinancialProductionSource::Download( MacroPlan, true );
       
       Application.Download( "Financial productions.xlsx", binaryValue.AsBinaryData() );
     *]
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelFinancialProductionReportOperation_ButtonProductionImport_OnCl.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelFinancialProductionReportOperation_ButtonProductionImport_OnCl.def
index 03863b1..eece9c0 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelFinancialProductionReportOperation_ButtonProductionImport_OnCl.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelFinancialProductionReportOperation_ButtonProductionImport_OnCl.def
@@ -28,6 +28,9 @@
           source.ReadStructure();
           
           WebMessageBox::Success( Translations::A_VWED_Success() );
+          traverse( MacroPlan, FinancialProductionSource, psource, psource.IsImport() and psource <> source ){
+            psource.Delete();
+          }
         }
       } onerror {
         WebMessageBox::Error( e.GeneralInformation() );
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelGeneration_ddslGeneration_OnSelectionChanged.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelGeneration_ddslGeneration_OnSelectionChanged.def
new file mode 100644
index 0000000..8d3aab8
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelGeneration_ddslGeneration_OnSelectionChanged.def
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: PanelGeneration/ddslGeneration
+Response OnSelectionChanged () id:Response_PanelGeneration_ddslGeneration_OnSelectionChanged
+{
+  #keys: '[415136.0.840791771]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebDropDownStringList_OnSelectionChanged'
+  QuillAction
+  {
+    Body:
+    [*
+      Form.filter();
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelMQBMLB_ddslMQBMLB_OnSelectionChanged.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelMQBMLB_ddslMQBMLB_OnSelectionChanged.def
new file mode 100644
index 0000000..f2ad88a
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelMQBMLB_ddslMQBMLB_OnSelectionChanged.def
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: PanelMQBMLB/ddslMQBMLB
+Response OnSelectionChanged () id:Response_PanelMQBMLB_ddslMQBMLB_OnSelectionChanged
+{
+  #keys: '[415136.0.842090372]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebDropDownStringList_OnSelectionChanged'
+  QuillAction
+  {
+    Body:
+    [*
+      Form.filter();
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelPower_ddslPower_OnSelectionChanged.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelPower_ddslPower_OnSelectionChanged.def
new file mode 100644
index 0000000..0b27c5e
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelPower_ddslPower_OnSelectionChanged.def
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: PanelPower/ddslPower
+Response OnSelectionChanged () id:Response_PanelPower_ddslPower_OnSelectionChanged
+{
+  #keys: '[415136.0.842090478]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebDropDownStringList_OnSelectionChanged'
+  QuillAction
+  {
+    Body:
+    [*
+      Form.filter();
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_ddslUnit_OnCreated.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_ddslUnit_OnCreated.def
new file mode 100644
index 0000000..a70ff22
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_ddslUnit_OnCreated.def
@@ -0,0 +1,19 @@
+Quintiq file version 2.0
+#parent: PanelUnit/ddslUnit
+Response OnCreated () id:Response_PanelUnit_ddslUnit_OnCreated
+{
+  #keys: '[415136.0.848320822]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebComponent_OnCreated'
+  QuillAction
+  {
+    Body:
+    [*
+      
+      valueString := "<All>;Spider Assy Line 1;Body in White Line 3";
+      
+      this.Strings( valueString );
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_ddslUnit_OnSelectionChanged.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_ddslUnit_OnSelectionChanged.def
new file mode 100644
index 0000000..45dd899
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_ddslUnit_OnSelectionChanged.def
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: PanelUnit/ddslUnit
+Response OnSelectionChanged () id:Response_PanelUnit_ddslUnit_OnSelectionChanged
+{
+  #keys: '[415136.0.840791631]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebDropDownStringList_OnSelectionChanged'
+  QuillAction
+  {
+    Body:
+    [*
+      dhUnit.Data( selection );
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_dhUnit_OnCreated.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_dhUnit_OnCreated.def
new file mode 100644
index 0000000..91b4a0b
--- /dev/null
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Response_PanelUnit_dhUnit_OnCreated.def
@@ -0,0 +1,16 @@
+Quintiq file version 2.0
+#parent: PanelUnit/dhUnit
+Response OnCreated () id:Response_PanelUnit_dhUnit_OnCreated
+{
+  #keys: '[415136.0.848341171]'
+  CanBindMultiple: false
+  DefinitionID: 'Responsedef_WebComponent_OnCreated'
+  QuillAction
+  {
+    Body:
+    [*
+      this.Data( '<All>' );
+    *]
+    GroupServerCalls: false
+  }
+}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/_ROOT_Component_FormFinancialProductionReport.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/_ROOT_Component_FormFinancialProductionReport.def
index aee99fe..2001ad9 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/_ROOT_Component_FormFinancialProductionReport.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/_ROOT_Component_FormFinancialProductionReport.def
@@ -8,7 +8,27 @@
   Children:
   [
     #child: PanelFinancialProductionReportHeader
-    #child: PanelFinancialProductionReportTable
+    #child: PanelTable
+    Component DataHolderTable
+    {
+      #keys: '[415136.0.840720309]'
+      BaseType: 'WebDataHolder'
+      Databinding: 'FinancialProductionReport'
+      Properties:
+      [
+        Taborder: 0
+      ]
+    }
+    Component dhProductIDs
+    {
+      #keys: '[415136.0.849431513]'
+      BaseType: 'WebDataHolder'
+      Databinding: 'String'
+      Properties:
+      [
+        Taborder: 1
+      ]
+    }
   ]
   Properties:
   [

--
Gitblit v1.9.3