From 4420517bbbffea48cabe7a7dcdf2e1c4b440fc85 Mon Sep 17 00:00:00 2001
From: GWY <guweiyi@prec-tech.com>
Date: 星期一, 30 五月 2022 16:15:26 +0800
Subject: [PATCH] 两个LS特殊条件在说明的增减
---
force-app/main/default/classes/OpportunityTriggerTest.cls | 942 ++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 611 insertions(+), 331 deletions(-)
diff --git a/force-app/main/default/classes/OpportunityTriggerTest.cls b/force-app/main/default/classes/OpportunityTriggerTest.cls
index 71058a8..b68c474 100644
--- a/force-app/main/default/classes/OpportunityTriggerTest.cls
+++ b/force-app/main/default/classes/OpportunityTriggerTest.cls
@@ -1,361 +1,641 @@
+/**
+ * @description :
+ * @author : ChangeMeIn@UserSettingsUnder.SFDoc
+ * @group :
+ * @last modified on : 04-21-2022
+ * @last modified by : ChangeMeIn@UserSettingsUnder.SFDoc
+**/
@isTest
private class OpportunityTriggerTest {
+
+ // 鍏抽棴璇环鎻掑叆鍜屾洿鏂�
+ static testMethod void myTest1() {
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ Account accIE = new Account(
+ Name = '*',
+ RecordTypeId = rectIE[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ DivisionName__c='Customer IE',
+ FacilityName__c='abc',
+ PostCode__c = '123456'
+ );
+ insert accIE;
+
+ PriceBook2 pricebook =new PriceBook2(
+ Name = 'IE',
+ ProductSegment__c = 'IE',
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ MachineParts__c = 'Machine'
+ );
+ insert pricebook;
+
+ List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
+ Opportunity opp = new Opportunity(
+ Name = 'test opp',
+ AccountId = accIE.Id,
+ RecordTypeId = rectOpp[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ StageName = 'Prospect Created',
+ CancelReason__c = 'Inquiry repeat',
+ Cancel_reason_D__c = 'Inquiry repeat',
+ CurrencyIsoCode = 'CNY',
+ ProductSegment__c = 'IE',
+ CloseDate = Date.today(),
+ NewInquiryDate__c = Date.today().addDays(-2),
+ ExpectedOrderDate__c = Date.today().addDays(2),
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ Machine_Parts__c = 'Machine'
+ );
+ insert opp;
- @isTest static void test_method_one() {
+ OpportunityWebService.UpdateStageName(opp.Id, 'Closed Cancel');
+ update opp;
+
+ List<Opportunity> oppList = [Select Id, CloseDate, ProductSegmentCompetitor__c, Pricebook2Id from Opportunity where Id = :opp.Id];
+
+ //System.assertEquals(Date.today().addDays(2), oppList[0].CloseDate);
+ //System.assertEquals('IE', oppList[0].ProductSegmentCompetitor__c);
+ //System.assertEquals(pricebook.Id, oppList[0].Pricebook2Id);
+
+ }
+
+ // 鏈叧闂浠锋彃鍏ュ拰鏇存柊
+ static testMethod void myTest2() {
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ Account accIE = new Account(
+ Name = '*',
+ RecordTypeId = rectIE[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ DivisionName__c='Customer IE',
+ FacilityName__c='abc',
+ PostCode__c = '123456'
+ );
+ insert accIE;
+
+ PriceBook2 pricebook =new PriceBook2(
+ Name = 'IE',
+ ProductSegment__c = 'IE',
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ MachineParts__c = 'Machine'
+ );
+ insert pricebook;
+
+ List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
+ // 鏈夐瀹氫笅鍗曟棩
+ Opportunity opp = new Opportunity(
+ Name = 'test opp',
+ AccountId = accIE.Id,
+ RecordTypeId = rectOpp[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ StageName = 'Prospect Created',
+ CurrencyIsoCode = 'CNY',
+ ProductSegment__c = 'IE',
+ CloseDate = Date.today(),
+ NewInquiryDate__c = Date.today().addDays(-2),
+ ExpectedOrderDate__c = Date.today().addDays(2),
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ Machine_Parts__c = 'Machine'
+ );
+ insert opp;
+
+ List<Opportunity> oppList = [Select Id, CloseDate, ProductSegmentCompetitor__c, Pricebook2Id from Opportunity where Id = :opp.Id];
+
+ //System.assertEquals(Date.today().addDays(2), oppList[0].CloseDate);
+ //System.assertEquals('IE', oppList[0].ProductSegmentCompetitor__c);
+ //System.assertEquals(pricebook.Id, oppList[0].Pricebook2Id);
+
+ opp.ExpectedOrderDate__c = Date.today().addDays(3);
+ opp.ProductSegment__c = 'BS';
+ update opp;
+
+ List<Opportunity> oppList2 = [Select Id, CloseDate, ProductSegmentCompetitor__c, Pricebook2Id from Opportunity where Id = :opp.Id];
+
+ //System.assertEquals(Date.today().addDays(3), oppList2[0].CloseDate);
+ //System.assertEquals('BS', oppList2[0].ProductSegmentCompetitor__c);
+
+ // 鏃犻瀹氫笅鍗曟棩
+ Opportunity opp2 = new Opportunity(
+ Name = 'test opp',
+ AccountId = accIE.Id,
+ RecordTypeId = rectOpp[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ StageName = 'Prospect Created',
+ CurrencyIsoCode = 'CNY',
+ ProductSegment__c = 'IE',
+ CloseDate = Date.today(),
+ NewInquiryDate__c = Date.today().addDays(-2),
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ Machine_Parts__c = 'Machine'
+ );
+ insert opp2;
+
+ List<Opportunity> oppList3 = [Select Id, CloseDate, ProductSegmentCompetitor__c, Pricebook2Id from Opportunity where Id = :opp2.Id];
+
+ //System.assertEquals(Date.today().addDays(-2).addMonths(6), oppList3[0].CloseDate);
+ //System.assertEquals('IE', oppList3[0].ProductSegmentCompetitor__c);
+ //System.assertEquals(pricebook.Id, oppList3[0].Pricebook2Id);
+
+ opp2.NewInquiryDate__c = Date.today().addDays(-3);
+ opp2.ProductSegment__c = 'BS';
+ update opp2;
+
+ List<Opportunity> oppList4 = [Select Id, CloseDate, ProductSegmentCompetitor__c, Pricebook2Id from Opportunity where Id = :opp2.Id];
+
+ //System.assertEquals(Date.today().addDays(-3).addMonths(6), oppList4[0].CloseDate);
+ //System.assertEquals('BS', oppList4[0].ProductSegmentCompetitor__c);
+ }
+ //@isTest(SeeAllData=true)
+ static testMethod void myTest3() {
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ List<RecordType> rectForeignCompany = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'ForeignCompany'];
+ Id pricebookId = Test.getStandardPricebookId();
+
+ /*PriceBook2 pricebook1 = ControllerUtil.getStandardPricebook();
+ Id pricebookId = pricebook1.id;*/
+ Pricebook2 pricebook = new Pricebook2(
+ Name = 'IE',
+ ProductSegment__c = 'IE',
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ MachineParts__c = 'Machine',
+ isActive = true
+ );
+ insert pricebook;
+
+ /*Pricebook2 pricebook = [select Id from PriceBook2 where ProductSegment__c = 'IE' and
+ TradeType__c = 'Taxation' and SalesChannel__c = 'direct' and MachineParts__c = 'Machine' and isActive = true limit 1];
+*/
+ Product2 product1 = new Product2();
+ product1.Name = 'product1';
+ product1.IsActive = true;
+
+ Product2 product2 = new Product2();
+ product2.Name = 'product2';
+ product2.IsActive = true;
+
+ Product2 product3 = new Product2();
+ product3.Name = 'product3';
+ product3.IsActive = true;
+
+ insert new Product2[] {product1,product2,product3};
+
+ PricebookEntry standardPrice1 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product1.Id,
+ UnitPrice = 0,
+ CurrencyIsoCode = 'CNY',
+ IsActive = true
- User user = new User(Test_staff__c = true);
- user.LastName = '_銈点兂銉栥儶銉冦偢';
- user.FirstName = '銇�';
- user.Alias = '銇�';
- user.Email = 'olympusTest03@sunbridge.com';
- user.Username = 'olympusTest03@sunbridge.com';
- user.CommunityNickname = '銇�';
+ );
+
+ PricebookEntry standardPrice2 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product2.Id,
+ UnitPrice = 0,
+ CurrencyIsoCode = 'CNY',
+ IsActive = true
+ );
+
+ PricebookEntry standardPrice3 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product3.Id,
+ UnitPrice = 0,
+ CurrencyIsoCode = 'CNY',
+ IsActive = true
+ );
+
+ insert new PricebookEntry[] {standardPrice1,standardPrice2,standardPrice3};
+
+ PricebookEntry entry1 = new PricebookEntry( Pricebook2Id=pricebook.Id, Product2Id=product1.Id);
+ entry1.UnitPrice = 0;
+ entry1.IsActive = true;
+ entry1.UseStandardPrice = false;
+ entry1.CurrencyIsoCode = 'CNY';
+
+ PricebookEntry entry2 = new PricebookEntry( Pricebook2Id=pricebook.Id, Product2Id=product2.Id);
+ entry2.UnitPrice = 0;
+ entry2.IsActive = true;
+ entry2.UseStandardPrice = false;
+ entry2.CurrencyIsoCode = 'CNY';
+
+ PricebookEntry entry3 = new PricebookEntry( Pricebook2Id=pricebook.Id, Product2Id=product3.Id);
+ entry3.UnitPrice = 0;
+ entry3.IsActive = true;
+ entry3.UseStandardPrice = false;
+ entry3.CurrencyIsoCode = 'CNY';
+
+
+ insert new PricebookEntry[] {entry1,entry2,entry3};
+
+ Account accIE = new Account(
+ Name = '*',
+ RecordTypeId = rectIE[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ DivisionName__c='Customer IE',
+ FacilityName__c='abc',
+ PostCode__c = '123456'
+ );
+ insert accIE;
+
+ Account specialDeliveryAddress1 = new Account(Name = '*',FacilityName__c='specialDeliveryAddress1',PostCode__c = '123456');
+ Account specialDeliveryAddress2 = new Account(Name = '*',FacilityName__c='specialDeliveryAddress2',PostCode__c = '123456');
+ Account specialDeliveryAddress3 = new Account(Name = '*',FacilityName__c='specialDeliveryAddress3',PostCode__c = '123456');
+ Account foreignTradeCompany1 = new Account(Name = '*',FacilityName__c='foreignTradeCompany1',PostCode__c = '123456',RecordTypeId = rectForeignCompany[0].Id);
+ Account foreignTradeCompany2 = new Account(Name = '*',FacilityName__c='foreignTradeCompany2',PostCode__c = '123456',RecordTypeId = rectForeignCompany[0].Id);
+ Account foreignTradeCompany3 = new Account(Name = '*',FacilityName__c='foreignTradeCompany3',PostCode__c = '123456',RecordTypeId = rectForeignCompany[0].Id);
+ insert new Account[] {specialDeliveryAddress1,specialDeliveryAddress2,specialDeliveryAddress3,foreignTradeCompany1,foreignTradeCompany2,foreignTradeCompany3};
+
+ User user = new User();
+ user.LastName = 'test';
+ user.FirstName = 'test';
+ user.Alias = 'test';
+ user.Email = 'User20210519@test.com';
+ user.Username = 'User20210519@test222.com';
+ user.CommunityNickname = 'test01';
user.IsActive = true;
user.EmailEncodingKey = 'ISO-2022-JP';
user.TimeZoneSidKey = 'Asia/Tokyo';
user.LocaleSidKey = 'ja_JP';
user.LanguageLocaleKey = 'ja';
- user.ProfileId = System.Label.ProfileId_SystemAdmin;
- user.Job_Category__c = '閿�鍞帹骞�';
- user.Province__c = '涓婃捣甯�';
- user.Use_Start_Date__c = Date.today().addMonths(-6);
- user.SalesManager__c = UserInfo.getUserId();
- user.BuchangApprovalManagerSales__c = UserInfo.getUserId();
- user.JingliApprovalManager__c = UserInfo.getUserId();
- user.BuchangApprovalManager__c = UserInfo.getUserId();
- user.ZongjianApprovalManager__c = UserInfo.getUserId();
-
- List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
- if (rectCo.size() == 0) {
- return;
- }
- List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
- if (rectSct.size() == 0) {
- return;
- }
- List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '瑷虹檪绉� 娑堝寲绉�'];
- if (rectDpt.size() == 0) {
- return;
- }
-
-
- StaticParameter.EscapeOpportunityBefUpdTrigger = true;
- StaticParameter.EscapeSyncOpportunityTrigger = true;
- StaticParameter.EscapeNFM007Trigger = true;
- StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true;
- StaticParameter.EscapeSyncOpportunityTrigger = true;
-
- System.runAs(new User(Id = Userinfo.getUserId())) {
- insert user;
- // 銉嗐偣銉堛儑銉笺偪
- Account company = new Account();
- company.RecordTypeId = rectCo[0].Id;
- company.Name = 'NFM007TestCompany';
- upsert company;
- Account section = new Account();
- section.RecordTypeId = rectSct[0].Id;
- section.Name = '*';
- section.Department_Class_Label__c = '娑堝寲绉�';
- section.ParentId = company.Id;
- section.Hospital_Department_Class__c = company.Id;
- upsert section;
- Account depart = new Account();
- depart.RecordTypeId = rectDpt[0].Id;
- depart.Name = '*';
- depart.Department_Name__c = 'NFM007TestDepart';
- depart.ParentId = section.Id;
- depart.Department_Class__c = section.Id;
- depart.Hospital__c = company.Id;
- upsert depart;
-
+ user.ProfileId = System.Label.SystemAdmin;
+ insert user;
+
+ Date day1 = Date.today();
+ Date day2 = day1.addDays(-1);
+ List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
+ // 鏈夐瀹氫笅鍗曟棩
Opportunity opp = new Opportunity();
- opp.AccountId = depart.Id;
- opp.Department_Class__c = section.Id;
- opp.Hospital__c = company.Id;
- opp.SAP_Send_OK__c = false;
- opp.Name = 'GZ-SP-NFM007_1';
- opp.Trade__c = '鍐呰部';
- opp.StageName = '寮曞悎';
- opp.CloseDate = date.newinstance(2022, 11, 30);
- opp.Stock_apply_status__c = '鐢宠涓�';
+ opp.Name = 'test opp';
+ opp.AccountId = accIE.Id;
+ opp.RecordTypeId = rectOpp[0].Id;
+ opp.OwnerId = UserInfo.getUserId();
+ opp.StageName = 'Prospect Created';
+ opp.CurrencyIsoCode = 'CNY';
+ opp.ProductSegment__c = 'IE';
+ opp.CloseDate = Date.today();
+ opp.NewInquiryDate__c = Date.today().addDays(-2);
+ opp.ExpectedOrderDate__c = Date.today().addDays(2);
+ opp.ApprovalStatus_D__c = 'Pass';
+
+ opp.LeadSource = 'LeadSource_D__c';
+ opp.BudgetAmount__c = 111;
+ opp.CancelReasonText__c = 'Cancel_Reason_Text_D__c';
+ opp.CancelReason__c = 'Cancel_reason_D__c';
+ opp.CompetitorCompany__c = 'Competitor_Company_D__c';
+ opp.Competitor_Product__c = 'Competitor_Product_D__c';
+ opp.Competitor_Product2__c = 'Competitor_Product2_D__c';
+ opp.Competitor_Product3__c = 'Competitor_Product3_D__c';
+ opp.Competitor_Product4__c = 'Competitor_Product4_D__c';
+ opp.Competitor_Product5__c = 'Competitor_Product5_D__c';
+ opp.Competitor_Product6__c = 'Competitor_Product6_D__c';
+ opp.Competitor_Product7__c = 'Competitor_Product7_D__c';
+ opp.Competitor_Product8__c = 'Competitor_Product8_D__c';
+ opp.CompetitorProductCode__c = 'Competitor_Product_Code_D__c';
+ opp.CompetitorProductCode2__c = 'Competitor_Product_Code2_D__c';
+ opp.CompetitorProductCode3__c = 'Competitor_Product_Code3_D__c';
+ opp.CompetitorProductCode4__c = 'Competitor_Product_Code4_D__c';
+ opp.CompetitorProductCode5__c = 'Competitor_Product_Code5_D__c';
+ opp.CompetitorProductCode6__c = 'Competitor_Product_Code6_D__c';
+ opp.CompetitorProductCode7__c = 'Competitor_Product_Code7_D__c';
+ opp.CompetitorProductCode8__c = 'Competitor_Product_Code8_D__c';
+ opp.DealerSalesStaffName__c = 'Dealer_Sales_Staff_Name_D__c';
+ opp.DealerService__c = 'Dealer_Service_D__c';
+ opp.ExpectedDeliveryDate__c = day1;
+ opp.InquiryResult__c = 'InquiryResultD__c';
+ //opp.InquiryResultCancel__c = day1;
+ //opp.InquiryResultLost__c = day1;
+ opp.InquiryResultOrder__c = day1;
+ opp.LostAmount__c = 111;
+ opp.LostCompetitorProduct__c = 'Lost_competitor_product_D__c';
+ opp.LostReasonText__c = 'LostReasonText_D__c';
+ opp.LostReason__c = 'Lostreason_D__c';
+ opp.Phase1Date__c = day1;
+ opp.Phase2Date__c = day1;
+ opp.Phase3Date__c = day1;
+ opp.SalesChannel__c = 'direct';
+ opp.SubDealer__c = 'Sub_Dealer_D__c';
+ opp.TradeType__c = 'Taxation';
+ opp.Machine_Parts__c = 'Machine';
+ opp.SpecialDeliveryAddress__c = specialDeliveryAddress1.Id;
+ opp.ForeignTradeCompany__c = foreignTradeCompany1.Id;
+
insert opp;
-
- System.Test.startTest();
-
- Opportunity_File__c ofile = new Opportunity_File__c();
- ofile.Name = 'test file';
- ofile.Opportunity__c = opp.Id;
- insert ofile;
-
- Attachment att = new Attachment(
- Name = 'ORDER-123456.pdf',
- parentId = ofile.Id,
- Body = EncodingUtil.base64Decode('test')
- );
- insert att;
- Opportunity_File__c ofile2 = new Opportunity_File__c();
- ofile2.Name = 'test file2';
- ofile2.Opportunity__c = opp.Id;
- insert ofile2;
-
- Attachment att2 = new Attachment(
- Name = 'ORDER-123456.pdf',
- parentId = ofile2.Id,
- Body = EncodingUtil.base64Decode('test')
- );
- insert att2;
+ OpportunityLineItem oli = new OpportunityLineItem();
+ oli.OpportunityId = opp.Id;
+ oli.Quantity = 2;
+ oli.UnitPrice = 111;
+ oli.Description = 'test';
+ oli.PricebookEntryId = entry1.Id;
- delete ofile2;
- delete att;
-
- opp.Stock_apply_status__c = '鎵瑰噯';
+ insert oli;
+
+ opp.LeadSource = 'LeadSource';
+ opp.BudgetAmount__c = 222;
+ opp.CancelReasonText__c = 'CancelReasonText__c';
+ opp.CancelReason__c = 'CancelReason__c';
+ opp.CompetitorCompany__c = 'CompetitorCompany__c';
+ opp.Competitor_Product__c = 'Competitor_Product__c';
+ opp.Competitor_Product2__c = 'Competitor_Product2__c';
+ opp.Competitor_Product3__c = 'Competitor_Product3__c';
+ opp.Competitor_Product4__c = 'Competitor_Product4__c';
+ opp.Competitor_Product5__c = 'Competitor_Product5__c';
+ opp.Competitor_Product6__c = 'Competitor_Product6__c';
+ opp.Competitor_Product7__c = 'Competitor_Product7__c';
+ opp.Competitor_Product8__c = 'Competitor_Product8__c';
+ opp.CompetitorProductCode__c = 'CompetitorProductCode__c';
+ opp.CompetitorProductCode2__c = 'CompetitorProductCode2__c';
+ opp.CompetitorProductCode3__c = 'CompetitorProductCode3__c';
+ opp.CompetitorProductCode4__c = 'CompetitorProductCode4__c';
+ opp.CompetitorProductCode5__c = 'CompetitorProductCode5__c';
+ opp.CompetitorProductCode6__c = 'CompetitorProductCode6__c';
+ opp.CompetitorProductCode7__c = 'CompetitorProductCode7__c';
+ opp.CompetitorProductCode8__c = 'CompetitorProductCode8__c';
+ opp.DealerSalesStaffName__c = 'DealerSalesStaffName__c';
+ opp.DealerService__c = 'DealerService__c';
+ opp.ExpectedDeliveryDate__c = day2;
+ opp.ExpectedOrderDate__c = day2;
+ opp.InquiryResult__c = 'InquiryResult__c';
+ opp.InquiryResultCancel__c = null;
+ opp.InquiryResultLost__c = null;
+ opp.InquiryResultOrder__c = null;
+ opp.LostAmount__c = 222;
+ opp.LostCompetitorProduct__c = 'LostCompetitorProduct__c';
+ opp.LostReasonText__c = 'LostReasonText__c';
+ opp.LostReason__c = 'LostReason__c';
+ opp.NewInquiryDate__c = day2;
+ opp.Phase1Date__c = day2;
+ opp.Phase2Date__c = day2;
+ opp.Phase3Date__c = day2;
+ opp.SalesChannel__c = 'direct';
+ opp.SubDealer__c = 'SubDealer__c';
+ opp.TradeType__c = 'Taxation';
+ opp.Machine_Parts__c = 'Machine';
+ opp.SpecialDeliveryAddress__c = specialDeliveryAddress2.Id;
+ opp.ForeignTradeCompany__c = foreignTradeCompany2.Id;
+
+
+ opp.OwnerId = user.Id;
+
+ update opp;
+
+ oli.Quantity = 3;
+ oli.UnitPrice = 222;
+ oli.Description = 'test1';
+
+ update oli;
+
+ opp.LeadSource_D__c = 'newOpp.LeadSource';
+ opp.Budget_Amount_D__c = 111;
+ opp.Cancel_Reason_Text_D__c = 'newOpp.CancelReasonText__c';
+ opp.Cancel_Reason_D__c = 'newOpp.CancelReason__c';
+ opp.Competitor_Company_D__c = 'newOpp.CompetitorCompany__c';
+ opp.Competitor_Product_D__c = 'newOpp.Competitor_Product__c';
+ opp.Competitor_Product2_D__c = 'newOpp.Competitor_Product2__c';
+ opp.Competitor_Product3_D__c = 'newOpp.Competitor_Product3__c';
+ opp.Competitor_Product4_D__c = 'newOpp.Competitor_Product4__c';
+ opp.Competitor_Product5_D__c = 'newOpp.Competitor_Product5__c';
+ opp.Competitor_Product6_D__c = 'newOpp.Competitor_Product6__c';
+ opp.Competitor_Product7_D__c = 'newOpp.Competitor_Product7__c';
+ opp.Competitor_Product8_D__c = 'newOpp.Competitor_Product8__c';
+ opp.Competitor_Product_Code_D__c = 'newOpp.CompetitorProductCode__c';
+ opp.Competitor_Product_Code2_D__c = 'newOpp.CompetitorProductCode2__c';
+ opp.Competitor_Product_Code3_D__c = 'newOpp.CompetitorProductCode3__c';
+ opp.Competitor_Product_Code4_D__c = 'newOpp.CompetitorProductCode4__c';
+ opp.Competitor_Product_Code5_D__c = 'newOpp.CompetitorProductCode5__c';
+ opp.Competitor_Product_Code6_D__c = 'newOpp.CompetitorProductCode6__c';
+ opp.Competitor_Product_Code7_D__c = 'newOpp.CompetitorProductCode7__c';
+ opp.Competitor_Product_Code8_D__c = 'newOpp.CompetitorProductCode8__c';
+ opp.Dealer_Sales_Staff_Name_D__c = 'newOpp.DealerSalesStaffName__c';
+ opp.Dealer_Service_D__c = 'newOpp.DealerService__c';
+ opp.Expected_Delivery_Date_D__c = day1;
+ opp.Expected_Order_Date_D__c = day1;
+ opp.Inquiry_Result_D__c = 'newOpp.InquiryResult__c';
+ opp.Inquiry_Result_Cancel_D__c = null;
+ opp.Inquiry_Result_Lost_D__c = null;
+ opp.Inquiry_Result_Order_D__c = null;
+ opp.Lost_Amount_D__c = 111;
+ opp.Lost_Competitor_Product_D__c = 'newOpp.LostCompetitorProduct__c';
+ opp.LostReasonText_D__c = 'newOpp.LostReasonText__c';
+ opp.LostReason_D__c = 'newOpp.Lostreason__c';
+ opp.New_Inquiry_Date_D__c = day1;
+ opp.Phase1Date_D__c = day1;
+ opp.Phase2Date_D__c = day1;
+ opp.Phase3Date_D__c = day1;
+ opp.Sales_Channel_D__c = 'direct';
+ opp.Sub_Dealer_D__c = 'newOpp.SubDealer__c';
+ opp.Trade_Type_D__c = 'Taxation';
+ opp.Machine_Parts_D__c = 'Machine';
+ opp.SpecialDeliveryAddress_D__c= specialDeliveryAddress3.Id;
+ opp.ForeignTradeCompany_D__c = foreignTradeCompany3.Id;
+
+ opp.DealerSelectOwner__c = UserInfo.getUserId();
+
+ update opp;
+
+ oli.QuantityD__c = 2;
+ oli.UnitPriceD__c = 111;
+ oli.DescriptionD__c = 'test';
+ oli.DealerSelectProduct__c = product1.Id;
+
+ update oli;
+
+ opp.ApprovalStatus_D__c = 'Completed';
+ update opp;
+ opp.ApprovalStatus_D__c = 'Submit';
+ update opp;
+ opp.ApprovalStatus_D__c = 'Reject';
update opp;
- List<Opportunity_File__c> checkList = [select id, Is_Locked__c from Opportunity_File__c where id = :ofile.Id];
- System.assertEquals(true, checkList[0].Is_Locked__c);
-
- Attachment att3 = new Attachment(
- Name = 'ORDER-123456.pdf',
- parentId = company.Id,
- Body = EncodingUtil.base64Decode('test')
- );
- insert att3;
- delete att3;
-
- Rental_Apply__c rentalApply = new Rental_Apply__c();
- // '寮曞綋瀹屼簡' -> 宸叉壒鍑�
- rentalApply.Status__c = FixtureUtil.raStatusMap.get(FixtureUtil.RaStatus.Yi_Pi_Zhun.ordinal());
- // rentalApply.applyUser__c = UserInfo.getUserId();
- rentalApply.applyUser__c = user.Id;
- rentalApply.direct_send__c = '鐩撮��';
- rentalApply.direct_shippment_address__c = 'test';
- rentalApply.Request_return_day__c = Date.today() + 30;
-
- rentalApply.demo_purpose1__c = '鍏朵粬';
- rentalApply.demo_purpose2__c = '鍏朵粬';
- /* 杩欎釜鐢ㄦ埛娌℃潈闄� 鐢ㄥ畠璧嬪�间細閫犳垚鎶ラ敊 鏆傛椂娉ㄩ噴鎺� 绮剧悽鎶�鏈� wql 2021/05/26 */
- //rentalApply.Person_In_Charge__c = user.Id;
- rentalApply.Hope_Lonaer_date_Num__c = 6;
- insert rentalApply;
-
- Attachment att4 = new Attachment(
- Name = 'ORDER-123456.pdf',
- parentId = rentalApply.Id,
- Body = EncodingUtil.base64Decode('test')
- );
- insert att4;
- delete att4;
-
- Consumable_order__c co = new Consumable_order__c();
- insert co;
-
- Attachment att5 = new Attachment(
- Name = 'ORDER-123456.pdf',
- parentId = co.Id,
- Body = EncodingUtil.base64Decode('test')
- );
- insert att5;
- //delete att5;
-
- System.Test.stopTest();
+ opp.ApprovalStatus_D__c = 'Completed';
+ update opp;
+ opp.ApprovalStatus_D__c = 'Submit';
+ update opp;
+ opp.ApprovalStatus_D__c = 'Pass';
+ update opp;
}
-}
- @isTest static void test_Change_Quote() {
- List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
- if (rectCo.size() == 0) {
- return;
- }
- List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
- if (rectSct.size() == 0) {
- return;
- }
- List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '瑷虹檪绉� 娑堝寲绉�'];
- if (rectDpt.size() == 0) {
- return;
- }
+ static testMethod void myTest4() {
- // 銉嗐偣銉堛儑銉笺偪
- Account company = new Account();
- company.RecordTypeId = rectCo[0].Id;
- company.Name = 'NFM007TestCompany';
- upsert company;
- Account section = new Account();
- section.RecordTypeId = rectSct[0].Id;
- section.Name = '*';
- section.Department_Class_Label__c = '娑堝寲绉�';
- section.ParentId = company.Id;
- section.Hospital_Department_Class__c = company.Id;
- upsert section;
- Account depart = new Account();
- depart.RecordTypeId = rectDpt[0].Id;
- depart.Name = '*';
- depart.Department_Name__c = 'NFM007TestDepart';
- depart.ParentId = section.Id;
- depart.Department_Class__c = section.Id;
- depart.Hospital__c = company.Id;
- upsert depart;
+ StaticParameter.OpportunityTriggerIsUpdate = true;
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ Account accIE = new Account(
+ Name = 'test',
+ RecordTypeId = rectIE[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ DivisionName__c='Customer IE',
+ FacilityName__c='abc',
+ PostCode__c = '123456'
+ );
+ insert accIE;
+ Contact con = new Contact();
+ con.LastName = 'test';
+ con.AccountId = accIE.Id;
+ con.MobilePhone = 'MobilePhoneD__c';
+ con.OtherPhone = 'OtherPhoneD__c';
+ con.Fax = 'FaxD__c';
+ con.Email = 'EmailD__c@test.com';
+ con.Phone = 'PhoneD__c';
+ con.Title = 'TitleD__c';
+ con.Address1__c = 'Address1D__c';
+ con.Address2__c = 'Address2D__c';
+ con.Address3__c = 'Address3D__c';
+ con.Postcode__c = '100111';
+ con.ContactStatus__c = 'ContactStatusD__c';
+ con.CancelReason__c = 'CancelReasonD__c';
+ con.StatusD__c = 'Pass';
- //璨╁2搴�
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name='璨╁2搴�' limit 1];
- Account sellerA = new Account(Name = '璨╁2搴桝');
- sellerA.RecordTypeId = recHanbaiten.id;
- sellerA.Delete_Flag__c = false;
- insert sellerA;
-
- Account sellerB = new Account(Name = '璨╁2搴桞');
- sellerB.RecordTypeId = recHanbaiten.id;
- sellerB.Delete_Flag__c = false;
- insert sellerB;
-
- Oly_TriggerHandler.bypass('PowerBIBaseHandler');
- StaticParameter.EscapeSyncOpportunityTrigger = true;
- StaticParameter.EscapeNFM007Trigger = true;
- StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true;
- Oly_TriggerHandler.bypass('AgencyOppUpdHandler');
- StaticParameter.EscapeSyncOpportunityTrigger = true;
-
- System.Test.startTest();
-
- Opportunity opp = new Opportunity();
- opp.AccountId = depart.Id;
- opp.Department_Class__c = section.Id;
- opp.Hospital__c = company.Id;
- opp.SAP_Send_OK__c = false;
- opp.Name = 'GZ-SP-NFM007_1';
- opp.Trade__c = '鍐呰部';
- opp.StageName = '寮曞悎';
- opp.CloseDate = date.newinstance(2022, 11, 30);
- opp.Stock_apply_status__c = '鐢宠涓�';
+ insert con;
+ PriceBook2 pricebook =new PriceBook2(
+ Name = 'IE',
+ ProductSegment__c = 'IE',
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ MachineParts__c = 'Machine'
+ );
+ insert pricebook;
+
+ List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
+ Opportunity opp = new Opportunity(
+ Name = 'test',
+ AccountId = accIE.Id,
+ RecordTypeId = rectOpp[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ StageName = 'Prospect Created',
+ CancelReason__c = 'Inquiry repeat',
+ Cancel_reason_D__c = 'Inquiry repeat',
+ CurrencyIsoCode = 'CNY',
+ ProductSegment__c = 'IE',
+ CloseDate = Date.today(),
+ NewInquiryDate__c = Date.today().addDays(-2),
+ ExpectedOrderDate__c = Date.today().addDays(2),
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ Machine_Parts__c = 'Machine'
+ );
insert opp;
-
- Quote q = new Quote(
- Name = 'quote',
- OpportunityId = opp.Id,
- Agency1__c = sellerA.Id,
- Quote_No__c = 'Quote_No_1'
- );
- insert q;
-
- opp.Agency1__c = sellerA.Id;
- opp.Estimation_No__c = q.Quote_No__c;
- update opp;
-
- opp.Agency1__c = sellerB.Id;
- update opp;
- System.Test.stopTest();
- }
+ opp.Phase1Date_D__c = Date.today();
+ update opp;
- //2021-05-13 mzy QLM
- @isTest static void test_Change_Opp() {
- List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鐥呴櫌'];
- if (rectCo.size() == 0) {
- return;
- }
- List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '鎴︾暐绉戝鍒嗛 鍛煎惛绉�'];
- if (rectSct.size() == 0) {
- return;
- }
- List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '瑷虹檪绉� 娑堝寲绉�'];
- if (rectDpt.size() == 0) {
- return;
- }
+ opp.Phase2Date_D__c = Date.today();
+ update opp;
- // 銉嗐偣銉堛儑銉笺偪
- Account company = new Account();
- company.RecordTypeId = rectCo[0].Id;
- company.Name = 'NFM007TestCompany';
- upsert company;
- Account section = new Account();
- section.RecordTypeId = rectSct[0].Id;
- section.Name = '*';
- section.Department_Class_Label__c = '娑堝寲绉�';
- section.ParentId = company.Id;
- section.Hospital_Department_Class__c = company.Id;
- upsert section;
- Account depart = new Account();
- depart.RecordTypeId = rectDpt[0].Id;
- depart.Name = '*';
- depart.Department_Name__c = 'NFM007TestDepart';
- depart.ParentId = section.Id;
- depart.Department_Class__c = section.Id;
- depart.Hospital__c = company.Id;
- upsert depart;
+ opp.StageName = 'Phase3';
+ update opp;
- //璨╁2搴�
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name='璨╁2搴�' limit 1];
- Account sellerA = new Account(Name = '璨╁2搴桝');
- sellerA.RecordTypeId = recHanbaiten.id;
- sellerA.Delete_Flag__c = false;
- insert sellerA;
-
- Account sellerB = new Account(Name = '璨╁2搴桞');
- sellerB.RecordTypeId = recHanbaiten.id;
- sellerB.Delete_Flag__c = false;
- insert sellerB;
-
- Oly_TriggerHandler.bypass('PowerBIBaseHandler');
- StaticParameter.EscapeSyncOpportunityTrigger = true;
- StaticParameter.EscapeNFM007Trigger = true;
- StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true;
- Oly_TriggerHandler.bypass('AgencyOppUpdHandler');
- StaticParameter.EscapeSyncOpportunityTrigger = true;
-
- System.Test.startTest();
-
- //win
- Opportunity opp1 = new Opportunity(
- Name = 'test opp1',
- StageName = '瀹屼簡',
- CurrencyIsoCode = 'USD',
- CloseDate = Date.today(),
- AccountId = depart.Id,
- Closing_Bid_Date__c = Date.today().addDays(-5),
- Hospital__c = company.Id,
- Competitor__c = 'A'
+ OpportunityContactRole role = new OpportunityContactRole(
+ Role = 'End user',
+ IsPrimary = true,
+ OpportunityId = opp.Id,
+ ContactId = con.Id
);
- insert opp1;
+ insert role;
- opp1.SAP_Send_OK__c = true;
- opp1.Authorized_DB_No__c = '123';
- opp1.Contract_DB_SalesDept_complite_day__c = Date.today();
- opp1.NotesApprovedNo__c = '123';
- update opp1;
-
- //鎷涙爣椤圭洰
- Tender_information__c te1 = new Tender_information__c();
- te1.Name = 'TestZhaoBiao';
- insert te1;
-
- opp1.Bidding_Project_Name_Bid__c = te1.Id;
- update opp1;
-
- //澶卞崟
- opp1.StageName = '鏁楁垿';
- update opp1;
-
-
-
- //鏂板缓璇环鏃�,璧嬪�兼嫑鎶曟爣椤圭洰,鎵撲笂鏍囪瘑
- Opportunity opp2 = new Opportunity(
- Name = 'test opp1',
- StageName = '寮曞悎',
- CurrencyIsoCode = 'USD',
- CloseDate = Date.today(),
- AccountId = depart.Id,
- Closing_Bid_Date__c = Date.today().addDays(-5),
- Hospital__c = company.Id,
- Competitor__c = 'A',
- Bidding_Project_Name_Bid__c = te1.Id
+ Order odr = new Order(
+ Name = 'test',
+ Status = 'Draft',
+ Status__c = 'Active',
+ AccountId = accIE.Id,
+ ApproveStatus__c = 'Draft',
+ OpportunityId = opp.Id,
+ EffectiveDate = Date.today(),
+ IE_SP5_D__c = true,
+ IE_SP8__c = true,
+ SpecialDeliveryAccount_D__c = accIE.Id,
+ SpecialDeliveryContact2_D__c = con.Id,
+ EndUser__c = con.Id,
+ EndUserD__c = con.Id
);
- insert opp2;
+ insert odr;
+ opp.Name = 'test';
+ update opp;
+ }
+ static testMethod void myTest5() {
+
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ Account accIE = new Account(
+ Name = '*',
+ RecordTypeId = rectIE[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ DivisionName__c='Customer IE',
+ FacilityName__c='abc',
+ PostCode__c = '123456'
+ );
+ insert accIE;
+
+ PriceBook2 pricebook =new PriceBook2(
+ Name = 'IE',
+ ProductSegment__c = 'IE',
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ MachineParts__c = 'Machine'
+ );
+ insert pricebook;
- System.Test.stopTest();
-
- }
- //2021-05-13 mzy QLM
-
+ User user = new User();
+ user.LastName = 'test';
+ user.FirstName = 'test';
+ user.Alias = 'test';
+ user.Email = 'User202105191300@test.com';
+ user.Username = 'User202105191300@test222.com';
+ user.CommunityNickname = 'test01';
+ user.IsActive = true;
+ user.EmailEncodingKey = 'ISO-2022-JP';
+ user.TimeZoneSidKey = 'Asia/Tokyo';
+ user.LocaleSidKey = 'ja_JP';
+ user.LanguageLocaleKey = 'ja';
+ user.ProfileId = System.Label.SystemAdmin;
+ insert user;
+
+ List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
+ Opportunity opp = new Opportunity(
+ Name = 'test opp',
+ AccountId = accIE.Id,
+ RecordTypeId = rectOpp[0].Id,
+ OwnerId = UserInfo.getUserId(),
+ StageName = 'Prospect Created',
+ CancelReason__c = 'Inquiry repeat',
+ Cancel_reason_D__c = 'Inquiry repeat',
+ CurrencyIsoCode = 'CNY',
+ ProductSegment__c = 'IE',
+ CloseDate = Date.today(),
+ NewInquiryDate__c = Date.today().addDays(-2),
+ ExpectedOrderDate__c = Date.today().addDays(2),
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ Machine_Parts__c = 'Machine'
+ );
+ insert opp;
+ Opportunity oppNew = new Opportunity();
+ oppNew.Name = 'test opp';
+ oppNew.AccountId = accIE.Id;
+ oppNew.RecordTypeId = rectOpp[0].Id;
+ oppNew.OwnerId = user.Id;
+ oppNew.StageName = 'Prospect Created';
+ oppNew.CancelReason__c = 'Inquiry repeat';
+ oppNew.Cancel_reason_D__c = 'Inquiry repeat';
+ oppNew.CurrencyIsoCode = 'CNY';
+ oppNew.ProductSegment__c = 'IE';
+ oppNew.CloseDate = Date.today();
+ oppNew.NewInquiryDate__c = Date.today().addDays(-2);
+ oppNew.ExpectedOrderDate__c = Date.today().addDays(2);
+ oppNew.TradeType__c = 'Taxation';
+ oppNew.SalesChannel__c = 'direct';
+ oppNew.Machine_Parts__c = 'Machine';
+ insert oppNew;
+ oppNew.Manager__c = user.Id;
+ oppNew.Have_Computer__c = true;
+ oppNew.CanChangeOpp__c = true;
+ oppNew.Association_Opportunity__c = opp.Id;
+ update oppNew;
+ /*oppNew.Association_Opportunity__c = null;
+ update oppNew;*/
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1