@isTest
|
public class LexEquipmentRentalApply_FromQISCtlTest {
|
static testMethod void LexEquipmentRentalApply_FromQISCtlTest() {
|
User u3 = new User();
|
u3.LastName = '_サンブリッジ';
|
u3.FirstName = 'う';
|
u3.Alias = 'う';
|
u3.Email = 'olympusTest03@sunbridge.com';
|
u3.Username = 'olympusTest03@sunbridge.com';
|
u3.CommunityNickname = 'う';
|
u3.IsActive = true;
|
u3.EmailEncodingKey = 'ISO-2022-JP';
|
u3.TimeZoneSidKey = 'Asia/Tokyo';
|
u3.LocaleSidKey = 'ja_JP';
|
u3.LanguageLocaleKey = 'ja';
|
u3.ProfileId = System.Label.ProfileId_SystemAdmin;
|
// u3.Job_Category__c = '销售推广';
|
u3.Job_Category__c = '销售服务';
|
u3.Province__c = '北京市';
|
u3.Use_Start_Date__c = Date.today().addMonths(-6);
|
|
User thisUser = [ select Id from User where Id = :UserInfo.getUserId() ];
|
System.runAs ( thisUser ) {
|
insert u3;
|
}
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
User hpOwner = new User(Test_staff__c = true, 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);
|
System.runAs ( thisUser ) {
|
insert hpOwner;
|
}
|
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return ;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Account' and Name IN ('診療科 消化科', '診療科 呼吸科') order by Name desc];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
|
system.runAs(u3) {
|
ControllerUtil.EscapeNFM001Trigger = true;
|
// 客户
|
Account hospital = new Account();
|
// 记录类型ID
|
// 01210000000QemGAAS
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
// 客户名
|
hospital.Name = '北京市医院';
|
insert hospital;
|
|
// 戦略科室を得る
|
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
|
// 客户
|
Account dep = new Account();
|
// 01210000000Qfm7AAC
|
// 记录类型ID
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
|
// 客户名
|
dep.Name = 'test de/p';
|
dep.ParentId = strategicDep[0].Id;
|
// 战略科室分类
|
dep.Department_Class__c = strategicDep[0].Id;
|
// 医院
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
|
|
//备品借出申请
|
Rental_Apply__c raObj = new Rental_Apply__c();
|
raObj.Name = 'testra';
|
raObj.Product_category__c = 'GI';
|
raObj.Demo_purpose1__c = '其他';
|
raObj.demo_purpose2__c = '其他';
|
raObj.Person_In_Charge__c = Userinfo.getUserId();
|
raObj.applyUser__c = Userinfo.getUserId();
|
raObj.Demo_purpose_text__c = '123';
|
raObj.Request_shipping_day__c = Date.toDay();
|
raObj.Request_return_day__c = Date.toDay();
|
raObj.direct_send__c = '上门自提';
|
raObj.Loaner_received_staff__c = '王五';
|
raObj.Loaner_received_staff_phone__c = '110';
|
raObj.pickup_time__c = System.now();
|
insert raObj;
|
|
RecordType rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity' and DeveloperName = 'Opportunity' ];
|
Opportunity opp = new Opportunity(
|
Name='testOpp1',
|
StageName='引合',
|
CloseDate=Date.today(),
|
AccountId=dep.Id,
|
Sales_Root__c = 'OCM直接販売',
|
Competitor__c ='A',
|
Click_Close_Date__c = null,
|
RecordType = rectOpp
|
);
|
insert opp;
|
|
Statu_Achievements__c Sac = new Statu_Achievements__c(
|
name = 'zhucan_one',
|
Opportunity__c = opp.id,
|
DeliveryDate__c = Date.today(),
|
ContractNO__c = 'ContractNO1',
|
ContractAmount__c = 1234
|
);
|
|
// 设备
|
Asset asset = new Asset();
|
asset.Name = '测试机器';
|
asset.AccountId = dep.Id;
|
asset.Department_Class__c = strategicDep[0].Id;
|
asset.Hospital__c = hospital.Id;
|
asset.SerialNumber = 'testserial';
|
asset.Backorder__c = Sac.Id;
|
insert asset;
|
|
//QIS
|
QIS_Report__c qis = new QIS_Report__c();
|
qis.nonyushohin__c = asset.Id;
|
qis.Hospital__c = hospital.Id;
|
qis.RC__c = UserInfo.getUserId();
|
qis.Department_Class__c = strategicDep[0].Id;
|
qis.Hospital_Department__c = dep.Id;
|
qis.Damage_For_Doc_Or_Pat__c = '有';
|
qis.Relation_With_The_Problem__c = '有可能';
|
qis.Report_For_Goz__c = '不知道';
|
insert qis;
|
|
LexEquipmentRentalApply_FromQISCtl.init(qis.Id);
|
LexEquipmentRentalApply_FromQISCtl.rentalApp(raObj.Id);
|
LexEquipmentRentalApply_FromQISCtl.UserInfo_Owner();
|
}
|
}
|
}
|