From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新

---
 force-app/main/default/classes/NFM007TriggerTest.cls |   83 ++++++++++++++++++++++++++++++++---------
 1 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/force-app/main/default/classes/NFM007TriggerTest.cls b/force-app/main/default/classes/NFM007TriggerTest.cls
index 621bd37..7dd1240 100644
--- a/force-app/main/default/classes/NFM007TriggerTest.cls
+++ b/force-app/main/default/classes/NFM007TriggerTest.cls
@@ -8,6 +8,7 @@
         StaticParameter.EscapeNFM001Trigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
         if (rectCo.size() == 0) {
             return;
@@ -60,7 +61,6 @@
                                                 LicenseAndAccount__c = company1.Id
                                                 );
         insert linc;
-        System.Test.startTest();
         // 鍐嶅彇寰�
         //List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
         //List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id in :accountIds order by Management_Code__c];
@@ -76,7 +76,24 @@
         product.Asset_Model_No__c = '11111';
         product.ProductCode = 'OTV-SP1H-NA-12E';
         product.MDM_Model_No__c = 'test';
+        product.CanNotCancelledGurantee__c=true;
         insert product;
+
+        Product_Register__c prc = new Product_Register__c(Name = '鍥芥娉ㄨ繘20162220210',
+            MedPrdClass__c = '3',
+            ValidFrom__c = date.newinstance(2018, 07, 22),
+            ValidTo__c = date.newinstance(2028, 07, 22),
+            RegisterNoClass_Old__c = '6815',
+            RegisterNoClass_New__c = '6815',
+            RegisterNoStatus__c = '鏈夋晥'
+            );
+        insert prc;
+
+        Product_Register_Link__c prlc = new Product_Register_Link__c(
+            Product2__c = product.Id,
+            Product_Register__c = prc.Id
+            );
+        insert prlc;
         
         PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id);
         entry.UnitPrice = 0;
@@ -89,18 +106,20 @@
         opp.AccountId           = depart.Id;
         opp.Department_Class__c = section.Id;
         opp.Hospital__c         = company.Id;
-        opp.SAP_Send_OK__c      = true;
+        opp.SAP_Send_OK__c      = false;
         opp.Gurantee_Period__c = '2';
         opp.Name                = 'GZ-SP-NFM007_1';
         opp.Trade__c            = '鍐呰部';
         opp.StageName           = '寮曞悎';
         opp.Sales_Root__c       = '璨╁2搴�';
-        opp.CloseDate           = date.newinstance(2022, 11, 30);
+        // opp.CloseDate           = date.newinstance(2022, 11, 30);
+        opp.CloseDate           = date.today();
         opp.Agency1__c = company1.Id;
         opp.Authorized_DB_No__c = 'Test20180522';
         opp.Contract_DB_SalesDept_complite_day__c = date.newinstance(2019, 05, 22);
         opp.NotesApprovedNo__c = 'Test20180622';
         opp.Estimation_Id__c    = '';
+        opp.multiYearWarranty__c =true;
         insert opp;
 
         Quote quo = new Quote();
@@ -114,6 +133,8 @@
         quo.OCM_Agent1_Price__c = 203;
         quo.Pricebook2Id = pricebookId;
         insert quo;
+
+        System.Test.startTest();
 
         //QuoteLineItem qli = new QuoteLineItem();
         //qli.QuoteId = quo.Id;
@@ -163,6 +184,7 @@
         oppli.PricebookEntryId = entry.Id;
         insert oppli;
         System.Test.stopTest();
+        StaticParameter.EscapeOppandStaTrigger = false;
         //Test.startTest();
         // NFM007銈堛倞銆侀�佷俊銇椼仾銇勩亾銇�
         //System.assertEquals('', NFM007Controller.debug_msg);
@@ -178,6 +200,7 @@
         StaticParameter.EscapeNFM001Trigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
         if (rectCo.size() == 0) {
             return;
@@ -230,7 +253,6 @@
                                                 LicenseAndAccount__c = company1.Id
                                                 );
         insert linc;
-        System.Test.startTest();
         // 鍐嶅彇寰�
         //List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
         //List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id in :accountIds order by Management_Code__c];
@@ -247,12 +269,14 @@
         opp.Trade__c            = '鍐呰部';
         opp.StageName           = '寮曞悎';
         opp.Sales_Root__c       = '璨╁2搴�';
-        opp.CloseDate           = date.newinstance(2022, 11, 30);
+        // opp.CloseDate           = date.newinstance(2022, 11, 30);
+        opp.CloseDate           = date.today();
         opp.Agency1__c = company1.Id;
         opp.Authorized_DB_No__c = 'Test20180522';
         opp.Contract_DB_SalesDept_complite_day__c = date.newinstance(2019, 05, 22);
         opp.NotesApprovedNo__c = 'Test20180622';
         opp.Estimation_Id__c    = '';
+        opp.multiYearWarranty__c =true;
         insert opp;
 
         Quote quo = new Quote();
@@ -266,6 +290,7 @@
         quo.OCM_Agent1_Price__c = 203;
         quo.Pricebook2Id = pricebookId;
         insert quo;
+        System.Test.startTest();
         opp.Estimation_Decision__c = true;
         opp.Estimation_Id__c    = quo.ID;
         update opp;
@@ -280,7 +305,7 @@
         product3.Asset_Model_No__c = '11111';
         product3.MDM_Model_No__c = '123';
         product3.ProductCode = 'OTV-SP1H-NA-12E';
-
+        product3.CanNotCancelledGurantee__c=true;
         insert product3;
 
         PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product3.Id);
@@ -323,18 +348,19 @@
         oppli.PricebookEntryId = entry.Id;
         insert oppli;
         System.Test.stopTest();
+        StaticParameter.EscapeOppandStaTrigger = false;
         //Test.startTest();
         // NFM007銈堛倞銆侀�佷俊銇椼仾銇勩亾銇�
         //System.assertEquals('', NFM007Controller.debug_msg);
         opp.SAP_Send_OK__c      = true;
         opp.Gurantee_Period__c = '2';
-        opp.oldData_flg__c = true;
+        // opp.oldData_flg__c = true;  //20221229 lt DB202211430986 璇环鍘嗗彶涓嶄娇鐢ㄥ瓧娈� 
         opp.Estimation_Decision__c = true;
         update opp;  
         //Test.stopTest();
     }
 
-    //static testMethod void testUpdateHospital() {
+      //static testMethod void testUpdateHospital() {
     //    List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
     //    if (rectCo.size() == 0) {
     //        return;
@@ -862,6 +888,7 @@
         StaticParameter.EscapeNFM001Trigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
         if (rectCo.size() == 0) {
             return;
@@ -914,7 +941,6 @@
                                                 LicenseAndAccount__c = company1.Id
                                                 );
         insert linc;
-        System.Test.startTest();
         // 鍐嶅彇寰�
         //List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
         //List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id in :accountIds order by Management_Code__c];
@@ -931,12 +957,14 @@
         opp.Trade__c            = '鍐呰部';
         opp.StageName           = '寮曞悎';
         opp.Sales_Root__c       = '璨╁2搴�';
-        opp.CloseDate           = date.newinstance(2022, 11, 30);
+        // opp.CloseDate           = date.newinstance(2022, 11, 30);
+        opp.CloseDate           = date.today();
         opp.Agency1__c = company1.Id;
         opp.Authorized_DB_No__c = 'Test20180522';
         opp.Contract_DB_SalesDept_complite_day__c = date.newinstance(2019, 05, 22);
         opp.NotesApprovedNo__c = 'Test20180622';
         opp.Estimation_Id__c    = '';
+        opp.multiYearWarranty__c =true;
         insert opp;
 
         Quote quo = new Quote();
@@ -950,6 +978,7 @@
         quo.OCM_Agent1_Price__c = 203;
         quo.Pricebook2Id = pricebookId;
         insert quo;
+        System.Test.startTest();
         opp.Estimation_Decision__c = true;
         opp.Estimation_Id__c    = quo.ID;
         update opp;
@@ -964,7 +993,7 @@
         product3.Asset_Model_No__c = '11111';
         product3.MDM_Model_No__c = '123';
         product3.ProductCode = 'OTV-SP1H-NA-12E';
-
+        product3.CanNotCancelledGurantee__c=true;
         insert product3;
 
         PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product3.Id);
@@ -1040,12 +1069,13 @@
         oppli.PricebookEntryId = entry.Id;
         insert oppli;
         System.Test.stopTest();
+        StaticParameter.EscapeOppandStaTrigger = false;
         //Test.startTest();
         // NFM007銈堛倞銆侀�佷俊銇椼仾銇勩亾銇�
         //System.assertEquals('', NFM007Controller.debug_msg);
         opp.SAP_Send_OK__c      = true;
         opp.Gurantee_Period__c = '2';
-        opp.oldData_flg__c = true;
+        // opp.oldData_flg__c = true;  //20221229 lt DB202211430986 璇环鍘嗗彶涓嶄娇鐢ㄥ瓧娈�
         opp.Estimation_Decision__c = true;
         // opp.Estimation_Decision__c = true;
         opp.Estimation_Id__c    = quo.ID;
@@ -1059,6 +1089,7 @@
         StaticParameter.EscapeNFM001Trigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
         if (rectCo.size() == 0) {
             return;
@@ -1111,7 +1142,6 @@
                                                 LicenseAndAccount__c = company1.Id
                                                 );
         insert linc;
-        System.Test.startTest();
         // 鍐嶅彇寰�
         //List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
         //List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id in :accountIds order by Management_Code__c];
@@ -1128,12 +1158,13 @@
         opp.Trade__c            = '鍐呰部';
         opp.StageName           = '寮曞悎';
         opp.Sales_Root__c       = '璨╁2搴�';
-        opp.CloseDate           = date.newinstance(2022, 11, 30);
-        opp.Agency1__c = company1.Id;
+        // opp.CloseDate           = date.newinstance(2022, 11, 30);
+        opp.CloseDate           = date.today();
         opp.Authorized_DB_No__c = 'Test20180522';
         opp.Contract_DB_SalesDept_complite_day__c = date.newinstance(2019, 05, 22);
         opp.NotesApprovedNo__c = 'Test20180622';
         opp.Estimation_Id__c    = '';
+        opp.multiYearWarranty__c =true;
         insert opp;
 
         Quote quo = new Quote();
@@ -1147,6 +1178,7 @@
         quo.OCM_Agent1_Price__c = 203;
         quo.Pricebook2Id = pricebookId;
         insert quo;
+        System.Test.startTest();
         opp.Estimation_Decision__c = true;
         opp.Estimation_Id__c    = quo.ID;
         update opp;
@@ -1166,6 +1198,7 @@
         product3.Asset_Model_No__c = '11111';
         product3.MDM_Model_No__c = '123';
         product3.ProductCode = 'OTV-SP1H-NA-12E';
+        product3.CanNotCancelledGurantee__c=true;
 
         insert product3;
 
@@ -1210,12 +1243,13 @@
         insert oppli;
         
         System.Test.stopTest();
+        StaticParameter.EscapeOppandStaTrigger = false;
         //Test.startTest();
         // NFM007銈堛倞銆侀�佷俊銇椼仾銇勩亾銇�
         //System.assertEquals('', NFM007Controller.debug_msg);
         opp.SAP_Send_OK__c      = true;
         opp.Gurantee_Period__c = '2';
-        opp.oldData_flg__c = true;
+        // opp.oldData_flg__c = true;  //20221229 lt DB202211430986 璇环鍘嗗彶涓嶄娇鐢ㄥ瓧娈�
         opp.Estimation_Decision__c = true;
         update opp;  
         //Test.stopTest();
@@ -1226,6 +1260,7 @@
         StaticParameter.EscapeNFM001Trigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger = true;
         StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
+        StaticParameter.EscapeOppandStaTrigger = true;
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
         if (rectCo.size() == 0) {
             return;
@@ -1278,7 +1313,6 @@
                                                 LicenseAndAccount__c = company1.Id
                                                 );
         insert linc;
-        System.Test.startTest();
         // 鍐嶅彇寰�
         //List<Id> accountIds = new Id[] {company.Id, section.Id, depart.Id};
         //List<Account> accList = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id in :accountIds order by Management_Code__c];
@@ -1295,12 +1329,15 @@
         opp.Trade__c            = '澶栬部';
         opp.StageName           = '寮曞悎';
         opp.Sales_Root__c       = '璨╁2搴�';
-        opp.CloseDate           = date.newinstance(2022, 11, 30);
+        // opp.CloseDate           = date.newinstance(2022, 11, 30);
+        opp.CloseDate           = date.today();
         opp.Agency1__c = company1.Id;
         opp.Authorized_DB_No__c = 'Test20180522';
         opp.Contract_DB_SalesDept_complite_day__c = date.newinstance(2019, 05, 22);
         opp.NotesApprovedNo__c = 'Test20180622';
         opp.Estimation_Id__c    = '';
+        opp.multiYearWarranty__c =true;
+        opp.CurrencyIsoCode = 'USD';
         insert opp;
 
         Quote quo = new Quote();
@@ -1314,6 +1351,7 @@
         quo.OCM_Agent1_Price__c = 203;
         quo.Pricebook2Id = pricebookId;
         insert quo;
+        System.Test.startTest();
         opp.Estimation_Decision__c = true;
         opp.Estimation_Id__c    = quo.ID;
         update opp;
@@ -1333,6 +1371,7 @@
         product3.Asset_Model_No__c = '11111';
         product3.MDM_Model_No__c = '123';
         product3.ProductCode = 'OTV-SP1H-NA-12E';
+        product3.CanNotCancelledGurantee__c=true;
 
         insert product3;
 
@@ -1380,11 +1419,17 @@
         //Test.startTest();
         // NFM007銈堛倞銆侀�佷俊銇椼仾銇勩亾銇�
         //System.assertEquals('', NFM007Controller.debug_msg);
+        StaticParameter.EscapeOppandStaTrigger = false;
         opp.SAP_Send_OK__c      = true;
         opp.Gurantee_Period__c = '2';
-        opp.oldData_flg__c = true;
+        // opp.oldData_flg__c = true;  //20221229 lt DB202211430986 璇环鍘嗗彶涓嶄娇鐢ㄥ瓧娈�
         opp.Estimation_Decision__c = true;
         update opp;  
         //Test.stopTest();
     }
+
+    static testMethod void test_00() {
+        NFM007Controller controller = new NFM007Controller();
+        controller.test();
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1