From f50c0ec115e25dc7f980bafda8169ed5ddfe1a8f Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 08 四月 2022 21:04:16 +0800
Subject: [PATCH] Session
---
force-app/main/default/classes/NewQuoteEntryControllerTest.cls | 3732 +++++++++++++++-------------------------------------------
1 files changed, 965 insertions(+), 2,767 deletions(-)
diff --git a/force-app/main/default/classes/NewQuoteEntryControllerTest.cls b/force-app/main/default/classes/NewQuoteEntryControllerTest.cls
index 3ac80b9..2b51218 100644
--- a/force-app/main/default/classes/NewQuoteEntryControllerTest.cls
+++ b/force-app/main/default/classes/NewQuoteEntryControllerTest.cls
@@ -1,2784 +1,982 @@
@isTest
private class NewQuoteEntryControllerTest {
- private static Product2 product = null;
- private static Pricebook2 pricebook = null;
+ @isTest
+ static void test_init1() {
+ Id pricebookId = Test.getStandardPricebookId();
+
+ Pricebook2 pricebook = new Pricebook2(
+ Name = 'IE',
+ ProductSegment__c = 'IE',
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ MachineParts__c = 'Machine',
+ isActive = true,
+ CurrencyIsoCode = 'CNY'
+ );
+ insert pricebook;
+
+ system.debug('---pricebook---'+ pricebook);
+
+ Product2 product1 = new Product2();
+ product1.Name = 'product1';
+ product1.ProductCode = 'product1';
+ product1.Product_ECCode__c = 'product1';
+ product1.IsActive = true;
+ product1.ProductStatus__c = '1';
+ product1.NMPAStatus_one__c = 'Z1';
+ product1.MaterialStatus_one_Start__c = Date.today().addDays(-22);
+ product1.MaterialStatus_one_End__c = Date.today().addDays(22);
+
+ //Product2 product2 = new Product2();
+ //product2.Name = 'product2';
+ //product2.ProductCode = 'product2';
+ //product2.Product_ECCode__c = 'product2';
+ //product2.IsActive = true;
+ //product2.ProductStatus__c = '1';
+ //product2.NMPAStatus_one__c = 'Z1';
+ //product2.MaterialStatus_one_Start__c = Date.today().addDays(-22);
+ //product2.MaterialStatus_one_End__c = Date.today().addDays(22);
+
+ //Product2 product3 = new Product2();
+ //product3.Name = 'product3';
+ //product3.ProductCode = 'product3';
+ //product3.Product_ECCode__c = 'product3';
+ //product3.IsActive = true;
+ //product3.ProductStatus__c = '1';
+ //product3.NMPAStatus_one__c = 'Z1';
+ //product3.MaterialStatus_one_Start__c = Date.today().addDays(-22);
+ //product3.MaterialStatus_one_End__c = Date.today().addDays(22);
+
+ //insert new Product2[] {product1, product2, product3};
+ insert new Product2[] {product1};
+
+ PricebookEntry standardPrice1 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product1.Id,
+ UnitPrice = 0,
+ IsActive = true,
+ CurrencyIsoCode = 'CNY'
+ );
+
+ //PricebookEntry standardPrice2 = new PricebookEntry(
+ // Pricebook2Id = pricebookId,
+ // Product2Id = product2.Id,
+ // UnitPrice = 0,
+ // IsActive = true,
+ // CurrencyIsoCode = 'CNY'
+ //);
+
+ //PricebookEntry standardPrice3 = new PricebookEntry(
+ // Pricebook2Id = pricebookId,
+ // Product2Id = product3.Id,
+ // UnitPrice = 0,
+ // IsActive = true,
+ // CurrencyIsoCode = 'CNY'
+ //);
+
+ //insert new PricebookEntry[] {standardPrice1, standardPrice2, standardPrice3};
+ insert new PricebookEntry[] {standardPrice1};
+
+ system.debug('standardPrice1--->' + standardPrice1);
+ PricebookEntry entry1 = new PricebookEntry(
+ Pricebook2Id = pricebook.Id,
+ Product2Id = product1.Id,
+ UnitPrice = 0,
+ IsActive = true,
+ UseStandardPrice = false,
+ CurrencyIsoCode = 'CNY'
+
+ );
+ system.debug('--entry1-' + entry1.Pricebook2Id);
+ //PricebookEntry entry2 = new PricebookEntry(
+ // Pricebook2Id = pricebook.Id,
+ // Product2Id = product2.Id,
+ // UnitPrice = 0,
+ // IsActive = true,
+ // UseStandardPrice = false,
+ // CurrencyIsoCode = 'CNY'
+ //);
+ //system.debug('--entry2-' + entry2.Pricebook2Id);
+ //PricebookEntry entry3 = new PricebookEntry(
+ // Pricebook2Id = pricebook.Id,
+ // Product2Id = product3.Id,
+ // UnitPrice = 0,
+ // IsActive = true,
+ // UseStandardPrice = false,
+ // CurrencyIsoCode = 'CNY'
+ //);
+ //system.debug('--entry3-' + entry3.Pricebook2Id);
+ //insert new PricebookEntry[] {entry1, entry2, entry3};
+ insert new PricebookEntry[] {entry1};
- private static Opportunity opprtunity = null;
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ Account user = new Account(
+ Name = '*',
+ FacilityName__c = 'user',
+ PostCode__c = '123456',
+ RecordTypeId = rectIE[0].Id
+ );
+ insert user;
- static final String RC_HOSPITAL = '鐥呴櫌';
- static final String RC_OPP = '寮曞悎';
- static final String RC_SENRYAKUKASHITSUBUNRUI = '鎴︾暐绉戝鍒嗛 娑堝寲绉�';
- static final String RC_BYOUIN = '鐥呴櫌';
- static final String RC_SHINRYOUKA = '瑷虹檪绉� 銇濄伄浠�';
- static final String RC_HANBAOITEN = '璨╁2搴�';
- static final String RC_KEIYAKU = '濂戠磩';
-
- static {
- product = new Product2( Name = '銉嗐偣銉堝晢鍝�');
- insert product;
- system.debug('##product.Id=[' + product.Id + ']' );
-
- pricebook = ControllerUtil.getStandardPricebook();
- system.debug('##pricebook.Id=[' + pricebook.Id + ']' );
- }
-
- private static PricebookEntry buildPB( String input) {
- PricebookEntry entry = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product.Id);
-
- entry.UnitPrice = 0;
- entry.IsActive = true;
- entry.UseStandardPrice = false;
- entry.CurrencyIsoCode = input;
- insert entry;
- return entry;
- }
-
- public static Opportunity buildOppInstance( String inputTrade, String CurrencyIsoCode) {
- Opportunity target = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today());
- target.Trade__c = inputTrade;
- target.owner_not_automatically_update__c = true;
- target.CurrencyIsoCode = CurrencyIsoCode;
- target.Wholesale_Price__c = 9000;
- return target;
- }
-
- private static QuoteLineItem insertQuoteLineItem( Quote input, Pricebookentry entry) {
- QuoteLineItem target = new QuoteLineItem();
- target.Name__c = '銉嗐偣銉堝晢鍝�';
- target.QuoteId = input.Id;
- target.Quantity = 1;
- target.Cost_Subtotal__c = 0;
- target.Cost__c = 200;
-// target.TotalPrice = 100;
- target.UnitPrice = 10;
- target.PricebookEntryId = entry.Id;
- insert target;
- return target;
- }
-
-
- private static String quoteNo = 'textQutote01';
- public static String trade = '鍐呰部';
- public static String CurrencyIso = 'CNY';
-
- private static Boolean isUnitPrice = true;
- private static Boolean isOfferAmount = true;
- private static Boolean isTotalPrice = true;
- private static Boolean isDiscountRate = true;
- private static Boolean isDiscountAmount = true;
- private static Boolean isTradingPrice = true;
- private static Boolean isContractDetail = true;
-
- private static Date offerExpireDate = Date.today();
- private static String clientName = 'test client';
- private static String offerComment = 'test comment';
- private static Date offerPrintDate = Date.today();
- private static String agentName = 'test agent name';
-
- static testMethod void TestInit01() {
- system.debug('---------------------------------------Start initTest-----');
- NewQuoteEntryController QuotePage = new NewQuoteEntryController();
- //Line 119 User銇甉uote_Correct__c銆丵uote_Special_Operation__c銆丼AP_Send_OFF__c銈掋儐銈广儓銇熴倎銆�
- String userId = UserInfo.getUserId();
- User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
- u1.Quote_Correct__c = false;
- u1.Quote_Special_Operation__c = true;
- u1.Cost_Referable__c = true;
- update u1;
-
- // PricebookEntry
- PricebookEntry entryUSD = buildPB( 'USD');
- PricebookEntry entryCNY = buildPB( 'CNY');
-
- // 寮曞悎浣滄垚
- Opportunity opp = buildOppInstance( trade, CurrencyIso);
- opp.Trade__c = trade;
- opp.owner_not_automatically_update__c = true;
- opp.Sales_Root__c = 'AAA';
- opp.Pricebook2Id = pricebook.id;
+ Opportunity opp = new Opportunity(
+ Name = 'test opp',
+ AccountId = user.Id,
+ 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',
+ Pricebook2Id = pricebook.Id
+ );
insert opp;
+ system.debug('opp------>' + opp.Pricebook2Id);
+ OpportunityLineItem oli1 = new OpportunityLineItem(
+ OpportunityId = opp.Id,
+ PricebookEntryId = entry1.Id,
+ Quantity = 1,
+ UnitPrice = 30
+ );
+ //system.debug('--oli1-' + oli1.PricebookEntryId);
+ //OpportunityLineItem oli2 = new OpportunityLineItem(
+ // OpportunityId = opp.Id,
+ // PricebookEntryId = entry2.Id,
+ // Quantity = 2,
+ // UnitPrice = 30
+ //);
+ //system.debug('--oli2-' + oli2.PricebookEntryId);
+ //OpportunityLineItem oli3 = new OpportunityLineItem(
+ // OpportunityId = opp.Id,
+ // PricebookEntryId = entry3.Id,
+ // Quantity = 3,
+ // UnitPrice = 30
+ //);
+ //system.debug('--oli3-' + oli3.PricebookEntryId);
+ //insert new OpportunityLineItem[] {oli1, oli2, oli3};
+ //insert new OpportunityLineItem[] {oli1};
- //瑕嬬銉囥兗銈夸綔鎴�
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
-
- insert quote;
- quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
- System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);
-
- // 瑕嬬鍝佺洰浣滄垚
- QuoteLineItem item01 = insertQuoteLineItem( quote, entryCNY);
- QuoteLineItem item02 = insertQuoteLineItem( quote, entryCNY);
-
- //瑕嬬銉囥兗銈挎绱�
- opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
- System.Test.startTest();
- test1( opp, quote , QuotePage);
- test2( opp, quote , QuotePage);
- test3( opp, quote , QuotePage);
- test4( opp, quote , QuotePage);
- System.Test.stopTest();
-// test5( opp, quote , QuotePage);
-// test6( opp, quote , QuotePage);
-// test7( opp, quote , QuotePage);
-
-
-
-
- system.debug('---------------------------------------End initTest-----');
- }
-
- static testMethod void testInit02() {
- system.debug('---------------------------------------Start initTest-----');
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
- NewQuoteEntryController QuotePage = new NewQuoteEntryController();
- //Line 119 User銇甉uote_Correct__c銆丵uote_Special_Operation__c銆丼AP_Send_OFF__c銈掋儐銈广儓銇熴倎銆�
- String userId = UserInfo.getUserId();
- User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
- u1.Quote_Correct__c = true;
- u1.Quote_Special_Operation__c = false;
- u1.Cost_Referable__c = true;
- update u1;
-
- // PricebookEntry
- PricebookEntry entryUSD = buildPB( 'USD');
- PricebookEntry entryCNY = buildPB( 'CNY');
- // 寮曞悎浣滄垚
- Opportunity opp = buildOppInstance( trade, CurrencyIso);
- opp.owner_not_automatically_update__c = true;
- opp.Trade__c = trade;
- opp.Sales_Root__c = 'AAA';
- opp.Pricebook2Id = pricebook.id;
- insert opp;
-
- //瑕嬬銉囥兗銈夸綔鎴�
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
-
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- insert quote;
- quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
- System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);
-
- // 瑕嬬鍝佺洰浣滄垚
- QuoteLineItem item01 = insertQuoteLineItem( quote, entryCNY);
- QuoteLineItem item02 = insertQuoteLineItem( quote, entryCNY);
- System.Test.startTest();
- //瑕嬬銉囥兗銈挎绱�
- opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
-// test1( opp, quote , QuotePage);
-// test2( opp, quote , QuotePage);
-// test3( opp, quote , QuotePage);
-// test4( opp, quote , QuotePage);
- test5( opp, quote , QuotePage);
-
- //test7( opp, quote , QuotePage);
- System.Test.stopTest();
- system.debug('---------------------------------------End initTest-----');
- }
- }
-
- static testMethod void testInit02_01() {
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
- system.debug('---------------------------------------Start initTest-----');
- NewQuoteEntryController QuotePage = new NewQuoteEntryController();
- //Line 119 User銇甉uote_Correct__c銆丵uote_Special_Operation__c銆丼AP_Send_OFF__c銈掋儐銈广儓銇熴倎銆�
- String userId = UserInfo.getUserId();
- User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
- u1.Quote_Correct__c = true;
- u1.Quote_Special_Operation__c = false;
- u1.Cost_Referable__c = true;
- update u1;
-
- // PricebookEntry
- PricebookEntry entryUSD = buildPB( 'USD');
- PricebookEntry entryCNY = buildPB( 'CNY');
- // 寮曞悎浣滄垚
- Opportunity opp = buildOppInstance( trade, CurrencyIso);
- opp.owner_not_automatically_update__c = true;
- opp.Trade__c = trade;
- opp.Sales_Root__c = 'AAA';
- opp.Pricebook2Id = pricebook.id;
- insert opp;
-
- //瑕嬬銉囥兗銈夸綔鎴�
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
-
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- quote.Cancel_Decide__c = false;
- insert quote;
- quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
- System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);
-
- // 瑕嬬鍝佺洰浣滄垚
- QuoteLineItem item01 = insertQuoteLineItem( quote, entryCNY);
- QuoteLineItem item02 = insertQuoteLineItem( quote, entryCNY);
- System.Test.startTest();
- //瑕嬬銉囥兗銈挎绱�
- opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
-
- test6( opp, quote , QuotePage);
- //test7( opp, quote , QuotePage);
- System.Test.stopTest();
- }
- }
-
-// static testMethod void testInit02_2() {
-// Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
-// User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
-// system.runAs(MacOwner) {
-// system.debug('---------------------------------------Start initTest-----');
-// NewQuoteEntryController QuotePage = new NewQuoteEntryController();
-// //Line 119 User銇甉uote_Correct__c銆丵uote_Special_Operation__c銆丼AP_Send_OFF__c銈掋儐銈广儓銇熴倎銆�
-// String userId = UserInfo.getUserId();
-// User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
-// u1.Quote_Correct__c = true;
-// u1.Quote_Special_Operation__c = false;
-// u1.Cost_Referable__c = true;
-// update u1;
-
-// // PricebookEntry
-// PricebookEntry entryUSD = buildPB( 'USD');
-// PricebookEntry entryCNY = buildPB( 'CNY');
-// // 寮曞悎浣滄垚
-// Opportunity opp = buildOppInstance( trade, CurrencyIso);
-// opp.owner_not_automatically_update__c = true;
-// opp.Trade__c = trade;
-// opp.Sales_Root__c = 'AAA';
-// opp.Pricebook2Id = pricebook.id;
-// insert opp;
-
-// //瑕嬬銉囥兗銈夸綔鎴�
-// Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
-// quote.OpportunityId = opp.Id;
-// quote.Pricebook2Id = pricebook.id;
-// quote.Quote_No__c = quoteNo;
-
-// quote.Unit_Price__c = isUnitPrice;
-// quote.Offer_Amount__c = isOfferAmount;
-// quote.TOTAL__c = isTotalPrice;
-// quote.Discount__c = isDiscountRate;
-// quote.Pricing__c = isDiscountAmount;
-// quote.Preferential_Trading_Price__c = isTradingPrice;
-// quote.Contract__c = isContractDetail;
-// quote.Quote_Comment__c = offerComment;
-// // insert quote;
-// quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
-// System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);
-
-// // 瑕嬬鍝佺洰浣滄垚
-// QuoteLineItem item01 = insertQuoteLineItem( quote, entryCNY);
-// QuoteLineItem item02 = insertQuoteLineItem( quote, entryCNY);
-// System.Test.startTest();
-// //瑕嬬銉囥兗銈挎绱�
-// opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
-// // test1( opp, quote , QuotePage);
-// // test2( opp, quote , QuotePage);
-// // test3( opp, quote , QuotePage);
-// // test4( opp, quote , QuotePage);
-// test5( opp, quote , QuotePage);
-
-// //test6( opp, quote , QuotePage);
-// //test7( opp, quote , QuotePage);
-// System.Test.stopTest();
-// system.debug('---------------------------------------End initTest-----');
-// }
-// }
-
- static testMethod void testInit02_2_01() {
- system.debug('---------------------------------------Start initTest-----');
- NewQuoteEntryController QuotePage = new NewQuoteEntryController();
- //Line 119 User銇甉uote_Correct__c銆丵uote_Special_Operation__c銆丼AP_Send_OFF__c銈掋儐銈广儓銇熴倎銆�
- String userId = UserInfo.getUserId();
- User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
- u1.Quote_Correct__c = true;
- u1.Quote_Special_Operation__c = false;
- u1.Cost_Referable__c = true;
- update u1;
-
- // PricebookEntry
- PricebookEntry entryUSD = buildPB( 'USD');
- PricebookEntry entryCNY = buildPB( 'CNY');
- // 寮曞悎浣滄垚
- Opportunity opp = buildOppInstance( trade, CurrencyIso);
- opp.owner_not_automatically_update__c = true;
- opp.Trade__c = trade;
- opp.Sales_Root__c = 'AAA';
- opp.Pricebook2Id = pricebook.id;
- insert opp;
-
- //瑕嬬銉囥兗銈夸綔鎴�
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
-
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- insert quote;
- quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
- System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);
-
- // 瑕嬬鍝佺洰浣滄垚
- QuoteLineItem item01 = insertQuoteLineItem( quote, entryCNY);
- QuoteLineItem item02 = insertQuoteLineItem( quote, entryCNY);
- System.Test.startTest();
- //瑕嬬銉囥兗銈挎绱�
- opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
- //test5( opp, quote , QuotePage);
- //test7( opp, quote , QuotePage);
- System.Test.stopTest();
- }
-// static testMethod void TestInit03() {
-
-
-// system.debug('---------------------------------------Start initTest-----');
-// NewQuoteEntryController QuotePage = new NewQuoteEntryController();
-// String userId = UserInfo.getUserId();
-// User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
-// u1.Quote_Correct__c = true;
-// u1.Quote_Special_Operation__c = true;
-// u1.Cost_Referable__c = false;
-// update u1;
-
-// // PricebookEntry
-// PricebookEntry entryUSD = buildPB( 'USD');
-// PricebookEntry entryCNY = buildPB( 'CNY');
-// CurrencyIso = 'USD';
-// trade = '澶栬部';
-// // 寮曞悎浣滄垚
-// Opportunity opp = buildOppInstance( trade, CurrencyIso);
-// opp.owner_not_automatically_update__c = true;
-// opp.Trade__c = trade;
-// opp.Sales_Root__c = 'AAA';
-// opp.Pricebook2Id = pricebook.id;
-// insert opp;
-
-// //瑕嬬銉囥兗銈夸綔鎴�
-// Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
-// quote.OpportunityId = opp.Id;
-// quote.Pricebook2Id = pricebook.id;
-// quote.Quote_No__c = quoteNo;
-
-// quote.Unit_Price__c = isUnitPrice;
-// quote.Offer_Amount__c = isOfferAmount;
-// quote.TOTAL__c = isTotalPrice;
-// quote.Discount__c = isDiscountRate;
-// quote.Pricing__c = isDiscountAmount;
-// quote.Preferential_Trading_Price__c = isTradingPrice;
-// quote.Contract__c = isContractDetail;
-// quote.Quote_Comment__c = offerComment;
-// insert quote;
-// quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
-// System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);
-
-// // 瑕嬬鍝佺洰浣滄垚
-// QuoteLineItem item01 = insertQuoteLineItem( quote, entryUSD);
-// QuoteLineItem item02 = insertQuoteLineItem( quote, entryUSD);
-
-// //瑕嬬銉囥兗銈挎绱�
-// opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
-// System.Test.startTest();
-// test1( opp, quote , QuotePage);
-// test2( opp, quote , QuotePage);
-// test3( opp, quote , QuotePage);
-// test4( opp, quote , QuotePage);
-// // test5( opp, quote , QuotePage);
-// // test6( opp, quote , QuotePage);
-// // test7( opp, quote , QuotePage);
-// System.Test.stopTest();
-
-
-
-
-// system.debug('---------------------------------------End initTest-----');
-// }
-
- static testMethod void testInit04() {
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
-
- system.debug('---------------------------------------Start initTest-----');
- NewQuoteEntryController QuotePage = new NewQuoteEntryController();
- String userId = UserInfo.getUserId();
- User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
- u1.Quote_Correct__c = true;
- u1.Quote_Special_Operation__c = false;
- u1.Cost_Referable__c = true;
- update u1;
-
- // PricebookEntry
- PricebookEntry entryUSD = buildPB( 'USD');
- PricebookEntry entryCNY = buildPB( 'CNY');
- CurrencyIso = 'USD';
- trade = '澶栬部';
- // 寮曞悎浣滄垚
- Opportunity opp = buildOppInstance( trade, CurrencyIso);
- opp.owner_not_automatically_update__c = true;
- opp.Trade__c = trade;
- opp.Sales_Root__c = 'AAA';
- opp.Pricebook2Id = pricebook.id;
- insert opp;
-
- //瑕嬬銉囥兗銈夸綔鎴�
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
-
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- insert quote;
- quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
- System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);
-
- // 瑕嬬鍝佺洰浣滄垚
- QuoteLineItem item01 = insertQuoteLineItem( quote, entryUSD);
- QuoteLineItem item02 = insertQuoteLineItem( quote, entryUSD);
-
- System.Test.startTest();
- //瑕嬬銉囥兗銈挎绱�
- opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
-
- //System.Test.startTest();
-// test1( opp, quote , QuotePage);
-// test2( opp, quote , QuotePage);
-// test3( opp, quote , QuotePage);
-// test4( opp, quote , QuotePage);
- test5( opp, quote , QuotePage);
- //System.Test.stopTest();
-
- //test6( opp, quote , QuotePage);
- //test7( opp, quote , QuotePage);
- System.Test.stopTest();
- system.debug('---------------------------------------End initTest-----');
- }
- }
- static testMethod void testInit04_01() {
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
- NewQuoteEntryController QuotePage = new NewQuoteEntryController();
- String userId = UserInfo.getUserId();
- User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
- u1.Quote_Correct__c = true;
- u1.Quote_Special_Operation__c = false;
- u1.Cost_Referable__c = true;
- update u1;
-
- // PricebookEntry
- PricebookEntry entryUSD = buildPB( 'USD');
- PricebookEntry entryCNY = buildPB( 'CNY');
- CurrencyIso = 'USD';
- trade = '澶栬部';
- // 寮曞悎浣滄垚
- Opportunity opp = buildOppInstance( trade, CurrencyIso);
- opp.owner_not_automatically_update__c = true;
- opp.Trade__c = trade;
- opp.Sales_Root__c = 'AAA';
- opp.Pricebook2Id = pricebook.id;
- insert opp;
-
- //瑕嬬銉囥兗銈夸綔鎴�
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
-
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- insert quote;
- quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
- System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);
-
- // 瑕嬬鍝佺洰浣滄垚
- QuoteLineItem item01 = insertQuoteLineItem( quote, entryUSD);
- QuoteLineItem item02 = insertQuoteLineItem( quote, entryUSD);
-
- System.Test.startTest();
- //瑕嬬銉囥兗銈挎绱�
- opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
-
- test6( opp, quote , QuotePage);
- //test7( opp, quote , QuotePage);
- System.Test.stopTest();
- }
- }
-
- static testMethod void testInit04_2() {
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
- system.debug('---------------------------------------Start initTest-----');
- NewQuoteEntryController QuotePage = new NewQuoteEntryController();
- String userId = UserInfo.getUserId();
- User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
- u1.Quote_Correct__c = true;
- u1.Quote_Special_Operation__c = false;
- u1.Cost_Referable__c = true;
- update u1;
-
- // PricebookEntry
- PricebookEntry entryUSD = buildPB( 'USD');
- PricebookEntry entryCNY = buildPB( 'CNY');
- CurrencyIso = 'USD';
- trade = '澶栬部';
- // 寮曞悎浣滄垚
- Opportunity opp = buildOppInstance( trade, CurrencyIso);
- opp.owner_not_automatically_update__c = true;
- opp.Trade__c = trade;
- opp.Sales_Root__c = 'AAA';
- opp.Pricebook2Id = pricebook.id;
- insert opp;
-
- //瑕嬬銉囥兗銈夸綔鎴�
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
-
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- insert quote;
- quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
- System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);
-
- // 瑕嬬鍝佺洰浣滄垚
- QuoteLineItem item01 = insertQuoteLineItem( quote, entryUSD);
- QuoteLineItem item02 = insertQuoteLineItem( quote, entryUSD);
-
- System.Test.startTest();
- //瑕嬬銉囥兗銈挎绱�
- opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
-
- //System.Test.startTest();
-// test1( opp, quote , QuotePage);
-// test2( opp, quote , QuotePage);
-// test3( opp, quote , QuotePage);
-// test4( opp, quote , QuotePage);
- test5( opp, quote , QuotePage);
- //System.Test.stopTest();
-
- //test6( opp, quote , QuotePage);
- //test7( opp, quote , QuotePage);
- System.Test.stopTest();
-
- }
- system.debug('---------------------------------------End initTest-----');
- }
-
- static testMethod void testInit04_2_01() {
- NewQuoteEntryController QuotePage = new NewQuoteEntryController();
- String userId = UserInfo.getUserId();
- User u1 = [SELECT Id, Quote_Correct__c, Quote_Special_Operation__c, Cost_Referable__c FROM User WHERE Id = :userId];
- u1.Quote_Correct__c = true;
- u1.Quote_Special_Operation__c = false;
- u1.Cost_Referable__c = true;
- update u1;
-
- // PricebookEntry
- PricebookEntry entryUSD = buildPB( 'USD');
- PricebookEntry entryCNY = buildPB( 'CNY');
- CurrencyIso = 'USD';
- trade = '澶栬部';
- // 寮曞悎浣滄垚
- Opportunity opp = buildOppInstance( trade, CurrencyIso);
- opp.owner_not_automatically_update__c = true;
- opp.Trade__c = trade;
- opp.Sales_Root__c = 'AAA';
- opp.Pricebook2Id = pricebook.id;
- insert opp;
-
- //瑕嬬銉囥兗銈夸綔鎴�
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
-
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- insert quote;
- quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
- System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);
-
- // 瑕嬬鍝佺洰浣滄垚
- QuoteLineItem item01 = insertQuoteLineItem( quote, entryUSD);
- QuoteLineItem item02 = insertQuoteLineItem( quote, entryUSD);
-
- System.Test.startTest();
- //瑕嬬銉囥兗銈挎绱�
- opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
-
- //test7( opp, quote , QuotePage);
- System.Test.stopTest();
- }
- static testMethod void TestInit05() {
- system.debug('---------------------------------------Start initTest-----');
- NewQuoteEntryController QuotePage = new NewQuoteEntryController();
- //Line 119 User銇甉uote_Correct__c銆丵uote_Special_Operation__c銆丼AP_Send_OFF__c銈掋儐銈广儓銇熴倎銆�
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User hpOwner = new User(Test_staff__c = true, Job_Category__c = '閿�鍞湇鍔�' , LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- insert hpOwner;
- String userId = hpOwner.id;
- // PricebookEntry
- PricebookEntry entryUSD = buildPB( 'USD');
- PricebookEntry entryCNY = buildPB( 'CNY');
-
- // 寮曞悎浣滄垚
- Opportunity opp = buildOppInstance( trade, CurrencyIso);
- opp.Trade__c = trade;
- opp.owner_not_automatically_update__c = true;
- opp.Sales_Root__c = 'AAA';
- opp.Pricebook2Id = pricebook.id;
- insert opp;
-
- //瑕嬬銉囥兗銈夸綔鎴�
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
-
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- insert quote;
- quote = [SELECT Id, OpportunityId, Quote_no__c, Quote_No_Auto__c, CurrencyIsoCode FROM Quote WHERE Id = :quote.id];
- System.assertEquals( CurrencyIso, quote.CurrencyIsoCode);
-
- // 瑕嬬鍝佺洰浣滄垚
-// QuoteLineItem item01 = insertQuoteLineItem( quote, entryCNY);
-// QuoteLineItem item02 = insertQuoteLineItem( quote, entryCNY);
-
- //瑕嬬銉囥兗銈挎绱�
- opprtunity = [SElECT Id, Opportunity_no__c, CurrencyIsoCode FROM Opportunity WHERE Id = :opp.id];
- System.Test.startTest();
-// test1( opp, quote , QuotePage);
-// test2( opp, quote , QuotePage);
-// test3( opp, quote , QuotePage);
-// test5( opp, quote , QuotePage);
-// test6( opp, quote , QuotePage);
-// test7( opp, quote , QuotePage);
- test8( opp, quote , QuotePage);
- System.Test.stopTest();
-
-
-
- system.debug('---------------------------------------End initTest-----');
- }
- // 椤甸潰鍙傛暟浠�涔堥兘涓嶅甫鐨� 鎵嬪姩璁剧疆quoid 鍜� oppId init 鍔� save
- private static void test1( Opportunity opp, Quote quote , NewQuoteEntryController QuotePage) {
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry');
+ PageReference page = new PageReference('/apex/NewQuoteService?oppid=' + opp.Id + '&openType=service');
System.Test.setCurrentPage(page);
-
- QuotePage.oppId = opp.id;
- QuotePage.quoId = quote.id;
- QuotePage.init();
- QuotePage.Save();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
- }
- // 椤甸潰鍙傛暟甯﹁浠穒d 鐨� 鎵嬪姩璁剧疆quoid init 鍔� save
- private static void test2( Opportunity opp, Quote quote , NewQuoteEntryController QuotePage) {
- system.debug('---------------------------------------Start initTest2-----');
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry?oppId=' + opprtunity.id );
- System.Test.setCurrentPage(page);
-
- QuotePage.oppId = opp.id;
- QuotePage.quoId = quote.id;
- QuotePage.init();
- QuotePage.Save();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
- }
-// 椤甸潰鍙傛暟浠�涔堥兘涓嶅甫鐨� 鎵嬪姩璁剧疆 oppId init 鍔� save
- private static void test3( Opportunity opp, Quote quote , NewQuoteEntryController QuotePage) {
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry');
- System.Test.setCurrentPage(page);
-
- QuotePage.oppId = opp.id;
- QuotePage.init();
- QuotePage.Save();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
- }
- // 椤甸潰鍙傛暟浠�涔堥兘涓嶅甫鐨� 鎵嬪姩璁剧疆 oppId init 鍔� save
- private static void test4(Opportunity opp, Quote quote , NewQuoteEntryController QuotePage) {
- opp = buildOppInstance( trade, CurrencyIso);
- opp.Trade__c = trade;
- opp.Sales_Root__c = '璨╁2搴�';
- opp.StageName = '寮曞悎';
- opp.Fixed_Check__c = false;
- opp.Pricebook2Id = pricebook.id;
- insert opp;
-
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry');
- System.Test.setCurrentPage(page);
-
- QuotePage.oppId = opp.id;
- QuotePage.init();
- QuotePage.Save();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
- }
-
- private static void test5(Opportunity opp, Quote quote , NewQuoteEntryController QuotePage) {
-
- //璨╁2搴�
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
- Account sellerA = new Account(Name = '璨╁2搴�');
- sellerA.RecordTypeId = recHanbaiten.id;
- sellerA.Delete_Flag__c = false;
- insert sellerA;
-
- //濂戠磩
- RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_KEIYAKU limit 1];
- Account keiyaku = new Account(Name = '*');
- keiyaku.RecordTypeId = recKeiyaku.id;
- keiyaku.Agent_Ref__c = sellerA.id;
- keiyaku.ParentId = sellerA.id;
- keiyaku.Delete_Flag__c = false;
- insert keiyaku;
-
- opp = buildOppInstance( trade, CurrencyIso);
- opp.Trade__c = trade;
- opp.Sales_Root__c = '璨╁2搴�';
- opp.StageName = '寮曞悎';
- opp.Fixed_Check__c = false;
- opp.Pricebook2Id = pricebook.id;
- opp.AccountId = keiyaku.id;
- opp.Hospital__c = keiyaku.id;
- insert opp;
-
-
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry');
- System.Test.setCurrentPage(page);
-
- //Apexpages.currentPage().getParameters().put('id', quote.id);
- QuotePage.oppId = opp.id;
- QuotePage.init();
- QuotePage.Save();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
- }
-
- private static void test6(Opportunity opp, Quote quote , NewQuoteEntryController QuotePage) {
-
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
- Account sellerA = new Account(Name = '璨╁2搴�');
- sellerA.RecordTypeId = recHanbaiten.id;
- insert sellerA;
-
- //濂戠磩
- RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_KEIYAKU limit 1];
- Account keiyaku = new Account(Name = '*');
- keiyaku.RecordTypeId = recKeiyaku.id;
- keiyaku.Agent_Ref__c = sellerA.id;
- keiyaku.ParentId = sellerA.id;
- keiyaku.Delete_Flag__c = false;
- insert keiyaku;
-
-
- opp = buildOppInstance( trade, CurrencyIso);
- opp.Trade__c = trade;
- opp.Sales_Root__c = '璨╁2搴�';
- opp.StageName = '寮曞悎';
- opp.Fixed_Check__c = false;
- opp.Pricebook2Id = pricebook.id;
- opp.AccountId = keiyaku.id;
- opp.Hospital__c = keiyaku.id;
- insert opp;
-
-
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry');
- System.Test.setCurrentPage(page);
-
- Apexpages.currentPage().getParameters().put('id', quote.id);
- QuotePage.oppId = null;
- QuotePage.init();
- QuotePage.Save();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
- }
-
- private static void test7(Opportunity opp, Quote quote , NewQuoteEntryController QuotePage) {
-
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
- Account sellerA = new Account(Name = '璨╁2搴�');
- sellerA.RecordTypeId = recHanbaiten.id;
- insert sellerA;
-
- //濂戠磩
- RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_KEIYAKU limit 1];
- Account keiyaku = new Account(Name = '*');
- keiyaku.RecordTypeId = recKeiyaku.id;
- keiyaku.Agent_Ref__c = sellerA.id;
- keiyaku.ParentId = sellerA.id;
- keiyaku.Delete_Flag__c = false;
- insert keiyaku;
-
-
- opp = buildOppInstance( trade, CurrencyIso);
- opp.Trade__c = trade;
- opp.Sales_Root__c = '璨╁2搴�';
- opp.StageName = '寮曞悎';
- opp.Fixed_Check__c = false;
- opp.Pricebook2Id = pricebook.id;
- opp.AccountId = keiyaku.id;
- opp.Hospital__c = keiyaku.id;
- insert opp;
-
- delete quote;
-
- Product2 product1 = new Product2( Name = '銉嗐偣銉堝晢鍝�');
- insert product1;
- system.debug('##product.Id=[' + product1.Id + ']' );
-
- PricebookEntry pE = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
-
- pE.UnitPrice = 0;
- pE.IsActive = true;
- pE.UseStandardPrice = false;
- pE.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE;
-
- OpportunityLineItem oli = new OpportunityLineItem();
- //target.QuoteId = input.Id;
- oli.Quantity = 1;
-// target.TotalPrice = 100;
- oli.UnitPrice = 0;
- oli.PricebookEntryId = pE.Id;
- oli.OpportunityId = opp.id;
- //oli.op
- insert oli;
-
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry');
- System.Test.setCurrentPage(page);
-
- Apexpages.currentPage().getParameters().put('oppid', opp.id);
- //Apexpages.currentPage().getParameters().put('id', quote.id);
- QuotePage.oppId = null;
- QuotePage.quoId = null;
- QuotePage.init();
- QuotePage.Save();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
- }
-// OpportunityLineItem=0浠躲伄銉嗐偣銉�
- private static void test8(Opportunity opp, Quote quote , NewQuoteEntryController QuotePage) {
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
- RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
- Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
- hospital.RecordTypeId = recByoin.id;
- hospital.Site = '銉嗐偣銉堢梾闄㈤儴闁�';
- hospital.Alias_Name2__c = '銉嗐偣銉堢梾闄㈠垾鍚�';
-// insert hospital;
-
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
- Account sellerA = new Account(Name = '璨╁2搴�');
- sellerA.RecordTypeId = recHanbaiten.id;
-// sellerA.Hospital__c = hospital.id;
- insert sellerA;
-
- //濂戠磩
- RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_KEIYAKU limit 1];
- Account keiyaku = new Account(Name = '*');
- keiyaku.RecordTypeId = recKeiyaku.id;
- keiyaku.Agent_Ref__c = sellerA.id;
- keiyaku.ParentId = sellerA.id;
- keiyaku.Site = '銉嗐偣銉堢梾闄㈤儴闁�';
- keiyaku.Delete_Flag__c = false;
- insert keiyaku;
-
-
-
- opp = buildOppInstance( trade, CurrencyIso);
- opp.Trade__c = trade;
- opp.Sales_Root__c = '璨╁2搴�';
- opp.StageName = '寮曞悎';
- opp.Fixed_Check__c = false;
- opp.Pricebook2Id = pricebook.id;
- opp.AccountId = keiyaku.id;
- opp.Hospital__c = keiyaku.id;
- insert opp;
-
-// delete quote;
-
- Product2 product1 = new Product2( Name = '銉嗐偣銉堝晢鍝�');
- insert product1;
- system.debug('##product.Id=[' + product1.Id + ']' );
-
- PricebookEntry pE = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
-
- pE.UnitPrice = 0;
- pE.IsActive = true;
- pE.UseStandardPrice = false;
- pE.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE;
-
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry');
- System.Test.setCurrentPage(page);
-
- Apexpages.currentPage().getParameters().put('oppid', opp.id);
- //Apexpages.currentPage().getParameters().put('id', quote.id);
- QuotePage.oppId = null;
- QuotePage.quoId = null;
- QuotePage.init();
- QuotePage.Save();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
- }
- }
- static testMethod void check_QuoteEntryController001() {
-
- RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
- Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
- hospital.RecordTypeId = recByoin.id;
- hospital.Site = '銉嗐偣銉堢梾闄㈤儴闁�';
- hospital.Alias_Name2__c = '銉嗐偣銉堢梾闄㈠垾鍚�';
- insert hospital;
-
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
- Account sellerA = new Account(Name = '璨╁2搴�');
- sellerA.RecordTypeId = recHanbaiten.id;
- sellerA.Hospital__c = hospital.id;
- insert sellerA;
-
- RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_KEIYAKU limit 1];
- Account contractA = new Account(Name = '*');
- contractA.RecordTypeId = recKeiyaku.id;
- contractA.Agent_Ref__c = sellerA.id;
- contractA.ParentId = sellerA.id;
- insert contractA;
-
- System.Test.startTest();
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
- Opportunity opp = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today());
- opp.Trade__c = '鍐呰部';
- opp.CurrencyIsoCode = CurrencyIso;
- opp.Sales_Root__c = '璨╁2搴�';
- opp.StageName = '寮曞悎';
- opp.owner_not_automatically_update__c = true;
- opp.Fixed_Check__c = false;
- opp.Pricebook2Id = pricebook.id;
- opp.Purchase_Type__c = '涓�鑸紩鍚�';
- opp.Promise_Class__c = '鍐呰部';
- opp.Fund_Basis__c = '鏀垮簻璩囬噾';
- opp.AccountId = contractA.id;
- opp.Hospital__c = contractA.id;
- opp.Agency1__c = sellerA.id;
- opp.Agency2__c = sellerA.id;
- opp.Wholesale_Price__c = 9000;
- insert opp;
-
- Product2 product1 = new Product2( Name = '11111');
- product1.SFDA_Status__c = '涓嶈';
- product1.Intra_Trade_List_RMB_1__c = 100;
- product1.Intra_Trade_List_RMB_Date1__c = date.today();
- product1.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product1.Intra_Trade_Cost_RMB_1__c = 200;
- product1.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product1.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product1.Manual_Entry__c = false;
- product1.Asset_Model_No__c = '11111';
- product1.MDM_Model_No__c = '11111';
- product1.ProductCode = 'OTV-SP1H-NA-12E';
-
- product1.Estimated_ConsumptionDueDate__c = date.today(); //20211012 lt add
-
- insert product1;
- system.debug('##product.Id=[' + product1.Id + ']' );
-
- Product2 product2 = new Product2( Name = '11112');
- product2.SFDA_Status__c = '涓嶈';
- product2.Intra_Trade_List_RMB_Date1__c = date.today();
- product2.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product2.Intra_Trade_Cost_RMB_1__c = 200;
- product2.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product2.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product2.Manual_Entry__c = false;
- product2.Asset_Model_No__c = '11112';
- product2.MDM_Model_No__c = '11112';
-// product2.ProductCode = 'OTV-SP1H-NA-12E';
- insert product2;
- system.debug('##product1.Id=[' + product1.Id + ']' );
- system.debug('##product2.Id=[' + product2.Id + ']' );
-
- PricebookEntry pE = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
-
- pE.UnitPrice = 0;
- pE.IsActive = true;
- pE.UseStandardPrice = false;
- pE.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE;
-
- PricebookEntry pE2 = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product2.Id);
-
- pE2.UnitPrice = 0;
- pE2.IsActive = true;
- pE2.UseStandardPrice = false;
- pE2.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE2;
-
- OpportunityLineItem oli = new OpportunityLineItem();
- //target.QuoteId = input.Id;
- oli.Quantity = 1;
-// target.TotalPrice = 100;
- oli.UnitPrice = 10;
- oli.PricebookEntryId = pE.Id;
- oli.OpportunityId = opp.id;
- oli.Cost__c = 100;
- //oli.op
- insert oli;
-
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- quote.QuoteName__c = '銉嗐偣銉堣绌�';
- quote.Dealer_Final_Price__c = 100;
- quote.Quote_Adjust_Calculate__c = 10;
- quote.Quote_Adjust_Amount__c = 10;
- quote.OCM_Agent1_Price__c = 10;
- quote.Agent1_Agent2_Price__c = 10;
-
- insert quote;
-
- // 銈汇儍銉堝搧
- Product_Set__c ps1 = new Product_Set__c();
- ps1.Name = '銈汇儍銉堝搧锛�';
- ps1.Product_Set_CD__c = '111111';
- ps1.Description__c = '瑾槑';
- ps1.Qty__c = 10;
- //ps1.Valid__c = true;
- ps1.Valid_Date__c = date.today().addDays(-5);
- insert ps1;
-
- Product_Set_Detail__c psd1 = new Product_Set_Detail__c();
- psd1.Product_Set__c = ps1.id;
- psd1.Price__c = 100;
- psd1.Quantity__c = 10;
- psd1.Product__c = product1.id;
-
- insert psd1;
-
- //System.Test.startTest();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry?copyid='+quote.Id);
- System.Test.setCurrentPage(page);
-
- Apexpages.currentPage().getParameters().put('oppid', opp.id);
- NewQuoteEntryController controller = new NewQuoteEntryController();
- //Apexpages.currentPage().getParameters().put('id', quote.id);
- controller.oppId = null;
- controller.quoId = null;
- controller.enableSales = false;
- controller.init();
- controller.dataCheck();
- controller.select_index = 0;
- controller.Product_text = product1.id;
- controller.setProduct_text = ps1.id;
- controller.setProductEntry();
-// controller.settingProduct2();
- controller.OppReflection();
- controller.PriceStatusUpdate();
- controller.SalesId1 = sellerA.id;
- controller.SalesId2 = sellerA.id;
- controller.getSalesId1();
- controller.getSalesId2();
- controller.cancel();
-
- Quote quoteAfterInsert = [SELECT OpportunityId, Pricebook2Id, Name, Quote_No__c, Unit_Price__c, Offer_Amount__c, TOTAL__c,
- Discount__c, Pricing__c, Preferential_Trading_Price__c, Contract__c, Quote_Comment__c,
- QuoteName__c, Dealer_Final_Price__c, Quote_Adjust_Calculate__c, Quote_Adjust_Amount__c,
- OCM_Agent1_Price__c, Agent1_Agent2_Price__c
- FROM Quote WHERE Id = :quote.id];
- system.assertEquals( quote.OCM_Agent1_Price__c, quoteAfterInsert.OCM_Agent1_Price__c);
-
- controller.enableSales = false;
- controller.opp.Agency1__c = null;
- controller.quo.OCM_Agent1_Price__c = null;
- controller.opp.Agency2__c = null;
- controller.quo.Agent1_Agent2_Price__c = null;
- controller.quo.QuoteName__c = 'aaa';
- controller.quo.Dealer_Final_Price__c = 100;
- controller.quo.Quote_Adjust_Calculate__c = 100;
- controller.quo.Quote_Adjust_Amount__c = 10;
- controller.quo.Quote_Expiration_Date__c = date.today();
- controller.oppId = opp.id;
-// controller.PricebookId = pricebook.id;
- NewQuoteEntryController.QELine act = new NewQuoteEntryController.QELine(oli, 0);
-
- act.Asset_Model = '11111';
-
- act.pageObject.Quantity__c = 10;
- act.pageObject.UnitPrice = 100;
- act.pageObject.Subtotal__c = 1000;
- act.pageObject.PricebookEntryId = pE2.id;
- List<NewQuoteEntryController.QELine> actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- controller.activities = actList;
- controller.dataCheck();
- controller.quo.OCM_Agent1_Price_Page__c = 1243;
- controller.dataEntry();
- controller.QuoteDecision();
- controller.Print();
-
- actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- Add_Report.getProduct2(product2.id);
-
-// QELine(QELine tmp, Integer i) 闁㈡暟銈掋儐銈广儓
- actList = new List<NewQuoteEntryController.QELine>();
- act.Asset_Model = null;
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- Add_Report.getProduct2(product2.id);
-
-// dataCheckDecide闁㈡暟銈掋儊銈с儍銈�
- controller.enableSales = true;
- controller.QuoteDecision = false;
- controller.QuoteDecision();
- controller.Print();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
- }
- System.Test.stopTest();
-
-
- }
- //娴嬭瘯绋嬪簭 娴嬪璐� 绮剧悽鎶�鏈� wql 2021/02/20 start
- static testMethod void check_QuoteEntryController002() {
-
- RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
- Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
- hospital.RecordTypeId = recByoin.id;
- hospital.Site = '銉嗐偣銉堢梾闄㈤儴闁�';
- hospital.Alias_Name2__c = '銉嗐偣銉堢梾闄㈠垾鍚�';
- insert hospital;
-
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
- Account sellerA = new Account(Name = '璨╁2搴�');
- sellerA.RecordTypeId = recHanbaiten.id;
- sellerA.Hospital__c = hospital.id;
- insert sellerA;
-
- RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_KEIYAKU limit 1];
- Account contractA = new Account(Name = '*');
- contractA.RecordTypeId = recKeiyaku.id;
- contractA.Agent_Ref__c = sellerA.id;
- contractA.ParentId = sellerA.id;
- insert contractA;
-
- System.Test.startTest();
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
- Opportunity opp = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today());
- opp.Trade__c = '澶栬部';
- opp.CurrencyIsoCode = CurrencyIso;
- opp.Sales_Root__c = '璨╁2搴�';
- opp.StageName = '寮曞悎';
- opp.owner_not_automatically_update__c = true;
- opp.Fixed_Check__c = false;
- opp.Pricebook2Id = pricebook.id;
- opp.Purchase_Type__c = '涓�鑸紩鍚�';
- opp.Promise_Class__c = '澶栬部';
- opp.Fund_Basis__c = '鏀垮簻璩囬噾';
- opp.AccountId = contractA.id;
- opp.Hospital__c = contractA.id;
- opp.Agency1__c = sellerA.id;
- opp.Agency2__c = sellerA.id;
- opp.Wholesale_Price__c = 9000;
- insert opp;
-
- Product2 product1 = new Product2( Name = '11111');
- product1.SFDA_Status__c = '涓嶈';
- product1.Intra_Trade_List_RMB_1__c = 100;
- product1.Intra_Trade_List_RMB_Date1__c = date.today();
- product1.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product1.Intra_Trade_Cost_RMB_1__c = 200;
- product1.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product1.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product1.Manual_Entry__c = false;
- product1.Asset_Model_No__c = '11111';
- product1.MDM_Model_No__c = '11111';
- product1.ProductCode = 'OTV-SP1H-NA-12E';
- product1.Foreign_Trade_List_US_1__c = 200;
- product1.Foreign_Trade_List_US_Date1__c =date.today();
- product1.Foreign_Trade_List_US_End_Date1__c =date.today().addDays(1);
- product1.Foreign_Trade_Cost_US_1__c = 200;
- product1.Foreign_Trade_Cost_US_Date1__c =date.today();
- product1.Foreign_Trade_Cost_US_End_Date1__c=date.today().addDays(1);
- product1.LastbuyProductFLG__c=true;
- insert product1;
- system.debug('##product.Id=[' + product1.Id + ']' );
-
- Product2 product2 = new Product2( Name = '11112');
- product2.SFDA_Status__c = '涓嶈';
- product2.Intra_Trade_List_RMB_Date1__c = date.today();
- product2.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product2.Intra_Trade_Cost_RMB_1__c = 200;
- product2.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product2.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product2.Manual_Entry__c = false;
- product2.Asset_Model_No__c = '11112';
- product2.MDM_Model_No__c = '11112';
-// product2.ProductCode = 'OTV-SP1H-NA-12E';
- product2.Foreign_Trade_List_US_1__c = 200;
- product2.Foreign_Trade_List_US_Date1__c =date.today();
- product2.Foreign_Trade_List_US_End_Date1__c =date.today().addDays(1);
- product2.Foreign_Trade_Cost_US_1__c = 200;
- product2.Foreign_Trade_Cost_US_Date1__c =date.today();
- product2.Foreign_Trade_Cost_US_End_Date1__c=date.today().addDays(1);
- product2.LastbuyProductFLG__c=true;
- insert product2;
- system.debug('##product1.Id=[' + product1.Id + ']' );
- system.debug('##product2.Id=[' + product2.Id + ']' );
-
- PricebookEntry pE = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
-
- pE.UnitPrice = 0;
- pE.IsActive = true;
- pE.UseStandardPrice = false;
- pE.CurrencyIsoCode = 'USD';
- //pE.
- insert pE;
- system.debug('##pE=[' + pE + ']' );
- PricebookEntry pE2 = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product2.Id);
-
- pE2.UnitPrice = 0;
- pE2.IsActive = true;
- pE2.UseStandardPrice = false;
- pE2.CurrencyIsoCode = 'USD';
- //pE.
- insert pE2;
-
- OpportunityLineItem oli = new OpportunityLineItem();
- //target.QuoteId = input.Id;
- oli.Quantity = 1;
-// target.TotalPrice = 100;
- oli.UnitPrice = 10;
- oli.PricebookEntryId = pE.Id;
- oli.OpportunityId = opp.id;
- oli.Cost__c = 100;
- //oli.op
- insert oli;
-
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- quote.QuoteName__c = '銉嗐偣銉堣绌�';
- quote.Dealer_Final_Price__c = 100;
- quote.Quote_Adjust_Calculate__c = 10;
- quote.Quote_Adjust_Amount__c = 10;
- quote.OCM_Agent1_Price__c = 10;
- quote.Agent1_Agent2_Price__c = 10;
-
- insert quote;
- //棰勭暀浜у搧
- QuoteLineItem qa=new QuoteLineItem();
- qa.Name__c = '銉嗐偣銉堝晢鍝�';
- qa.QuoteId = quote.Id;
- qa.Quantity = 3;
- qa.Cost_Subtotal__c = 0;
- qa.Cost__c = 200;
- qa.UnitPrice = 10;
- qa.PricebookEntryId = pE.Id;
- qa.Id__c=pE.Product2Id;
- // target.TotalPrice = 100;
-
- insert qa;
- QuoteLineItem qb=new QuoteLineItem();
- qb.Name__c = '銉嗐偣銉堝晢鍝�';
- qb.QuoteId = quote.Id;
- qb.Quantity = 3;
- qb.Cost_Subtotal__c = 0;
- qb.Cost__c = 200;
- qb.UnitPrice = 10;
- qb.PricebookEntryId = pE2.Id;
- qb.Id__c=pE2.Product2Id;
-
- List<Id> QuoteLineItemList = new List<Id>();
- QuoteLineItemList.add(qa.Id);
- QuoteLineItemList.add(qb.Id);
- // List<QuoteLineItem> QuoteLineItemListss=[Select Id,Id__c, Asset_Model_No__c, SFDA_Status__c, Product_Sales_Possibility__c,
- // //CHAN-BKU3XH 妫�鏌ユ槸鍚﹀瓨鍦ㄤ笉鏄悓涓�涓緵閿�鍟嗗悕绉� 绮剧悽鎶�鏈� 2020/02/17 Start 澧炲姞瀛楁 涓嶅彲鍙栨秷澶氬勾淇�&&澧炲姞妫�绱㈤樋瑗胯禌澶� 2020/09/10
- // Name__c, BSS_Category__c, Quote.Quote_Print_Date__c,PricebookEntry.Product2.VenderName__c,PricebookEntry.Product2.CanNotCancelledGurantee__c,PricebookEntry.Product2.Is_DangerousChemicals__c,
- // //CHAN-BKU3XH 妫�鏌ユ槸鍚﹀瓨鍦ㄤ笉鏄悓涓�涓緵閿�鍟嗗悕绉� 绮剧悽鎶�鏈� 2020/02/17 end 澧炲姞瀛楁
- // Qty_Unit__c, Cost__c, UnitPrice__c, ListPrice__c, Quantity, TotalPrice__c,
- // PricebookEntry.Product2.SFDA_Status__c, ProductCode__c, Product_Cost__c, Product_ListPrice__c, PricebookEntry.Product2.Sales_Possibility__c, PricebookEntry.Product2.Name,
- // PricebookEntryId, PricebookEntry.Product2Id, UnitPrice_Page__c, PricebookEntry.Product2.Packing_list_manual__c, PricebookEntry.Product2.StorageStatus__c
- // , AgencyUnitPrice__c, AgencySubtotal__c, Present__c // CHAN-B4YAB8 2018/9/29 璧犻�併�佺粡閿�鍟嗗崟浠峰拰灏忚
- // // 澶氬勾淇濅慨 start
- // //ET淇冮攢鏍囪 start
- // , multiYearWarranty__c , If_Cancel_Guarantee__c , GuaranteePeriod__c,
- // //ET淇冮攢鏍囪 end
- // ServicePrice__c , GuranteePrice__c, ProductEntend_gurantee_period_all__c,
- // ProductGuranteePrice__c, GuranteeType__c,
- // warrantyType__c, productServicePrice__c, NoDiscountTotal__c
- // , provistonPeriod__c
- // , PricebookEntry.Product2.Entend_gurantee_period_all__c
- // , PricebookEntry.Product2.Intra_Trade_Gurantee_RMB__c
- // , PricebookEntry.Product2.Intra_Trade_Service_RMB__c
- // , PricebookEntry.Product2.GuranteeType__c
- // // 缁翠慨鍚堝悓鎶ヤ环
- // , PricebookEntry.Product2.Maintenance_Price_Year__c
- // , Maintenance_Price_Year__c
- // // 澶氬勾淇濅慨 end
- // //澶栬锤澶氬勾淇� 2021/01/04 绮剧悽鎶�鏈� wql start
- // //缁翠慨鍚堝悓鎶ヤ环锛圲SD锛�
- // ,PricebookEntry.Product2.Repair_Contract_USD__c
- // //璁℃彁閲戦锛堜笉鍚◣锛孶SD锛�
- // ,PricebookEntry.Product2.Intra_Trade_Foreign_RMB__c
- // //NoDiscount 閲戦锛圲SD锛�
- // ,PricebookEntry.Product2.NoDiscount_Foreign__c
- // ,Quote.Opportunity.Trade__c
- // //澶栬锤澶氬勾淇� 2021/01/04 绮剧悽鎶�鏈� wql end
-
- // //SFDC鍋滄棰勮 lt 20211009 start
- // ,PricebookEntry.Product2.Estimated_ConsumptionDueDate__c
- // //SFDC鍋滄棰勮 lt 20211009 end
- // from QuoteLineItem where Id in :QuoteLineItemList];
-
- LastbuyProduct__c lbp=new LastbuyProduct__c();
- lbp.effectiveFLG__c=true;
- lbp.InquiryCode__c = opp.Id;
- lbp.ProductName__c = product1.Id;
- lbp.LastbuyQuantity__c=2;
- insert lbp;
-
- // 銈汇儍銉堝搧
- Product_Set__c ps1 = new Product_Set__c();
- ps1.Name = '銈汇儍銉堝搧锛�';
- ps1.Product_Set_CD__c = '111111';
- ps1.Description__c = '瑾槑';
- ps1.Qty__c = 10;
- //ps1.Valid__c = true;
- ps1.Valid_Date__c = date.today().addDays(-5);
- insert ps1;
-
- Product_Set_Detail__c psd1 = new Product_Set_Detail__c();
- psd1.Product_Set__c = ps1.id;
- psd1.Price__c = 100;
- psd1.Quantity__c = 10;
- psd1.Product__c = product1.id;
-
- insert psd1;
-
- //System.Test.startTest();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry');
- System.Test.setCurrentPage(page);
-
- Apexpages.currentPage().getParameters().put('oppid', opp.id);
- NewQuoteEntryController controller = new NewQuoteEntryController();
- //Apexpages.currentPage().getParameters().put('id', quote.id);
- controller.oppId = null;
- controller.quoId = null;
- controller.enableSales = false;
- controller.init();
- controller.dataCheck();
- controller.select_index = 0;
- controller.Product_text = product1.id;
- controller.setProduct_text = ps1.id;
- controller.setProductEntry();
-// controller.settingProduct2();
- controller.OppReflection();
- controller.PriceStatusUpdate();
- controller.SalesId1 = sellerA.id;
- controller.SalesId2 = sellerA.id;
- controller.getSalesId1();
- controller.getSalesId2();
- controller.cancel();
-
- Quote quoteAfterInsert = [SELECT OpportunityId, Pricebook2Id, Name, Quote_No__c, Unit_Price__c, Offer_Amount__c, TOTAL__c,
- Discount__c, Pricing__c, Preferential_Trading_Price__c, Contract__c, Quote_Comment__c,
- QuoteName__c, Dealer_Final_Price__c, Quote_Adjust_Calculate__c, Quote_Adjust_Amount__c,
- OCM_Agent1_Price__c, Agent1_Agent2_Price__c
- FROM Quote WHERE Id = :quote.id];
- system.assertEquals( quote.OCM_Agent1_Price__c, quoteAfterInsert.OCM_Agent1_Price__c);
-
- controller.enableSales = false;
- controller.opp.Agency1__c = null;
- controller.quo.OCM_Agent1_Price__c = null;
- controller.opp.Agency2__c = null;
- controller.quo.Agent1_Agent2_Price__c = null;
- controller.quo.QuoteName__c = 'aaa';
- controller.quo.Dealer_Final_Price__c = 100;
- controller.quo.Quote_Adjust_Calculate__c = 100;
- controller.quo.Quote_Adjust_Amount__c = 10;
- controller.quo.Quote_Expiration_Date__c = date.today();
- controller.oppId = opp.id;
-// controller.PricebookId = pricebook.id;
-
- NewQuoteEntryController.QELine act = new NewQuoteEntryController.QELine(oli, 0);
-
- act.Asset_Model = '11111';
-
- act.pageObject.Quantity__c = 10;
- act.pageObject.UnitPrice = 100;
- act.pageObject.Subtotal__c = 1000;
- act.pageObject.PricebookEntryId = pE2.id;
- system.debug('##act.pageObject=[' + act.pageObject + ']' );
- Integer ge=0;
- List<NewQuoteEntryController.QELine> actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- // for(QuoteLineItem qqq : QuoteLineItemListss){
- // NewQuoteEntryController.QELine act2 = new NewQuoteEntryController.QELine(qqq, 0,'');
- // if(ge== 0){
- // act2.Asset_Model = '11111';
- // }else if(ge== 1){
- // act2.Asset_Model = '22222';
- // }
- // act2.pageObject=qqq;
- // actList.add(act2);
- // }
- controller.activities = actList;
- controller.dataCheck();
- controller.quo.OCM_Agent1_Price_Page__c = 1243;
- controller.dataEntry();
- controller.QuoteDecision();
- controller.Print();
- //鎶ラ敊
- // controller.ReservedProductVerification();
- // String[] azzz=new String[] {'1','2'};
- // System.debug(azzz[3]);
- actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- Add_Report.getProduct2(product2.id);
-
-// QELine(QELine tmp, Integer i) 闁㈡暟銈掋儐銈广儓
- actList = new List<NewQuoteEntryController.QELine>();
- act.Asset_Model = null;
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- Add_Report.getProduct2(product2.id);
-
-// dataCheckDecide闁㈡暟銈掋儊銈с儍銈�
- controller.enableSales = true;
- controller.QuoteDecision = false;
- controller.QuoteDecision();
- controller.Print();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
- }
- System.Test.stopTest();
-
-
- }
-
- static testMethod void dataEntryTest() {
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
- StaticParameter.EscapeNFM001AgencyContractTrigger = true;
- StaticParameter.EscapeAccountTrigger = true;
- ControllerUtil.EscapeNFM001Trigger = true;
- Oly_TriggerHandler.bypass('PowerBIBaseHandler');
- StaticParameter.EscapeSyncOpportunityTrigger = true;
- StaticParameter.EscapeNFM007Trigger = true;
- StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true;
- Oly_TriggerHandler.bypass('AgencyOppUpdHandler');
- StaticParameter.EscapeSyncOpportunityTrigger = true;
- StaticParameter.EscapeSyncProduct2Trigger = true;
- Oly_TriggerHandler.bypass('PowerBIBaseHandler');
-
- RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
- Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
- hospital.RecordTypeId = recByoin.id;
- hospital.Site = '銉嗐偣銉堢梾闄㈤儴闁�';
- hospital.Alias_Name2__c = '銉嗐偣銉堢梾闄㈠垾鍚�';
- insert hospital;
-
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
- Account sellerA = new Account(Name = '璨╁2搴�');
- sellerA.RecordTypeId = recHanbaiten.id;
- sellerA.Hospital__c = hospital.id;
- insert sellerA;
-
- RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_KEIYAKU limit 1];
- Account contractA = new Account(Name = '*');
- contractA.RecordTypeId = recKeiyaku.id;
- contractA.Agent_Ref__c = sellerA.id;
- contractA.ParentId = sellerA.id;
- insert contractA;
-
- Opportunity opp = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today());
- opp.Trade__c = '鍐呰部';
- opp.CurrencyIsoCode = CurrencyIso;
- opp.Sales_Root__c = '璨╁2搴�';
- opp.StageName = '寮曞悎';
- opp.Fixed_Check__c = false;
- opp.owner_not_automatically_update__c = true;
- opp.Pricebook2Id = pricebook.id;
- opp.Purchase_Type__c = '涓�鑸紩鍚�';
- opp.Promise_Class__c = '鍐呰部';
- opp.Fund_Basis__c = '鏀垮簻璩囬噾';
- opp.AccountId = contractA.id;
- opp.Hospital__c = contractA.id;
- opp.Agency1__c = sellerA.id;
- opp.Agency2__c = sellerA.id;
- opp.Wholesale_Price__c = 9000;
- opp.Competitor__c = 'A1';
- insert opp;
-
- Product2 product1 = new Product2( Name = '11111');
- product1.SFDA_Status__c = '涓嶈';
- product1.Intra_Trade_List_RMB_1__c = 100;
- product1.Intra_Trade_List_RMB_Date1__c = date.today();
- product1.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product1.Intra_Trade_Cost_RMB_1__c = 200;
- product1.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product1.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product1.Manual_Entry__c = false;
- product1.Asset_Model_No__c = '11111';
- product1.MDM_Model_No__c = '11111';
- product1.ProductCode = 'OTV-SP1H-NA-12E';
- insert product1;
- system.debug('##product.Id=[' + product1.Id + ']' );
-
- Product2 product2 = new Product2( Name = '11112');
- product2.SFDA_Status__c = '涓嶈';
- product2.Intra_Trade_List_RMB_1__c = 100;
- product2.Intra_Trade_List_RMB_Date1__c = date.today();
- product2.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product2.Intra_Trade_Cost_RMB_1__c = 200;
- product2.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product2.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product2.Manual_Entry__c = false;
- product2.Asset_Model_No__c = '11112';
- product2.MDM_Model_No__c = '11112';
-// product2.ProductCode = 'OTV-SP1H-NA-12E';
- insert product2;
- system.debug('##product1.Id=[' + product1.Id + ']' );
- system.debug('##product2.Id=[' + product2.Id + ']' );
-
- PricebookEntry pE = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
-
- pE.UnitPrice = 0;
- pE.IsActive = true;
- pE.UseStandardPrice = false;
- pE.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE;
-
- PricebookEntry pE2 = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product2.Id);
-
- pE2.UnitPrice = 0;
- pE2.IsActive = true;
- pE2.UseStandardPrice = false;
- pE2.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE2;
-
- OpportunityLineItem oli = new OpportunityLineItem();
- //target.QuoteId = input.Id;
- oli.Quantity = 1;
-// target.TotalPrice = 100;
- oli.UnitPrice = 10;
- oli.PricebookEntryId = pE.Id;
- oli.OpportunityId = opp.id;
- oli.Cost__c = 100;
- //oli.op
- insert oli;
-
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- quote.QuoteName__c = '銉嗐偣銉堣绌�';
- quote.Dealer_Final_Price__c = 100;
- quote.Quote_Adjust_Calculate__c = 10;
- quote.Quote_Adjust_Amount__c = 10;
- quote.OCM_Agent1_Price__c = 10;
- quote.Agent1_Agent2_Price__c = 10;
-
- insert quote;
-
- // 銈汇儍銉堝搧
- Product_Set__c ps1 = new Product_Set__c();
- ps1.Name = '銈汇儍銉堝搧锛�';
- ps1.Product_Set_CD__c = '111111';
- ps1.Description__c = '瑾槑';
- ps1.Qty__c = 10;
- //ps1.Valid__c = true;
- ps1.Valid_Date__c = date.today().addDays(-5);
- insert ps1;
-
- Product_Set_Detail__c psd1 = new Product_Set_Detail__c();
- psd1.Product_Set__c = ps1.id;
- psd1.Price__c = 100;
- psd1.Quantity__c = 10;
- psd1.Product__c = product1.id;
-
- insert psd1;
- System.Test.startTest();
- //System.Test.startTest();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- // NewQuoteEntryController.QELine sqline = new NewQuoteEntryController.QELine(2, 'String VenderName', 'String ProductSetName', pE.id, 'String Asset_Model', 'String StorageStatus', ' String ProductCode', 'String Id_c', 'String SFDA_Status_c', 'String Sales_Possibility_c', 'String Name_c', 'String BSS_Category_c', 2, 123, 21, 312, 123, 1.1, 1.1, '', 1.1,0);
- PageReference page = new PageReference('/apex/NewQuoteEntry');
- System.Test.setCurrentPage(page);
-
- Apexpages.currentPage().getParameters().put('oppid', opp.id);
- NewQuoteEntryController controller = new NewQuoteEntryController();
- //Apexpages.currentPage().getParameters().put('id', quote.id);
- controller.oppId = null;
- controller.quoId = null;
- controller.enableSales = false;
-//System.Test.startTest();
- controller.init();
- controller.dataCheck();
- controller.select_index = 0;
- controller.Product_text = product1.id;
- controller.setProduct_text = ps1.id;
- controller.setProductEntry();
-// controller.settingProduct2();
- controller.OppReflection();
- controller.PriceStatusUpdate();
- controller.SalesId1 = sellerA.id;
- controller.SalesId2 = sellerA.id;
- controller.getSalesId1();
- controller.getSalesId2();
- controller.cancel();
-
- Quote quoteAfterInsert = [SELECT OpportunityId, Pricebook2Id, Name, Quote_No__c, Unit_Price__c, Offer_Amount__c, TOTAL__c,
- Discount__c, Pricing__c, Preferential_Trading_Price__c, Contract__c, Quote_Comment__c,
- QuoteName__c, Dealer_Final_Price__c, Quote_Adjust_Calculate__c, Quote_Adjust_Amount__c,
- OCM_Agent1_Price__c, Agent1_Agent2_Price__c
- FROM Quote WHERE Id = :quote.id];
- system.assertEquals( quote.OCM_Agent1_Price__c, quoteAfterInsert.OCM_Agent1_Price__c);
-
- controller.enableSales = false;
- controller.opp.Agency1__c = null;
- controller.quo.OCM_Agent1_Price__c = null;
- controller.opp.Agency2__c = null;
- controller.quo.Agent1_Agent2_Price__c = null;
- controller.quo.QuoteName__c = 'aaa';
- controller.quo.Dealer_Final_Price_Page__c = 100;
- controller.quo.Dealer_Final_Price__c = 100;
- controller.qb.Quote_Adjust_Calculate = 100;
- controller.quo.Quote_Adjust_Calculate__c = 100;
- controller.quo.Quote_Adjust_Amount_Page__c = 10;
- controller.quo.Quote_Adjust_Amount__c = 10;
- controller.quo.Quote_Expiration_Date__c = date.today();
- controller.oppId = opp.id;
-// controller.PricebookId = pricebook.id;
- NewQuoteEntryController.QELine act = new NewQuoteEntryController.QELine(oli, 0);
-
- act.Asset_Model = '11111';
-
- act.pageObject.Quantity__c = 10;
- act.pageObject.UnitPrice_Page__c = 100;
- act.pageObject.UnitPrice = 100;
- act.pageObject.Subtotal__c = 1000;
- act.pageObject.PricebookEntryId = pE2.id;
- act.pageObject.Id__c = product2.id;
- List<NewQuoteEntryController.QELine> actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- controller.activities = actList;
- controller.save();
- //controller.dataEntry();
- //controller.dataCheck();
- controller.QuoteDecision();
- controller.Print();
-
- actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- Add_Report.getProduct2(product2.id);
-
-// QELine(QELine tmp, Integer i) 闁㈡暟銈掋儐銈广儓
- actList = new List<NewQuoteEntryController.QELine>();
- act.Asset_Model = null;
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- System.Test.stopTest();
- Add_Report.getProduct2(product2.id);
-
-// dataCheckDecide闁㈡暟銈掋儊銈с儍銈�
- controller.enableSales = true;
- controller.QuoteDecision = false;
- controller.QuoteDecision();
- controller.Print();
- controller.testI();
- controller.getHiddenSaveBtn();
- controller.rowIdx = 10;
- controller.addRow();
- controller.PriceStatusUpdate();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
-
- //System.Test.stopTest();
- }
- }
-
- //娴嬭瘯闃胯タ璧涘 娴嬭瘯绋嬪簭 绮剧悽鎶�鏈� wql 2021/02/20 start
- static testMethod void check_QuoteEntryController003() {
-
- RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
- Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
- hospital.RecordTypeId = recByoin.id;
- hospital.Site = '銉嗐偣銉堢梾闄㈤儴闁�';
- hospital.Alias_Name2__c = '銉嗐偣銉堢梾闄㈠垾鍚�';
- insert hospital;
-
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
- Account sellerA = new Account(Name = '璨╁2搴�');
- sellerA.RecordTypeId = recHanbaiten.id;
- sellerA.Hospital__c = hospital.id;
- insert sellerA;
-
- RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_KEIYAKU limit 1];
- Account contractA = new Account(Name = '*');
- contractA.RecordTypeId = recKeiyaku.id;
- contractA.Agent_Ref__c = sellerA.id;
- contractA.ParentId = sellerA.id;
- insert contractA;
-
- System.Test.startTest();
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
- Opportunity opp = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today());
- opp.Trade__c = '鍐呰部';
- opp.CurrencyIsoCode = CurrencyIso;
- opp.Sales_Root__c = '璨╁2搴�';
- opp.StageName = '寮曞悎';
- opp.owner_not_automatically_update__c = true;
- opp.Fixed_Check__c = false;
- opp.Pricebook2Id = pricebook.id;
- opp.Purchase_Type__c = '涓�鑸紩鍚�';
- opp.Promise_Class__c = '鍐呰部';
- opp.Fund_Basis__c = '鏀垮簻璩囬噾';
- opp.AccountId = hospital.id;
- opp.Hospital__c = contractA.id;
- opp.Agency1__c = sellerA.id;
- opp.Agency2__c = sellerA.id;
- opp.Wholesale_Price__c = 9000;
- //闃胯タ璧涘
- opp.Is_Corrosion__c = true;
- opp.Purchase_Type__c ='ET24鏅傞枔璨╁2';
- opp.SAP_Province__c='涓婃捣甯�';
- insert opp;
-
- Product2 product1 = new Product2( Name = '11111');
- product1.SFDA_Status__c = '涓嶈';
- product1.Intra_Trade_List_RMB_1__c = 100;
- product1.Intra_Trade_List_RMB_Date1__c = date.today();
- product1.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product1.Intra_Trade_Cost_RMB_1__c = 200;
- product1.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product1.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product1.Manual_Entry__c = false;
- product1.Asset_Model_No__c = '11111';
- product1.MDM_Model_No__c = '11111';
- product1.ProductCode = 'OTV-SP1H-NA-12E';
- product1.Is_DangerousChemicals__c = true;
- insert product1;
- system.debug('##product.Id=[' + product1.Id + ']' );
-
- Product2 product2 = new Product2( Name = '11112');
- product2.SFDA_Status__c = '涓嶈';
- product2.Intra_Trade_List_RMB_Date1__c = date.today();
- product2.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product2.Intra_Trade_Cost_RMB_1__c = 200;
- product2.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product2.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product2.Manual_Entry__c = false;
- product2.Asset_Model_No__c = '11112';
- product2.MDM_Model_No__c = '11112';
- product2.Is_DangerousChemicals__c = true;
-// product2.ProductCode = 'OTV-SP1H-NA-12E';
- insert product2;
- system.debug('##product1.Id=[' + product1.Id + ']' );
- system.debug('##product2.Id=[' + product2.Id + ']' );
-
- PricebookEntry pE = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
-
- pE.UnitPrice = 0;
- pE.IsActive = true;
- pE.UseStandardPrice = false;
- pE.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE;
-
- PricebookEntry pE2 = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product2.Id);
-
- pE2.UnitPrice = 0;
- pE2.IsActive = true;
- pE2.UseStandardPrice = false;
- pE2.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE2;
-
- OpportunityLineItem oli = new OpportunityLineItem();
- //target.QuoteId = input.Id;
- oli.Quantity = 1;
-// target.TotalPrice = 100;
- oli.UnitPrice = 10;
- oli.PricebookEntryId = pE.Id;
- oli.OpportunityId = opp.id;
- oli.Cost__c = 100;
-
- insert oli;
-
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- quote.QuoteName__c = '銉嗐偣銉堣绌�';
- quote.Dealer_Final_Price__c = 100;
- quote.Quote_Adjust_Calculate__c = 10;
- quote.Quote_Adjust_Amount__c = 10;
- quote.OCM_Agent1_Price__c = 10;
- quote.Agent1_Agent2_Price__c = 10;
- quote.Agency1__c =sellerA.id;
- quote.Agency2__c =sellerA.id;
-
- insert quote;
-
- // 銈汇儍銉堝搧
- Product_Set__c ps1 = new Product_Set__c();
- ps1.Name = '銈汇儍銉堝搧锛�';
- ps1.Product_Set_CD__c = '111111';
- ps1.Description__c = '瑾槑';
- ps1.Qty__c = 10;
- //ps1.Valid__c = true;
- ps1.Valid_Date__c = date.today().addDays(-5);
- insert ps1;
-
- Product_Set_Detail__c psd1 = new Product_Set_Detail__c();
- psd1.Product_Set__c = ps1.id;
- psd1.Price__c = 100;
- psd1.Quantity__c = 10;
- psd1.Product__c = product1.id;
-
- insert psd1;
-
- //System.Test.startTest();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry');
- System.Test.setCurrentPage(page);
-
- Apexpages.currentPage().getParameters().put('oppid', opp.id);
- NewQuoteEntryController controller = new NewQuoteEntryController();
- //Apexpages.currentPage().getParameters().put('id', quote.id);
- // controller.oppId = opp.id;
- // controller.quoId = quote.id;
- controller.oppId = null;
- controller.quoId = null;
- controller.enableSales = false;
- controller.init();
- //system.assertEquals( opp.Agency1__c,sellerA.id );
-
- controller.dataCheck();
- controller.select_index = 0;
- controller.Product_text = product1.id;
- controller.setProduct_text = ps1.id;
- controller.setProductEntry();
-// controller.settingProduct2();
- controller.OppReflection();
- controller.PriceStatusUpdate();
- controller.SalesId1 = sellerA.id;
- controller.SalesId2 = sellerA.id;
- controller.getSalesId1();
- controller.getSalesId2();
- controller.cancel();
- controller.quo.QuoteName__c = 'aaa';
- controller.quo.Dealer_Final_Price_Page__c = 100;
- controller.quo.Dealer_Final_Price__c = 100;
- controller.qb.Quote_Adjust_Calculate = 100;
- controller.quo.Quote_Adjust_Calculate__c = 100;
- controller.quo.Quote_Adjust_Amount_Page__c = 10;
- controller.quo.Quote_Adjust_Amount__c = 10;
- controller.quo.Quote_Expiration_Date__c = date.today();
- controller.opp.Agency1__c = sellerA.id;
- //controller.quo.Agency1__c = sellerA.id;
- controller.oppId = opp.id;
-
- Quote quoteAfterInsert = [SELECT OpportunityId, Pricebook2Id, Name, Quote_No__c, Unit_Price__c, Offer_Amount__c, TOTAL__c,
- Discount__c, Pricing__c, Preferential_Trading_Price__c, Contract__c, Quote_Comment__c,
- QuoteName__c, Dealer_Final_Price__c, Quote_Adjust_Calculate__c, Quote_Adjust_Amount__c,
- OCM_Agent1_Price__c, Agent1_Agent2_Price__c
- FROM Quote WHERE Id = :quote.id];
- system.assertEquals( quote.OCM_Agent1_Price__c, quoteAfterInsert.OCM_Agent1_Price__c);
-
- controller.enableSales = false;
- controller.opp.Agency1__c = sellerA.id;
- controller.quo.OCM_Agent1_Price__c = 100;
- controller.opp.Agency2__c = sellerA.id;
- controller.quo.Agent1_Agent2_Price__c = 100;
- controller.quo.QuoteName__c = 'aaa';
- controller.quo.Dealer_Final_Price__c = 100;
- controller.quo.Quote_Adjust_Calculate__c = 100;
- controller.quo.Quote_Adjust_Amount__c = 10;
- controller.quo.Quote_Expiration_Date__c = date.today();
- controller.oppId = opp.id;
-// controller.PricebookId = pricebook.id;
- NewQuoteEntryController.QELine act = new NewQuoteEntryController.QELine(oli, 0);
-
- act.Asset_Model = '11111';
-
- act.pageObject.Quantity__c = 10;
- act.pageObject.UnitPrice = 100;
- act.pageObject.Subtotal__c = 1000;
- act.pageObject.PricebookEntryId = pE2.id;
- act.pageObject.SFDA_Status__c = '鏈夊姽';
- act.pageObject.UnitPrice_Page__c = 100;
- act.pageObject.AgencyUnitPrice__c = 100;
- List<NewQuoteEntryController.QELine> actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- controller.activities = actList;
- controller.dataCheck();
- controller.quo.OCM_Agent1_Price_Page__c = 1243;
- controller.dataEntry();
- controller.opp.Agency1__c = sellerA.id;
- controller.quo.OCM_Agent1_Price__c = 100;
- controller.opp.Agency2__c = sellerA.id;
- controller.quo.Agent1_Agent2_Price__c = 100;
- controller.Save();
- controller.QuoteDecision();
- //system.assertEquals( opp.Agency1__c,sellerA.id );
- controller.Print();
-
- actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- Add_Report.getProduct2(product2.id);
-
-// QELine(QELine tmp, Integer i) 闁㈡暟銈掋儐銈广儓
- actList = new List<NewQuoteEntryController.QELine>();
- act.Asset_Model = null;
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- Add_Report.getProduct2(product2.id);
-
-// dataCheckDecide闁㈡暟銈掋儊銈с儍銈�
- controller.enableSales = true;
- controller.QuoteDecision = false;
- controller.QuoteDecision();
- controller.Print();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
- }
- System.Test.stopTest();
-
-
- }
- //娴嬭瘯闃胯タ璧涘 娴嬭瘯绋嬪簭 绮剧悽鎶�鏈� wql 2021/02/20 end
-
- //20211015 lt start
- static testMethod void check_QuoteEntryController004() {
-
- RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
- Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
- hospital.RecordTypeId = recByoin.id;
- hospital.Site = '銉嗐偣銉堢梾闄㈤儴闁�';
- hospital.Alias_Name2__c = '銉嗐偣銉堢梾闄㈠垾鍚�';
- insert hospital;
-
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
- Account sellerA = new Account(Name = '璨╁2搴�');
- sellerA.RecordTypeId = recHanbaiten.id;
- sellerA.Hospital__c = hospital.id;
- insert sellerA;
-
- RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_KEIYAKU limit 1];
- Account contractA = new Account(Name = '*');
- contractA.RecordTypeId = recKeiyaku.id;
- contractA.Agent_Ref__c = sellerA.id;
- contractA.ParentId = sellerA.id;
- insert contractA;
-
- System.Test.startTest();
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
- Opportunity opp = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today());
- opp.Trade__c = '鍐呰部';
- opp.CurrencyIsoCode = CurrencyIso;
- opp.Sales_Root__c = '璨╁2搴�';
- opp.StageName = '寮曞悎';
- opp.owner_not_automatically_update__c = true;
- opp.Fixed_Check__c = false;
- opp.Pricebook2Id = pricebook.id;
- opp.Purchase_Type__c = '涓�鑸紩鍚�';
- opp.Promise_Class__c = '鍐呰部';
- opp.Fund_Basis__c = '鏀垮簻璩囬噾';
- opp.AccountId = hospital.id;
- //opp.Hospital__c = contractA.id;
- opp.Agency1__c = sellerA.id;
- opp.Agency2__c = sellerA.id;
- opp.Wholesale_Price__c = 9000;
- //闃胯タ璧涘
- opp.Is_Corrosion__c = true;
- opp.Purchase_Type__c ='ET24鏅傞枔璨╁2';
- opp.SAP_Province__c='涓婃捣甯�';
-
- opp.Authorized_Finish_Sales__c = '111'; //20211019
-
- insert opp;
-
- Product2 product1 = new Product2( Name = '11111');
- product1.SFDA_Status__c = '涓嶈';
- product1.Intra_Trade_List_RMB_1__c = 100;
- product1.Intra_Trade_List_RMB_Date1__c = date.today();
- product1.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product1.Intra_Trade_Cost_RMB_1__c = 200;
- product1.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product1.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product1.Manual_Entry__c = false;
- product1.Asset_Model_No__c = '11111';
- product1.MDM_Model_No__c = '11111';
- product1.ProductCode = 'OTV-SP1H-NA-12E';
- product1.Is_DangerousChemicals__c = true;
- insert product1;
- system.debug('##product.Id=[' + product1.Id + ']' );
-
- Product2 product2 = new Product2( Name = '11112');
- product2.SFDA_Status__c = '涓嶈';
- product2.Intra_Trade_List_RMB_Date1__c = date.today();
- product2.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product2.Intra_Trade_Cost_RMB_1__c = 200;
- product2.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product2.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product2.Manual_Entry__c = false;
- product2.Asset_Model_No__c = '11112';
- product2.MDM_Model_No__c = '11112';
- product2.Is_DangerousChemicals__c = true;
-// product2.ProductCode = 'OTV-SP1H-NA-12E';
- insert product2;
- system.debug('##product1.Id=[' + product1.Id + ']' );
- system.debug('##product2.Id=[' + product2.Id + ']' );
-
- PricebookEntry pE = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
-
- pE.UnitPrice = 0;
- pE.IsActive = true;
- pE.UseStandardPrice = false;
- pE.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE;
-
- PricebookEntry pE2 = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product2.Id);
-
- pE2.UnitPrice = 0;
- pE2.IsActive = true;
- pE2.UseStandardPrice = false;
- pE2.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE2;
-
- OpportunityLineItem oli = new OpportunityLineItem();
- //target.QuoteId = input.Id;
- oli.Quantity = 1;
-// target.TotalPrice = 100;
- oli.UnitPrice = 10;
- oli.PricebookEntryId = pE.Id;
- oli.OpportunityId = opp.id;
- oli.Cost__c = 100;
-
- insert oli;
-
- //quote.Quote_No__c = quoteNo;
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = opp.Opportunity_No__c+'-01';
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- quote.QuoteName__c = '銉嗐偣銉堣绌�';
- quote.Dealer_Final_Price__c = 100;
- quote.Quote_Adjust_Calculate__c = 10;
- quote.Quote_Adjust_Amount__c = 10;
- quote.OCM_Agent1_Price__c = 10;
- quote.Agent1_Agent2_Price__c = 10;
- quote.Agency1__c =sellerA.id;
- quote.Agency2__c =sellerA.id;
- //quote.DeveloperName = 'SI_Oppor'; //20211019
-
- insert quote;
-
- Quote quote1 = new Quote( Name = '銉嗐偣銉堣绌�');
- quote1.OpportunityId = opp.Id;
- quote1.Pricebook2Id = pricebook.id;
- //quote1.Quote_No__c = quoteNo;
- quote1.Unit_Price__c = isUnitPrice;
- quote1.Offer_Amount__c = isOfferAmount;
- quote1.TOTAL__c = isTotalPrice;
- quote1.Discount__c = isDiscountRate;
- quote1.Pricing__c = isDiscountAmount;
- quote1.Preferential_Trading_Price__c = isTradingPrice;
- quote1.Contract__c = isContractDetail;
- quote1.Quote_Comment__c = offerComment;
- quote1.QuoteName__c = '銉嗐偣銉堣绌�';
- quote1.Dealer_Final_Price__c = 100;
- quote1.Quote_Adjust_Calculate__c = 10;
- quote1.Quote_Adjust_Amount__c = 10;
- quote1.OCM_Agent1_Price__c = 10;
- quote1.Agent1_Agent2_Price__c = 10;
- quote1.Agency1__c =sellerA.id;
- quote1.Agency2__c =sellerA.id;
-
- insert quote1;
-
- // 銈汇儍銉堝搧
- Product_Set__c ps1 = new Product_Set__c();
- ps1.Name = '銈汇儍銉堝搧锛�';
- ps1.Product_Set_CD__c = '111111';
- ps1.Description__c = '瑾槑';
- ps1.Qty__c = 10;
- //ps1.Valid__c = true;
- ps1.Valid_Date__c = date.today().addDays(-5);
- insert ps1;
-
- Product_Set_Detail__c psd1 = new Product_Set_Detail__c();
- psd1.Product_Set__c = ps1.id;
- psd1.Price__c = 100;
- psd1.Quantity__c = 10;
- psd1.Product__c = product1.id;
-
- insert psd1;
-
- //System.Test.startTest();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- PageReference page = new PageReference('/apex/NewQuoteEntry');
- System.Test.setCurrentPage(page);
-
- Apexpages.currentPage().getParameters().put('oppid', opp.id);
- NewQuoteEntryController controller = new NewQuoteEntryController();
-
- //Apexpages.currentPage().getParameters().put('id', quote.id);
- // controller.oppId = opp.id;
- // controller.quoId = quote.id;
- controller.oppId = null;
- controller.quoId = null;
- controller.enableSales = false;
- controller.init();
- //system.assertEquals( opp.Agency1__c,sellerA.id );
-
- controller.dataCheck();
- controller.select_index = 0;
- controller.Product_text = product1.id;
- controller.setProduct_text = ps1.id;
- controller.setProductEntry();
-// controller.settingProduct2();
- controller.OppReflection();
- controller.PriceStatusUpdate();
- controller.SalesId1 = sellerA.id;
- controller.SalesId2 = sellerA.id;
- controller.getSalesId1();
- controller.getSalesId2();
- controller.cancel();
- controller.quo.QuoteName__c = 'aaa';
- controller.quo.Dealer_Final_Price_Page__c = 100;
- controller.quo.Dealer_Final_Price__c = 100;
- controller.qb.Quote_Adjust_Calculate = 100;
- controller.quo.Quote_Adjust_Calculate__c = 100;
- controller.quo.Quote_Adjust_Amount_Page__c = 10;
- controller.quo.Quote_Adjust_Amount__c = 10;
- controller.quo.Quote_Expiration_Date__c = date.today();
- controller.opp.Agency1__c = sellerA.id;
- //controller.quo.Agency1__c = sellerA.id;
- controller.oppId = opp.id;
-
- Quote quoteAfterInsert = [SELECT OpportunityId, Pricebook2Id, Name, Quote_No__c, Unit_Price__c, Offer_Amount__c, TOTAL__c,
- Discount__c, Pricing__c, Preferential_Trading_Price__c, Contract__c, Quote_Comment__c,
- QuoteName__c, Dealer_Final_Price__c, Quote_Adjust_Calculate__c, Quote_Adjust_Amount__c,
- OCM_Agent1_Price__c, Agent1_Agent2_Price__c
- FROM Quote WHERE Id = :quote.id];
- system.assertEquals( quote.OCM_Agent1_Price__c, quoteAfterInsert.OCM_Agent1_Price__c);
-
- controller.enableSales = false;
- controller.opp.Agency1__c = sellerA.id;
- controller.quo.OCM_Agent1_Price__c = 100;
- controller.opp.Agency2__c = sellerA.id;
- controller.quo.Agent1_Agent2_Price__c = 100;
- controller.quo.QuoteName__c = 'aaa';
- controller.quo.Dealer_Final_Price__c = 100;
- controller.quo.Quote_Adjust_Calculate__c = 100;
- controller.quo.Quote_Adjust_Amount__c = 10;
- controller.quo.Quote_Expiration_Date__c = date.today();
- controller.oppId = opp.id;
-// controller.PricebookId = pricebook.id;
- NewQuoteEntryController.QELine act = new NewQuoteEntryController.QELine(oli, 0);
-
- act.Asset_Model = '11111';
-
- act.pageObject.Quantity__c = 10;
- act.pageObject.UnitPrice = 100;
- act.pageObject.Subtotal__c = 1000;
- act.pageObject.PricebookEntryId = pE2.id;
- act.pageObject.SFDA_Status__c = '鏈夊姽';
- act.pageObject.UnitPrice_Page__c = 100;
- act.pageObject.AgencyUnitPrice__c = 100;
- List<NewQuoteEntryController.QELine> actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- controller.activities = actList;
- controller.dataCheck();
- controller.quo.OCM_Agent1_Price_Page__c = 1243;
- controller.dataEntry();
- controller.opp.Agency1__c = sellerA.id;
- controller.quo.OCM_Agent1_Price__c = 100;
- controller.opp.Agency2__c = sellerA.id;
- controller.quo.Agent1_Agent2_Price__c = 100;
- controller.Save();
- controller.QuoteDecision();
- //system.assertEquals( opp.Agency1__c,sellerA.id );
- controller.Print();
-
- actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- Add_Report.getProduct2(product2.id);
-
- controller.Back();
- controller.Jump();
-
-
-// QELine(QELine tmp, Integer i) 闁㈡暟銈掋儐銈广儓
- actList = new List<NewQuoteEntryController.QELine>();
- //act.Asset_Model = null; //20211025
- act.Asset_Model = '123'; //20211025
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- Add_Report.getProduct2(product2.id);
-
-// dataCheckDecide闁㈡暟銈掋儊銈с儍銈�
- controller.enableSales = true;
- controller.QuoteDecision = true;
- controller.QuoteDecision();
- controller.Print();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
-
- }
- System.Test.stopTest();
-
-
- }
-
- static testMethod void dataEntryTest1() {
- Profile p = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin];
- User MacOwner = new User(Test_staff__c = true, Batch_User__c = true, LastName = 'hp1', FirstName = 'owner1', Alias = 'hp', CommunityNickname = 'hpOwner1', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com1', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
- system.runAs(MacOwner) {
- StaticParameter.EscapeNFM001AgencyContractTrigger = true;
- StaticParameter.EscapeAccountTrigger = true;
- ControllerUtil.EscapeNFM001Trigger = true;
- Oly_TriggerHandler.bypass('PowerBIBaseHandler');
- StaticParameter.EscapeSyncOpportunityTrigger = true;
- StaticParameter.EscapeNFM007Trigger = true;
- StaticParameter.EscapeOpportunityHpDeptUpdTrigger = true;
- Oly_TriggerHandler.bypass('AgencyOppUpdHandler');
- StaticParameter.EscapeSyncOpportunityTrigger = true;
- StaticParameter.EscapeSyncProduct2Trigger = true;
- Oly_TriggerHandler.bypass('PowerBIBaseHandler');
-
- RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
- Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
- hospital.RecordTypeId = recByoin.id;
- hospital.Site = '銉嗐偣銉堢梾闄㈤儴闁�';
- hospital.Alias_Name2__c = '銉嗐偣銉堢梾闄㈠垾鍚�';
- insert hospital;
-
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
- Account sellerA = new Account(Name = '璨╁2搴�');
- sellerA.RecordTypeId = recHanbaiten.id;
- sellerA.Hospital__c = hospital.id;
- insert sellerA;
-
- RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_KEIYAKU limit 1];
- Account contractA = new Account(Name = '*');
- contractA.RecordTypeId = recKeiyaku.id;
- contractA.Agent_Ref__c = sellerA.id;
- contractA.ParentId = sellerA.id;
- insert contractA;
-
- //20211025 lt
- Account ac = new Account();
- ac.name = '123';
- ac.ParentId = sellerA.id;
-
- insert ac;
- //20211025 lt
-
- Opportunity opp = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today());
- opp.Trade__c = '鍐呰部';
- opp.CurrencyIsoCode = CurrencyIso;
- opp.Sales_Root__c = '璨╁2搴�';
- opp.StageName = '寮曞悎';
- opp.Fixed_Check__c = false;
- opp.owner_not_automatically_update__c = true;
- opp.Pricebook2Id = pricebook.id;
- opp.Purchase_Type__c = '涓�鑸紩鍚�';
- opp.Promise_Class__c = '鍐呰部';
- opp.Fund_Basis__c = '鏀垮簻璩囬噾';
- opp.AccountId = sellerA.id; //20211025
- opp.AccountId = hospital.id;
- opp.Hospital__c = contractA.id;
- opp.Agency1__c = sellerA.id;
- opp.Agency2__c = sellerA.id;
- opp.Wholesale_Price__c = 9000;
- opp.Competitor__c = 'A1';
- opp.SAP_Province__c='涓婃捣甯�'; //20211022
- opp.Purchase_Type__c ='ET24鏅傞枔璨╁2'; //20211022
- opp.Is_Corrosion__c = false; //20211022
-
- opp.Authorized_Finish_Sales__c = '111'; //20211025
-
- insert opp;
-
- Product2 product1 = new Product2( Name = '11111');
- product1.SFDA_Status__c = '涓嶈';
- product1.Intra_Trade_List_RMB_1__c = 100;
- product1.Intra_Trade_List_RMB_Date1__c = date.today();
- product1.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product1.Intra_Trade_Cost_RMB_1__c = 200;
- product1.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product1.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product1.Manual_Entry__c = false;
- product1.Asset_Model_No__c = '11111';
- product1.MDM_Model_No__c = '11111';
- product1.ProductCode = 'OTV-SP1H-NA-12E';
- insert product1;
- system.debug('##product.Id=[' + product1.Id + ']' );
-
- Product2 product2 = new Product2( Name = '11112');
- product2.SFDA_Status__c = '涓嶈';
- product2.Intra_Trade_List_RMB_1__c = 100;
- product2.Intra_Trade_List_RMB_Date1__c = date.today();
- product2.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product2.Intra_Trade_Cost_RMB_1__c = 200;
- product2.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product2.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product2.Manual_Entry__c = false;
- product2.Asset_Model_No__c = '11112';
- product2.MDM_Model_No__c = '11112';
- // product2.ProductCode = 'OTV-SP1H-NA-12E';
- insert product2;
- system.debug('##product1.Id=[' + product1.Id + ']' );
- system.debug('##product2.Id=[' + product2.Id + ']' );
-
- PricebookEntry pE = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
-
- pE.UnitPrice = 0;
- pE.IsActive = true;
- pE.UseStandardPrice = false;
- pE.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE;
-
- PricebookEntry pE2 = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product2.Id);
-
- pE2.UnitPrice = 0;
- pE2.IsActive = true;
- pE2.UseStandardPrice = false;
- pE2.CurrencyIsoCode = CurrencyIso;
- //pE.
- insert pE2;
-
- OpportunityLineItem oli = new OpportunityLineItem();
- //target.QuoteId = input.Id;
- oli.Quantity = 1;
- // target.TotalPrice = 100;
- oli.UnitPrice = 10;
- oli.PricebookEntryId = pE.Id;
- oli.OpportunityId = opp.id;
- oli.Cost__c = 100;
- //oli.op
- insert oli;
-
- Quote quote = new Quote( Name = '銉嗐偣銉堣绌�');
- quote.OpportunityId = opp.Id;
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
- quote.Unit_Price__c = isUnitPrice;
- quote.Offer_Amount__c = isOfferAmount;
- quote.TOTAL__c = isTotalPrice;
- quote.Discount__c = isDiscountRate;
- quote.Pricing__c = isDiscountAmount;
- quote.Preferential_Trading_Price__c = isTradingPrice;
- quote.Contract__c = isContractDetail;
- quote.Quote_Comment__c = offerComment;
- quote.QuoteName__c = '銉嗐偣銉堣绌�';
- quote.Dealer_Final_Price__c = 100;
- quote.Quote_Adjust_Calculate__c = 10;
- quote.Quote_Adjust_Amount__c = 10;
- quote.OCM_Agent1_Price__c = 10;
- quote.Agent1_Agent2_Price__c = 10;
-
- insert quote;
-
- // 銈汇儍銉堝搧
- Product_Set__c ps1 = new Product_Set__c();
- ps1.Name = '銈汇儍銉堝搧锛�';
- ps1.Product_Set_CD__c = '111111';
- ps1.Description__c = '瑾槑';
- ps1.Qty__c = 10;
- //ps1.Valid__c = true;
- ps1.Valid_Date__c = date.today().addDays(-5);
- insert ps1;
-
- Product_Set_Detail__c psd1 = new Product_Set_Detail__c();
- psd1.Product_Set__c = ps1.id;
- psd1.Price__c = 100;
- psd1.Quantity__c = 10;
- psd1.Product__c = product1.id;
-
- insert psd1;
- System.Test.startTest();
- //System.Test.startTest();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�闁嬪
- // NewQuoteEntryController.QELine sqline = new NewQuoteEntryController.QELine(2, 'String VenderName', 'String ProductSetName', pE.id, 'String Asset_Model', 'String StorageStatus', ' String ProductCode', 'String Id_c', 'String SFDA_Status_c', 'String Sales_Possibility_c', 'String Name_c', 'String BSS_Category_c', 2, 123, 21, 312, 123, 1.1, 1.1, '', 1.1,0);
- PageReference page = new PageReference('/apex/NewQuoteEntry');
- System.Test.setCurrentPage(page);
-
- Apexpages.currentPage().getParameters().put('oppid', opp.id);
- NewQuoteEntryController controller = new NewQuoteEntryController();
- //Apexpages.currentPage().getParameters().put('id', quote.id);
- controller.oppId = null;
- controller.quoId = null;
- controller.enableSales = false;
- //System.Test.startTest();
- controller.init();
- controller.select_index = 0;
- controller.Product_text = product1.id;
- controller.setProduct_text = ps1.id;
- controller.setProductEntry();
- // controller.settingProduct2();
- controller.OppReflection();
- controller.PriceStatusUpdate();
- controller.SalesId1 = sellerA.id;
- controller.SalesId2 = sellerA.id;
- controller.getSalesId1();
- controller.getSalesId2();
- controller.cancel();
-
- Quote quoteAfterInsert = [SELECT OpportunityId, Pricebook2Id, Name, Quote_No__c, Unit_Price__c, Offer_Amount__c, TOTAL__c,
- Discount__c, Pricing__c, Preferential_Trading_Price__c, Contract__c, Quote_Comment__c,
- QuoteName__c, Dealer_Final_Price__c, Quote_Adjust_Calculate__c, Quote_Adjust_Amount__c,
- OCM_Agent1_Price__c, Agent1_Agent2_Price__c
- FROM Quote WHERE Id = :quote.id];
- system.assertEquals( quote.OCM_Agent1_Price__c, quoteAfterInsert.OCM_Agent1_Price__c);
-
- controller.enableSales = false;
- controller.opp.Agency1__c = null;
- controller.quo.OCM_Agent1_Price__c = null;
- controller.opp.Agency2__c = null;
- controller.quo.Agent1_Agent2_Price__c = null;
- controller.quo.QuoteName__c = 'aaa';
- controller.quo.Dealer_Final_Price_Page__c = 100;
- controller.quo.Dealer_Final_Price__c = 100;
- controller.qb.Quote_Adjust_Calculate = 100;
- controller.quo.Quote_Adjust_Calculate__c = 100;
- controller.quo.Quote_Adjust_Amount_Page__c = 10;
- controller.quo.Quote_Adjust_Amount__c = 10;
- controller.quo.Quote_Expiration_Date__c = date.today();
- controller.oppId = opp.id;
- // controller.PricebookId = pricebook.id;
- NewQuoteEntryController.QELine act = new NewQuoteEntryController.QELine(oli, 0);
-
- act.Asset_Model = '11111';
-
- act.pageObject.Quantity__c = 10;
- act.pageObject.UnitPrice_Page__c = 100;
- act.pageObject.UnitPrice = 100;
- act.pageObject.Subtotal__c = 1000;
- act.pageObject.PricebookEntryId = pE2.id;
- act.pageObject.Id__c = product2.id;
- List<NewQuoteEntryController.QELine> actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- controller.activities = actList;
- controller.save();
- //controller.dataEntry();
- //controller.dataCheck();
- controller.QuoteDecision();
- controller.Print();
-
- actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- Add_Report.getProduct2(product2.id);
-
- // QELine(QELine tmp, Integer i) 闁㈡暟銈掋儐銈广儓
- actList = new List<NewQuoteEntryController.QELine>();
- //act.Asset_Model = null; //20211025
- act.Asset_Model = '123'; //20211025
- actList.add(act);
- controller.activities = actList;
- controller.excel_text = 'OTV-SP1H-NA-12E\t1';
- controller.excelImport();
- System.Test.stopTest();
- Add_Report.getProduct2(product2.id);
-
- // dataCheckDecide闁㈡暟銈掋儊銈с儍銈�
- controller.enableSales = true;
- controller.QuoteDecision = true;
- controller.QuoteDecision();
- controller.Print();
- controller.testI();
- controller.getHiddenSaveBtn();
- controller.rowIdx = 10;
- controller.addMultipleRow();
- controller.PriceStatusUpdate();
- //##銉氥兗銈搞儑銉愩儍銈般偦銈偡銉с兂銆�绲備簡
-
- //System.Test.stopTest();
- }
- }
- //20211015 lt end
- static testMethod void dataEntryTest2() {
- RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_BYOUIN limit 1];
- Account hospital = new Account(Name = '銉嗐偣銉堢梾闄�');
- hospital.RecordTypeId = recByoin.id;
- hospital.Site = '銉嗐偣銉堢梾闄㈤儴闁�';
- hospital.Alias_Name2__c = '銉嗐偣銉堢梾闄㈠垾鍚�';
- insert hospital;
-
- RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
- Account sellerA = new Account(Name = '璨╁2搴�');
- sellerA.RecordTypeId = recHanbaiten.id;
- sellerA.Hospital__c = hospital.id;
- insert sellerA;
-
- Product2 product2 = new Product2( Name = '11112');
- product2.SFDA_Status__c = '涓嶈';
- product2.Intra_Trade_List_RMB_1__c = 100;
- product2.Intra_Trade_List_RMB_Date1__c = date.today();
- product2.Intra_Trade_List_RMB_End_Date1__c = date.today().addDays(1);
- product2.Intra_Trade_Cost_RMB_1__c = 200;
- product2.Intra_Trade_Cost_RMB_Date1__c = date.today();
- product2.Intra_Trade_Cost_RMB_End_Date1__c = date.today().addDays(1);
- product2.Manual_Entry__c = false;
- product2.Asset_Model_No__c = '11112';
- product2.MDM_Model_No__c = '11112';
- insert product2;
-
- PricebookEntry pE2 = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = product2.Id);
- pE2.UnitPrice = 0;
- pE2.IsActive = true;
- pE2.UseStandardPrice = false;
- pE2.CurrencyIsoCode = CurrencyIso;
- insert pE2;
-
- Opportunity opp1 = buildOppInstance( trade, CurrencyIso);
- opp1.Trade__c = trade;
- opp1.owner_not_automatically_update__c = true;
- opp1.Sales_Root__c = 'AAA';
- opp1.Pricebook2Id = pricebook.id;
- opp1.Estimation_Decision__c=true;
- insert opp1;
-
- OpportunityLineItem oli = new OpportunityLineItem();
- oli.Quantity = 1;
- oli.UnitPrice = 10;
- oli.PricebookEntryId = pE2.Id;
- oli.OpportunityId = opp1.id;
- oli.Cost__c = 100;
- insert oli;
-
- NewQuoteEntryController.QELine act = new NewQuoteEntryController.QELine(oli, 0);
- act.Asset_Model = '';
- act.pageObject.Quantity__c = 10;
- act.pageObject.UnitPrice = 100;
- act.pageObject.Subtotal__c = 1000;
- act.pageObject.PricebookEntryId = pE2.id;
- List<NewQuoteEntryController.QELine> actList = new List<NewQuoteEntryController.QELine>();
- actList.add(act);
-
NewQuoteEntryController controller = new NewQuoteEntryController();
- controller.oppId=opp1.Id;
- controller.enableSales=true;
- Quote quote=new Quote();
- quote.QuoteName__c = '銉嗐偣銉堣绌�';
- quote.Dealer_Final_Price_Page__c = 100;
- quote.Quote_Adjust_Amount_Page__c = 10;
- quote.Quote_Expiration_Date__c = date.today();
- quote.Agency1__c = sellerA.id;
- quote.OCM_Agent1_Price_Page__c = 1243;
- quote.OpportunityId = opp1.id;
- quote.Name ='銉嗐偣銉堣绌�';
- quote.Pricebook2Id = pricebook.id;
- quote.Quote_No__c = quoteNo;
- insert quote;
- system.debug('act2++++++++++'+pE2);
- QuoteLineItem item02 = new QuoteLineItem();
- item02.Name__c = '銉嗐偣銉堝晢鍝�';
- item02.QuoteId = quote.Id;
- item02.Quantity = 1;
- item02.Cost_Subtotal__c = 0;
- item02.Cost__c = 200;
- item02.UnitPrice = 10;
- item02.PricebookEntryId = pE2.Id;
- insert item02;
+ controller.init();
- // quote.QuoteName__c = '銉嗐偣銉堣绌�';
- // quote.QuoteName__c = '銉嗐偣銉堣绌�';
- controller.quo=quote;
- NewQuoteEntryController.QuoteBean qbs=new NewQuoteEntryController.QuoteBean();
- qbs.Quote_Adjust_Calculate = 100;
- controller.qb = qbs;
- controller.activities=actList;
- controller.opp=opp1;
- controller.dataEntry();
+ controller.quo.Name = '鎶ヤ环1';
+ controller.quo.PaymentTerms__c = 'ZTT1';
+ controller.quo.Shipment_Term__c = 'CIP';
+ controller.quo.Shipment_Term2__c = 'BEIJING';
+ controller.quo.DeliveryLeadTime__c = 90;
+ controller.quo.Warranty__c = 1;
+ controller.quo.ExpirationDate = Date.today();
+ controller.quo.Custom_Price_Total_Text__c = 1000;
+ controller.quo.Total_Price_Text__c = 922;
- NewQuoteEntryController.QELine act2 = new NewQuoteEntryController.QELine(oli, 0);
- act2.Asset_Model = '111111';
- act2.pageObject.Quantity__c = 1;
- act2.pageObject.UnitPrice_Page__c = 100;
- act2.pageObject.AgencyUnitPrice__c = 100;
- act2.pageObject.PricebookEntryId = pE2.id;
- List<NewQuoteEntryController.QELine> actList2 = new List<NewQuoteEntryController.QELine>();
- actList2.add(act2);
- system.debug('act2++++++++++'+act2);
- controller.activities=actList2;
- controller.standardPricebook = pricebook;
- for(NewQuoteEntryController.QELine aaa :controller.activities){
- aaa.Asset_Model = '111111';
- }
- system.debug('activities++++++++++'+controller.activities);
- NewQuoteEntryController.oppInfo opps = new NewQuoteEntryController.oppInfo(opp1);
+/* controller.activities[0].pageObject.PricebookEntryId = entry1.Id;
+ controller.activities[0].pageObject.Set__c = 'set01';
+ controller.activities[0].pageObject.UnitPrice = 11;
+ controller.activities[0].pageObject.Quantity = 1
+ controller.activities[0].pageObject.Discount = 0;
+ controller.activities[0].pageObject.Custom_Price__c = 20;
+ controller.activities[0].pageObject.Description = 'test1';*/
+ System.Test.StartTest();
+ controller.Save();
- controller.oppInfo = opps;
- controller.dataEntry();
+ //system.assertEquals('',controller.errormessage);
+
+ controller.excelImport();
+ controller.testI();
+ controller.OppReflection();
+
+ controller.BackBtn();
+
+ controller.Decide();
+
+ controller.UnDecide();
+ System.Test.StopTest();
}
+
+ //@isTest
+ static void test_init2() {
+ Id pricebookId = Test.getStandardPricebookId();
+
+ Pricebook2 pricebook = new Pricebook2(
+ Name = 'IE',
+ ProductSegment__c = 'IE',
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ MachineParts__c = 'Machine',
+ isActive = true
+ );
+ insert pricebook;
+
+ Product2 product1 = new Product2();
+ product1.Name = 'product1';
+ product1.ProductCode = 'product1';
+ product1.Product_ECCode__c = 'product1';
+ product1.IsActive = true;
+ product1.ProductStatus__c = '1';
+ product1.NMPAStatus_one__c = 'Z1';
+ product1.MaterialStatus_one_Start__c = Date.today().addDays(-22);
+ product1.MaterialStatus_one_End__c = Date.today().addDays(22);
+
+ Product2 product2 = new Product2();
+ product2.Name = 'product2';
+ product2.ProductCode = 'product2';
+ product2.Product_ECCode__c = 'product2';
+ product2.IsActive = true;
+ product2.ProductStatus__c = '1';
+ product2.NMPAStatus_one__c = 'Z1';
+ product2.MaterialStatus_one_Start__c = Date.today().addDays(-22);
+ product2.MaterialStatus_one_End__c = Date.today().addDays(22);
+
+ Product2 product3 = new Product2();
+ product3.Name = 'product3';
+ product3.ProductCode = 'product3';
+ product3.Product_ECCode__c = 'product3';
+ product3.IsActive = true;
+ product3.ProductStatus__c = '1';
+ product3.NMPAStatus_one__c = 'Z1';
+ product3.MaterialStatus_one_Start__c = Date.today().addDays(-22);
+ product3.MaterialStatus_one_End__c = Date.today().addDays(22);
+
+ insert new Product2[] {product1, product2, product3};
+
+ PricebookEntry standardPrice1 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product1.Id,
+ UnitPrice = 10,
+ IsActive = true,
+ CurrencyIsoCode = 'CNY'
+ );
+
+ PricebookEntry standardPrice2 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product2.Id,
+ UnitPrice = 10,
+ IsActive = true,
+ CurrencyIsoCode = 'CNY'
+ );
+
+ PricebookEntry standardPrice3 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product3.Id,
+ UnitPrice = 10,
+ IsActive = true,
+ CurrencyIsoCode = 'CNY'
+ );
+
+ insert new PricebookEntry[] {standardPrice1, standardPrice2, standardPrice3};
+
+ PricebookEntry entry1 = new PricebookEntry(
+ Pricebook2Id = pricebook.Id,
+ Product2Id = product1.Id,
+ UnitPrice = 10,
+ IsActive = true,
+ UseStandardPrice = false,
+ CurrencyIsoCode = 'CNY',
+ CostPrice1__c = 100,
+ EffectiveDateFrom1__c = Date.today().addDays(-1),
+ EffectiveDateTo1__c = Date.today().addDays(1),
+ SalesPrice1__c = 200,
+ EffectiveDateFrom1_sales__c = Date.today().addDays(-1),
+ EffectiveDateTo1_sales__c = Date.today().addDays(1)
+ );
+
+ PricebookEntry entry2 = new PricebookEntry(
+ Pricebook2Id = pricebook.Id,
+ Product2Id = product2.Id,
+ UnitPrice = 10,
+ IsActive = true,
+ UseStandardPrice = false,
+ CurrencyIsoCode = 'CNY',
+ CostPrice1__c = 100,
+ EffectiveDateFrom1__c = Date.today().addDays(-1),
+ EffectiveDateTo1__c = Date.today().addDays(1),
+ SalesPrice1__c = 200,
+ EffectiveDateFrom1_sales__c = Date.today().addDays(-1),
+ EffectiveDateTo1_sales__c = Date.today().addDays(1)
+ );
+
+ PricebookEntry entry3 = new PricebookEntry(
+ Pricebook2Id = pricebook.Id,
+ Product2Id = product3.Id,
+ UnitPrice = 10,
+ IsActive = true,
+ UseStandardPrice = false,
+ CurrencyIsoCode = 'CNY',
+ CostPrice1__c = 100,
+ EffectiveDateFrom1__c = Date.today().addDays(-1),
+ EffectiveDateTo1__c = Date.today().addDays(1),
+ SalesPrice1__c = 200,
+ EffectiveDateFrom1_sales__c = Date.today().addDays(-1),
+ EffectiveDateTo1_sales__c = Date.today().addDays(1)
+ );
+
+ insert new PricebookEntry[] {entry1, entry2, entry3};
+
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ Account user = new Account(
+ Name = '*',
+ FacilityName__c = 'user',
+ PostCode__c = '123456',
+ RecordTypeId = rectIE[0].Id,
+ ProductSegment__c = 'IE'
+ );
+ insert user;
+
+ Opportunity opp = new Opportunity(
+ Name = 'test opp',
+ AccountId = user.Id,
+ StageName = 'Prospect Created',
+ //CurrencyIsoCode = 'CNY',
+ ProductSegment__c = 'IE',
+ CloseDate = Date.today().addDays(2),
+ NewInquiryDate__c = Date.today().addDays(-2),
+ ExpectedOrderDate__c = Date.today().addDays(2),
+ TradeType__c = 'Taxation',
+ Trade_Type_D__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ Sales_Channel_D__c = 'direct',
+ Machine_Parts__c = 'Machine',
+ Machine_Parts_D__c = 'Machine'
+ //,
+ //Pricebook2Id = pricebook.Id
+ );
+ insert opp;
+
+ Quote quo = new Quote(
+ Name = 'quo',
+ OpportunityId = opp.Id,
+ Pricebook2Id = pricebook.Id,
+ SetName1__c = 'setname1',
+ SetQty1__c = 1,
+ SetName2__c = 'setname2',
+ SetQty2__c = 2,
+ CurrencyIsoCode = 'CNY',
+ Custom_Price_Total_Text__c = 1000
+ );
+ insert quo;
+ QuoteLineItem qli1 = new QuoteLineItem(
+ QuoteId = quo.Id,
+ PricebookEntryId = entry1.Id,
+ Quantity = 1,
+ UnitPrice = 10,
+ Set__c = 'set01'
+ );
+
+ QuoteLineItem qli2 = new QuoteLineItem(
+ QuoteId = quo.Id,
+ PricebookEntryId = entry2.Id,
+ Quantity = 2,
+ UnitPrice = 10,
+ Set__c = 'set01'
+ );
+
+ QuoteLineItem qli3 = new QuoteLineItem(
+ QuoteId = quo.Id,
+ PricebookEntryId = entry3.Id,
+ Quantity = 1,
+ UnitPrice = 10,
+ Set__c = 'set02'
+ );
+
+ insert new QuoteLineItem[] {qli1, qli2, qli3};
+
+ opp.SyncedQuoteId = quo.Id;
+ upsert opp;
+
+ PageReference page = new PageReference('/apex/NewQuoteService?id=' + quo.Id);
+ System.Test.setCurrentPage(page);
+ NewQuoteEntryController controller = new NewQuoteEntryController();
+
+ controller.init();
+
+ controller.Refresh();
+
+ controller.fileName = 'test1';
+ controller.csvExport();
+
+ String strblob = '"濂楄/鍗曞搧","浜у搧code","浜у搧鍚嶇О","鏁伴噺","鎶樻墸"\n"鍗曞搧","product1","product1","2.00","0.00"\n';
+
+ controller.contentFile = Blob.valueOf(strblob);
+
+ controller.csvRead();
+
+ strblob = '濂楄/鍗曞搧,浜у搧code,浜у搧鍚嶇О,鏁伴噺,鎶樻墸\nset01,product1,product1,2,49\nset01,product2,product2,2,49';
+
+ controller.contentFile = Blob.valueOf(strblob);
+
+ controller.csvRead();
+
+ controller.reloadPage();
+ }
+
+ @isTest
+ static void test_init3() {
+ Id pricebookId = Test.getStandardPricebookId();
+
+ Pricebook2 pricebook = new Pricebook2(
+ Name = 'IE',
+ ProductSegment__c = 'IE',
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ MachineParts__c = 'Machine',
+ isActive = true
+ );
+ insert pricebook;
+
+ Product2 product1 = new Product2();
+ product1.Name = 'product1';
+ product1.ProductCode = 'product1';
+ product1.Product_ECCode__c = 'product1';
+ product1.IsActive = true;
+ product1.ProductStatus__c = '1';
+ product1.NMPAStatus_one__c = 'Z1';
+ product1.MaterialStatus_one_Start__c = Date.today().addDays(-22);
+ product1.MaterialStatus_one_End__c = Date.today().addDays(22);
+
+ Product2 product2 = new Product2();
+ product2.Name = 'product2';
+ product2.ProductCode = 'product2';
+ product2.Product_ECCode__c = 'product2';
+ product2.IsActive = true;
+ product2.ProductStatus__c = '1';
+ product2.NMPAStatus_one__c = 'Z1';
+ product2.MaterialStatus_one_Start__c = Date.today().addDays(-22);
+ product2.MaterialStatus_one_End__c = Date.today().addDays(22);
+
+ Product2 product3 = new Product2();
+ product3.Name = 'product3';
+ product3.ProductCode = 'product3';
+ product3.Product_ECCode__c = 'product3';
+ product3.IsActive = true;
+ product3.ProductStatus__c = '1';
+ product3.NMPAStatus_one__c = 'Z1';
+ product3.MaterialStatus_one_Start__c = Date.today().addDays(-22);
+ product3.MaterialStatus_one_End__c = Date.today().addDays(22);
+
+ insert new Product2[] {product1, product2, product3};
+
+ PricebookEntry standardPrice1 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product1.Id,
+ UnitPrice = 0,
+ IsActive = true,
+ CurrencyIsoCode = 'CNY'
+ );
+
+ PricebookEntry standardPrice2 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product2.Id,
+ UnitPrice = 0,
+ IsActive = true,
+ CurrencyIsoCode = 'CNY'
+ );
+
+ PricebookEntry standardPrice3 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product3.Id,
+ UnitPrice = 0,
+ IsActive = true,
+ CurrencyIsoCode = 'CNY'
+ );
+
+ insert new PricebookEntry[] {standardPrice1, standardPrice2, standardPrice3};
+
+ PricebookEntry entry1 = new PricebookEntry(
+ Pricebook2Id = pricebook.Id,
+ Product2Id = product1.Id,
+ UnitPrice = 1,
+ IsActive = true,
+ UseStandardPrice = false,
+ CurrencyIsoCode = 'CNY'
+ );
+
+ PricebookEntry entry2 = new PricebookEntry(
+ Pricebook2Id = pricebook.Id,
+ Product2Id = product2.Id,
+ UnitPrice = 1,
+ IsActive = true,
+ UseStandardPrice = false,
+ CurrencyIsoCode = 'CNY'
+ );
+
+ PricebookEntry entry3 = new PricebookEntry(
+ Pricebook2Id = pricebook.Id,
+ Product2Id = product3.Id,
+ UnitPrice = 1,
+ IsActive = true,
+ UseStandardPrice = false,
+ CurrencyIsoCode = 'CNY'
+ );
+
+ insert new PricebookEntry[] {entry1, entry2, entry3};
+
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ Account user = new Account(
+ Name = '*',
+ FacilityName__c = 'user',
+ PostCode__c = '123456',
+ RecordTypeId = rectIE[0].Id
+ );
+ insert user;
+
+ Opportunity opp = new Opportunity(
+ Name = 'test opp',
+ AccountId = user.Id,
+ 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',
+ Pricebook2Id = pricebook.Id
+ );
+ insert opp;
+
+ Quote quo = new Quote(
+ Name = 'quo',
+ OpportunityId = opp.Id,
+ Pricebook2Id = pricebook.Id,
+ SetName1__c = 'setname1',
+ SetQty1__c = 1,
+ SetName2__c = 'setname2',
+ SetQty2__c = 2,
+ Custom_Price_Total_Text__c = 1000
+ );
+ insert quo;
+
+ opp.SyncedQuoteId = quo.Id;
+ //update opp;
+
+ PageReference page = new PageReference('/apex/NewQuoteService?copyid=' + quo.Id);
+ System.Test.setCurrentPage(page);
+ NewQuoteEntryController controller = new NewQuoteEntryController();
+
+ controller.init();
+
+ PageReference page2 = new PageReference('/apex/NewQuoteService?oppid=' + opp.Id);
+ System.Test.setCurrentPage(page2);
+ NewQuoteEntryController controller2 = new NewQuoteEntryController();
+
+ controller2.init();
+ controller2.setProductEntry();
+ }
+ //浜у搧閰嶅鐩稿叧
+ @isTest
+ static void test_init4() {
+ Id pricebookId = Test.getStandardPricebookId();
+
+ Pricebook2 pricebook = new Pricebook2(
+ Name = 'IE',
+ ProductSegment__c = 'IE',
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ MachineParts__c = 'Machine',
+ isActive = true
+ );
+ insert pricebook;
+
+ Product2 product1 = new Product2();
+ product1.Name = 'product1';
+ product1.ProductCode = 'product1';
+ product1.Product_ECCode__c = 'product1';
+ product1.ProductModels__c = true;
+ product1.ProductStatus__c = '1';
+ product1.NMPAStatus_one__c = 'Z1';
+ product1.MaterialStatus_one_Start__c = Date.today().addDays(-22);
+ product1.MaterialStatus_one_End__c = Date.today().addDays(22);
+ insert product1;
+
+ PricebookEntry standardPrice1 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product1.Id,
+ UnitPrice = 0,
+ IsActive = true,
+ CurrencyIsoCode = 'CNY'
+ );
+ insert standardPrice1;
+
+ PricebookEntry entry1 = new PricebookEntry(Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
+ entry1.UnitPrice = 0;
+ entry1.IsActive = true;
+ entry1.UseStandardPrice = false;
+ entry1.CurrencyIsoCode = 'CNY';
+ insert entry1;
+
+ Product_Search__c ps = new Product_Search__c(Product__c = product1.Id);
+
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ Account user = new Account(
+ Name = '*',
+ FacilityName__c = 'user',
+ PostCode__c = '123456',
+ RecordTypeId = rectIE[0].Id
+ );
+ insert user;
+
+ Opportunity opp = new Opportunity(
+ Name = 'test opp',
+ AccountId = user.Id,
+ 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',
+ Pricebook2Id = pricebook.Id
+ );
+ insert opp;
+ Quote quo = new Quote(
+ Name = 'quo',
+ OpportunityId = opp.Id,
+ SetName1__c = 'IXP-7P2',
+ SetQty1__c = 1,
+ Is_Decided__c = false
+ );
+ insert quo;
+ List<productSet__c> insertproductSets = new List<productSet__c>();
+ productSet__c proSet1 = new productSet__c();
+ proSet1.Code__c = 'IXP-7P2';
+ proSet1.Name = 'IXP-7P2';
+ proSet1.IsValid__c = true;
+ proSet1.Name = 'IXP-7P2';
+ insertproductSets.add(proSet1);
+ productSet__c proSet2 = new productSet__c();
+ proSet2.Code__c = 'IXP-7P1SC';
+ proSet2.Name = 'IXP-7P1SC';
+ proSet2.IsValid__c = true;
+ proSet2.Name = 'IXP-7P1SC';
+ insertproductSets.add(proSet2);
+ productSet__c proSet3 = new productSet__c();
+ proSet3.Code__c = 'IXSP-T7LED';
+ proSet3.Name = 'IXSP-T7LED';
+ proSet3.IsValid__c = true;
+ proSet3.Name = 'IXSP-T7LED';
+ insertproductSets.add(proSet3);
+ productSet__c proSet4 = new productSet__c();
+ proSet4.Code__c = 'IXSP-T7LED4';
+ proSet4.Name = 'IXSP-T7LED4';
+ proSet4.IsValid__c = true;
+ proSet4.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet4);
+ productSet__c proSet5 = new productSet__c();
+ proSet5.Code__c = 'IXSP-T7LED4';
+ proSet5.Name = 'IXSP-T7LED4';
+ proSet5.IsValid__c = true;
+ proSet5.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet5);
+ productSet__c proSet6 = new productSet__c();
+ proSet6.Code__c = 'IXSP-T7LED4';
+ proSet6.Name = 'IXSP-T7LED4';
+ proSet6.IsValid__c = true;
+ proSet6.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet6);
+ productSet__c proSet7 = new productSet__c();
+ proSet7.Code__c = 'IXSP-T7LED4';
+ proSet7.Name = 'IXSP-T7LED4';
+ proSet7.IsValid__c = true;
+ proSet7.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet7);
+ productSet__c proSet8 = new productSet__c();
+ proSet8.Code__c = 'IXSP-T7LED4';
+ proSet8.Name = 'IXSP-T7LED4';
+ proSet8.IsValid__c = true;
+ proSet8.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet8);
+ productSet__c proSet9 = new productSet__c();
+ proSet9.Code__c = 'IXSP-T7LED4';
+ proSet9.Name = 'IXSP-T7LED4';
+ proSet9.IsValid__c = true;
+ proSet9.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet9);
+ productSet__c proSet10 = new productSet__c();
+ proSet10.Code__c = 'IXSP-T7LED4';
+ proSet10.Name = 'IXSP-T7LED4';
+ proSet10.IsValid__c = true;
+ proSet10.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet10);
+ productSet__c proSet11 = new productSet__c();
+ proSet11.Code__c = 'IXP-7P2';
+ proSet11.Name = 'IXP-7P2';
+ proSet11.IsValid__c = true;
+ proSet11.Name = 'IXP-7P2';
+ insertproductSets.add(proSet11);
+ productSet__c proSet12 = new productSet__c();
+ proSet12.Code__c = 'IXP-7P1SC';
+ proSet12.Name = 'IXP-7P1SC';
+ proSet12.IsValid__c = true;
+ proSet12.Name = 'IXP-7P1SC';
+ insertproductSets.add(proSet12);
+ productSet__c proSet13 = new productSet__c();
+ proSet13.Code__c = 'IXSP-T7LED';
+ proSet13.Name = 'IXSP-T7LED';
+ proSet13.IsValid__c = true;
+ proSet13.Name = 'IXSP-T7LED';
+ insertproductSets.add(proSet13);
+ productSet__c proSet14 = new productSet__c();
+ proSet14.Code__c = 'IXSP-T7LED4';
+ proSet14.Name = 'IXSP-T7LED4';
+ proSet14.IsValid__c = true;
+ proSet14.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet14);
+ productSet__c proSet15 = new productSet__c();
+ proSet15.Code__c = 'IXSP-T7LED4';
+ proSet15.Name = 'IXSP-T7LED4';
+ proSet15.IsValid__c = true;
+ proSet15.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet15);
+ productSet__c proSet16 = new productSet__c();
+ proSet16.Code__c = 'IXSP-T7LED4';
+ proSet16.Name = 'IXSP-T7LED4';
+ proSet16.IsValid__c = true;
+ proSet16.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet16);
+ productSet__c proSet17 = new productSet__c();
+ proSet17.Code__c = 'IXSP-T7LED4';
+ proSet17.Name = 'IXSP-T7LED4';
+ proSet17.IsValid__c = true;
+ proSet17.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet17);
+ productSet__c proSet18 = new productSet__c();
+ proSet18.Code__c = 'IXSP-T7LED4';
+ proSet18.Name = 'IXSP-T7LED4';
+ proSet18.IsValid__c = true;
+ proSet18.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet18);
+ productSet__c proSet19 = new productSet__c();
+ proSet19.Code__c = 'IXSP-T7LED4';
+ proSet19.Name = 'IXSP-T7LED4';
+ proSet19.IsValid__c = true;
+ proSet19.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet19);
+ productSet__c proSet20 = new productSet__c();
+ proSet20.Code__c = 'IXSP-T7LED4';
+ proSet20.Name = 'IXSP-T7LED4';
+ proSet20.IsValid__c = true;
+ proSet20.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet20);
+ productSet__c proSet21 = new productSet__c();
+ proSet21.Code__c = 'IXP-7P2';
+ proSet21.Name = 'IXP-7P2';
+ proSet21.IsValid__c = true;
+ proSet21.Name = 'IXP-7P2';
+ insertproductSets.add(proSet21);
+ productSet__c proSet22 = new productSet__c();
+ proSet22.Code__c = 'IXP-7P1SC';
+ proSet22.Name = 'IXP-7P1SC';
+ proSet22.IsValid__c = true;
+ proSet22.Name = 'IXP-7P1SC';
+ insertproductSets.add(proSet22);
+ productSet__c proSet23 = new productSet__c();
+ proSet23.Code__c = 'IXSP-T7LED';
+ proSet23.Name = 'IXSP-T7LED';
+ proSet23.IsValid__c = true;
+ proSet23.Name = 'IXSP-T7LED';
+ insertproductSets.add(proSet23);
+ productSet__c proSet24 = new productSet__c();
+ proSet24.Code__c = 'IXSP-T7LED4';
+ proSet24.Name = 'IXSP-T7LED4';
+ proSet24.IsValid__c = true;
+ proSet24.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet24);
+ productSet__c proSet25 = new productSet__c();
+ proSet25.Code__c = 'IXSP-T7LED4';
+ proSet25.Name = 'IXSP-T7LED4';
+ proSet25.IsValid__c = true;
+ proSet25.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet25);
+ productSet__c proSet26 = new productSet__c();
+ proSet26.Code__c = 'IXSP-T7LED4';
+ proSet26.Name = 'IXSP-T7LED4';
+ proSet26.IsValid__c = true;
+ proSet26.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet26);
+ productSet__c proSet27 = new productSet__c();
+ proSet27.Code__c = 'IXSP-T7LED5';
+ proSet27.Name = 'IXSP-T7LED5';
+ proSet27.IsValid__c = true;
+ proSet27.Name = 'IXSP-T7LED5';
+ insertproductSets.add(proSet27);
+ productSet__c proSet28 = new productSet__c();
+ proSet28.Code__c = 'IXSP-T7LED4';
+ proSet28.Name = 'IXSP-T7LED4';
+ proSet28.IsValid__c = true;
+ proSet28.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet28);
+ productSet__c proSet29 = new productSet__c();
+ proSet29.Code__c = 'IXSP-T7LED4';
+ proSet29.Name = 'IXSP-T7LED4';
+ proSet29.IsValid__c = true;
+ proSet29.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet29);
+ productSet__c proSet30 = new productSet__c();
+ proSet30.Code__c = 'IXSP-T7LED4';
+ proSet30.Name = 'IXSP-T7LED4';
+ proSet30.IsValid__c = true;
+ proSet30.Name = 'IXSP-T7LED4';
+ insertproductSets.add(proSet30);
+
+ insert insertproductSets;
+
+ productSetItem__c productSetItem = new productSetItem__c();
+ productSetItem.productSet__c = proSet1.Id;
+ productSetItem.Count__c = 5;
+ productSetItem.product__c = product1.Id;
+ insert productSetItem ;
+ //List<productSet__c> insertproductSets = new List<productSet__c>(){
+ // proSet1,proSet2,proSet3,proSet4,proSet5,proSet6,proSet7,proSet8,proSet9,proSet10,
+ // proSet21,proSet22,proSet23,proSet24,proSet25,proSet26,proSet27,proSet28,proSet29,proSet30,
+ // proSet11,proSet12,proSet13,proSet14,proSet15,proSet16,proSet17,proSet18,proSet19,proSet20
+ //};
+
+ //PageReference page = new PageReference('/apex/SearchProduct?oppId=' + opp.Id + '&val=product1');
+ PageReference page = new PageReference('/apex/NewQuoteEntry?id=' + quo.Id );
+ //PageReference page = new PageReference('/apex/SearchSetProduct?gainQuoteSetNameAndSetQty=IXP-7P2%2C3%3BIXP-7P1SC%2C2');
+ //PageReference page = new PageReference('/apex/SearchSetProduct??gainQuoteSetNameAndSetQty=');
+
+ System.Test.setCurrentPage(page);
+ NewQuoteEntryController controller = new NewQuoteEntryController();
+
+ controller.init();
+ controller.Save();
+ controller.decideORundecideQuote(quo.Id,true);
+ controller.Decide();
+ controller.setProduct_text = proSet1.Id+',1,49;'+proSet2.Id +',2,49;'+proSet3.Id+',3,49;'+proSet4.Id+',3,49;'+proSet5.Id+',1,49;'+proSet6.Id +',2,49;'+proSet7.Id+',3,49;'+proSet8.Id+',3,49;'+proSet9.Id+',3,49;'+proSet10.Id+',3,49;';
+ controller.setProduct_text += proSet11.Id+',1,49;'+proSet12.Id +',2,49;'+proSet13.Id+',3,49;'+proSet14.Id+',3,49;'+proSet15.Id+',1,49;'+proSet16.Id +',2,49;'+proSet17.Id+',3,49;'+proSet18.Id+',3,49;'+proSet19.Id+',3,49;'+proSet20.Id+',3,49;';
+ controller.setProduct_text += proSet21.Id+',1,49;'+proSet22.Id +',2,49;'+proSet23.Id+',3,49;'+proSet24.Id+',3,49;'+proSet25.Id+',1,49;'+proSet26.Id +',2,49;'+proSet27.Id+',3,49;'+proSet28.Id+',3,49;'+proSet29.Id+',3,49;'+proSet30.Id+',3,49;';
+ controller.setProductEntry();
+ }
+
+ //浜у搧閰嶅鐩稿叧
+ @isTest
+ static void test_init5() {
+ Id pricebookId = Test.getStandardPricebookId();
+
+ Pricebook2 pricebook = new Pricebook2(
+ Name = 'IE',
+ ProductSegment__c = 'IE',
+ TradeType__c = 'Taxation',
+ SalesChannel__c = 'direct',
+ MachineParts__c = 'Machine',
+ isActive = true
+ );
+ insert pricebook;
+
+ Product2 product1 = new Product2();
+ product1.Name = 'product1';
+ product1.ProductCode = 'product1';
+ product1.Product_ECCode__c = 'product1';
+ product1.ProductModels__c = true;
+ product1.ProductStatus__c = '1';
+ product1.NMPAStatus_one__c = 'Z1';
+ product1.MaterialStatus_one_Start__c = Date.today().addDays(-22);
+ product1.MaterialStatus_one_End__c = Date.today().addDays(22);
+ insert product1;
+
+ PricebookEntry standardPrice1 = new PricebookEntry(
+ Pricebook2Id = pricebookId,
+ Product2Id = product1.Id,
+ UnitPrice = 0,
+ IsActive = true,
+ CurrencyIsoCode = 'CNY'
+ );
+ insert standardPrice1;
+
+ PricebookEntry entry1 = new PricebookEntry(Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
+ entry1.UnitPrice = 0;
+ entry1.IsActive = true;
+ entry1.UseStandardPrice = false;
+ entry1.CurrencyIsoCode = 'CNY';
+ insert entry1;
+
+ Product_Search__c ps = new Product_Search__c(Product__c = product1.Id);
+
+ List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
+ Account user = new Account(
+ Name = '*',
+ FacilityName__c = 'user',
+ PostCode__c = '123456',
+ RecordTypeId = rectIE[0].Id
+ );
+ insert user;
+
+ Opportunity opp = new Opportunity(
+ Name = 'test opp',
+ AccountId = user.Id,
+ 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',
+ Pricebook2Id = pricebook.Id
+ );
+ insert opp;
+ Quote quo = new Quote(
+ Name = 'quo',
+ OpportunityId = opp.Id,
+ SetName1__c = 'IXP-7P2',
+ SetQty1__c = 1,
+ Is_Decided__c = true
+ );
+ insert quo;
+ List<productSet__c> insertproductSets = new List<productSet__c>();
+ productSet__c proSet1 = new productSet__c();
+ proSet1.Code__c = 'IXP-7P2';
+ proSet1.Name = 'IXP-7P2';
+ proSet1.IsValid__c = true;
+ proSet1.Name = 'IXP-7P2';
+ insertproductSets.add(proSet1);
+ productSet__c proSet2 = new productSet__c();
+ proSet2.Code__c = 'IXP-7P1SC';
+ proSet2.Name = 'IXP-7P1SC';
+ proSet2.IsValid__c = true;
+ proSet2.Name = 'IXP-7P1SC';
+ insertproductSets.add(proSet2);
+ productSet__c proSet3 = new productSet__c();
+ proSet3.Code__c = 'IXSP-T7LED';
+ proSet3.Name = 'IXSP-T7LED';
+ proSet3.IsValid__c = true;
+ proSet3.Name = 'IXSP-T7LED';
+ insertproductSets.add(proSet3);
+
+
+ insert insertproductSets;
+
+ productSetItem__c productSetItem = new productSetItem__c();
+ productSetItem.productSet__c = proSet1.Id;
+ productSetItem.Count__c = 5;
+ productSetItem.product__c = product1.Id;
+ insert productSetItem ;
+ PageReference page = new PageReference('/apex/NewQuoteEntry?id=' + quo.Id );
+ System.Test.setCurrentPage(page);
+ NewQuoteEntryController controller = new NewQuoteEntryController();
+ Map<String,String> productSetCodeMap = new Map<String,String>();
+ productSetCodeMap.put('IXP-7P1SC', '3;49');
+ //productSetCodeMap.put('111111111', '3;49');
+ controller.init();
+ controller.setProduct_text = proSet1.Id+',1,49;'+proSet2.Id +',2,49;';
+ controller.setProductEntry();
+ controller.acquireProductSetId(productSetCodeMap);
+ controller.Save();
+ //controller.decideORundecideQuote(quo.Id,true);
+ //controller.Decide();
+ }
+
}
\ No newline at end of file
--
Gitblit v1.9.1