高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
@isTest
class OCM_Ctrl2_test {
    final static string ra1 = [select id , SobjectType, developername  from recordtype where SobjectType='Rental_Apply__c' and developername='StandardRequest'][0].id;
    final static string acc1 = [select id , SobjectType, developername  from recordtype where SobjectType='Account' and developername='HP'][0].id;
    
    @isTest
    static void rental_apply() {
        Account hp = new Account(RecordTypeId = acc1, Name = 'AccountTestHp1');
        insert hp;
        
        Rental_Apply__c rentalApply = new Rental_Apply__c();
        rentalApply.recordTypeId = ra1;
        rentalApply.CurrencyIsoCode = 'CNY';
        rentalApply.applyUser__c = Userinfo.getUserId();
        rentalApply.direct_send__c = '直送';
        rentalApply.direct_shippment_address__c = 'test';
        rentalApply.Request_return_day__c = Date.today() + 30;
        rentalApply.account__c = hp.id;
        insert rentalApply;
        
        PageReference pr = Page.AL_MobileApp_Land;
        pr.getParameters().put('pid', rentalApply.id);
        Test.setCurrentPage(pr);
        OCM_Ctrl2 c1 = new OCM_Ctrl2();
    }
    
    @isTest
    static void asset() {
        Account hp = new Account(RecordTypeId = acc1, Name = 'AccountTestHp1');
        insert hp;
        
        Product2 prd1 = new Product2();
        prd1.ProductCode_Ext__c     = 'Prd1';
        prd1.ProductCode            = 'Prd1';
        prd1.Repair_Product_Code__c = 'Prd1_RP';
        prd1.Name                   = 'Prd1';
        prd1.Manual_Entry__c        = false;
        prd1.Category2__c = '本体';
        prd1.Category3__c = '纤维镜';
        prd1.Category4__c = 'CV';
        prd1.Category5__c = '260SL系列';
        prd1.Asset_Model_No__c = '1001';
        insert prd1;
        
        Asset ast1 = new Asset();
        ast1.Name                   = '保有設備1';
        ast1.Hospital__c            = hp.Id;
        ast1.AccountId              = hp.Id;
        ast1.Product2Id             = prd1.Id;
        ast1.SerialNumber           = 'SerialNumber1';
        ast1.Guarantee_period_for_products__c = Date.today();
        ast1.InstallDate                      = Date.today();
        insert ast1;
        
        PageReference pr = Page.AL_MobileApp_Land;
        pr.getParameters().put('pid', ast1.id);
        Test.setCurrentPage(pr);
        OCM_Ctrl2 c1 = new OCM_Ctrl2();
    }
    
    @isTest
    static void repair() {
        Account hp = new Account(RecordTypeId = acc1, Name = 'AccountTestHp1');
        insert hp;
        
        Product2 prd1 = new Product2();
        prd1.ProductCode_Ext__c     = 'Prd1';
        prd1.ProductCode            = 'Prd1';
        prd1.Repair_Product_Code__c = 'Prd1_RP';
        prd1.Name                   = 'Prd1';
        prd1.Manual_Entry__c        = false;
        prd1.Category2__c = '本体';
        prd1.Category3__c = '纤维镜';
        prd1.Category4__c = 'CV';
        prd1.Category5__c = '260SL系列';
        prd1.Asset_Model_No__c = '1001';
        insert prd1;
        
        Asset ast1 = new Asset();
        ast1.Name                   = '保有設備1';
        ast1.Hospital__c            = hp.Id;
        ast1.AccountId              = hp.Id;
        ast1.Product2Id             = prd1.Id;
        ast1.SerialNumber           = 'SerialNumber1';
        ast1.Guarantee_period_for_products__c = Date.today();
        ast1.InstallDate                      = Date.today();
        insert ast1;
        
        final string acc2 = [select id , SobjectType, developername  from recordtype where SobjectType='Account' and developername='Department_Class_BF'][0].id; //戦略科室分類 呼吸科
        Account Department_Class_BF = new Account(RecordTypeId = acc2, Name = 'Department_Class_BF',ParentId=hp.id,Department_Class_Label__c='呼吸科');
        insert Department_Class_BF;
        final string acc3 = [select id , SobjectType, developername  from recordtype where SobjectType='Account' and developername='Department_BF'][0].id; //戦略科室分類 呼吸科
        Account Department_BF = new Account(RecordTypeId = acc3, Name = 'Department_BF',ParentId=Department_Class_BF.id,Hospital__c=hp.id,Department_Class__c=Department_Class_BF.id);
        insert Department_BF;  
        
        Repair__c repair1 = new Repair__c();
        repair1.Service_Repair_No__c = 'repair1';
        repair1.Hospital__c            = hp.Id;
        repair1.Account__c             = Department_BF.Id;
        repair1.Department_Class__c = Department_Class_BF.id;
        repair1.Delivered_Product__c = ast1.Id;
        repair1.Repair_List_Price__c = 100;
        repair1.Billing_Amount__c = 10;
        repair1.Paid_Amount__c = 1;
        repair1.Failure_Occurrence_Date__c = Date.today().addDays(-1);
        repair1.Repair_Returned_To_HP_Date__c = Date.today().addDays(3);
        repair1.Repair_Shipped_Date__c = Date.today().addDays(1);
        insert repair1;
        
        PageReference pr = Page.AL_MobileApp_Land;
        pr.getParameters().put('pid', repair1.id);
        Test.setCurrentPage(pr);
        OCM_Ctrl2 c1 = new OCM_Ctrl2();
    }
}