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_MappingCustomerOrderData.qbl |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/_Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl
index 7ec0576..9d01ece 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl
@@ -1,7 +1,8 @@
 Quintiq file version 2.0
 #parent: #root
 Method MappingCustomerOrderData (
-  Strings businessTypes
+  Strings businessTypes,
+  GlobalOTDTable globalOTDTable
 )
 {
   Description: 'ETL璁㈠崟棰勬祴'
@@ -9,15 +10,20 @@
   [*
     // yypsybs Aug-15-2023 (created)
     // 寰呭鐞嗘暟鎹�
-    listToDeal := construct( structured[MappingCustomerOrder] );
+    listToDeal := construct( Global_MappingCustomOrders );
     if( isnull( businessTypes ) or businessTypes.Size() = 0 ) {
-        listToDeal := selectset( this, MappingCustomerOrder, item, true );
+        listToDeal := selectset( globalOTDTable, Global_MappingCustomOrder, item, true );
     } else {
-        listToDeal := selectset( this, MappingCustomerOrder, item, businessTypes.Find( item.BusinessType() ) <> -1 );
+        organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businessTypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() );
+        listToDeal := selectset( globalOTDTable, 
+                                 Global_MappingCustomOrder, 
+                                 item, 
+                                 ( businessTypes.Find( item.BusinessType() ) <> -1 ) and 
+                                 ( organcodelist.Find( item.StockingPointID().SubString( 0, 3 ) ) >= 0 ) );
     }
     queryStartDate := guard( min( this, Period_MP, item, true, item.StartDate() ) - Duration::Days( 30 ), DateTime::MinDateTime() ).Date();
     queryEndDate := guard( max( this, Period_MP, item, true, item.EndDate() ), Date::MaxDate() );
-    listToDeal := selectset( listToDeal, Elements, item, item.OrderDate() >= queryStartDate /*and item.OrderDate() <= queryEndDate*/, not isnull( Product_MP::FindById( this, item.ProductID() ) ) and not isnull( StockingPoint_MP::FindById( this, item.StockPointID() ) ) and not isnull( SalesSegment_MP::FindByName( this, item.SalesSegmentName() ) ) );
+    listToDeal := selectset( listToDeal, Elements, item, item.OrderDate() >= queryStartDate /*and item.OrderDate() <= queryEndDate*/, not isnull( Product_MP::FindById( this, item.ProductID() ) ) and not isnull( StockingPoint_MP::FindById( this, item.StockingPointID() ) ) and not isnull( SalesSegment_MP::FindByName( this, item.SalesSegmentName() ) ) );
     
     totalcount := listToDeal.Size();
     info( "CustomerOrder has " + totalcount.AsQUILL() + " rows in total" );
@@ -32,12 +38,18 @@
         }
     //  if( not isnull( Product_MP::FindById( this, item.ProductID() ) ) ){
     //    info( item.ProductID().AsQUILL() );
-      CustomerOrder::CreateOrUpdate( this, item.CurrencyID(), item.Customer(), item.CustomerID(), item.ID(), 
-                                     item.OrderDate(), item.OrderID(), item.OrderLineID(), item.Price(), 
-                                     priorityName, item.ProductID(), 
-                                     item.StockPointID(), 
-                                     item.SalesSegmentName(), 
-                                     item.Quantity(), item.UnitOfMeasureName(), item.OrderType(), item.IsAvailable());
+      customOrder := CustomerOrder::CreateOrUpdate( this, item.CurrencyID(), item.Customer(), item.CustomerID(), item.ID(), 
+                                                    item.OrderDate(), item.OrderID(), item.OrderLineID(), item.Price(), 
+                                                    priorityName, item.ProductID(), 
+                                                    item.StockingPointID(), 
+                                                    item.SalesSegmentName(), 
+                                                    item.Quantity(), item.UnitOfMeasureName(), item.OrderType(), item.IsAvailable());
+      customOrder.BusinessType( item.BusinessType() );
+      customOrder.OrderType( item.OrderType() );
+      customOrder.OrderTime( item.OrderTime() );
+      customOrder.ProductGrade( item.ProductGrade() );
+      customOrder.SegmentPriority( item.SegmentPriority() );
+      customOrder.SheetProfitability( item.SheetProfitability() );
     //  }else{
     //    info( "invaild product: " + item.ProductID().AsQUILL() );
     //    }

--
Gitblit v1.9.3