liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@isTest
private class LexPast2YearsRepairPriceReportTest {
   
    @isTest
    public static void test_init() {
        // Report report = new Report();
        // report.DeveloperName = 'Last2YearsRepairPrice3';
        // insert report;
       // Implement test code
        // 病院を作る
        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;
        insert contract;
        
        // 维修合同报价を作成する
        Maintenance_Contract_Estimate__c contactEsti = new Maintenance_Contract_Estimate__c(
            Name = 'contract estimate 1',
            Maintenance_Contract__c = contract.Id,
            Contract_Esti_Start_Date__c = Date.today(),
            Contract_Start_Date__c = Date.today(),
            Contract_Range__c = 12,
            Maintenance_Price__c = 1500,
            Estimate_Trial_Money__c = 1500,
            NotUse_Oxygenated_Water__c = true,
            Discount_Percentage__c = 12.3,
            Discount_Price__c = 1000
        );
        insert contactEsti;
        
        Test.startTest();
        LexPast2YearsRepairPriceReportController.init(contactEsti.Id);
        Test.stopTest();
    }
 
}