From 5b5c1e16deaa3a9d6d0ed1ffca390655ed103df7 Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期五, 14 七月 2023 14:56:14 +0800 Subject: [PATCH] lex community --- force-app/main/default/classes/LexConsumableGoodsInfoTest.cls | 1844 ++++++++++++++++++++++++----------------------------------- 1 files changed, 756 insertions(+), 1,088 deletions(-) diff --git a/force-app/main/default/classes/LexConsumableGoodsInfoTest.cls b/force-app/main/default/classes/LexConsumableGoodsInfoTest.cls index fb566bb..9f28b06 100644 --- a/force-app/main/default/classes/LexConsumableGoodsInfoTest.cls +++ b/force-app/main/default/classes/LexConsumableGoodsInfoTest.cls @@ -1,1113 +1,781 @@ @istest public class LexConsumableGoodsInfoTest { - @IsTest - static void lexConsumableGoodsInfoTest1() { - user MyUser_Test; - Account myAccount1; - User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true); - insert n; - System.runAs(thisUser) { - Profile prof1 = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - StaticParameter.EscapeConsumableOrderDetail2Trigger = true; + @IsTest + static void lexConsumableGoodsInfoTest1(){ + user MyUser_Test; + Account myAccount1; + User thisUser = [ select Id from User where Id = :UserInfo.getUserId()]; + NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true); + insert n; + System.runAs(thisUser){ + Profile prof1 = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + StaticParameter.EscapeConsumableOrderDetail2Trigger = true; + + RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌']; + Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus'); + insert olympus; + myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888',Product_Limit_Date__c = 'Test07|3|100,Test08|10|50'); + insert myAccount1; + Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id); + insert core; + MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '閲嶅簡'); + insert MyUser_Test; - RecordType rectCoO = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '鐥呴櫌' - ]; - Account olympus = new Account( - RecordTypeId = rectCoO.Id, - AgentCode_Ext__c = '9999900', - Name = 'olympus' - ); - insert olympus; - myAccount1 = new Account( - name = 'Testaccount001', - Dealer_discount__c = 10, - RecordTypeId = rectCo[0].Id, - AgentCode_Ext__c = '8888888', - Product_Limit_Date__c = 'Test07|3|100,Test08|10|50' - ); - insert myAccount1; - Contact core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.id - ); - insert core; - MyUser_Test = new User( - ContactId = core.id, - Alias = 'newUser', - Email = 'newuser@testorg.com', - EmailEncodingKey = 'UTF-8', - LastName = 'TestUser', - LanguageLocaleKey = 'zh_CN', - LocaleSidKey = 'zh_CN', - ProfileId = prof1.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com', - Work_Location__c = '閲嶅簡' - ); - insert MyUser_Test; + } + + system.runAs(MyUser_Test){ + //浜у搧鏁版嵁 + Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '鏈夊姽',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false); + insert new Product2[] {prod07,prod08,prod09}; + + //鍒朵綔浜у搧 + Product2__c proG = new Product2__c(Name='MH-155:鐧藉钩琛″附',OT_CODE_Text__c='Test001',Product2__c = prod07.Id); + insert proG; + Product2__c proH = new Product2__c(Name='MB-677:BNC鐢电紗',OT_CODE_Text__c='Test002',Product2__c = prod08.Id); + insert proH; + Product2__c proF = new Product2__c(Name='TooMAJ-643R:姘村泭闉樼003',OT_CODE_Text__c='Test003',Product2__c = prod09.Id); + insert proF; + + + //璁㈠崟 + Consumable_order__c order = new Consumable_order__c(); + order.Name = 'testMing'; + order.Order_status__c = '鎵瑰噯'; + order.RecordTypeid = System.Label.RT_ConOrder_Order; + order.Dealer_Info__c = myAccount1.id; + order.Inventory_date__c = Date.today(); + order.Order_type__c = '璁㈠崟'; + order.Order_ProType__c = 'ET'; + insert order; + //鍒拌揣 + Consumable_order__c order2 = new Consumable_order__c(); + order2.Name = 'testMing1'; + order2.Order_status__c = '鎵瑰噯'; + order2.RecordTypeid = '01210000000c9dqAAA'; + order2.Dealer_Info__c = myAccount1.id; + order2.Order_type__c = '鍒拌揣'; + order2.Order_ProType__c = 'ET'; + insert order2; + + List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>(); + //鍒朵綔Consumable_order_details__c-------ProductCount + // 閿�鍞� + Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c(); + dataForProductCount7.Bar_Code__c = '123456789298k250AAAAA'; + dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2); + dataForProductCount7.Arrive_date__c = Date.today(); + dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount7.Consumable_Product__c = proH.id; + dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c; + dataForProductCount7.Box_Piece__c = '鐩�'; + dataForProductCount7.Used_date__c = Date.today(); + dataForProductCount7.Consumable_order_minor__c = order.id; + + conList.add(dataForProductCount7); + // 鍦ㄥ簱 杩囨湡 鐩� + Consumable_order_details2__c dataForProduct = new Consumable_order_details2__c(); + dataForProduct.Bar_Code__c = '123456789498k250BBBBB'; + dataForProduct.Sterilization_limit__c = Date.today().addDays(-2); + dataForProduct.Arrive_date__c = Date.today(); + dataForProduct.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProduct.Consumable_Product__c = proF.id; + dataForProduct.Asset_Model_No__c = proF.Asset_Model_No__c; + dataForProduct.Box_Piece__c = '鐩�'; + dataForProduct.Consumable_order_minor__c = order.id; + + conList.add(dataForProduct); + // 鍦ㄥ簱 杩囨湡 涓� + Consumable_order_details2__c dataForProductCount3 = new Consumable_order_details2__c(); + dataForProductCount3.Bar_Code__c = '123456788398k250CCCCC'; + dataForProductCount3.Sterilization_limit__c = Date.today().addDays(-2); + dataForProductCount3.Arrive_date__c = Date.today(); + dataForProductCount3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; + dataForProductCount3.Consumable_Product__c = proG.id; + dataForProductCount3.Asset_Model_No__c = proG.Asset_Model_No__c; + dataForProductCount3.Box_Piece__c = '涓�'; + dataForProductCount3.RemoveBox_No__c = 1; + dataForProductCount3.Consumable_order_minor__c = order.id; + conList.add(dataForProductCount3); + insert conList; + + //杩囨湡搴撳瓨姹囨�讳俊鎭� add by Wang Xueqin + List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>(); + Consumable_order_details2__c dataForProductCount4 = new Consumable_order_details2__c(); + dataForProductCount4.Bar_Code__c = '1001'; + dataForProductCount4.Arrive_date__c = Date.today(); + dataForProductCount4.Send_Date__c = null; + dataForProductCount4.Used_date__c = null; + dataForProductCount4.Return_date__c = null; + dataForProductCount4.Lose_Flag__c = false; + dataForProductCount4.Cancellation_Flag__c = false; + dataForProductCount4.Consumable_Product__c = proG.Id; + dataForProductCount4.Consumable_Arrived_order__c = order2.id; + dataForProductCount4.Used_account__c = myAccount1.Id; + dataForProductCount4.Sterilization_limit__c = Date.today().addDays(-2); + dataForProductCount4.Box_Piece__c = '鐩�'; + conList1.add(dataForProductCount4); + System.debug('conList1==>'+conList1); + //鏌ヨ鎵�鏈夎繃鏈熷簱瀛� + Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c(); + dataForProductCount5.Bar_Code__c = '1002'; + dataForProductCount5.Arrive_date__c = Date.today(); + dataForProductCount5.Send_Date__c = Date.today(); + dataForProductCount5.Used_date__c = Date.today(); + dataForProductCount5.Return_date__c = null; + dataForProductCount5.Lose_Flag__c = false; + dataForProductCount5.Cancellation_Flag__c = false; + dataForProductCount5.Consumable_Product__c = proG.Id; + dataForProductCount5.Consumable_Arrived_order__c = order2.id; + dataForProductCount5.Used_account__c = myAccount1.Id; + dataForProductCount5.Sterilization_limit__c = Date.today().addDays(-2); + dataForProductCount5.Box_Piece__c = '鐩�'; + conList1.add(dataForProductCount5); + insert conList1; + Test.startTest(); + LexConsumableGoodsInfo.initMoreThan7(dataForProductCount7.Id); + LexConsumableGoodsInfo.initMoreThan7All('all'); + LexConsumableGoodsInfo.initNotArrDet(dataForProductCount7.Id); + LexConsumableGoodsInfo.initNotArrDetAll('all'); + LexConsumableGoodsInfo.initArrDet(dataForProductCount7.Id); + LexConsumableGoodsInfo.initArrDetAll('all'); + LexConsumableGoodsInfo.initDeliveryDet(dataForProductCount7.Id); + LexConsumableGoodsInfo.initDeliveryDetAll('all'); + LexConsumableGoodsInfo.initTotalNum('1', 'all'); + LexConsumableGoodsInfo.initTotalNum(dataForProductCount7.Id, 'all'); + Test.stopTest(); + } } - System.runAs(MyUser_Test) { - //浜у搧鏁版嵁 - Product2 prod07 = new Product2( - Name = 'Test07', - ProductCode = 'Test07', - Asset_Model_No__c = 'Test07', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - Product2 prod08 = new Product2( - Name = 'Test08', - ProductCode = 'Test08', - Asset_Model_No__c = 'Test08', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - Product2 prod09 = new Product2( - Name = 'Test09', - ProductCode = 'Test09', - Asset_Model_No__c = 'Test09', - SFDA_Status__c = '鏈夊姽', - Dealer_special_Object__c = true, - Packing_list_manual__c = 1, - Manual_Entry__c = false - ); - insert new List<Product2>{ prod07, prod08, prod09 }; + @IsTest + static void lexConsumableGoodsInfoTest2(){ + User myUser_test = new User(); + Account myAccount1; + Contact core; + User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; + NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true); + insert n; + System.runAs(currentUser){ + Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + myAccount1 = new Account(name='testaccount001',RecordTypeId = rectCo[0].Id ,AgentCode_Ext__c = '9999900'); + insert myAccount1; + core = new Contact(email='jplumber@salesforce.com', + firstname='Joe', + lastname='Plumber', + accountid=myAccount1.id); + insert core; + myUser_test = New User( + ContactId = core.id, + Alias = 'newUser', + Email='newuser@testorg.com', + EmailEncodingKey='UTF-8', + LastName='testUser', + LanguageLocaleKey='zh_CN', + LocaleSidKey='zh_CN', + ProfileId = prof.Id, + TimeZoneSidKey='Asia/Shanghai', + UserName='testUser@testorg.com', + Work_Location__c='鍖椾含'); + insert myUser_test; + } + System.runAs(myUser_test){ + Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + insert new Product2[]{prod01,prod02}; + Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id); + Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id); + insert new Product2__c[] {pro1, pro2}; + //璁㈠崟 + Consumable_order__c Order1 = new Consumable_order__c( + Name='OCM_01_001', + RecordTypeId = System.Label.RT_ConOrder_Delivery, + Order_type__c ='璁㈠崟', + Dealer_info__c=myAccount1.Id, + Order_ProType__c = 'ET'); + Consumable_order__c Order2 = new Consumable_order__c( + Name='OCM_01_002', + RecordTypeId = System.Label.RT_ConOrder_Delivery, + Order_type__c ='璁㈠崟', + Dealer_info__c=myAccount1.Id, + Order_ProType__c = 'ET'); + insert new Consumable_order__c[] {Order1, Order2}; - //鍒朵綔浜у搧 - Product2__c proG = new Product2__c( - Name = 'MH-155:鐧藉钩琛″附', - OT_CODE_Text__c = 'Test001', - Product2__c = prod07.Id - ); - insert proG; - Product2__c proH = new Product2__c( - Name = 'MB-677:BNC鐢电紗', - OT_CODE_Text__c = 'Test002', - Product2__c = prod08.Id - ); - insert proH; - Product2__c proF = new Product2__c( - Name = 'TooMAJ-643R:姘村泭闉樼003', - OT_CODE_Text__c = 'Test003', - Product2__c = prod09.Id - ); - insert proF; + //鏄庣粏1 + Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); + createDetail.name = 'Too001'; + createDetail.Consumable_Product__c = pro1.id; + createDetail.Dealer_Custom_Price__c = 999.00; + createDetail.Consumable_count__c = 3; + createDetail.Consumable_order__c = Order1.id; + createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; + insert createDetail; + Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c(); + createDetail1.name = 'Too002'; + createDetail1.Consumable_Product__c = pro2.id; + createDetail1.Consumable_order__c = Order2.id; + createDetail1.Dealer_Custom_Price__c = 999.00; + createDetail1.Consumable_count__c = 4; + createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; + insert createDetail1; - //璁㈠崟 - Consumable_order__c order = new Consumable_order__c(); - order.Name = 'testMing'; - order.Order_status__c = '鎵瑰噯'; - order.RecordTypeid = System.Label.RT_ConOrder_Order; - order.Dealer_Info__c = myAccount1.id; - order.Inventory_date__c = Date.today(); - order.Order_type__c = '璁㈠崟'; - order.Order_ProType__c = 'ET'; - insert order; - //鍒拌揣 - Consumable_order__c order2 = new Consumable_order__c(); - order2.Name = 'testMing1'; - order2.Order_status__c = '鎵瑰噯'; - order2.RecordTypeid = '01210000000c9dqAAA'; - order2.Dealer_Info__c = myAccount1.id; - order2.Order_type__c = '鍒拌揣'; - order2.Order_ProType__c = 'ET'; - insert order2; + //璁㈠崟鏄庣粏 + Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( + Name='OCM_01_001001', + Consumable_order_minor__c = Order1.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c( + Name='OCM_01_001002', + Consumable_order_minor__c = Order2.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro2.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( + Name='OCM_01_001003', + Consumable_order_minor__c = Order1.Id, + //Arrive_date__c = Date.today(), + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c( + Name='OCM_01_001004', + Consumable_order_minor__c = Order2.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro2.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2, Orderdet3, Orderdet4}; - List<Consumable_order_details2__c> conList = new List<Consumable_order_details2__c>(); - //鍒朵綔Consumable_order_details__c-------ProductCount - // 閿�鍞� - Consumable_order_details2__c dataForProductCount7 = new Consumable_order_details2__c(); - dataForProductCount7.Bar_Code__c = '123456789298k250AAAAA'; - dataForProductCount7.Sterilization_limit__c = Date.today().addDays(2); - dataForProductCount7.Arrive_date__c = Date.today(); - dataForProductCount7.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount7.Consumable_Product__c = proH.id; - dataForProductCount7.Asset_Model_No__c = proH.Asset_Model_No__c; - dataForProductCount7.Box_Piece__c = '鐩�'; - dataForProductCount7.Used_date__c = Date.today(); - dataForProductCount7.Consumable_order_minor__c = order.id; - - conList.add(dataForProductCount7); - // 鍦ㄥ簱 杩囨湡 鐩� - Consumable_order_details2__c dataForProduct = new Consumable_order_details2__c(); - dataForProduct.Bar_Code__c = '123456789498k250BBBBB'; - dataForProduct.Sterilization_limit__c = Date.today().addDays(-2); - dataForProduct.Arrive_date__c = Date.today(); - dataForProduct.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProduct.Consumable_Product__c = proF.id; - dataForProduct.Asset_Model_No__c = proF.Asset_Model_No__c; - dataForProduct.Box_Piece__c = '鐩�'; - dataForProduct.Consumable_order_minor__c = order.id; - - conList.add(dataForProduct); - // 鍦ㄥ簱 杩囨湡 涓� - Consumable_order_details2__c dataForProductCount3 = new Consumable_order_details2__c(); - dataForProductCount3.Bar_Code__c = '123456788398k250CCCCC'; - dataForProductCount3.Sterilization_limit__c = Date.today().addDays(-2); - dataForProductCount3.Arrive_date__c = Date.today(); - dataForProductCount3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery; - dataForProductCount3.Consumable_Product__c = proG.id; - dataForProductCount3.Asset_Model_No__c = proG.Asset_Model_No__c; - dataForProductCount3.Box_Piece__c = '涓�'; - dataForProductCount3.RemoveBox_No__c = 1; - dataForProductCount3.Consumable_order_minor__c = order.id; - conList.add(dataForProductCount3); - insert conList; - - //杩囨湡搴撳瓨姹囨�讳俊鎭� add by Wang Xueqin - List<Consumable_order_details2__c> conList1 = new List<Consumable_order_details2__c>(); - Consumable_order_details2__c dataForProductCount4 = new Consumable_order_details2__c(); - dataForProductCount4.Bar_Code__c = '1001'; - dataForProductCount4.Arrive_date__c = Date.today(); - dataForProductCount4.Send_Date__c = null; - dataForProductCount4.Used_date__c = null; - dataForProductCount4.Return_date__c = null; - dataForProductCount4.Lose_Flag__c = false; - dataForProductCount4.Cancellation_Flag__c = false; - dataForProductCount4.Consumable_Product__c = proG.Id; - dataForProductCount4.Consumable_Arrived_order__c = order2.id; - dataForProductCount4.Used_account__c = myAccount1.Id; - dataForProductCount4.Sterilization_limit__c = Date.today().addDays(-2); - dataForProductCount4.Box_Piece__c = '鐩�'; - conList1.add(dataForProductCount4); - System.debug('conList1==>' + conList1); - //鏌ヨ鎵�鏈夎繃鏈熷簱瀛� - Consumable_order_details2__c dataForProductCount5 = new Consumable_order_details2__c(); - dataForProductCount5.Bar_Code__c = '1002'; - dataForProductCount5.Arrive_date__c = Date.today(); - dataForProductCount5.Send_Date__c = Date.today(); - dataForProductCount5.Used_date__c = Date.today(); - dataForProductCount5.Return_date__c = null; - dataForProductCount5.Lose_Flag__c = false; - dataForProductCount5.Cancellation_Flag__c = false; - dataForProductCount5.Consumable_Product__c = proG.Id; - dataForProductCount5.Consumable_Arrived_order__c = order2.id; - dataForProductCount5.Used_account__c = myAccount1.Id; - dataForProductCount5.Sterilization_limit__c = Date.today().addDays(-2); - dataForProductCount5.Box_Piece__c = '鐩�'; - conList1.add(dataForProductCount5); - insert conList1; - Test.startTest(); - LexConsumableGoodsInfo.initMoreThan7(dataForProductCount7.Id); - LexConsumableGoodsInfo.initMoreThan7All('all'); - LexConsumableGoodsInfo.initNotArrDet(dataForProductCount7.Id); - LexConsumableGoodsInfo.initNotArrDetAll('all'); - LexConsumableGoodsInfo.initArrDet(dataForProductCount7.Id); - LexConsumableGoodsInfo.initArrDetAll('all'); - LexConsumableGoodsInfo.initDeliveryDet(dataForProductCount7.Id); - LexConsumableGoodsInfo.initDeliveryDetAll('all'); - LexConsumableGoodsInfo.initTotalNum('1', 'all'); - LexConsumableGoodsInfo.initTotalNum(dataForProductCount7.Id, 'all'); - Test.stopTest(); + LexConsumableGoodsInfo.initMoreThan7(Orderdet1.Id); + LexConsumableGoodsInfo.initMoreThan7All('all'); + LexConsumableGoodsInfo.initNotArrDet(Orderdet1.Id); + LexConsumableGoodsInfo.initNotArrDetAll('all'); + LexConsumableGoodsInfo.initArrDet(Orderdet1.Id); + LexConsumableGoodsInfo.initArrDetAll('all'); + LexConsumableGoodsInfo.initDeliveryDet(Orderdet1.Id); + LexConsumableGoodsInfo.initDeliveryDetAll('all'); + LexConsumableGoodsInfo.initTotalNum('1', 'all'); + LexConsumableGoodsInfo.initTotalNum(Orderdet1.Id, 'all'); + + } } - } - @IsTest - static void lexConsumableGoodsInfoTest2() { - User myUser_test = new User(); - Account myAccount1; - Contact core; - User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true); - insert n; - System.runAs(currentUser) { - Profile prof = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - myAccount1 = new Account( - name = 'testaccount001', - RecordTypeId = rectCo[0].Id, - AgentCode_Ext__c = '9999900' - ); - insert myAccount1; - core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.id - ); - insert core; - myUser_test = new User( - ContactId = core.id, - Alias = 'newUser', - Email = 'newuser@testorg.com', - EmailEncodingKey = 'UTF-8', - LastName = 'testUser', - LanguageLocaleKey = 'zh_CN', - LocaleSidKey = 'zh_CN', - ProfileId = prof.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com', - Work_Location__c = '鍖椾含' - ); - insert myUser_test; + @IsTest + static void lexConsumableGoodsInfoTest3(){ + User myUser_test = new User(); + Account myAccount1; + Contact core; + User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; + NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true); + insert n; + System.runAs(currentUser){ + Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + myAccount1 = new Account(name='testaccount001',RecordTypeId = rectCo[0].Id ,AgentCode_Ext__c = '9999900'); + insert myAccount1; + core = new Contact(email='jplumber@salesforce.com', + firstname='Joe', + lastname='Plumber', + accountid=myAccount1.id); + insert core; + myUser_test = New User( + ContactId = core.id, + Alias = 'newUser', + Email='newuser@testorg.com', + EmailEncodingKey='UTF-8', + LastName='testUser', + LanguageLocaleKey='zh_CN', + LocaleSidKey='zh_CN', + ProfileId = prof.Id, + TimeZoneSidKey='Asia/Shanghai', + UserName='testUser@testorg.com', + Work_Location__c='鍖椾含'); + insert myUser_test; + } + System.runAs(myUser_test){ + Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + insert new Product2[]{prod01,prod02}; + Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id); + Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id); + insert new Product2__c[] {pro1, pro2}; + //璁㈠崟 + Consumable_order__c Order1 = new Consumable_order__c( + Name='OCM_01_001', + RecordTypeId = System.Label.RT_ConOrder_Delivery, + Order_type__c ='璁㈠崟', + Dealer_info__c=myAccount1.Id, + Order_ProType__c = 'ET'); + Consumable_order__c Order2 = new Consumable_order__c( + Name='OCM_01_002', + RecordTypeId = System.Label.RT_ConOrder_Delivery, + Order_type__c ='璁㈠崟', + Dealer_info__c=myAccount1.Id, + Order_ProType__c = 'ET'); + insert new Consumable_order__c[] {Order1, Order2}; + + //鏄庣粏1 + Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); + createDetail.name = 'Too001'; + createDetail.Consumable_Product__c = pro1.id; + createDetail.Dealer_Custom_Price__c = 999.00; + createDetail.Consumable_count__c = 3; + createDetail.Consumable_order__c = Order1.id; + createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; + insert createDetail; + Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c(); + createDetail1.name = 'Too002'; + createDetail1.Consumable_Product__c = pro2.id; + createDetail1.Consumable_order__c = Order2.id; + createDetail1.Dealer_Custom_Price__c = 999.00; + createDetail1.Consumable_count__c = 4; + createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; + insert createDetail1; + + //璁㈠崟鏄庣粏 + Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( + Name='OCM_01_001001', + Consumable_order_minor__c = Order1.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c( + Name='OCM_01_001002', + Consumable_order_minor__c = Order2.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro2.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( + Name='OCM_01_001003', + Consumable_order_minor__c = Order1.Id, + //Arrive_date__c = Date.today(), + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c( + Name='OCM_01_001004', + Consumable_order_minor__c = Order2.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro2.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2, Orderdet3, Orderdet4}; + + LexConsumableGoodsInfo.initMoreThan7(Orderdet2.Id); + LexConsumableGoodsInfo.initMoreThan7All(''); + LexConsumableGoodsInfo.initNotArrDet(Orderdet2.Id); + LexConsumableGoodsInfo.initNotArrDetAll(''); + LexConsumableGoodsInfo.initArrDet(Orderdet2.Id); + LexConsumableGoodsInfo.initArrDetAll(''); + LexConsumableGoodsInfo.initDeliveryDet(Orderdet2.Id); + LexConsumableGoodsInfo.initDeliveryDetAll(''); + LexConsumableGoodsInfo.initTotalNum(Orderdet2.Id, ''); + } } - System.runAs(myUser_test) { - Product2 prod01 = new Product2( - Name = 'Test01', - ProductCode = 'Test01', - Asset_Model_No__c = 'Test01', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - Product2 prod02 = new Product2( - Name = 'Test02', - ProductCode = 'Test02', - Asset_Model_No__c = 'Test02', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - insert new List<Product2>{ prod01, prod02 }; - Product2__c pro1 = new Product2__c( - Name = 'Pro001', - OT_CODE_Text__c = 'Test001', - Product2__c = prod01.Id - ); - Product2__c pro2 = new Product2__c( - Name = 'Pro002', - OT_CODE_Text__c = 'Test002', - Product2__c = prod02.Id - ); - insert new List<Product2__c>{ pro1, pro2 }; - //璁㈠崟 - Consumable_order__c Order1 = new Consumable_order__c( - Name = 'OCM_01_001', - RecordTypeId = System.Label.RT_ConOrder_Delivery, - Order_type__c = '璁㈠崟', - Dealer_info__c = myAccount1.Id, - Order_ProType__c = 'ET' - ); - Consumable_order__c Order2 = new Consumable_order__c( - Name = 'OCM_01_002', - RecordTypeId = System.Label.RT_ConOrder_Delivery, - Order_type__c = '璁㈠崟', - Dealer_info__c = myAccount1.Id, - Order_ProType__c = 'ET' - ); - insert new List<Consumable_order__c>{ Order1, Order2 }; - //鏄庣粏1 - Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); - createDetail.name = 'Too001'; - createDetail.Consumable_Product__c = pro1.id; - createDetail.Dealer_Custom_Price__c = 999.00; - createDetail.Consumable_count__c = 3; - createDetail.Consumable_order__c = Order1.id; - createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; - insert createDetail; - Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c(); - createDetail1.name = 'Too002'; - createDetail1.Consumable_Product__c = pro2.id; - createDetail1.Consumable_order__c = Order2.id; - createDetail1.Dealer_Custom_Price__c = 999.00; - createDetail1.Consumable_count__c = 4; - createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; - insert createDetail1; + @IsTest + static void lexConsumableGoodsInfoTest4(){ + User myUser_test = new User(); + Account myAccount1; + Contact core; + User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; + NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true); + insert n; + System.runAs(currentUser){ + Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + myAccount1 = new Account(name='testaccount001',RecordTypeId = rectCo[0].Id ,AgentCode_Ext__c = '9999900'); + insert myAccount1; + core = new Contact(email='jplumber@salesforce.com', + firstname='Joe', + lastname='Plumber', + accountid=myAccount1.id); + insert core; + myUser_test = New User( + ContactId = core.id, + Alias = 'newUser', + Email='newuser@testorg.com', + EmailEncodingKey='UTF-8', + LastName='testUser', + LanguageLocaleKey='zh_CN', + LocaleSidKey='zh_CN', + ProfileId = prof.Id, + TimeZoneSidKey='Asia/Shanghai', + UserName='testUser@testorg.com', + Work_Location__c='鍖椾含'); + insert myUser_test; + } + System.runAs(myUser_test){ + Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + insert new Product2[]{prod01,prod02}; + Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id); + Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id); + insert new Product2__c[] {pro1, pro2}; + //璁㈠崟 + Consumable_order__c Order1 = new Consumable_order__c( + Name='OCM_01_001', + RecordTypeId = System.Label.RT_ConOrder_Delivery, + Order_type__c ='璁㈠崟', + Dealer_info__c=myAccount1.Id, + Order_ProType__c = 'ET'); + Consumable_order__c Order2 = new Consumable_order__c( + Name='OCM_01_002', + RecordTypeId = System.Label.RT_ConOrder_Delivery, + Order_type__c ='璁㈠崟', + Dealer_info__c=myAccount1.Id, + Order_ProType__c = 'ET'); + insert new Consumable_order__c[] {Order1, Order2}; - //璁㈠崟鏄庣粏 - Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( - Name = 'OCM_01_001001', - Consumable_order_minor__c = Order1.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c( - Name = 'OCM_01_001002', - Consumable_order_minor__c = Order2.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro2.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( - Name = 'OCM_01_001003', - Consumable_order_minor__c = Order1.Id, - //Arrive_date__c = Date.today(), - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c( - Name = 'OCM_01_001004', - Consumable_order_minor__c = Order2.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro2.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - insert new List<Consumable_order_details2__c>{ - Orderdet1, - Orderdet2, - Orderdet3, - Orderdet4 - }; + //鏄庣粏1 + Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); + createDetail.name = 'Too001'; + createDetail.Consumable_Product__c = pro1.id; + createDetail.Dealer_Custom_Price__c = 999.00; + createDetail.Consumable_count__c = 3; + createDetail.Consumable_order__c = Order1.id; + createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; + insert createDetail; + Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c(); + createDetail1.name = 'Too002'; + createDetail1.Consumable_Product__c = pro2.id; + createDetail1.Consumable_order__c = Order2.id; + createDetail1.Dealer_Custom_Price__c = 999.00; + createDetail1.Consumable_count__c = 4; + createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; + insert createDetail1; - LexConsumableGoodsInfo.initMoreThan7(Orderdet1.Id); - LexConsumableGoodsInfo.initMoreThan7All('all'); - LexConsumableGoodsInfo.initNotArrDet(Orderdet1.Id); - LexConsumableGoodsInfo.initNotArrDetAll('all'); - LexConsumableGoodsInfo.initArrDet(Orderdet1.Id); - LexConsumableGoodsInfo.initArrDetAll('all'); - LexConsumableGoodsInfo.initDeliveryDet(Orderdet1.Id); - LexConsumableGoodsInfo.initDeliveryDetAll('all'); - LexConsumableGoodsInfo.initTotalNum('1', 'all'); - LexConsumableGoodsInfo.initTotalNum(Orderdet1.Id, 'all'); + //璁㈠崟鏄庣粏 + Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( + Name='OCM_01_001001', + Consumable_order_minor__c = Order1.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c( + Name='OCM_01_001002', + Consumable_order_minor__c = Order2.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro2.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( + Name='OCM_01_001003', + Consumable_order_minor__c = Order1.Id, + //Arrive_date__c = Date.today(), + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c( + Name='OCM_01_001004', + Consumable_order_minor__c = Order2.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro2.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2, Orderdet3, Orderdet4}; + + LexConsumableGoodsInfo.initMoreThan7(Orderdet3.Id); + LexConsumableGoodsInfo.initNotArrDet(Orderdet3.Id); + LexConsumableGoodsInfo.initArrDet(Orderdet3.Id); + LexConsumableGoodsInfo.initDeliveryDet(Orderdet3.Id); + LexConsumableGoodsInfo.initTotalNum(Orderdet3.Id, 'all'); + } } - } - @IsTest - static void lexConsumableGoodsInfoTest3() { - User myUser_test = new User(); - Account myAccount1; - Contact core; - User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true); - insert n; - System.runAs(currentUser) { - Profile prof = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - myAccount1 = new Account( - name = 'testaccount001', - RecordTypeId = rectCo[0].Id, - AgentCode_Ext__c = '9999900' - ); - insert myAccount1; - core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.id - ); - insert core; - myUser_test = new User( - ContactId = core.id, - Alias = 'newUser', - Email = 'newuser@testorg.com', - EmailEncodingKey = 'UTF-8', - LastName = 'testUser', - LanguageLocaleKey = 'zh_CN', - LocaleSidKey = 'zh_CN', - ProfileId = prof.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com', - Work_Location__c = '鍖椾含' - ); - insert myUser_test; + @IsTest + static void lexConsumableGoodsInfoTest5(){ + User myUser_test = new User(); + Account myAccount1; + Contact core; + User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; + NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true); + insert n; + System.runAs(currentUser){ + Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + myAccount1 = new Account(name='testaccount001',RecordTypeId = rectCo[0].Id ,AgentCode_Ext__c = '9999900'); + insert myAccount1; + core = new Contact(email='jplumber@salesforce.com', + firstname='Joe', + lastname='Plumber', + accountid=myAccount1.id); + insert core; + myUser_test = New User( + ContactId = core.id, + Alias = 'newUser', + Email='newuser@testorg.com', + EmailEncodingKey='UTF-8', + LastName='testUser', + LanguageLocaleKey='zh_CN', + LocaleSidKey='zh_CN', + ProfileId = prof.Id, + TimeZoneSidKey='Asia/Shanghai', + UserName='testUser@testorg.com', + Work_Location__c='鍖椾含'); + insert myUser_test; + } + System.runAs(myUser_test){ + Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + insert new Product2[]{prod01,prod02}; + Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id); + Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id); + insert new Product2__c[] {pro1, pro2}; + //璁㈠崟 + Consumable_order__c Order1 = new Consumable_order__c( + Name='OCM_01_001', + RecordTypeId = System.Label.RT_ConOrder_Delivery, + Order_type__c ='璁㈠崟', + Dealer_info__c=myAccount1.Id, + Order_ProType__c = 'ET'); + Consumable_order__c Order2 = new Consumable_order__c( + Name='OCM_01_002', + RecordTypeId = System.Label.RT_ConOrder_Delivery, + Order_type__c ='璁㈠崟', + Dealer_info__c=myAccount1.Id, + Order_ProType__c = 'ET'); + insert new Consumable_order__c[] {Order1, Order2}; + + //鏄庣粏1 + Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); + createDetail.name = 'Too001'; + createDetail.Consumable_Product__c = pro1.id; + createDetail.Dealer_Custom_Price__c = 999.00; + createDetail.Consumable_count__c = 3; + createDetail.Consumable_order__c = Order1.id; + createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; + insert createDetail; + Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c(); + createDetail1.name = 'Too002'; + createDetail1.Consumable_Product__c = pro2.id; + createDetail1.Consumable_order__c = Order2.id; + createDetail1.Dealer_Custom_Price__c = 999.00; + createDetail1.Consumable_count__c = 4; + createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; + insert createDetail1; + + //璁㈠崟鏄庣粏 + Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( + Name='OCM_01_001001', + Consumable_order_minor__c = Order1.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c( + Name='OCM_01_001002', + Consumable_order_minor__c = Order2.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro2.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( + Name='OCM_01_001003', + Consumable_order_minor__c = Order1.Id, + //Arrive_date__c = Date.today(), + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c( + Name='OCM_01_001004', + Consumable_order_minor__c = Order2.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro2.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery); + insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2, Orderdet3, Orderdet4}; + + LexConsumableGoodsInfo.initMoreThan7(Orderdet4.Id); + LexConsumableGoodsInfo.initNotArrDet(Orderdet4.Id); + LexConsumableGoodsInfo.initArrDet(Orderdet4.Id); + LexConsumableGoodsInfo.initDeliveryDet(Orderdet4.Id); + LexConsumableGoodsInfo.initTotalNum(Orderdet4.Id, 'all'); + } } - System.runAs(myUser_test) { - Product2 prod01 = new Product2( - Name = 'Test01', - ProductCode = 'Test01', - Asset_Model_No__c = 'Test01', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - Product2 prod02 = new Product2( - Name = 'Test02', - ProductCode = 'Test02', - Asset_Model_No__c = 'Test02', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - insert new List<Product2>{ prod01, prod02 }; - Product2__c pro1 = new Product2__c( - Name = 'Pro001', - OT_CODE_Text__c = 'Test001', - Product2__c = prod01.Id - ); - Product2__c pro2 = new Product2__c( - Name = 'Pro002', - OT_CODE_Text__c = 'Test002', - Product2__c = prod02.Id - ); - insert new List<Product2__c>{ pro1, pro2 }; - //璁㈠崟 - Consumable_order__c Order1 = new Consumable_order__c( - Name = 'OCM_01_001', - RecordTypeId = System.Label.RT_ConOrder_Delivery, - Order_type__c = '璁㈠崟', - Dealer_info__c = myAccount1.Id, - Order_ProType__c = 'ET' - ); - Consumable_order__c Order2 = new Consumable_order__c( - Name = 'OCM_01_002', - RecordTypeId = System.Label.RT_ConOrder_Delivery, - Order_type__c = '璁㈠崟', - Dealer_info__c = myAccount1.Id, - Order_ProType__c = 'ET' - ); - insert new List<Consumable_order__c>{ Order1, Order2 }; - //鏄庣粏1 - Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); - createDetail.name = 'Too001'; - createDetail.Consumable_Product__c = pro1.id; - createDetail.Dealer_Custom_Price__c = 999.00; - createDetail.Consumable_count__c = 3; - createDetail.Consumable_order__c = Order1.id; - createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; - insert createDetail; - Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c(); - createDetail1.name = 'Too002'; - createDetail1.Consumable_Product__c = pro2.id; - createDetail1.Consumable_order__c = Order2.id; - createDetail1.Dealer_Custom_Price__c = 999.00; - createDetail1.Consumable_count__c = 4; - createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; - insert createDetail1; - - //璁㈠崟鏄庣粏 - Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( - Name = 'OCM_01_001001', - Consumable_order_minor__c = Order1.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c( - Name = 'OCM_01_001002', - Consumable_order_minor__c = Order2.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro2.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( - Name = 'OCM_01_001003', - Consumable_order_minor__c = Order1.Id, - //Arrive_date__c = Date.today(), - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c( - Name = 'OCM_01_001004', - Consumable_order_minor__c = Order2.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro2.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - insert new List<Consumable_order_details2__c>{ - Orderdet1, - Orderdet2, - Orderdet3, - Orderdet4 - }; - - LexConsumableGoodsInfo.initMoreThan7(Orderdet2.Id); - LexConsumableGoodsInfo.initMoreThan7All(''); - LexConsumableGoodsInfo.initNotArrDet(Orderdet2.Id); - LexConsumableGoodsInfo.initNotArrDetAll(''); - LexConsumableGoodsInfo.initArrDet(Orderdet2.Id); - LexConsumableGoodsInfo.initArrDetAll(''); - LexConsumableGoodsInfo.initDeliveryDet(Orderdet2.Id); - LexConsumableGoodsInfo.initDeliveryDetAll(''); - LexConsumableGoodsInfo.initTotalNum(Orderdet2.Id, ''); + @IsTest + static void lexConsumableGoodsInfoTest6(){ + LexConsumableGoodsInfo.ShowRecords sr = new LexConsumableGoodsInfo.ShowRecords(); + sr.prodModel = 'test'; + sr.recordCount = 1; + sr.compareTo(new LexConsumableGoodsInfo.ShowRecords()); } - } - @IsTest - static void lexConsumableGoodsInfoTest4() { - User myUser_test = new User(); - Account myAccount1; - Contact core; - User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true); - insert n; - System.runAs(currentUser) { - Profile prof = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - myAccount1 = new Account( - name = 'testaccount001', - RecordTypeId = rectCo[0].Id, - AgentCode_Ext__c = '9999900' - ); - insert myAccount1; - core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.id - ); - insert core; - myUser_test = new User( - ContactId = core.id, - Alias = 'newUser', - Email = 'newuser@testorg.com', - EmailEncodingKey = 'UTF-8', - LastName = 'testUser', - LanguageLocaleKey = 'zh_CN', - LocaleSidKey = 'zh_CN', - ProfileId = prof.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com', - Work_Location__c = '鍖椾含' - ); - insert myUser_test; + @IsTest + static void lexConsumableGoodsInfoTest7(){ + User myUser_test = new User(); + Account myAccount1; + Contact core; + User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; + NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true); + insert n; + System.runAs(currentUser){ + Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + myAccount1 = new Account(name='testaccount001',RecordTypeId = rectCo[0].Id ,AgentCode_Ext__c = '9999900'); + insert myAccount1; + core = new Contact(email='jplumber@salesforce.com', + firstname='Joe', + lastname='Plumber', + accountid=myAccount1.id); + insert core; + myUser_test = New User( + ContactId = core.id, + Alias = 'newUser', + Email='newuser@testorg.com', + EmailEncodingKey='UTF-8', + LastName='testUser', + LanguageLocaleKey='zh_CN', + LocaleSidKey='zh_CN', + ProfileId = prof.Id, + TimeZoneSidKey='Asia/Shanghai', + UserName='testUser@testorg.com', + Work_Location__c='鍖椾含', + UserPro_Type__c = 'ET'); + insert myUser_test; + } + System.runAs(myUser_test){ + Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + insert new Product2[]{prod01,prod02}; + Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id); + Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id); + insert new Product2__c[] {pro1, pro2}; + //璁㈠崟 + Consumable_order__c Order1 = new Consumable_order__c( + Name='OCM_01_001', + RecordTypeId = System.Label.RT_ConOrder_Delivery, + Order_type__c ='璁㈠崟', + Dealer_info__c = myAccount1.Id, + Delivery_detail_count__c = 1, + Order_ProType__c = 'ET', + showFalseNotshowTrue__c = false); + insert new Consumable_order__c[] {Order1}; + + //鏄庣粏1 + Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); + createDetail.name = 'Too001'; + createDetail.Consumable_Product__c = pro1.id; + createDetail.Dealer_Custom_Price__c = 999.00; + createDetail.Consumable_count__c = 3; + createDetail.Consumable_order__c = Order1.id; + createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; + insert createDetail; + + //璁㈠崟鏄庣粏 + Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( + Name='OCM_01_001001', + Asset_Model_No__c = 'Test01', + Consumable_order_minor__c = Order1.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery, + Cancellation_Flag__c = false); + Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( + Name='OCM_01_001003', + Asset_Model_No__c = 'Test01', + Consumable_order_minor__c = Order1.Id, + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery, + Cancellation_Flag__c = false); + insert new Consumable_order_details2__c[] {Orderdet1, Orderdet3}; + LexConsumableGoodsInfo.initNotArrDet(Order1.Id); + LexConsumableGoodsInfo.initNotArrDetAll('all'); + } } - System.runAs(myUser_test) { - Product2 prod01 = new Product2( - Name = 'Test01', - ProductCode = 'Test01', - Asset_Model_No__c = 'Test01', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - Product2 prod02 = new Product2( - Name = 'Test02', - ProductCode = 'Test02', - Asset_Model_No__c = 'Test02', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - insert new List<Product2>{ prod01, prod02 }; - Product2__c pro1 = new Product2__c( - Name = 'Pro001', - OT_CODE_Text__c = 'Test001', - Product2__c = prod01.Id - ); - Product2__c pro2 = new Product2__c( - Name = 'Pro002', - OT_CODE_Text__c = 'Test002', - Product2__c = prod02.Id - ); - insert new List<Product2__c>{ pro1, pro2 }; - //璁㈠崟 - Consumable_order__c Order1 = new Consumable_order__c( - Name = 'OCM_01_001', - RecordTypeId = System.Label.RT_ConOrder_Delivery, - Order_type__c = '璁㈠崟', - Dealer_info__c = myAccount1.Id, - Order_ProType__c = 'ET' - ); - Consumable_order__c Order2 = new Consumable_order__c( - Name = 'OCM_01_002', - RecordTypeId = System.Label.RT_ConOrder_Delivery, - Order_type__c = '璁㈠崟', - Dealer_info__c = myAccount1.Id, - Order_ProType__c = 'ET' - ); - insert new List<Consumable_order__c>{ Order1, Order2 }; - //鏄庣粏1 - Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); - createDetail.name = 'Too001'; - createDetail.Consumable_Product__c = pro1.id; - createDetail.Dealer_Custom_Price__c = 999.00; - createDetail.Consumable_count__c = 3; - createDetail.Consumable_order__c = Order1.id; - createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; - insert createDetail; - Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c(); - createDetail1.name = 'Too002'; - createDetail1.Consumable_Product__c = pro2.id; - createDetail1.Consumable_order__c = Order2.id; - createDetail1.Dealer_Custom_Price__c = 999.00; - createDetail1.Consumable_count__c = 4; - createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; - insert createDetail1; + @IsTest + static void lexConsumableGoodsInfoTest8(){ + User myUser_test = new User(); + Account myAccount1; + Contact core; + User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; + NoteStay__c n = new NoteStay__c(Name = 'NoteStay',IsStay__c = true); + insert n; + System.runAs(currentUser){ + Profile prof = [select Id from Profile where Name ='901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)']; + List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '璨╁2搴�']; + if (rectCo.size() == 0) { + return; + } + myAccount1 = new Account(name='testaccount001',RecordTypeId = rectCo[0].Id ,AgentCode_Ext__c = '9999900'); + insert myAccount1; + core = new Contact(email='jplumber@salesforce.com', + firstname='Joe', + lastname='Plumber', + accountid=myAccount1.id); + insert core; + myUser_test = New User( + ContactId = core.id, + Alias = 'newUser', + Email='newuser@testorg.com', + EmailEncodingKey='UTF-8', + LastName='testUser', + LanguageLocaleKey='zh_CN', + LocaleSidKey='zh_CN', + ProfileId = prof.Id, + TimeZoneSidKey='Asia/Shanghai', + UserName='testUser@testorg.com', + Work_Location__c='鍖椾含', + UserPro_Type__c = 'ET'); + insert myUser_test; + } + System.runAs(myUser_test){ + Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '鏈夊姽',Manual_Entry__c = false); + insert new Product2[]{prod01,prod02}; + Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id); + Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id); + insert new Product2__c[] {pro1, pro2}; + //璁㈠崟 + Consumable_order__c Order1 = new Consumable_order__c( + Name='OCM_01_001', + RecordTypeId = System.Label.RT_ConOrder_Delivery, + Order_type__c ='璁㈠崟', + Dealer_info__c = myAccount1.Id, + Delivery_detail_count__c = 1, + Order_ProType__c = 'ET', + showFalseNotshowTrue__c = false); + insert new Consumable_order__c[] {Order1}; - //璁㈠崟鏄庣粏 - Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( - Name = 'OCM_01_001001', - Consumable_order_minor__c = Order1.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c( - Name = 'OCM_01_001002', - Consumable_order_minor__c = Order2.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro2.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( - Name = 'OCM_01_001003', - Consumable_order_minor__c = Order1.Id, - //Arrive_date__c = Date.today(), - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c( - Name = 'OCM_01_001004', - Consumable_order_minor__c = Order2.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro2.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - insert new List<Consumable_order_details2__c>{ - Orderdet1, - Orderdet2, - Orderdet3, - Orderdet4 - }; + //鏄庣粏1 + Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); + createDetail.name = 'Too001'; + createDetail.Consumable_Product__c = pro1.id; + createDetail.Dealer_Custom_Price__c = 999.00; + createDetail.Consumable_count__c = 3; + createDetail.Consumable_order__c = Order1.id; + createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; + insert createDetail; - LexConsumableGoodsInfo.initMoreThan7(Orderdet3.Id); - LexConsumableGoodsInfo.initNotArrDet(Orderdet3.Id); - LexConsumableGoodsInfo.initArrDet(Orderdet3.Id); - LexConsumableGoodsInfo.initDeliveryDet(Orderdet3.Id); - LexConsumableGoodsInfo.initTotalNum(Orderdet3.Id, 'all'); + //璁㈠崟鏄庣粏 + Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( + Name='OCM_01_001001', + Consumable_order_minor__c = Order1.Id, + Arrive_date__c = Date.today(), + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery, + Cancellation_Flag__c = false); + Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( + Name='OCM_01_001003', + Consumable_order_minor__c = Order1.Id, + Consumable_Product__c = pro1.id, + RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery, + Cancellation_Flag__c = false); + insert new Consumable_order_details2__c[] {Orderdet1, Orderdet3}; + LexConsumableGoodsInfo.initNotArrDetAll('all'); + } } - } - - @IsTest - static void lexConsumableGoodsInfoTest5() { - User myUser_test = new User(); - Account myAccount1; - Contact core; - User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true); - insert n; - System.runAs(currentUser) { - Profile prof = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - myAccount1 = new Account( - name = 'testaccount001', - RecordTypeId = rectCo[0].Id, - AgentCode_Ext__c = '9999900' - ); - insert myAccount1; - core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.id - ); - insert core; - myUser_test = new User( - ContactId = core.id, - Alias = 'newUser', - Email = 'newuser@testorg.com', - EmailEncodingKey = 'UTF-8', - LastName = 'testUser', - LanguageLocaleKey = 'zh_CN', - LocaleSidKey = 'zh_CN', - ProfileId = prof.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com', - Work_Location__c = '鍖椾含' - ); - insert myUser_test; - } - System.runAs(myUser_test) { - Product2 prod01 = new Product2( - Name = 'Test01', - ProductCode = 'Test01', - Asset_Model_No__c = 'Test01', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - Product2 prod02 = new Product2( - Name = 'Test02', - ProductCode = 'Test02', - Asset_Model_No__c = 'Test02', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - insert new List<Product2>{ prod01, prod02 }; - Product2__c pro1 = new Product2__c( - Name = 'Pro001', - OT_CODE_Text__c = 'Test001', - Product2__c = prod01.Id - ); - Product2__c pro2 = new Product2__c( - Name = 'Pro002', - OT_CODE_Text__c = 'Test002', - Product2__c = prod02.Id - ); - insert new List<Product2__c>{ pro1, pro2 }; - //璁㈠崟 - Consumable_order__c Order1 = new Consumable_order__c( - Name = 'OCM_01_001', - RecordTypeId = System.Label.RT_ConOrder_Delivery, - Order_type__c = '璁㈠崟', - Dealer_info__c = myAccount1.Id, - Order_ProType__c = 'ET' - ); - Consumable_order__c Order2 = new Consumable_order__c( - Name = 'OCM_01_002', - RecordTypeId = System.Label.RT_ConOrder_Delivery, - Order_type__c = '璁㈠崟', - Dealer_info__c = myAccount1.Id, - Order_ProType__c = 'ET' - ); - insert new List<Consumable_order__c>{ Order1, Order2 }; - - //鏄庣粏1 - Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); - createDetail.name = 'Too001'; - createDetail.Consumable_Product__c = pro1.id; - createDetail.Dealer_Custom_Price__c = 999.00; - createDetail.Consumable_count__c = 3; - createDetail.Consumable_order__c = Order1.id; - createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; - insert createDetail; - Consumable_orderdetails__c createDetail1 = new Consumable_orderdetails__c(); - createDetail1.name = 'Too002'; - createDetail1.Consumable_Product__c = pro2.id; - createDetail1.Consumable_order__c = Order2.id; - createDetail1.Dealer_Custom_Price__c = 999.00; - createDetail1.Consumable_count__c = 4; - createDetail1.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; - insert createDetail1; - - //璁㈠崟鏄庣粏 - Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( - Name = 'OCM_01_001001', - Consumable_order_minor__c = Order1.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c( - Name = 'OCM_01_001002', - Consumable_order_minor__c = Order2.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro2.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( - Name = 'OCM_01_001003', - Consumable_order_minor__c = Order1.Id, - //Arrive_date__c = Date.today(), - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c( - Name = 'OCM_01_001004', - Consumable_order_minor__c = Order2.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro2.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery - ); - insert new List<Consumable_order_details2__c>{ - Orderdet1, - Orderdet2, - Orderdet3, - Orderdet4 - }; - - LexConsumableGoodsInfo.initMoreThan7(Orderdet4.Id); - LexConsumableGoodsInfo.initNotArrDet(Orderdet4.Id); - LexConsumableGoodsInfo.initArrDet(Orderdet4.Id); - LexConsumableGoodsInfo.initDeliveryDet(Orderdet4.Id); - LexConsumableGoodsInfo.initTotalNum(Orderdet4.Id, 'all'); - } - } - - @IsTest - static void lexConsumableGoodsInfoTest6() { - LexConsumableGoodsInfo.ShowRecords sr = new LexConsumableGoodsInfo.ShowRecords(); - sr.prodModel = 'test'; - sr.recordCount = 1; - sr.compareTo(new LexConsumableGoodsInfo.ShowRecords()); - } - - @IsTest - static void lexConsumableGoodsInfoTest7() { - User myUser_test = new User(); - Account myAccount1; - Contact core; - User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true); - insert n; - System.runAs(currentUser) { - Profile prof = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - myAccount1 = new Account( - name = 'testaccount001', - RecordTypeId = rectCo[0].Id, - AgentCode_Ext__c = '9999900' - ); - insert myAccount1; - core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.id - ); - insert core; - myUser_test = new User( - ContactId = core.id, - Alias = 'newUser', - Email = 'newuser@testorg.com', - EmailEncodingKey = 'UTF-8', - LastName = 'testUser', - LanguageLocaleKey = 'zh_CN', - LocaleSidKey = 'zh_CN', - ProfileId = prof.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com', - Work_Location__c = '鍖椾含', - UserPro_Type__c = 'ET' - ); - insert myUser_test; - } - System.runAs(myUser_test) { - Product2 prod01 = new Product2( - Name = 'Test01', - ProductCode = 'Test01', - Asset_Model_No__c = 'Test01', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - Product2 prod02 = new Product2( - Name = 'Test02', - ProductCode = 'Test02', - Asset_Model_No__c = 'Test02', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - insert new List<Product2>{ prod01, prod02 }; - Product2__c pro1 = new Product2__c( - Name = 'Pro001', - OT_CODE_Text__c = 'Test001', - Product2__c = prod01.Id - ); - Product2__c pro2 = new Product2__c( - Name = 'Pro002', - OT_CODE_Text__c = 'Test002', - Product2__c = prod02.Id - ); - insert new List<Product2__c>{ pro1, pro2 }; - //璁㈠崟 - Consumable_order__c Order1 = new Consumable_order__c( - Name = 'OCM_01_001', - RecordTypeId = System.Label.RT_ConOrder_Delivery, - Order_type__c = '璁㈠崟', - Dealer_info__c = myAccount1.Id, - Delivery_detail_count__c = 1, - Order_ProType__c = 'ET', - showFalseNotshowTrue__c = false - ); - insert new List<Consumable_order__c>{ Order1 }; - - //鏄庣粏1 - Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); - createDetail.name = 'Too001'; - createDetail.Consumable_Product__c = pro1.id; - createDetail.Dealer_Custom_Price__c = 999.00; - createDetail.Consumable_count__c = 3; - createDetail.Consumable_order__c = Order1.id; - createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; - insert createDetail; - - //璁㈠崟鏄庣粏 - Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( - Name = 'OCM_01_001001', - Asset_Model_No__c = 'Test01', - Consumable_order_minor__c = Order1.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery, - Cancellation_Flag__c = false - ); - Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( - Name = 'OCM_01_001003', - Asset_Model_No__c = 'Test01', - Consumable_order_minor__c = Order1.Id, - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery, - Cancellation_Flag__c = false - ); - insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet3 }; - LexConsumableGoodsInfo.initNotArrDet(Order1.Id); - LexConsumableGoodsInfo.initNotArrDetAll('all'); - } - } - - @IsTest - static void lexConsumableGoodsInfoTest8() { - User myUser_test = new User(); - Account myAccount1; - Contact core; - User currentUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; - NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true); - insert n; - System.runAs(currentUser) { - Profile prof = [ - SELECT Id - FROM Profile - WHERE Name = '901_缁忛攢鍟嗙ぞ鍖烘櫘閫氭潈闄恄2閲嶉獙璇�(ET)' - ]; - List<RecordType> rectCo = [ - SELECT Id - FROM RecordType - WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '璨╁2搴�' - ]; - if (rectCo.size() == 0) { - return; - } - myAccount1 = new Account( - name = 'testaccount001', - RecordTypeId = rectCo[0].Id, - AgentCode_Ext__c = '9999900' - ); - insert myAccount1; - core = new Contact( - email = 'jplumber@salesforce.com', - firstname = 'Joe', - lastname = 'Plumber', - accountid = myAccount1.id - ); - insert core; - myUser_test = new User( - ContactId = core.id, - Alias = 'newUser', - Email = 'newuser@testorg.com', - EmailEncodingKey = 'UTF-8', - LastName = 'testUser', - LanguageLocaleKey = 'zh_CN', - LocaleSidKey = 'zh_CN', - ProfileId = prof.Id, - TimeZoneSidKey = 'Asia/Shanghai', - UserName = 'testUser@testorg.com', - Work_Location__c = '鍖椾含', - UserPro_Type__c = 'ET' - ); - insert myUser_test; - } - System.runAs(myUser_test) { - Product2 prod01 = new Product2( - Name = 'Test01', - ProductCode = 'Test01', - Asset_Model_No__c = 'Test01', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - Product2 prod02 = new Product2( - Name = 'Test02', - ProductCode = 'Test02', - Asset_Model_No__c = 'Test02', - SFDA_Status__c = '鏈夊姽', - Manual_Entry__c = false - ); - insert new List<Product2>{ prod01, prod02 }; - Product2__c pro1 = new Product2__c( - Name = 'Pro001', - OT_CODE_Text__c = 'Test001', - Product2__c = prod01.Id - ); - Product2__c pro2 = new Product2__c( - Name = 'Pro002', - OT_CODE_Text__c = 'Test002', - Product2__c = prod02.Id - ); - insert new List<Product2__c>{ pro1, pro2 }; - //璁㈠崟 - Consumable_order__c Order1 = new Consumable_order__c( - Name = 'OCM_01_001', - RecordTypeId = System.Label.RT_ConOrder_Delivery, - Order_type__c = '璁㈠崟', - Dealer_info__c = myAccount1.Id, - Delivery_detail_count__c = 1, - Order_ProType__c = 'ET', - showFalseNotshowTrue__c = false - ); - insert new List<Consumable_order__c>{ Order1 }; - - //鏄庣粏1 - Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c(); - createDetail.name = 'Too001'; - createDetail.Consumable_Product__c = pro1.id; - createDetail.Dealer_Custom_Price__c = 999.00; - createDetail.Consumable_count__c = 3; - createDetail.Consumable_order__c = Order1.id; - createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order; - insert createDetail; - - //璁㈠崟鏄庣粏 - Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c( - Name = 'OCM_01_001001', - Consumable_order_minor__c = Order1.Id, - Arrive_date__c = Date.today(), - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery, - Cancellation_Flag__c = false - ); - Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c( - Name = 'OCM_01_001003', - Consumable_order_minor__c = Order1.Id, - Consumable_Product__c = pro1.id, - RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery, - Cancellation_Flag__c = false - ); - insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet3 }; - LexConsumableGoodsInfo.initNotArrDetAll('all'); - } - } -} +} \ No newline at end of file -- Gitblit v1.9.1