From 1a5a8be205641f5f79dd809f6c7e59fc84d76243 Mon Sep 17 00:00:00 2001
From: yunchai <yunying.chai@capgemini.com>
Date: 星期日, 08 十月 2023 09:11:26 +0800
Subject: [PATCH] Merge remote-tracking branch 'refs/remotes/origin/dev'

---
 _Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl
index 3713cc9..9a458dd 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl
@@ -1,6 +1,7 @@
 Quintiq file version 2.0
 #parent: #root
 Method MappingOperationCostData (
+  GlobalOTDTable globalOTDTable,
   Strings businesstypes
 )
 {
@@ -14,7 +15,12 @@
     if( isnull( businesstypes ) or businesstypes.Size() = 0 ) {
         listtodeal := selectset( this, MappingOperation, item, true );
     } else {
-        listtodeal := selectset( this, MappingOperation, item, businesstypes.Find( item.BusinessType() ) <> -1 );
+        organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businesstypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() );
+        listtodeal := selectset( this, 
+                                 MappingOperation, 
+                                 item, 
+                                 ( businesstypes.Find( item.BusinessType() ) <> -1 ) and 
+                                 ( organcodelist.Find( item.OrganCode() ) >= 0 ) );
     }
     
     // Get the list to deal with max sequence number
@@ -41,7 +47,10 @@
       if( count - [Number](count/1000) * 1000 = 0 or count = totalcount ){
         info( "Now is dealing with the " + count.AsQUILL() + "OperationCost " + "( " + count.AsQUILL() + "/" + totalcount.AsQUILL() + " ) " + (count/totalcount*100).Round( 1 ).AsQUILL() + "%" );
         }
-      id := item.OrganCode() + "_" + item.ProductID() + "_" + item.ProcessSection() + "_" + item.Line();
+      id := item.OrganCode() + "_" + item.ProductID() + "_" + item.ProcessSection();
+      if( guard( item.Line(), "" ).Length() > 0 ) {
+          id := id + "_" + item.Line();
+        }
       operation := Operation::FindOperationTypeIndex( id );
       account := Account_MP::FindByName( this, "Operation cost" );
       isfromdb := false;

--
Gitblit v1.9.3