From 85fb8fdf8bdef29cbe8a1f64bc27e049454e7142 Mon Sep 17 00:00:00 2001
From: yunchai <yunying.chai@capgemini.com>
Date: 星期一, 25 九月 2023 22:15:28 +0800
Subject: [PATCH] 合并DEV并且更新了冲减到订单

---
 _Main/BL/Type_CustomerOrder/StaticMethod_CreateOrUpdate.qbl |   51 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/_Main/BL/Type_CustomerOrder/StaticMethod_CreateOrUpdate.qbl b/_Main/BL/Type_CustomerOrder/StaticMethod_CreateOrUpdate.qbl
index d1d98d9..3ec5f41 100644
--- a/_Main/BL/Type_CustomerOrder/StaticMethod_CreateOrUpdate.qbl
+++ b/_Main/BL/Type_CustomerOrder/StaticMethod_CreateOrUpdate.qbl
@@ -27,7 +27,7 @@
     product := Product_MP::FindById( macroPlan, productId );
     salesSegment := SalesSegment_MP::FindByName( macroPlan, salesSegmentName );
     stockingPoint := StockingPoint_MP::FindById(  macroPlan, stockingPointId );
-    currency := Currency_MP::FindById( macroPlan, currencyId );
+    //currency := Currency_MP::FindById( macroPlan, currencyId );
     unitOfMeasure := null( UnitOfMeasure_MP )
     priority := null( Priority );
     if( unitOfMeasureName <> "" ) {
@@ -38,33 +38,58 @@
     }
     // 妫�鏌ヤ緷璧栭」
     if( isnull( product) ) {
-        error( "product not found" );  
+        info( "product not found" );  
     }
     if( isnull( salesSegment) ) {
-        error( "sales segment not found" );  
+        info( "sales segment not found" );  
     }
     if( isnull( stockingPoint) ) {
-        error( "stock point not found" );  
+        info( "stock point not found" );  
     }
-    if( isnull( currency) ) {
-        error( "currency not found" );  
-    }
+    //if( isnull( currency) ) {
+    //    error( "currency not found" );  
+    //}
     if( unitOfMeasureName <> "" and isnull( unitOfMeasure) ) {
-        error( "unit of measure not found" );  
+        info( "unit of measure not found" );  
     }
     if( priorityName <> "" and isnull( stockingPoint) ) {
-        error( "priority not found" );  
+        info( "priority not found" );  
     }
     // 鏂板/鏇存柊
     result := CustomerOrder::FindById( macroPlan, id );
     if( isnull( result ) ) {
         CustomerOrder::Create( product, stockingPoint, id, orderDate, quantity, price, 
-                               priorityName, salesSegmentName, currency.Name(), unitOfMeasureName, 
+                               priorityName, salesSegmentName, currencyId, unitOfMeasureName, 
                                false, customerName, customerId, orderId, orderLineId, true, true, true );
     } else {
-        result.Update( product, stockingPoint, orderDate, quantity, price, 
-                       priorityName, salesSegmentName, currency.Name(), unitOfMeasureName, 
-                       false, customerName, customerId, orderId, orderLineId, true, true, true );
+        if( result.ProductID() = productId 
+            and result.StockingPointID() = stockingPointId 
+            and result.StartDate() = orderDate 
+            and result.Quantity() = quantity 
+            and result.Price() = price 
+            and result.PriorityName() = priorityName 
+            and result.SalesSegmentName() = salesSegmentName 
+            and result.CurrencyID() = currencyId 
+            and result.UnitOfMeasureName() = unitOfMeasureName 
+            and result.CustomerName() = customerName 
+            and result.CustomerID() = customerId 
+            and result.OrderID() = orderId 
+            and result.OrderLineID() = orderLineId ){
+              info( "No need to update this order: " + id );
+              }else{
+                if( result.IsLocked() = true ){
+                  pispips := selectset( result, ProductInStockingPoint_MP.ProductInStockingPointInPeriod, pispip, true );
+                  pispipLeafs := selectset( pispips, 
+                                            Elements.astype( ProductInStockingPointInPeriodPlanningLeaf ), 
+                                            pispip, 
+                                            true );
+                  ProductInStockingPointInPeriod::LockUnlockPlanning( pispipLeafs, false, true );
+                }
+                result.Update( product, stockingPoint, orderDate, quantity, price, 
+                               priorityName, salesSegmentName, currencyId, unitOfMeasureName, 
+                               false, customerName, customerId, orderId, orderLineId, true, true, true );
+                result.IsLocked( false );
+                }
     }
     return result;
   *]

--
Gitblit v1.9.3