From 3ef592a0cd20ce531526b3ecbe73c3e0f31838b0 Mon Sep 17 00:00:00 2001
From: lihongji <3117313295@qq.com>
Date: 星期三, 18 九月 2024 16:13:23 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Component_MatrixEditorTable#623.def  |    2 
 _Main/BL/Type_FinancialProductionReport/Method_GenerateColumn.qbl                                   |   12 +
 _Main/BL/Type_FinancialSalesReport/Method_GenerateColumn.qbl                                        |   12 +
 _Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl                               |  119 ++++++++------
 _Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_MatrixEditorTable.def |    2 
 _Main/BL/Type_ChangeLossSetting/StaticMethod_ValidateInput.qbl                                      |    2 
 _Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl                                      |   18 +
 _Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl                              |  236 ++++++++++++++++-------------
 _Main/BL/Type_FinancialProductionColumn/Attribute_IsDay.qbl                                         |    7 
 _Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl                                 |   26 +-
 _Main/BL/Type_FinancialSalesColumn/Attribute_IsDay.qbl                                              |    7 
 _Main/BL/Type_FinancialProductionReport/Method_Generate.qbl                                         |    2 
 12 files changed, 264 insertions(+), 181 deletions(-)

diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
index 42c2471..8a22432 100644
--- a/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
@@ -29,23 +29,27 @@
     //澶栫搴撳叆搴撹垂鐢細鍙栬嚜璐㈠姟浜ч噺鎶ヨ〃鐨勪骇閲忥紝鍦ㄤ骇鍝佽〃鏍规嵁鍙戝姩鏈哄彿鎵惧埌瀵瑰簲鐨凣eneration 鍜屾í绾靛埗锛屽湪鍙戝姩鏈烘垚鏈弬鏁拌〃閲屾壘鍒板搴旂殑鍖呰瀹归噺鍜屽叆搴撳崟浠凤紝鐢ㄥ叕寮忚绠楋紝鏈堝害杩涜姹囨��
     traverse( owner, FinancialProductionSource, source, not source.IsImport() ){//璐㈠姟浜ч噺鎶ヨ〃闈炲鍏�
       traverse( source, FinancialProductionReport, report, not report.IsShow() ){//璐㈠姟浜ч噺鎶ヨ〃涓嶆樉绀�
-        traverse( report, FinancialProductionRow, row, row.Unit() = ccunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' ) ){//璐㈠姟浜ч噺鎶ヨ〃閲岀殑闀挎槬浜ч噺, 涓嶄负0
+        traverse( report, FinancialProductionRow, row, row.Unit() = ccunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' and cell.FinancialProductionColumn().IsDay() ) ){//璐㈠姟浜ч噺鎶ヨ〃閲岀殑闀挎槬浜ч噺, 涓嶄负0
           product             := row.Product_MP();
           productparents      := product.GetAllParent();
           if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
             //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-            enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
+            enginecosts       := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
                                                  and engine.Factory() = ccunit );
-            if( not isnull( enginecost ) ){
-              ccrow               := table.GetRow( row.Name() );
+            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
+              ccrow           := table.GetRow( row.Name() );
               products.Add( product );
-              traverse( row, FinancialProductionCell, cell, cell.Value() <> '0' ){
-                //鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环锛屽叆搴撻噺绛変簬闀挎槬浜ч噺
-                quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
-                column            := selectobject( table, Column, column, column.Name() = cell.FinancialProductionColumn().Name() );
-                //澶栫搴撳叆搴撹垂鐢�
-                ccrow.SetRentEnterCost( column, quantity );
+              traverse( row, FinancialProductionCell, cell, cell.Value() <> '0' and cell.FinancialProductionColumn().IsDay() ){
+                cellcolumn    := cell.FinancialProductionColumn();
+                enginecost    := selectobject( enginecosts, Elements, engine, engine.StartDate() <= cellcolumn.Period() and engine.EndDate() >= cellcolumn.Period() );
+                if( not isnull( enginecost ) ){
+                  //鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环锛屽叆搴撻噺绛変簬闀挎槬浜ч噺
+                  quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                  column            := selectobject( table, Column, column, column.Name() = cell.FinancialProductionColumn().Name() );
+                  //澶栫搴撳叆搴撹垂鐢�
+                  ccrow.SetRentEnterCost( column, quantity );
+                }
               }
             }
           }
@@ -55,23 +59,27 @@
     //澶栫搴撳嚭搴撹垂鐢細鍑哄簱閲忕瓑浜庨暱鏄ラ攢閲忥紝鍙栬嚜璐㈠姟閿�閲忔姤琛ㄧ殑閿�閲忥紝鍦ㄤ骇鍝佽〃鏍规嵁鍙戝姩鏈哄彿鎵惧埌瀵瑰簲鐨凣eneration 鍜屾í绾靛埗锛屽湪鍙戝姩鏈烘垚鏈弬鏁拌〃閲屾壘鍒板搴旂殑鍖呰瀹归噺鍜屽嚭搴撳崟浠凤紝鐢ㄥ叕寮忚绠楋紝鏈堝害杩涜姹囨��
     traverse( owner, FinancialSalesSource, source, not source.IsImport() ){//璐㈠姟閿�閲忔姤琛ㄩ潪瀵煎叆
       traverse( source, FinancialSalesReport, report, not report.IsShow() ){//璐㈠姟閿�閲忔姤琛ㄤ笉鏄剧ず
-        traverse( report, FinancialSalesRow, row, row.Unit() = ccunit and exists( row, FinancialSalesCell, cell, cell.Value() <> '0' ) ){//璐㈠姟閿�閲忔姤琛ㄩ噷鐨勯暱鏄ヤ骇閲�, 涓嶄负0
+        traverse( report, FinancialSalesRow, row, row.Unit() = ccunit and exists( row, FinancialSalesCell, cell, cell.Value() <> '0' and cell.FinancialSalesColumn().IsDay() ) ){//璐㈠姟閿�閲忔姤琛ㄩ噷鐨勯暱鏄ヤ骇閲�, 涓嶄负0
           product             := row.Product_MP();
           productparents      := product.GetAllParent();
           if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
             //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-            enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
+            enginecosts       := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
                                                  and engine.Factory() = ccunit );
-            if( not isnull( enginecost ) ){
-              ccrow               := table.GetRow( row.Name() );
+            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
+              ccrow           := table.GetRow( row.Name() );
               products.Add( product );
-              traverse( row, FinancialSalesCell, cell, cell.Value() <> '0' ){
-                //鍑哄簱閲�/鍖呰瀹归噺*鍑哄簱鍗曚环锛屽叆搴撻噺绛変簬闀挎槬閿�閲�
-                quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
-                column            := selectobject( table, Column, column, column.Name() = cell.FinancialSalesColumn().Name() );
-                //澶栫搴撳嚭搴撹垂鐢�
-                ccrow.SetRentOutCost( column, quantity );
+              traverse( row, FinancialSalesCell, cell, cell.Value() <> '0' and cell.FinancialSalesColumn().IsDay() ){
+                cellcolumn    := cell.FinancialSalesColumn();
+                enginecost    := selectobject( enginecosts, Elements, engine, engine.StartDate() <= cellcolumn.Period() and engine.EndDate() >= cellcolumn.Period() );
+                if( not isnull( enginecost ) ){
+                  //鍑哄簱閲�/鍖呰瀹归噺*鍑哄簱鍗曚环锛屽叆搴撻噺绛変簬闀挎槬閿�閲�
+                  quantity    := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                  column      := selectobject( table, Column, column, column.Name() = cell.FinancialSalesColumn().Name() );
+                  //澶栫搴撳嚭搴撹垂鐢�
+                  ccrow.SetRentOutCost( column, quantity );
+                }
               }
             }
           }
@@ -92,25 +100,29 @@
           periodname         := periodtime.Format( "M2/D2/Y" );
           
           column             := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
-          traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
-            product          := pit.Product_MP();
-            productparents   := product.GetAllParent();
-            if( exists( productparents, Elements, e, e.ID() = produtparent ) ){////鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
-              //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
-              enginecost       := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower()
-                                                 and engine.MLB_MQB() = product.MQBMLB()
-                                                 and engine.Factory() = ccunit );
-              //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
-              transcost        := selectobject( owner, LogisticsCostTransport, trans, trans.Origin() = ccline 
-                                                and trans.Destination() = ccrent 
-                                                and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent,  e.ID() = trans.Product() ) ) );
-              if( not isnull( enginecost ) and not isnull( transcost ) ){
-                row              := table.GetRow( pit.ProductID() );
-                products.Add( product );
-                //杩愯緭鏁伴噺/鍖呰瀹归噺/瑁呰浇瀹归噺*杩愯緭鍗曚环
-                quantity       := ceil( ceil( [Number]pit.Quantity() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//鍥涜垗浜斿叆
-                
-                row.SetFactoryToRentTransCost( column, quantity );
+          enginecosts        := selectset( owner, LogisticsCostEngine, engine, engine.StartDate() <= trip.Arrival().Date() and engine.EndDate() >= trip.Arrival().Date() );
+          transcosts         := selectset( owner, LogisticsCostTransport, trans, trans.StartDate() <= trip.Arrival().Date() and trans.EndDate() >= trip.Arrival().Date() );
+          if( not isnull( enginecosts ) and enginecosts.Size() > 0 and not isnull( transcosts ) and transcosts.Size() > 0 ){
+            traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
+              product          := pit.Product_MP();
+              productparents   := product.GetAllParent();
+              if( exists( productparents, Elements, e, e.ID() = produtparent ) ){////鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
+                //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
+                enginecost     := selectobject( enginecosts, Elements, engine, engine.Generation().ToLower() = product.Generation().ToLower()
+                                                   and engine.MLB_MQB() = product.MQBMLB()
+                                                   and engine.Factory() = ccunit );
+                //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
+                transcost      := selectobject( transcosts, Elements, trans, trans.Origin() = ccline 
+                                                  and trans.Destination() = ccrent 
+                                                  and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent,  e.ID() = trans.Product() ) ) );
+                if( not isnull( enginecost ) and not isnull( transcost ) ){
+                  row          := table.GetRow( pit.ProductID() );
+                  products.Add( product );
+                  //杩愯緭鏁伴噺/鍖呰瀹归噺/瑁呰浇瀹归噺*杩愯緭鍗曚环
+                  quantity     := ceil( ceil( [Number]pit.Quantity() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//鍥涜垗浜斿叆
+                  
+                  row.SetFactoryToRentTransCost( column, quantity );
+                }
               }
             }
           }
@@ -120,30 +132,33 @@
     //澶栫搴撲粨鍌ㄨ垂鐢細浠撳偍鏁伴噺/鍖呰瀹归噺*浠撳偍鍗曚环锛屽湪Actual inventories閲屽彇鍒伴暱鏄ュ绉熷簱璇ュ彂鍔ㄦ満鐨勪粨鍌ㄩ噺锛屾牴鎹彂鍔ㄦ満鍙锋壘鍒板搴旂殑Generation 鍜屾í绾靛埗锛屽湪鍙戝姩鏈烘垚鏈弬鏁拌〃閲屾壘鍒板搴旂殑浠撳偍鍗曚环鍜屽寘瑁呭閲忥紝鐢ㄥ叕寮忚绠楋紝鏈堝害杩涜姹囨��
     traverse( owner, StockingPoint_MP, stockingpoint ){
       //鏄惁灞炰簬闀挎槬澶栫搴�
-      isccrent               := table.IsInUnit( stockingpoint, ccrent );
+      isccrent                 := table.IsInUnit( stockingpoint, ccrent );
       if( isccrent ){
         traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() 
                   and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ) ){
           //鑾峰彇琛�
-          product            := pisp.Product_MP();
-          productparents     := product.GetAllParent();
+          product              := pisp.Product_MP();
+          productparents       := product.GetAllParent();
           if( exists( productparents, Elements, e, e.ID() = produtparent ) ){////鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
             //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-            enginecost         := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
+            enginecosts        := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
                                                  and engine.Factory() = ccunit );
-            if( not isnull( enginecost ) ){
-              row                := table.GetRow( pisp.ProductID() );
+            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
+              row              := table.GetRow( pisp.ProductID() );
               products.Add( product );
               //褰損roduct planning鐨勬棩鏈熷尯闂村湪闇�瑕佺殑鏃ユ湡鍖洪棿鍐� 
               traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ){
-                periodtime := pispip.Start().StartOfMonth().Date();
-                periodname := periodtime.Format( "M2/D2/Y" );
-                quantity   := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
-                
-                column := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
-                
-                row.SetRentStorageCost( column, quantity );
+                enginecost     := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date() );
+                if( not isnull( enginecost ) ){
+                  periodtime   := pispip.Start().StartOfMonth().Date();
+                  periodname   := periodtime.Format( "M2/D2/Y" );
+                  quantity     := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
+                  
+                  column       := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
+                  
+                  row.SetRentStorageCost( column, quantity );
+                }
               }    
             }
           }
diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl
index 7df872f..63f7b8e 100644
--- a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl
@@ -46,43 +46,47 @@
           periodname         := periodtime.Format( "M2/D2/Y" );
           
           column             := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
-          traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 and not isnull( column ) and exists( pit.Product_MP().GetAllParent(), Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
-            quantity         := [Number]pit.Quantity();
-            row              := table.GetRow( pit.ProductID() );
-            product          := pit.Product_MP();
-            productparents   := product.GetAllParent();
-            if( isccrent ){//鐩殑鍦版槸闀挎槬澶栫搴�
-              //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
-              enginecost     := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower()
-                                                 and engine.MLB_MQB() = product.MQBMLB()
-                                                 and engine.Factory() = ccunit );
-              if( not isnull( enginecost ) ){
-                products.Add( product );
-                cell         := selectobject( row, Cell, cell, cell.Column() = column );
-                cell.CCRentQuantity( cell.CCRentQuantity() + quantity );
-                //闀挎槬澶栫搴撳叆搴撹垂鐢細鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环
-                entercost    := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
-                //闀挎槬澶栫搴撳嚭搴撹垂鐢�: 鍑哄簱閲�/鍖呰瀹归噺*鍑哄簱鍗曚环
-                outcost      := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
-                cell.CCRentEnterCost( cell.CCRentEnterCost() + entercost );
-                cell.CCRentOutCost( cell.CCRentOutCost() + outcost );
+          enginecosts        := selectset( owner, LogisticsCostEngine, engine, engine.StartDate() <= trip.Departure().Date() and engine.EndDate() >= trip.Departure().Date() );
+          transcosts         := selectset( owner, LogisticsCostTransport, trans, trans.StartDate() <= trip.Departure().Date() and trans.EndDate() >= trip.Departure().Date() );
+          if( not isnull( enginecosts ) and enginecosts.Size() > 0 and not isnull( transcosts ) and transcosts.Size() > 0 ){
+            traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 and not isnull( column ) and exists( pit.Product_MP().GetAllParent(), Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
+              quantity       := [Number]pit.Quantity();
+              row            := table.GetRow( pit.ProductID() );
+              product        := pit.Product_MP();
+              productparents := product.GetAllParent();
+              if( isccrent ){//鐩殑鍦版槸闀挎槬澶栫搴�
+                //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
+                enginecost   := selectobject( enginecosts, Elements, engine, engine.Generation().ToLower() = product.Generation().ToLower()
+                                                   and engine.MLB_MQB() = product.MQBMLB()
+                                                   and engine.Factory() = ccunit );
+                if( not isnull( enginecost ) ){
+                  products.Add( product );
+                  cell       := selectobject( row, Cell, cell, cell.Column() = column );
+                  cell.CCRentQuantity( cell.CCRentQuantity() + quantity );
+                  //闀挎槬澶栫搴撳叆搴撹垂鐢細鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环
+                  entercost  := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                  //闀挎槬澶栫搴撳嚭搴撹垂鐢�: 鍑哄簱閲�/鍖呰瀹归噺*鍑哄簱鍗曚环
+                  outcost    := ceil( quantity / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                  cell.CCRentEnterCost( cell.CCRentEnterCost() + entercost );
+                  cell.CCRentOutCost( cell.CCRentOutCost() + outcost );
+                }
               }
-            }
-            if( isdlrent ){//鐩殑鍦版槸澶ц繛澶栫搴�
-              //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
-              enginecost     := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
-                                                 and engine.MLB_MQB() = product.MQBMLB()
-                                                 and engine.Factory() = dlunit  );
-              //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
-              transcost      := selectobject( owner, LogisticsCostTransport, trans, trans.Origin() = laneleg.OriginStockingPointID() 
-                                                and trans.Destination() = laneleg.DestinationStockingPointID() 
-                                                and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent,  e.ID() = trans.Product() ) ) );
-              if( not isnull( enginecost ) and not isnull( transcost ) ){
-                products.Add( product );
-                cell         := selectobject( row, Cell, cell, cell.Column() = column );
-                //杩愯緭鏁伴噺/鍖呰瀹归噺/瑁呰浇瀹归噺*杩愯緭鍗曚环
-                cost         := ceil( ceil( quantity / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//鍥涜垗浜斿叆
-                cell.FactoryToDLRentTransCost( cell.FactoryToDLRentTransCost() + cost );
+              if( isdlrent ){//鐩殑鍦版槸澶ц繛澶栫搴�
+                //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
+                enginecost   := selectobject( enginecosts, Elements, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
+                                                   and engine.MLB_MQB() = product.MQBMLB()
+                                                   and engine.Factory() = dlunit  );
+                //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
+                transcost    := selectobject( transcosts, Elements, trans, trans.Origin() = laneleg.OriginStockingPointID() 
+                                                  and trans.Destination() = laneleg.DestinationStockingPointID() 
+                                                  and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent,  e.ID() = trans.Product() ) ) );
+                if( not isnull( enginecost ) and not isnull( transcost ) ){
+                  products.Add( product );
+                  cell       := selectobject( row, Cell, cell, cell.Column() = column );
+                  //杩愯緭鏁伴噺/鍖呰瀹归噺/瑁呰浇瀹归噺*杩愯緭鍗曚环
+                  cost       := ceil( ceil( quantity / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();//鍥涜垗浜斿叆
+                  cell.FactoryToDLRentTransCost( cell.FactoryToDLRentTransCost() + cost );
+                }
               }
             }
           }
@@ -92,21 +96,25 @@
     //澶ц繛澶栫搴撳叆搴撹垂鐢細鍏ュ簱閲�/鍖呰瀹归噺*鍏ュ簱鍗曚环锛屽叆搴撻噺绛変簬澶ц繛宸ュ巶璇ヤ骇鍝佷骇閲忓噺鍘诲彂寰�闀挎槬鐨勬暟閲�
     traverse( owner, FinancialProductionSource, source, not source.IsImport() ){//璐㈠姟浜ч噺鎶ヨ〃闈炲鍏�
       traverse( source, FinancialProductionReport, report, not report.IsShow() ){//璐㈠姟浜ч噺鎶ヨ〃涓嶆樉绀�
-        traverse( report, FinancialProductionRow, row, row.Unit() = dlunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' ) ){//璐㈠姟浜ч噺鎶ヨ〃閲岀殑澶ц繛浜ч噺, 涓嶄负0
-          product             := row.Product_MP();
-          products.Add( product );
-          productparents      := product.GetAllParent();
+        traverse( report, FinancialProductionRow, row, row.Unit() = dlunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' and cell.FinancialProductionColumn().IsDay() ) ){//璐㈠姟浜ч噺鎶ヨ〃閲岀殑澶ц繛浜ч噺, 涓嶄负0
+          product            := row.Product_MP();
+          productparents     := product.GetAllParent();
           if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
             //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-            enginecost        := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
+            enginecosts      := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
                                                  and engine.Factory() = dlunit );
-            if( not isnull( enginecost ) ){
-              ccrow               := table.GetRow( row.Name() );
-              traverse( row, FinancialProductionCell, cell, cell.Value() <> '0' ){
-                column        := selectobject( table, Column, column, column.Name() = cell.FinancialProductionColumn().Name() );
-                //澶ц繛澶栫搴撳叆搴撹垂鐢�
-                ccrow.SetDLRentEnterCost( column, enginecost, cell );
+            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
+              products.Add( product );
+              ccrow          := table.GetRow( row.Name() );
+              traverse( row, FinancialProductionCell, cell, cell.Value() <> '0' and cell.FinancialProductionColumn().IsDay() ){
+                cellcolumn   := cell.FinancialProductionColumn();
+                enginecost   := selectobject( enginecosts, Elements, engine, engine.StartDate() <= cellcolumn.Period() and engine.EndDate() >= cellcolumn.Period() );
+                if( not isnull( enginecost ) ){
+                  column     := selectobject( table, Column, column, column.Name() = cell.FinancialProductionColumn().Name() );
+                  //澶ц繛澶栫搴撳叆搴撹垂鐢�
+                  ccrow.SetDLRentEnterCost( column, enginecost, cell );
+                }
               }
             }
           }
@@ -116,21 +124,25 @@
     //澶ц繛澶栫搴撳嚭搴撹垂鐢細鍑哄簱閲�/鍖呰瀹归噺*鍑哄簱鍗曚环锛屽嚭搴撻噺绛変簬澶ц繛宸ュ巶璇ヤ骇鍝侀攢閲忓噺鍘诲彂寰�闀挎槬鐨勬暟閲�
     traverse( owner, FinancialSalesSource, source, not source.IsImport() ){//璐㈠姟閿�閲忔姤琛ㄩ潪瀵煎叆
       traverse( source, FinancialSalesReport, report, not report.IsShow() ){//璐㈠姟閿�閲忔姤琛ㄤ笉鏄剧ず
-        traverse( report, FinancialSalesRow, row, row.Unit() = ccunit and exists( row, FinancialSalesCell, cell, cell.Value() <> '0' ) ){//璐㈠姟閿�閲忔姤琛ㄩ噷鐨勫ぇ杩炰骇閲�, 涓嶄负0
-          product             := row.Product_MP();
-          productparents      := product.GetAllParent();
+        traverse( report, FinancialSalesRow, row, row.Unit() = ccunit and exists( row, FinancialSalesCell, cell, cell.Value() <> '0' and cell.FinancialSalesColumn().IsDay() ) ){//璐㈠姟閿�閲忔姤琛ㄩ噷鐨勫ぇ杩炰骇閲�, 涓嶄负0
+          product            := row.Product_MP();
+          productparents     := product.GetAllParent();
           if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
-            products.Add( product );
             //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-            enginecost        := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
+            enginecosts      := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
                                                  and engine.Factory() = dlunit );
-            if( not isnull( enginecost ) ){
-              ccrow               := table.GetRow( row.Name() );
-              traverse( row, FinancialSalesCell, cell, cell.Value() <> '0' ){
-                column        := selectobject( table, Column, column, column.Name() = cell.FinancialSalesColumn().Name() );
-                //澶ц繛澶栫搴撳嚭搴撹垂鐢�
-                ccrow.SetDLRentOutCost( column, enginecost, cell );
+            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
+              products.Add( product );
+              ccrow          := table.GetRow( row.Name() );
+              traverse( row, FinancialSalesCell, cell, cell.Value() <> '0' and cell.FinancialSalesColumn().IsDay() ){
+                cellcolumn   := cell.FinancialSalesColumn();
+                enginecost   := selectobject( enginecosts, Elements, engine, engine.StartDate() <= cellcolumn.Period() and engine.EndDate() >= cellcolumn.Period() );
+                if(  not isnull( enginecost ) ){
+                  column     := selectobject( table, Column, column, column.Name() = cell.FinancialSalesColumn().Name() );
+                  //澶ц繛澶栫搴撳嚭搴撹垂鐢�
+                  ccrow.SetDLRentOutCost( column, enginecost, cell );
+                }
               }
             }
           }
@@ -150,24 +162,29 @@
         iscc                   := table.IsInUnit( destisp, ccunit );
         if( isdl and iscc ){
           //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-          enginecost           := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
+          enginecosts          := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
                                                  and engine.Factory() = ccunit );
           //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
-          transcost            := selectobject( owner, LogisticsCostTransport, trans, trans.Origin() = tprow.SourceStockpoingPointID() 
+          transcosts           := selectset( owner, LogisticsCostTransport, trans, trans.Origin() = tprow.SourceStockpoingPointID() 
                                                   and trans.Destination() = tprow.TargetStockpoingPointID() 
                                                   and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '鍙戝姩鏈�', 0 ) >= 0, e.ID() = produtparent,  e.ID() = trans.Product() ) ) );
-          if( not isnull( enginecost ) and not isnull( transcost ) ){
+          if( not isnull( enginecosts ) and enginecosts.Size() > 0 and not isnull( transcosts ) and transcosts.Size() > 0 ){
             row                := table.GetRow( product.ID() );
             products.Add( product );
             traverse( tprow,TransferPlanCell, tpcell, tpcell.TransferPlanColumn().ColumnDate() <> Date::MinDate() and [Number]tpcell.Value() > 0){
-              periodtime       := tpcell.TransferPlanColumn().ColumnDate().StartOfMonth();
-              periodname       := periodtime.Format( "M2/D2/Y" );
-              column           := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
-               
-              cost             := ceil( ceil( [Number]tpcell.Value() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();
-              cell             := selectobject( row, Cell, cell, cell.Column() = column );
-              cell.CCLongTransCoat( cell.CCLongTransCoat() + cost );
+              tpcolumndate     := tpcell.TransferPlanColumn().ColumnDate();
+              enginecost       := selectobject( enginecosts, Elements, engine, engine.StartDate() <= tpcolumndate and engine.EndDate() >= tpcolumndate );
+              transcost        := selectobject( transcosts, Elements, trans, trans.StartDate() <= tpcolumndate and trans.EndDate() >= tpcolumndate );
+              if( not isnull( enginecost ) and not isnull( transcost ) ){
+                periodtime     := tpcolumndate.StartOfMonth();
+                periodname     := periodtime.Format( "M2/D2/Y" );
+                column         := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
+                 
+                cost           := ceil( ceil( [Number]tpcell.Value() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();
+                cell           := selectobject( row, Cell, cell, cell.Column() = column );
+                cell.CCLongTransCoat( cell.CCLongTransCoat() + cost );
+              }
             }
           }
         }
@@ -183,23 +200,25 @@
         product               := forecast.Product_MP();
         productparents        := product.GetAllParent();
         if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
-          products.Add( forecast.Product_MP() );
-          
           //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-          enginecost          := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
+          enginecosts         := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
                                                  and engine.MLB_MQB() = product.MQBMLB()
                                                  and engine.Factory() = ccunit );
-          if( not isnull( enginecost ) ){
-            row                 := table.GetRow( forecast.ProductID() );
+          if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
+            products.Add( forecast.Product_MP() );
+            row               := table.GetRow( forecast.ProductID() );
             traverse( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() > 0 ){
-              periodtime       := psdip.StartDate().StartOfMonth();
-              periodname       := periodtime.Format( "M2/D2/Y" );
-        //      info( '-------------------------', periodname, periodtime );
-              column           := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
-        //      info( '-------------------------', column.Name() );
-              cost             := ceil( [Number]psdip.Quantity() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
-              cell             := selectobject( row, Cell, cell, cell.Column() = column );
-              cell.CCShortTransCost( cell.CCShortTransCost() + cost );
+              enginecost      := selectobject( enginecosts, Elements, engine, engine.StartDate() <= psdip.StartDate() and engine.EndDate() >= psdip.StartDate() );
+              if( not isnull( enginecost ) ){
+                periodtime    := psdip.StartDate().StartOfMonth();
+                periodname    := periodtime.Format( "M2/D2/Y" );
+          //      info( '-------------------------', periodname, periodtime );
+                column         := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
+          //      info( '-------------------------', column.Name() );
+                cost           := ceil( [Number]psdip.Quantity() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
+                cell           := selectobject( row, Cell, cell, cell.Column() = column );
+                cell.CCShortTransCost( cell.CCShortTransCost() + cost );
+              }
             }
           }
         }
@@ -221,33 +240,34 @@
           productparents      := product.GetAllParent();
           if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
             row               := table.GetRow( pisp.ProductID() );
-            products.Add( pisp.Product_MP() );
-            traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0  ){
-              periodtime      := pispip.Start().StartOfMonth().Date();
-              periodname      := periodtime.Format( "M2/D2/Y" );
-              column          := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
-              cell            := selectobject( row, Cell, cell, cell.Column() = column );
-              
-              if( isccrent ){
-                //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
-                enginecost     := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
-                                                   and engine.MLB_MQB() = product.MQBMLB()
-                                                   and engine.Factory() = ccunit );
-                 if( not isnull( enginecost ) ){
-                   cost        := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
-                   cell.CCRentStorageCost( cell.CCRentStorageCost() + cost );
-                 }
-              } else {
-                //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
-                enginecost     := selectobject( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() 
-                                                   and engine.MLB_MQB() = product.MQBMLB()
-                                                   and engine.Factory() = dlunit  );
-                 if( not isnull( enginecost ) ){
-                   cost        := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
-                   cell.DLRentStorageCost( cell.DLRentStorageCost() + cost );;
-                 }
-              }
-            }   
+            enginecosts       := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower() and engine.MLB_MQB() = product.MQBMLB() );
+            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
+              products.Add( pisp.Product_MP() );
+              traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0  ){
+                periodtime    := pispip.Start().StartOfMonth().Date();
+                periodname    := periodtime.Format( "M2/D2/Y" );
+                column        := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
+                cell          := selectobject( row, Cell, cell, cell.Column() = column );
+                
+                if( isccrent ){
+                  //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
+                  enginecost     := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date()
+                                                     and engine.Factory() = ccunit );
+                   if( not isnull( enginecost ) ){
+                     cost        := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
+                     cell.CCRentStorageCost( cell.CCRentStorageCost() + cost );
+                   }
+                } else {
+                  //鍦ㄥ彂鍔ㄦ満鎴愭湰鍙傛暟琛ㄦ壘鍒板搴旂殑鍖呰瀹归噺
+                  enginecost     := selectobject( enginecosts, Elements, engine, engine.StartDate() <= pispip.Start().Date() and engine.EndDate() >= pispip.Start().Date()
+                                                     and engine.Factory() = dlunit  );
+                   if( not isnull( enginecost ) ){
+                     cost        := ceil( [Number]pispip.NewSupplyQuantity() / enginecost.PackagingCapacity() ) * enginecost.StoragePrice();//鍥涜垗浜斿叆
+                     cell.DLRentStorageCost( cell.DLRentStorageCost() + cost );;
+                   }
+                }
+              }   
+            }
           }
         }
       }
diff --git a/_Main/BL/Type_ChangeLossSetting/StaticMethod_ValidateInput.qbl b/_Main/BL/Type_ChangeLossSetting/StaticMethod_ValidateInput.qbl
index 4db4239..065a5cc 100644
--- a/_Main/BL/Type_ChangeLossSetting/StaticMethod_ValidateInput.qbl
+++ b/_Main/BL/Type_ChangeLossSetting/StaticMethod_ValidateInput.qbl
@@ -31,7 +31,7 @@
                       or ( cls.ProductFirst() = product2 and cls.ProductSecond() = product1 ) ) ) ){
       feedback := Translations::MP_ChangeLossSetting_Exist()
     }
-    if( exists( owner, ChangeLossSetting, cls, cls <> old and not ( cls.StartDate() > enddate or cls.EndDate() < startdate ) ) ){
+    if( feedback = '' and exists( owner, ChangeLossSetting, cls, cls <> old and not ( cls.StartDate() > enddate or cls.EndDate() < startdate ) ) ){
       feedback := Translations::MP_ChangeLossSetting_DateCoincide()
     }
     
diff --git a/_Main/BL/Type_FinancialProductionColumn/Attribute_IsDay.qbl b/_Main/BL/Type_FinancialProductionColumn/Attribute_IsDay.qbl
new file mode 100644
index 0000000..175d66f
--- /dev/null
+++ b/_Main/BL/Type_FinancialProductionColumn/Attribute_IsDay.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute IsDay
+{
+  #keys: '3[415136.0.1144791862][415136.0.1144791861][415136.0.1144791863]'
+  ValueType: Boolean
+}
diff --git a/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl b/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl
index 8ed085f..d0781ad 100644
--- a/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl
+++ b/_Main/BL/Type_FinancialProductionReport/Method_Generate.qbl
@@ -24,7 +24,7 @@
       if( productids.ContainsAll( productid ) ){
         showrow := this.FinancialProductionRow( relnew, Name := row.Name(), Unit := row.Unit(), RowNr := row.RowNr() );
         
-        traverse( row, FinancialProductionCell, cell ){
+        traverse( row, FinancialProductionCell, cell, not cell.FinancialProductionColumn().IsDay() ){
           column   := selectobject( this, FinancialProductionColumn, column, column.Name() = cell.FinancialProductionColumn().Name() );
           
           sumcell  := selectobject( column, FinancialProductionCell, c, c.FinancialProductionRow() = sumrow );
diff --git a/_Main/BL/Type_FinancialProductionReport/Method_GenerateColumn.qbl b/_Main/BL/Type_FinancialProductionReport/Method_GenerateColumn.qbl
index 85b473e..c038063 100644
--- a/_Main/BL/Type_FinancialProductionReport/Method_GenerateColumn.qbl
+++ b/_Main/BL/Type_FinancialProductionReport/Method_GenerateColumn.qbl
@@ -11,10 +11,18 @@
     startofyear               := startofplanning.StartOfYear();
     startofnextyear           := startofplanning.StartOfNextYear();
     
-    for( start := startofyear; start < startofnextyear; start := start.StartOfNextMonth() ){
+    //for( start := startofyear; start < startofnextyear; start := start.StartOfNextMonth() ){
+    //  periodtime := start.Date();
+    //  periodname := periodtime.Format( "M2/D2/Y" );
+    //  this.FinancialProductionColumn( relnew, Name := periodname, Period := periodtime );
+    //}
+    for( start := startofyear; start < startofnextyear; start := start + Duration::Days( 1 ) ){
       periodtime := start.Date();
       periodname := periodtime.Format( "M2/D2/Y" );
-      this.FinancialProductionColumn( relnew, Name := periodname, Period := periodtime );
+      this.FinancialProductionColumn( relnew, Name := periodname, Period := periodtime, IsDay := true );
+      if( start = start.StartOfMonth() ){
+        this.FinancialProductionColumn( relnew, Name := periodname, Period := periodtime );
+      }
     }
   *]
 }
diff --git a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
index dc85d48..54ffc0b 100644
--- a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
@@ -36,28 +36,30 @@
     table.GenerateColumn( owner );
     //鍙栧綋鍓嶇増鏈殑product planning閲宯ew supply瀛楁锛屽垎澶ц繛鍜岄暱鏄ュ伐鍘傜殑浜х嚎锛岃繘琛屽姞鎬�
     traverse( owner, StockingPoint_MP, stockingpoint ){
-      unit         := stockingpoint.Unit();
-      parentunits  := unit.GetAllParent();
+      unit                    := stockingpoint.Unit();
+      parentunits             := unit.GetAllParent();
       //鏄惁灞炰簬闀挎槬宸ュ巶
-      iscc         := unit.ID() = ccalineunit or unit.ID() = ccmplineunit or exists( parentunits, Elements, punit, punit.ID() = ccalineunit or punit.ID() = ccmplineunit );
+      iscc                    := unit.ID() = ccalineunit or unit.ID() = ccmplineunit or exists( parentunits, Elements, punit, punit.ID() = ccalineunit or punit.ID() = ccmplineunit );
       //鏄惁灞炰簬澶ц繛宸ュ巶
-      isdl         := unit.ID() = dlalienunit or unit.ID() = dlmplineunit  or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit );
+      isdl                    := unit.ID() = dlalienunit or unit.ID() = dlmplineunit  or exists( parentunits, Elements, punit, punit.ID() = dlalienunit or punit.ID() = dlmplineunit );
       if( iscc or isdl ){
         traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() 
                   and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ) ){
           //鑾峰彇宸ュ巶琛�
-          factoryrow := table.GetRowByUnit( pisp.Product_MP(), ifexpr( iscc, ccunit, dlunit ) );
+          factoryrow          := table.GetRowByUnit( pisp.Product_MP(), ifexpr( iscc, ccunit, dlunit ) );
           //鑾峰彇鍚堣琛�
-          allrow     := table.GetRowByUnit( pisp.Product_MP(), allunit );
+          allrow              := table.GetRowByUnit( pisp.Product_MP(), allunit );
           products.Add( pisp.Product_MP() );
           //褰損roduct planning鐨勬棩鏈熷尯闂村湪闇�瑕佺殑鏃ユ湡鍖洪棿鍐� 
           traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.NewSupplyQuantity() <> 0 ){
-            periodtime := pispip.Start().StartOfMonth().Date();
-            periodname := periodtime.Format( "M2/D2/Y" );
-            quantity   := [Number]pispip.NewSupplyQuantity();//鍥涜垗浜斿叆
-            
-            column := selectobject( table, FinancialProductionColumn, column, column.Name() = periodname and column.Period() = periodtime );
-            
+            dayperiodtime     := pispip.Start().Date();
+            dayperiodname     := dayperiodtime.Format( "M2/D2/Y" );
+            periodtime        := pispip.Start().StartOfMonth().Date();
+            periodname        := periodtime.Format( "M2/D2/Y" );
+            quantity          := [Number]pispip.NewSupplyQuantity();//鍥涜垗浜斿叆
+            daycolumn         := selectobject( table, FinancialProductionColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
+            column            := selectobject( table, FinancialProductionColumn, column, column.Name() = periodname and column.Period() = periodtime and not column.IsDay() );
+            factoryrow.Initialize( daycolumn, quantity );
             factoryrow.Initialize( column, quantity );
             allrow.Initialize( column, quantity );
           }    
diff --git a/_Main/BL/Type_FinancialSalesColumn/Attribute_IsDay.qbl b/_Main/BL/Type_FinancialSalesColumn/Attribute_IsDay.qbl
new file mode 100644
index 0000000..76487f5
--- /dev/null
+++ b/_Main/BL/Type_FinancialSalesColumn/Attribute_IsDay.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute IsDay
+{
+  #keys: '3[415136.0.1144791876][415136.0.1144791875][415136.0.1144791877]'
+  ValueType: Boolean
+}
diff --git a/_Main/BL/Type_FinancialSalesReport/Method_GenerateColumn.qbl b/_Main/BL/Type_FinancialSalesReport/Method_GenerateColumn.qbl
index 8aed8c8..7d32e98 100644
--- a/_Main/BL/Type_FinancialSalesReport/Method_GenerateColumn.qbl
+++ b/_Main/BL/Type_FinancialSalesReport/Method_GenerateColumn.qbl
@@ -11,10 +11,18 @@
     startofyear               := startofplanning.StartOfYear();
     startofnextyear           := startofplanning.StartOfNextYear();
     
-    for( start := startofyear; start < startofnextyear; start := start.StartOfNextMonth() ){
+    //for( start := startofyear; start < startofnextyear; start := start.StartOfNextMonth() ){
+    //  periodtime := start.Date();
+    //  periodname := periodtime.Format( "M2/D2/Y" );
+    //  this.FinancialSalesColumn( relnew, Name := periodname, Period := periodtime );
+    //}
+    for( start := startofyear; start < startofnextyear; start := start + Duration::Days( 1 ) ){
       periodtime := start.Date();
       periodname := periodtime.Format( "M2/D2/Y" );
-      this.FinancialSalesColumn( relnew, Name := periodname, Period := periodtime );
+      this.FinancialSalesColumn( relnew, Name := periodname, Period := periodtime, IsDay := true );
+      if( start = start.StartOfMonth() ){
+        this.FinancialSalesColumn( relnew, Name := periodname, Period := periodtime );
+      }
     }
   *]
 }
diff --git a/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl b/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl
index 31f6bcd..500883e 100644
--- a/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_FinancialSalesSource/StaticMethod_Initialize.qbl
@@ -53,14 +53,18 @@
       
         products.Add( product );
         traverse( forecast, PlanningSalesDemandInPeriod, psdip, psdip.Quantity() <> 0 ){
+          dayperiodtime      := psdip.StartDate();
+          dayperiodname      := dayperiodtime.Format( "M2/D2/Y" );
           periodtime         := psdip.StartDate().StartOfMonth();
           periodname         := periodtime.Format( "M2/D2/Y" );
     //      info( '-------------------------', periodname, periodtime );
-          column             := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime );
+          daycolumn          := selectobject( table, FinancialSalesColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
+          column             := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime and not column.IsDay() );
     //      info( '-------------------------', column.Name() );
           quantity   := [Number]psdip.Quantity();//鍥涜垗浜斿叆
           
           factoryrow.Initialize( column, quantity );
+          factoryrow.Initialize( daycolumn, quantity );
           allrow.Initialize( column, quantity );
         }
       }
@@ -79,12 +83,16 @@
           ccrow             := table.GetRow( ccunit, product );
           products.Add( product );
           traverse( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().StartDate() < startofnextyear and pispip.DependentDemandAndSalesDemandQuantity() <> 0 ){
+            dayperiodtime   := pispip.Start().Date();
+            dayperiodname   := dayperiodtime.Format( "M2/D2/Y" );
             periodtime      := pispip.Start().StartOfMonth().Date();
             periodname      := periodtime.Format( "M2/D2/Y" );
-            column          := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime );
+            daycolumn       := selectobject( table, FinancialSalesColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
+            column          := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime and not column.IsDay() );
             quantity        := [Number]pispip.DependentDemandAndSalesDemandQuantity();//鍥涜垗浜斿叆
             
             ccrow.Initialize( column, quantity );//鍙朤otal Demand瀛楁鎸夋湀姹囨�婚渶姹傛暟閲�
+            ccrow.Initialize( daycolumn, quantity );
             allrow.Initialize( column, quantity );
           }
         }
@@ -102,10 +110,13 @@
       if( isdlspline and isccrent ){
         traverse( laneleg, Trip, trip, trip.Arrival() < startofnextyearlead and exists( trip, ProductInTrip, pit, pit.Quantity() <> 0 ) ){
     //      periodtime        := ( trip.Arrival() - FinancialSalesReport::GetDefaultTripLeadingTime() ).StartOfMonth().Date();
+          dayperiodtime     := trip.Departure().Date();
+          dayperiodname     := dayperiodtime.Format( "M2/D2/Y" );
           periodtime        := trip.Departure().StartOfMonth().Date();
           periodname        := periodtime.Format( "M2/D2/Y" );
           
-          column            := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime );
+          daycolumn         := selectobject( table, FinancialSalesColumn, column, column.Name() = dayperiodname and column.Period() = dayperiodtime and column.IsDay() );
+          column            := selectobject( table, FinancialSalesColumn, column, column.Name() = periodname and column.Period() = periodtime and not column.IsDay() );
           if( not isnull( column ) ){
             traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
               product       := pit.Product_MP();
@@ -113,6 +124,7 @@
               quantity      := [Number]pit.Quantity();//鍥涜垗浜斿叆
               dlrow         := table.GetRow( dlunit, pit.Product_MP() );
               dlrow.Initialize( column, quantity );//姹囨�绘暟閲�
+              dlrow.Initialize( daycolumn, quantity );
               
               allrow        := table.GetRow( allunit, pit.Product_MP() );
               allrow.Initialize( column, quantity );
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_MatrixEditorTable.def b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_MatrixEditorTable.def
index 2efd8dd..d861543 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_MatrixEditorTable.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialProductionReport/Component_MatrixEditorTable.def
@@ -18,6 +18,7 @@
           Properties:
           [
             DataType: 'FinancialProductionReport'
+            FixedFilter: 'not object.FinancialProductionColumn().IsDay()'
             Source: 'DataHolderTable'
             Taborder: 0
             Transformation: 'FinancialProductionColumn.FinancialProductionCell'
@@ -71,6 +72,7 @@
           Properties:
           [
             DataType: 'FinancialProductionReport'
+            FixedFilter: 'not object.IsDay()'
             Source: 'DataHolderTable'
             Taborder: 0
             Transformation: 'FinancialProductionColumn'
diff --git "a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Component_MatrixEditorTable\043623.def" "b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Component_MatrixEditorTable\043623.def"
index 9a203ad..4ef0432 100644
--- "a/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Component_MatrixEditorTable\043623.def"
+++ "b/_Main/UI/MacroPlannerWebApp/Component_FormFinancialSalesReport/Component_MatrixEditorTable\043623.def"
@@ -18,6 +18,7 @@
           Properties:
           [
             DataType: 'FinancialSalesReport'
+            FixedFilter: 'not object.FinancialSalesColumn().IsDay()'
             Source: 'DataHolderTable'
             Taborder: 0
             Transformation: 'FinancialSalesColumn.FinancialSalesCell'
@@ -71,6 +72,7 @@
           Properties:
           [
             DataType: 'FinancialSalesReport'
+            FixedFilter: 'not object.IsDay()'
             Source: 'DataHolderTable'
             Taborder: 0
             Transformation: 'FinancialSalesColumn'

--
Gitblit v1.9.3