From 13296fd8bb887ffde341bd93a6497ffa0ff5c7f4 Mon Sep 17 00:00:00 2001
From: yanyuan <yuan.yan@capgemini.com>
Date: 星期三, 06 九月 2023 18:04:00 +0800
Subject: [PATCH] Fix the ExtenalSupply & ActualPISPIP

---
 _Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl                                           |   16 ++++++--
 _Main/BL/Type_InventorySupply/StaticMethod_CreateOrUpdate.qbl                                          |   31 +++++++++++++++
 _Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl                                             |   16 ++++++--
 _Main/BL/Type_ActualProductInStockingPointInPeriod/_ROOT_Type_ActualProductInStockingPointInPeriod.qbl |    6 +++
 _Main/BL/Type_InventorySupply/_ROOT_Type_InventorySupply.qbl                                           |    6 +++
 _Main/BL/Type_ActualProductInStockingPointInPeriod/StaticMethod_CreateOrUpdate.qbl                     |   31 +++++++++++++++
 6 files changed, 98 insertions(+), 8 deletions(-)

diff --git a/_Main/BL/Type_ActualProductInStockingPointInPeriod/StaticMethod_CreateOrUpdate.qbl b/_Main/BL/Type_ActualProductInStockingPointInPeriod/StaticMethod_CreateOrUpdate.qbl
new file mode 100644
index 0000000..0c2492f
--- /dev/null
+++ b/_Main/BL/Type_ActualProductInStockingPointInPeriod/StaticMethod_CreateOrUpdate.qbl
@@ -0,0 +1,31 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CreateOrUpdate (
+  MacroPlan owner,
+  String productid,
+  String stockingpointid,
+  String description,
+  Real actualinventorylevelend,
+  Date manufactureddate
+)
+{
+  TextBody:
+  [*
+    // Administrator Sep-6-2023 (created)
+    date := Date :: Today();
+    actualpispip := ActualProductInStockingPointInPeriod::FindActualProductInStockingPointInPeriodTypeIndex( productid, stockingpointid, date, manufactureddate );
+    
+    if( isnull( actualpispip ) ){
+      ActualProductInStockingPointInPeriod::Create( owner,
+                                                    productid,
+                                                    stockingpointid,
+                                                    description,
+                                                    actualinventorylevelend,
+                                                    date,
+                                                    manufactureddate,
+                                                    true);
+      }else{
+        actualpispip.Update( actualinventorylevelend, description, true );
+        }
+  *]
+}
diff --git a/_Main/BL/Type_ActualProductInStockingPointInPeriod/_ROOT_Type_ActualProductInStockingPointInPeriod.qbl b/_Main/BL/Type_ActualProductInStockingPointInPeriod/_ROOT_Type_ActualProductInStockingPointInPeriod.qbl
new file mode 100644
index 0000000..f7f3c21
--- /dev/null
+++ b/_Main/BL/Type_ActualProductInStockingPointInPeriod/_ROOT_Type_ActualProductInStockingPointInPeriod.qbl
@@ -0,0 +1,6 @@
+Quintiq file version 2.0
+#root
+#parent: #DomainModel
+TypeSpecialization ActualProductInStockingPointInPeriod #extension
+{
+}
diff --git a/_Main/BL/Type_InventorySupply/StaticMethod_CreateOrUpdate.qbl b/_Main/BL/Type_InventorySupply/StaticMethod_CreateOrUpdate.qbl
new file mode 100644
index 0000000..14114a8
--- /dev/null
+++ b/_Main/BL/Type_InventorySupply/StaticMethod_CreateOrUpdate.qbl
@@ -0,0 +1,31 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CreateOrUpdate (
+  String id,
+  Product_MP productmp,
+  StockingPoint_MP stockingpoint,
+  Date date,
+  Date manufacturedate,
+  Real userquantity,
+  String description
+)
+{
+  TextBody:
+  [*
+    // Administrator Sep-6-2023 (created)
+    inventorysupply := InventorySupply::FindInventorySupplyTypeIndex( id );
+    
+    if( isnull( inventorysupply ) ){
+      InventorySupply::Create(id,
+                               productmp,
+                               stockingpoint,
+                               date,
+                               manufacturedate,
+                               userquantity,
+                               description,
+                               true);
+      }else{
+        inventorysupply.Update( userquantity );
+        }
+  *]
+}
diff --git a/_Main/BL/Type_InventorySupply/_ROOT_Type_InventorySupply.qbl b/_Main/BL/Type_InventorySupply/_ROOT_Type_InventorySupply.qbl
new file mode 100644
index 0000000..71216fe
--- /dev/null
+++ b/_Main/BL/Type_InventorySupply/_ROOT_Type_InventorySupply.qbl
@@ -0,0 +1,6 @@
+Quintiq file version 2.0
+#root
+#parent: #DomainModel
+TypeSpecialization InventorySupply #extension
+{
+}
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl
index 1b88a5c..87cbdf3 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingActualPISPIPData.qbl
@@ -26,14 +26,22 @@
         for( i :=0 ;i < businessTypes.Size();i++ ){
           businessType := businessTypes.Element( i);
           if( product.BusinessType() = businessType and not product.IsCommon()){
-            ActualProductInStockingPointInPeriod::Create( this,actual.ProductID(),actual.StockingPointID(),actual.Description(),actual.ActualInventoryLevelEnd(),
-                                                  date,actual.ManufacturedDate(),true);
+            ActualProductInStockingPointInPeriod::CreateOrUpdate( this,
+                                                                  actual.ProductID(),
+                                                                  actual.StockingPointID(),
+                                                                  actual.Description(),
+                                                                  actual.ActualInventoryLevelEnd(),
+                                                                  actual.ManufacturedDate());
           }
         }
         
       }else{
-        ActualProductInStockingPointInPeriod::Create( this,actual.ProductID(),actual.StockingPointID(),actual.Description(),actual.ActualInventoryLevelEnd(),
-                                                  date,actual.ManufacturedDate(),true);
+        ActualProductInStockingPointInPeriod::CreateOrUpdate( this,
+                                                              actual.ProductID(),
+                                                              actual.StockingPointID(),
+                                                              actual.Description(),
+                                                              actual.ActualInventoryLevelEnd(),
+                                                              actual.ManufacturedDate());
       }
         
       }
diff --git a/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl b/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
index 7072e59..7295bad 100644
--- a/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
+++ b/_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
@@ -30,15 +30,23 @@
           for( i :=0 ;i < businessTypes.Size();i++ ){
             businessType := businessTypes.Element( i);
             if( product.BusinessType() = businessType and not product.IsCommon()){
-              InventorySupply::Create(externalSupply.ID(),productMP,stockingpoint,externalSupply.Date(),externalSupply.ManufacturedDate(),externalSupply.UserQuantity(),"鍦ㄩ�斿湪鍒�",true);
+              InventorySupply::CreateOrUpdate( externalSupply.ID(),
+                                               productMP,
+                                               stockingpoint,
+                                               externalSupply.Date(),
+                                               externalSupply.ManufacturedDate(),
+                                               externalSupply.UserQuantity(),"鍦ㄩ�斿湪鍒�");
             }
           }
           
         }else{
-    //    productMP :=  Product_MP::FindById( this, externalSupply.ProductID() );
-    //    stockingpoint := StockingPoint_MP::FindById( this, externalSupply.StockingPointID() );
         if( not isnull( stockingpoint) and not isnull( productMP)){
-          InventorySupply::Create(externalSupply.ID(),productMP,stockingpoint,externalSupply.Date(),externalSupply.ManufacturedDate(),externalSupply.UserQuantity(),"鍦ㄩ�斿湪鍒�",true);
+          InventorySupply::CreateOrUpdate( externalSupply.ID(),
+                                           productMP,
+                                           stockingpoint,
+                                           externalSupply.Date(),
+                                           externalSupply.ManufacturedDate(),
+                                           externalSupply.UserQuantity(),"鍦ㄩ�斿湪鍒�");
         }
       
         }

--
Gitblit v1.9.3