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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
@isTest
class AL_MobileApp_ControllerTest {
    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 att_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;
        
        BLOB b = Blob.valueOf('ABCDEFGHIJKLMN');
        AL_MobileApp_Controller.CreateAttachmentRequest req = new AL_MobileApp_Controller.CreateAttachmentRequest();
        req.photoType = 'borrow_application';
        req.fname = 'ab.png';
        req.photo = EncodingUtil.base64Encode(b);
        req.id = rentalApply.Id;
        req.ms = DateTime.now().getTime();
        req.latitude = '30';
        req.longitude = '30';
        AL_MobileApp_Controller.CreateAttachmentResponse res = AL_MobileApp_Controller.createAttachment(req);
    }
    
    @isTest
    static void att_rental_apply2() {
        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;
        
        BLOB b = Blob.valueOf('ABCDEFGHIJKLMN');
        AL_MobileApp_Controller.CreateAttachmentRequest req = new AL_MobileApp_Controller.CreateAttachmentRequest();
        req.photoType = 'aaaaaaaaaaa';
        req.fname = 'ab.png';
        req.photo = EncodingUtil.base64Encode(b);
        req.id = rentalApply.Id;
        req.ms = DateTime.now().getTime();
        req.latitude = '30';
        req.longitude = '30';
        AL_MobileApp_Controller.CreateAttachmentResponse res = AL_MobileApp_Controller.createAttachment(req);
    }
    
    @isTest
    static void att_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;
        
        BLOB b = Blob.valueOf('ABCDEFGHIJKLMN');
        AL_MobileApp_Controller.CreateAttachmentRequest req = new AL_MobileApp_Controller.CreateAttachmentRequest();
        req.photoType = 'setup_confirmation';
        req.fname = 'ab.png';
        req.photo = EncodingUtil.base64Encode(b);
        req.id = ast1.Id;
        req.ms = DateTime.now().getTime();
        AL_MobileApp_Controller.CreateAttachmentResponse res = AL_MobileApp_Controller.createAttachment(req);
    }
    
    @isTest
    static void att_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;
        
        BLOB b = Blob.valueOf('ABCDEFGHIJKLMN');
        AL_MobileApp_Controller.CreateAttachmentRequest req = new AL_MobileApp_Controller.CreateAttachmentRequest();
        req.photoType = 'receipt';
        req.fname = 'ab.png';
        req.photo = EncodingUtil.base64Encode(b);
        req.id = repair1.Id;
        req.ms = DateTime.now().getTime();
        AL_MobileApp_Controller.CreateAttachmentResponse res = AL_MobileApp_Controller.createAttachment(req);
    }
}