@isTest private class LexContractAuthorizeControllerTest { private static Id pricebookId = ControllerUtil.getStandardPricebook().Id; static final String RC_BYOUIN = '病院'; static final String RC_HANBAOITEN = '販売店'; static final String RC_KEIYAKU = '契約'; private static String quoteNo = 'textQutote01'; static testMethod void testMethod1() { 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; sellerA.Business_Paper_Expiration_Date__c = Date.today().addDays(20); 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; License_Information__c l1 = new License_Information__c( name = 'test1', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); License_Information__c l2 = new License_Information__c( name = 'test2', LicenseType__c = '医疗器械经营许可证', ScopeKey__c = 'ss', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, Scope3__c = '6815;6822;6823;6825', ValidTo__c = Date.today().addDays(4) ); License_Information__c l3 = new License_Information__c( name = 'test3', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); insert new List{l1,l2,l3}; System.Test.startTest(); 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.Wholesale_Price__c = 9000; opp.Opportunity_stage__c = '还没申请预算'; opp.Close_Forecasted_Date__c = Date.today().addDays(50); opp.Special_Opp_lanhai__c = false; insert opp; Product2 product = new Product2( Name='テスト商品'); product.SFDA_Status__c = '有効'; product.Intra_Trade_List_RMB_1__c = 100; product.Intra_Trade_List_RMB_Date1__c = date.today(); product.Intra_Trade_Cost_RMB_1__c = 200; product.Intra_Trade_Cost_RMB_Date1__c = date.today(); product.Manual_Entry__c = false; product.Asset_Model_No__c = '11111'; product.ProductCode = 'OTV-SP1H-NA-12E'; insert product; PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id); entry.UnitPrice = 0; entry.IsActive = true; entry.UseStandardPrice = false; entry.CurrencyIsoCode = 'CNY'; insert entry; OpportunityLineItem oppli = new OpportunityLineItem(); oppli.OpportunityId = opp.Id; oppli.SFDA_Status__c = '有効'; oppli.Name__c = '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'; oppli.ListPrice__c = 112; oppli.Quantity = 113; oppli.UnitPrice = 114; oppli.UnitPrice__c = 115; oppli.Qty_Unit__c = '116'; oppli.Cost__c = 117; oppli.BSS_Category__c = 'G&R'; oppli.Item_Order__c = 1; oppli.PricebookEntryId = entry.Id; insert oppli; Product_Register__c prc = new Product_Register__c(Name = '国械注进20162220210', MedPrdClass__c = '3', ValidFrom__c = date.newinstance(2018, 07, 22), ValidTo__c = date.newinstance(2028, 07, 22), RegisterNoClass_Old__c = '6815', RegisterNoClass_New__c = '6815', RegisterNoStatus__c = '有效' ); insert prc; Product_Register_Link__c prlc = new Product_Register_Link__c( Product2__c = product.Id, Product_Register__c = prc.Id ); insert prlc; LexContractAuthorizeController c=new LexContractAuthorizeController(); LexContractAuthorizeController.init(opp.Id); LexContractAuthorizeController.getProfileId(); LexContractAuthorizeController.judgeIsAssistantAppliedOutTime('textQutote01'); LexContractAuthorizeController.searchOpportunity(opp.Id); LexContractAuthorizeController.checkDangerItem('d'); LexContractAuthorizeController.oppCheck(opp.Id,'1'); LexContractAuthorizeController.oppCheck(opp.Id,'0'); LexContractAuthorizeController.updReg(opp.Id); LexContractAuthorizeController.updateOppotunity(opp.Id); LexContractAuthorizeController.queryProfileId(); LexContractAuthorizeController.init(null); LexContractAuthorizeController.getProfileId(); LexContractAuthorizeController.judgeIsAssistantAppliedOutTime(null); LexContractAuthorizeController.searchOpportunity(null); LexContractAuthorizeController.checkDangerItem(null); LexContractAuthorizeController.updReg(null); LexContractAuthorizeController.updateOppotunity(null); LexContractAuthorizeController.submitApprovalRequest(opp.Id); // LexContractAuthorizeController.test(); try{ LexContractAuthorizeController.accSendEmail('Strinlacklist','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('123','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('12','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); }catch(Exception e){ } } static testMethod void testMethod2() { 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; sellerA.Business_Paper_Expiration_Date__c = Date.today().addDays(20); 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; License_Information__c l1 = new License_Information__c( name = 'test1', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); License_Information__c l2 = new License_Information__c( name = 'test2', LicenseType__c = '医疗器械经营许可证', ScopeKey__c = 'ss', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, Scope3__c = '6815;6822;6823;6825', ValidTo__c = Date.today().addDays(4) ); License_Information__c l3 = new License_Information__c( name = 'test3', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); insert new List{l1,l2,l3}; System.Test.startTest(); 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.Wholesale_Price__c = 9000; opp.Opportunity_stage__c = '还没申请预算'; opp.Close_Forecasted_Date__c = Date.today().addDays(50); opp.Special_Opp_lanhai__c = false; insert opp; Product2 product = new Product2( Name='テスト商品'); product.SFDA_Status__c = '有効'; product.Intra_Trade_List_RMB_1__c = 100; product.Intra_Trade_List_RMB_Date1__c = date.today(); product.Intra_Trade_Cost_RMB_1__c = 200; product.Intra_Trade_Cost_RMB_Date1__c = date.today(); product.Manual_Entry__c = false; product.Asset_Model_No__c = '11111'; product.ProductCode = 'OTV-SP1H-NA-12E'; insert product; PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id); entry.UnitPrice = 0; entry.IsActive = true; entry.UseStandardPrice = false; entry.CurrencyIsoCode = 'CNY'; insert entry; OpportunityLineItem oppli = new OpportunityLineItem(); oppli.OpportunityId = opp.Id; oppli.SFDA_Status__c = '有効'; oppli.Name__c = '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'; oppli.ListPrice__c = 112; oppli.Quantity = 113; oppli.UnitPrice = 114; oppli.UnitPrice__c = 115; oppli.Qty_Unit__c = '116'; oppli.Cost__c = 117; oppli.BSS_Category__c = 'G&R'; oppli.Item_Order__c = 1; oppli.PricebookEntryId = entry.Id; insert oppli; Product_Register__c prc = new Product_Register__c(Name = '国械注进20162220210', MedPrdClass__c = '3', ValidFrom__c = date.newinstance(2018, 07, 22), ValidTo__c = date.newinstance(2028, 07, 22), RegisterNoClass_Old__c = '6815', RegisterNoClass_New__c = '6815', RegisterNoStatus__c = '有效' ); insert prc; Product_Register_Link__c prlc = new Product_Register_Link__c( Product2__c = product.Id, Product_Register__c = prc.Id ); insert prlc; try{ LexContractAuthorizeController.accSendEmail('123','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('12','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); }catch(Exception e){ } } static testMethod void testMethod3() { 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; sellerA.Business_Paper_Expiration_Date__c = Date.today().addDays(20); 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; License_Information__c l1 = new License_Information__c( name = 'test1', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); License_Information__c l2 = new License_Information__c( name = 'test2', LicenseType__c = '医疗器械经营许可证', ScopeKey__c = 'ss', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, Scope3__c = '6815;6822;6823;6825', ValidTo__c = Date.today().addDays(4) ); License_Information__c l3 = new License_Information__c( name = 'test3', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); insert new List{l1,l2,l3}; System.Test.startTest(); 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.Wholesale_Price__c = 9000; opp.Opportunity_stage__c = '还没申请预算'; opp.Close_Forecasted_Date__c = Date.today().addDays(50); opp.Special_Opp_lanhai__c = false; insert opp; Product2 product = new Product2( Name='テスト商品'); product.SFDA_Status__c = '有効'; product.Intra_Trade_List_RMB_1__c = 100; product.Intra_Trade_List_RMB_Date1__c = date.today(); product.Intra_Trade_Cost_RMB_1__c = 200; product.Intra_Trade_Cost_RMB_Date1__c = date.today(); product.Manual_Entry__c = false; product.Asset_Model_No__c = '11111'; product.ProductCode = 'OTV-SP1H-NA-12E'; insert product; PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id); entry.UnitPrice = 0; entry.IsActive = true; entry.UseStandardPrice = false; entry.CurrencyIsoCode = 'CNY'; insert entry; OpportunityLineItem oppli = new OpportunityLineItem(); oppli.OpportunityId = opp.Id; oppli.SFDA_Status__c = '有効'; oppli.Name__c = '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'; oppli.ListPrice__c = 112; oppli.Quantity = 113; oppli.UnitPrice = 114; oppli.UnitPrice__c = 115; oppli.Qty_Unit__c = '116'; oppli.Cost__c = 117; oppli.BSS_Category__c = 'G&R'; oppli.Item_Order__c = 1; oppli.PricebookEntryId = entry.Id; insert oppli; Product_Register__c prc = new Product_Register__c(Name = '国械注进20162220210', MedPrdClass__c = '3', ValidFrom__c = date.newinstance(2018, 07, 22), ValidTo__c = date.newinstance(2028, 07, 22), RegisterNoClass_Old__c = '6815', RegisterNoClass_New__c = '6815', RegisterNoStatus__c = '有效' ); insert prc; Product_Register_Link__c prlc = new Product_Register_Link__c( Product2__c = product.Id, Product_Register__c = prc.Id ); insert prlc; try{ LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('12','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); }catch(Exception e){ } } static testMethod void testMethod4() { 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; sellerA.Business_Paper_Expiration_Date__c = Date.today().addDays(20); 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; License_Information__c l1 = new License_Information__c( name = 'test1', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); License_Information__c l2 = new License_Information__c( name = 'test2', LicenseType__c = '医疗器械经营许可证', ScopeKey__c = 'ss', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, Scope3__c = '6815;6822;6823;6825', ValidTo__c = Date.today().addDays(4) ); License_Information__c l3 = new License_Information__c( name = 'test3', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); insert new List{l1,l2,l3}; System.Test.startTest(); 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.Wholesale_Price__c = 9000; opp.Opportunity_stage__c = '还没申请预算'; opp.Close_Forecasted_Date__c = Date.today().addDays(50); opp.Special_Opp_lanhai__c = false; insert opp; Product2 product = new Product2( Name='テスト商品'); product.SFDA_Status__c = '有効'; product.Intra_Trade_List_RMB_1__c = 100; product.Intra_Trade_List_RMB_Date1__c = date.today(); product.Intra_Trade_Cost_RMB_1__c = 200; product.Intra_Trade_Cost_RMB_Date1__c = date.today(); product.Manual_Entry__c = false; product.Asset_Model_No__c = '11111'; product.ProductCode = 'OTV-SP1H-NA-12E'; insert product; PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id); entry.UnitPrice = 0; entry.IsActive = true; entry.UseStandardPrice = false; entry.CurrencyIsoCode = 'CNY'; insert entry; OpportunityLineItem oppli = new OpportunityLineItem(); oppli.OpportunityId = opp.Id; oppli.SFDA_Status__c = '有効'; oppli.Name__c = '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'; oppli.ListPrice__c = 112; oppli.Quantity = 113; oppli.UnitPrice = 114; oppli.UnitPrice__c = 115; oppli.Qty_Unit__c = '116'; oppli.Cost__c = 117; oppli.BSS_Category__c = 'G&R'; oppli.Item_Order__c = 1; oppli.PricebookEntryId = entry.Id; insert oppli; Product_Register__c prc = new Product_Register__c(Name = '国械注进20162220210', MedPrdClass__c = '3', ValidFrom__c = date.newinstance(2018, 07, 22), ValidTo__c = date.newinstance(2028, 07, 22), RegisterNoClass_Old__c = '6815', RegisterNoClass_New__c = '6815', RegisterNoStatus__c = '有效' ); insert prc; Product_Register_Link__c prlc = new Product_Register_Link__c( Product2__c = product.Id, Product_Register__c = prc.Id ); insert prlc; try{ LexContractAuthorizeController.accSendEmail('12','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); }catch(Exception e){ } } static testMethod void testMethod5() { 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; sellerA.Business_Paper_Expiration_Date__c = Date.today().addDays(20); 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; License_Information__c l1 = new License_Information__c( name = 'test1', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); License_Information__c l2 = new License_Information__c( name = 'test2', LicenseType__c = '医疗器械经营许可证', ScopeKey__c = 'ss', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, Scope3__c = '6815;6822;6823;6825', ValidTo__c = Date.today().addDays(4) ); License_Information__c l3 = new License_Information__c( name = 'test3', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); insert new List{l1,l2,l3}; System.Test.startTest(); 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.Wholesale_Price__c = 9000; opp.Opportunity_stage__c = '还没申请预算'; opp.Close_Forecasted_Date__c = Date.today().addDays(50); opp.Special_Opp_lanhai__c = false; insert opp; Product2 product = new Product2( Name='テスト商品'); product.SFDA_Status__c = '有効'; product.Intra_Trade_List_RMB_1__c = 100; product.Intra_Trade_List_RMB_Date1__c = date.today(); product.Intra_Trade_Cost_RMB_1__c = 200; product.Intra_Trade_Cost_RMB_Date1__c = date.today(); product.Manual_Entry__c = false; product.Asset_Model_No__c = '11111'; product.ProductCode = 'OTV-SP1H-NA-12E'; insert product; PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id); entry.UnitPrice = 0; entry.IsActive = true; entry.UseStandardPrice = false; entry.CurrencyIsoCode = 'CNY'; insert entry; OpportunityLineItem oppli = new OpportunityLineItem(); oppli.OpportunityId = opp.Id; oppli.SFDA_Status__c = '有効'; oppli.Name__c = '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'; oppli.ListPrice__c = 112; oppli.Quantity = 113; oppli.UnitPrice = 114; oppli.UnitPrice__c = 115; oppli.Qty_Unit__c = '116'; oppli.Cost__c = 117; oppli.BSS_Category__c = 'G&R'; oppli.Item_Order__c = 1; oppli.PricebookEntryId = entry.Id; insert oppli; Product_Register__c prc = new Product_Register__c(Name = '国械注进20162220210', MedPrdClass__c = '3', ValidFrom__c = date.newinstance(2018, 07, 22), ValidTo__c = date.newinstance(2028, 07, 22), RegisterNoClass_Old__c = '6815', RegisterNoClass_New__c = '6815', RegisterNoStatus__c = '有效' ); insert prc; Product_Register_Link__c prlc = new Product_Register_Link__c( Product2__c = product.Id, Product_Register__c = prc.Id ); insert prlc; try{ LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); }catch(Exception e){ } } static testMethod void testMethod6() { 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; sellerA.Business_Paper_Expiration_Date__c = Date.today().addDays(20); 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; License_Information__c l1 = new License_Information__c( name = 'test1', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); License_Information__c l2 = new License_Information__c( name = 'test2', LicenseType__c = '医疗器械经营许可证', ScopeKey__c = 'ss', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, Scope3__c = '6815;6822;6823;6825', ValidTo__c = Date.today().addDays(4) ); License_Information__c l3 = new License_Information__c( name = 'test3', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); insert new List{l1,l2,l3}; System.Test.startTest(); 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.Wholesale_Price__c = 9000; opp.Opportunity_stage__c = '还没申请预算'; opp.Close_Forecasted_Date__c = Date.today().addDays(50); opp.Special_Opp_lanhai__c = false; insert opp; Product2 product = new Product2( Name='テスト商品'); product.SFDA_Status__c = '有効'; product.Intra_Trade_List_RMB_1__c = 100; product.Intra_Trade_List_RMB_Date1__c = date.today(); product.Intra_Trade_Cost_RMB_1__c = 200; product.Intra_Trade_Cost_RMB_Date1__c = date.today(); product.Manual_Entry__c = false; product.Asset_Model_No__c = '11111'; product.ProductCode = 'OTV-SP1H-NA-12E'; insert product; PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id); entry.UnitPrice = 0; entry.IsActive = true; entry.UseStandardPrice = false; entry.CurrencyIsoCode = 'CNY'; insert entry; OpportunityLineItem oppli = new OpportunityLineItem(); oppli.OpportunityId = opp.Id; oppli.SFDA_Status__c = '有効'; oppli.Name__c = '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'; oppli.ListPrice__c = 112; oppli.Quantity = 113; oppli.UnitPrice = 114; oppli.UnitPrice__c = 115; oppli.Qty_Unit__c = '116'; oppli.Cost__c = 117; oppli.BSS_Category__c = 'G&R'; oppli.Item_Order__c = 1; oppli.PricebookEntryId = entry.Id; insert oppli; Product_Register__c prc = new Product_Register__c(Name = '国械注进20162220210', MedPrdClass__c = '3', ValidFrom__c = date.newinstance(2018, 07, 22), ValidTo__c = date.newinstance(2028, 07, 22), RegisterNoClass_Old__c = '6815', RegisterNoClass_New__c = '6815', RegisterNoStatus__c = '有效' ); insert prc; Product_Register_Link__c prlc = new Product_Register_Link__c( Product2__c = product.Id, Product_Register__c = prc.Id ); insert prlc; try{ LexContractAuthorizeController.accSendEmail('23','String accname',sellerA.Id,'String angency2',UserInfo.getUserId(),'String ddid',opp.Id); }catch(Exception e){ } } static testMethod void testMethod7() { 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 = 'テスト病院別名'; hospital.TradeComplianceStatus__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; sellerA.Business_Paper_Expiration_Date__c = Date.today().addDays(20); 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; License_Information__c l1 = new License_Information__c( name = 'test1', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); License_Information__c l2 = new License_Information__c( name = 'test2', LicenseType__c = '医疗器械经营许可证', ScopeKey__c = 'ss', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, Scope3__c = '6815;6822;6823;6825', ValidTo__c = Date.today().addDays(4) ); License_Information__c l3 = new License_Information__c( name = 'test3', LicenseType__c = '危险化学品经营许可证', ValidFrom__c = Date.today().addDays(-5), LicenseAndAccount__c = sellerA.Id, ValidTo__c = Date.today().addDays(4) ); insert new List{l1,l2,l3}; System.Test.startTest(); 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.Wholesale_Price__c = 9000; opp.Opportunity_stage__c = '还没申请预算'; opp.Close_Forecasted_Date__c = Date.today().addDays(50); opp.Special_Opp_lanhai__c = false; insert opp; Product2 product = new Product2( Name='テスト商品'); product.SFDA_Status__c = '有効'; product.Intra_Trade_List_RMB_1__c = 100; product.Intra_Trade_List_RMB_Date1__c = date.today(); product.Intra_Trade_Cost_RMB_1__c = 200; product.Intra_Trade_Cost_RMB_Date1__c = date.today(); product.Manual_Entry__c = false; product.Asset_Model_No__c = '11111'; product.ProductCode = 'OTV-SP1H-NA-12E'; product.CountryOfOrigin__c = 'US'; insert product; PricebookEntry entry = new PricebookEntry( Pricebook2Id=pricebookId, Product2Id=product.Id); entry.UnitPrice = 0; entry.IsActive = true; entry.UseStandardPrice = false; entry.CurrencyIsoCode = 'CNY'; insert entry; OpportunityLineItem oppli = new OpportunityLineItem(); oppli.OpportunityId = opp.Id; oppli.SFDA_Status__c = '有効'; oppli.Name__c = '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'; oppli.ListPrice__c = 112; oppli.Quantity = 113; oppli.UnitPrice = 114; oppli.UnitPrice__c = 115; oppli.Qty_Unit__c = '116'; oppli.Cost__c = 117; oppli.BSS_Category__c = 'G&R'; oppli.Item_Order__c = 1; oppli.PricebookEntryId = entry.Id; insert oppli; Product_Register__c prc = new Product_Register__c(Name = '国械注进20162220210', MedPrdClass__c = '3', ValidFrom__c = date.newinstance(2018, 07, 22), ValidTo__c = date.newinstance(2028, 07, 22), RegisterNoClass_Old__c = '6815', RegisterNoClass_New__c = '6815', RegisterNoStatus__c = '有效' ); insert prc; Product_Register_Link__c prlc = new Product_Register_Link__c( Product2__c = product.Id, Product_Register__c = prc.Id ); insert prlc; try{ LexContractAuthorizeController.proTradeComplianceSendEmail(opp.Id,'授权申请'); LexContractAuthorizeController.getProTradeComplianceStatus(opp.Id); }catch(Exception e){ } } }