@isTest
|
private class NewQuoteEntryControllerTest {
|
|
private static Product2 product = null;
|
private static Pricebook2 pricebook = null;
|
|
|
private static Opportunity opprtunity = null;
|
|
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 = '販売店';
|
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のQuote_Correct__c、Quote_Special_Operation__c、SAP_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;
|
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);
|
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のQuote_Correct__c、Quote_Special_Operation__c、SAP_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のQuote_Correct__c、Quote_Special_Operation__c、SAP_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のQuote_Correct__c、Quote_Special_Operation__c、SAP_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のQuote_Correct__c、Quote_Special_Operation__c、SAP_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のQuote_Correct__c、Quote_Special_Operation__c、SAP_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');
|
System.Test.setCurrentPage(page);
|
|
QuotePage.oppId = opp.id;
|
QuotePage.quoId = quote.id;
|
QuotePage.init();
|
QuotePage.Save();
|
//##ページデバッグセクション 終了
|
}
|
// 页面参数带询价id 的 手动设置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 = '販売店';
|
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) {
|
|
//販売店
|
RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType = 'Account' and Name = :RC_HANBAOITEN limit 1];
|
Account sellerA = new Account(Name = '販売店');
|
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 = '販売店';
|
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 = '販売店');
|
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 = '販売店';
|
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 = '販売店');
|
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 = '販売店';
|
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 = '販売店');
|
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 = '販売店';
|
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 = '販売店');
|
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 = '販売店';
|
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 = 'セット品1';
|
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 = '販売店');
|
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 = '販売店';
|
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
|
// //维修合同报价(USD)
|
// ,PricebookEntry.Product2.Repair_Contract_USD__c
|
// //计提金额(不含税,USD)
|
// ,PricebookEntry.Product2.Intra_Trade_Foreign_RMB__c
|
// //NoDiscount 金额(USD)
|
// ,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 = 'セット品1';
|
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 = '販売店');
|
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 = '販売店';
|
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 = 'セット品1';
|
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 = '販売店');
|
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 = '販売店';
|
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時間販売';
|
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 = 'セット品1';
|
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 = '販売店');
|
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 = '販売店';
|
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時間販売';
|
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 = 'セット品1';
|
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 = '販売店');
|
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 = '販売店';
|
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時間販売'; //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 = 'セット品1';
|
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 = '販売店');
|
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;
|
|
// 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();
|
|
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.oppInfo = opps;
|
controller.dataEntry();
|
}
|
}
|