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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
@isTest
private class NewMCAgentUpperLimitPDFControllerTest {
 static testMethod void testDecide_01() {
 
        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);
        insert u3;
        
        system.runAs(u3) {
 
        ControllerUtil.EscapeNFM001Trigger = true;
 
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospita/l';
        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 de/p';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hospital.Id;
        insert dep;
        
        // 製品を作る
        Product2 productA = new Product2( Name='テスト商品', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
        insert productA;
        
 
        
 
        // 维修合同を作成する
        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.Service_Contract_Staff__c = u3.Id;
        contract.Payment_Plan_Sum_First__c = 1;
        insert contract;
        
        // 维修合同报价を作成する
        Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
            Name = 'contract estimate 1',
            Contract_Esti_Start_Date__c = Date.today(),
            Contract_Range__c = 2,
            Maintenance_Contract__c = contract.Id
        );
        Maintenance_Contract_Estimate__c contactEsti2 = new Maintenance_Contract_Estimate__c(
            Name = 'contract estimate 2',
            Contract_Esti_Start_Date__c = Date.today().addMonths(6),
            Contract_Range__c = 3,
            Maintenance_Contract__c = contract.Id
        );
        insert new Maintenance_Contract_Estimate__c[] {contactEsti1, contactEsti2};
        Maintenance_Contract__c testMC = new Maintenance_Contract__c();
 
        testMC.Name = 'test1';
        testMC.Service_Contract_Staff__c = u3.id ;
        testMC.Payment_Plan_Sum_First__c = 5020.00;
        testMc.Payment_Plan_Date_First__c = Date.Today();
        testMC.Small_Repair_Time__c = '7';
        testMC.Big_Repair_Time__c   = '15';
        testMC.Live_Technical_Support_Time__c = '24';
        testMC.Engineer_Name__c = 'test';
        testMC.Phone_Number__c ='1234';
        testMC.Tour_Check__c  = '0';
        testMC.Inspection_Time__c  = '0';
        testMC.Dedust__c  = '0';
        testMC.Department__c = dep.Id;
        testMC.Negotiate_Mean__c  = '1';
        testMC.Estimation_Id__c   = contactEsti1.id;
        testMC.First_Party_Contract_Number__c  = '1';
        testMC.Second_Party_Contract_Number__c  = '2';
        testMC.Term_Of_Payment__c  = '多次付款';
        testMC.one_off_payment_agreed_period__c  = '15';
        testMC.Contract_Amount__c  = 15.00;
        testMC.Total_Contract_Amount_In_Words__c  = '十五元整';
        // testMC.Total_Contract_Amount_In_Words__c  = '6';
        testMC.Payment_Plan_Sum_First_in_Word__c = '十五元整';
        testMC.SalesOfficeCode_selection__c = '沈阳RC';
        testMC.Management_Code__c = '1234';
        testMC.Total_Payment_Time__c = '3';
        testMC.Contract_Start_Date__c = Date.today().addMonths(6);
        testMC.Contract_End_Date__c   = Date.today().addMonths(7);
        upsert testMC;
        PageReference page = new PageReference('/apex/NewMCAgentPDFUpperLimit?id=' + testMC.Id);
        System.Test.setCurrentPage(page);
        NewMCAgentUpperLimitPDFController testNewMCAgentLimitPDFController = new NewMCAgentUpperLimitPDFController();
        // NewMCAgentPDFController testNewMCAgentPDFController = new NewMCAgentPDFController();
        testNewMCAgentLimitPDFController.init();
        // testNewMCAgentPDFController.init();
        testMC.Term_Of_Payment__c  = '一次性付款';
        upsert testMC;
        testNewMCAgentLimitPDFController.init();
        // testNewMCAgentPDFController.init();
        }
    }
    static testMethod void testDecide_02() {
 
        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);
        insert u3;
        
        system.runAs(u3) {
 
        ControllerUtil.EscapeNFM001Trigger = true;
 
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospita/l';
        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 de/p';
        dep.ParentId = strategicDep[0].Id;
        dep.Department_Class__c = strategicDep[0].Id;
        dep.Hospital__c = hospital.Id;
        insert dep;
        
        // 製品を作る
        Product2 productA = new Product2( Name='テスト商品', Maintenance_Price_Year__c = 12000, Manual_Entry__c = false);
        insert productA;
        
 
        
 
        // 维修合同を作成する
        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.Service_Contract_Staff__c = u3.Id;
        contract.Payment_Plan_Sum_First__c = 1;
        insert contract;
        
        // 维修合同报价を作成する
        Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c(
            Name = 'contract estimate 1',
            Contract_Esti_Start_Date__c = Date.today(),
            Contract_Range__c = 2,
            Maintenance_Contract__c = contract.Id
        );
        Maintenance_Contract_Estimate__c contactEsti2 = new Maintenance_Contract_Estimate__c(
            Name = 'contract estimate 2',
            Contract_Esti_Start_Date__c = Date.today().addMonths(6),
            Contract_Range__c = 3,
            Maintenance_Contract__c = contract.Id
        );
        insert new Maintenance_Contract_Estimate__c[] {contactEsti1, contactEsti2};
        Maintenance_Contract__c testMC = new Maintenance_Contract__c();
 
        testMC.Name = 'test1';
        testMC.Service_Contract_Staff__c = u3.id ;
        testMC.Payment_Plan_Sum_First__c = 5020.00;
        testMc.Payment_Plan_Date_First__c = Date.Today();
        testMC.Small_Repair_Time__c = '7';
        testMC.Big_Repair_Time__c   = '15';
        testMC.Live_Technical_Support_Time__c = '24';
        testMC.Engineer_Name__c = 'test';
        testMC.Phone_Number__c ='1234';
        testMC.Tour_Check__c  = '0';
        testMC.Inspection_Time__c  = '0';
        testMC.Dedust__c  = '0';
        testMC.Department__c = dep.Id;
        testMC.Negotiate_Mean__c  = '1';
        testMC.Estimation_Id__c   = contactEsti1.id;
        testMC.First_Party_Contract_Number__c  = '1';
        testMC.Second_Party_Contract_Number__c  = '2';
        testMC.Term_Of_Payment__c  = '多次付款';
        testMC.one_off_payment_agreed_period__c  = '15';
        testMC.Contract_Amount__c  = 15.00;
        testMC.Total_Contract_Amount_In_Words__c  = '十五元整';
        // testMC.Total_Contract_Amount_In_Words__c  = '6';
        testMC.Payment_Plan_Sum_First_in_Word__c = '十五元整';
        testMC.SalesOfficeCode_selection__c = '沈阳RC';
        testMC.Management_Code__c = '1234';
        testMC.Total_Payment_Time__c = '3';
        testMC.Contract_Start_Date__c = Date.today().addMonths(6);
        testMC.Contract_End_Date__c   = Date.today().addMonths(7);
        upsert testMC;
        PageReference page = new PageReference('/apex/NewMCAgentPDFUpperLimit?id=' + testMC.Id);
        System.Test.setCurrentPage(page);
        NewMCAgentUpperLimitPDFController testNewMCAgentLimitPDFController = new NewMCAgentUpperLimitPDFController();
        // NewMCAgentPDFController testNewMCAgentPDFController = new NewMCAgentPDFController();
        testNewMCAgentLimitPDFController.init();
        // testNewMCAgentPDFController.init();
        testMC.Term_Of_Payment__c  = '多次付款';
        upsert testMC;
        testNewMCAgentLimitPDFController.init();
        // testNewMCAgentPDFController.init();
        }
    }
}