@isTest
|
private class MaintenanceContractSetColunmWSTest {
|
static testMethod void testMethod1() {
|
|
// 病院を作る
|
Account hospital = new Account();
|
hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
|
hospital.Name = 'test hospital';
|
insert hospital;
|
|
// 戦略科室を得る
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
|
// 診療科を作る
|
Account dep = new Account();
|
dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id;
|
dep.Name = 'test dep';
|
dep.ParentId = strategicDep[0].Id;
|
dep.Department_Class__c = strategicDep[0].Id;
|
dep.Hospital__c = hospital.Id;
|
insert dep;
|
|
// 维修合同を作成する
|
Maintenance_Contract__c contract = new Maintenance_Contract__c();
|
contract.Name = 'tect contract';
|
contract.Hospital__c = hospital.Id;
|
contract.Department_Class__c = strategicDep[0].Id;
|
contract.Department__c = dep.Id;
|
contract.Contract_Start_Date__c = Date.today();
|
contract.RecordTypeId = [Select Id FROM RecordType WHERE Name = '维修合同'].Id;
|
contract.Contract_End_Date__c = Date.today();
|
insert contract;
|
|
// 维修合同を作成する
|
Maintenance_Contract__c contract1 = new Maintenance_Contract__c();
|
contract1.Name = 'tect contract';
|
contract1.Hospital__c = hospital.Id;
|
contract1.Department_Class__c = strategicDep[0].Id;
|
contract1.Department__c = dep.Id;
|
contract1.Maintenance_Contract_No__c = 'contact1';
|
contract1.Contract_Start_Date__c = Date.today();
|
contract1.Contract_Conclusion_Date__c = Date.today();
|
contract1.RecordTypeId = [Select Id FROM RecordType WHERE Name = '服务合同'].Id;
|
contract1.Contract_End_Date__c = Date.today();
|
insert contract1;
|
|
|
// 维修合同を作成する
|
Maintenance_Contract__c contract2 = new Maintenance_Contract__c();
|
contract2.Name = 'tect contract';
|
contract2.Hospital__c = hospital.Id;
|
contract2.Department_Class__c = strategicDep[0].Id;
|
contract2.Department__c = dep.Id;
|
contract2.Contract_Start_Date__c = Date.today();
|
contract2.RecordTypeId = [Select Id FROM RecordType WHERE Name = '维修合同'].Id;
|
contract2.Contract_End_Date__c = Date.today();
|
insert contract2;
|
|
// 维修合同を作成する
|
Maintenance_Contract__c contract3 = new Maintenance_Contract__c();
|
contract3.Name = 'tect contract';
|
contract3.Hospital__c = hospital.Id;
|
contract3.Department_Class__c = strategicDep[0].Id;
|
contract3.Department__c = dep.Id;
|
contract3.Contract_Start_Date__c = Date.today();
|
contract3.Maintenance_Contract_No__c = 'contact1';
|
contract3.Contract_Conclusion_Date__c = Date.today();
|
contract3.RecordTypeId = [Select Id FROM RecordType WHERE Name = '服务合同'].Id;
|
contract3.Contract_End_Date__c = Date.today();
|
insert contract3;
|
|
|
// 保有设备C (只有附属品 个体管理)
|
Asset assetC1 = new Asset(Asset_Owner__c = 'Olympus');
|
assetC1.RecordTypeId = System.Label.Asset_RecordType;
|
assetC1.SerialNumber = 'assetC1';
|
assetC1.Name = '测试';
|
assetC1.AccountId = dep.Id;
|
|
assetC1.Out_of_wh__c = 0;
|
// 保有设备
|
Asset asset = new Asset(Asset_Owner__c = 'Olympus');
|
asset.RecordTypeId = System.Label.Asset_RecordType;
|
asset.SerialNumber = 'asset';
|
Asset.AccountId = dep.Id;
|
asset.Freeze_sign__c = false;
|
asset.Out_of_wh__c = 0;
|
asset.Name = '测试';
|
insert new Asset[] {assetC1, asset};
|
|
//创建维修合同下的保有设备
|
Maintenance_Contract_Asset__c mc1 = new Maintenance_Contract_Asset__c();
|
mc1.Maintenance_Contract__c = contract2.Id;
|
mc1.LastMContract__c = contract3.Id;
|
mc1.Asset__c = assetC1.Id;
|
insert mc1;
|
|
//创建维修合同下的保有设备
|
Maintenance_Contract_Asset__c mc2 = new Maintenance_Contract_Asset__c();
|
mc2.Maintenance_Contract__c = contract1.Id;
|
mc2.LastMContract__c = contract.Id;
|
mc2.Asset__c = asset.Id;
|
insert mc2;
|
|
System.debug('上一期维修合同空白期:mc1 --- '+mc1.LastMContract_Gap__c);
|
System.debug('上一期维修合同空白期:mc2 --- '+mc2.LastMContract_Gap__c);
|
|
MaintenanceContractSetColunmWebService.updateColunm(contract.Id);
|
MaintenanceContractSetColunmWebService.updateColunm(contract2.Id);
|
|
MaintenanceContractSetColunmWebService.updateColunm(contract1.Id);
|
MaintenanceContractSetColunmWebService.updateColunm(contract3.Id);
|
|
}
|
}
|