buli
2023-07-14 e6068da47c1bef5517c9e5fdc8c726766867ad4e
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
@isTest
private class LexConInvoiceListTest {
    static testMethod void conInvoiceListTestinit() {
        user myUser_test;
        Account myAccount2;
        Account myAccount1;
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        System.runAs(thisUser) {
            Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
            List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'];
            if (rectCo.size() == 0) {
                return;
            }
            List<RecordType> rectHos = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
            if (rectHos.size() == 0) {
                return;
            }
            myAccount1 = new Account(name = 'testaccount001', RecordTypeId = rectCo[0].Id);
            myAccount2 = new Account(name = 'testaccount002', RecordTypeId = rectHos[0].Id);
            insert myAccount1;
            Contact core = new Contact(
                email = 'jplumber@salesforce.com',
                firstname = 'Joe',
                lastname = 'Plumber',
                accountid = myAccount1.id
            );
            insert core;
            myUser_test = new User(
                ContactId = core.id,
                Alias = 'newUser',
                Email = 'newuser@testorg.com',
                EmailEncodingKey = 'UTF-8',
                LastName = 'testUser',
                LanguageLocaleKey = 'zh_CN',
                LocaleSidKey = 'zh_CN',
                ProfileId = prof.Id,
                TimeZoneSidKey = 'Asia/Shanghai',
                UserName = 'testUser@testorg.com',
                Work_Location__c = '北京'
            );
            insert myUser_test;
        }
        System.runAs(myUser_test) {
            Consumable_order__c TestList1 = new Consumable_order__c(
                Name = 'Test1',
                Invoice_Date__c = Date.today(),
                Dealer_info__c = myAccount1.Id,
                Invoice_status__c = '草案中',
                Order_ForHospital__c = myAccount2.Id,
                SummonsForDirction__c = '直接销售给医院',
                Order_status__c = '草案中',
                Order_type__c = '发票',
                recordtypeid = System.Label.RT_ConOrder_Invoice,
                Order_ProType__c = 'ET'
            );
            Consumable_order__c TestList2 = new Consumable_order__c(
                Name = 'Test2',
                Invoice_Date__c = Date.today(),
                Dealer_info__c = myAccount1.Id,
                Invoice_status__c = '提交',
                Order_ForHospital__c = myAccount2.Id,
                SummonsForDirction__c = '直接销售给医院',
                Order_status__c = '草案中',
                Order_type__c = '发票',
                recordtypeid = System.Label.RT_ConOrder_Invoice,
                Order_ProType__c = 'ET'
            );
            insert new List<Consumable_order__c>{ TestList1, TestList2 };
            LexConInvoiceList.init();
            // ConInvoiceListController CDC = new ConInvoiceListController();
            // CDC.init();
            // System.assertEquals('Test1', CDC.raesList[0].name);
            // System.assertEquals('Test2', CDC.raesList[1].name);
            // CDC.SortLimited();
            // System.assertEquals('Test1', CDC.raesList[0].name);
            // System.assertEquals('Test2', CDC.raesList[1].name);
        }
    }
    //检索
    static testMethod void invoiceCodeSearchTest() {
        user myUser_test;
        Account myAccount2;
        Account myAccount1;
        User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        System.runAs(thisUser) {
            Profile prof = [SELECT Id FROM Profile WHERE Name = '901_经销商社区普通权限_2重验证(ET)'];
            List<RecordType> rectCo = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'];
            if (rectCo.size() == 0) {
                return;
            }
            List<RecordType> rectHos = [SELECT Id FROM RecordType WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'];
            if (rectHos.size() == 0) {
                return;
            }
            myAccount1 = new Account(name = 'testaccount001', RecordTypeId = rectCo[0].Id);
            myAccount2 = new Account(name = 'testaccount002', RecordTypeId = rectHos[0].Id);
            insert myAccount1;
            Contact core = new Contact(
                email = 'jplumber@salesforce.com',
                firstname = 'Joe',
                lastname = 'Plumber',
                accountid = myAccount1.id
            );
            insert core;
            myUser_test = new User(
                ContactId = core.id,
                Alias = 'newUser',
                Email = 'newuser@testorg.com',
                EmailEncodingKey = 'UTF-8',
                LastName = 'testUser',
                LanguageLocaleKey = 'zh_CN',
                LocaleSidKey = 'zh_CN',
                ProfileId = prof.Id,
                TimeZoneSidKey = 'Asia/Shanghai',
                UserName = 'testUser@testorg.com',
                Work_Location__c = '北京'
            );
            insert myUser_test;
        }
 
        System.runAs(myUser_test) {
            Consumable_order__c TestList1 = new Consumable_order__c(
                Name = 'Test1',
                Invoice_Date__c = Date.today(),
                Dealer_info__c = myAccount1.Id,
                Invoice_status__c = '草案中',
                Order_ForHospital__c = myAccount2.Id,
                SummonsForDirction__c = '直接销售给医院',
                Order_status__c = '草案中',
                Order_type__c = '发票',
                recordtypeid = System.Label.RT_ConOrder_Invoice,
                Order_ProType__c = 'ET'
            );
            Consumable_order__c TestList2 = new Consumable_order__c(
                Name = 'Test2',
                Invoice_Date__c = Date.today(),
                Dealer_info__c = myAccount1.Id,
                Invoice_status__c = '提交',
                Order_ForHospital__c = myAccount2.Id,
                SummonsForDirction__c = '直接销售给医院',
                Order_status__c = '草案中',
                Order_type__c = '发票',
                recordtypeid = System.Label.RT_ConOrder_Invoice,
                Order_ProType__c = 'ET'
            );
            insert new List<Consumable_order__c>{ TestList1, TestList2 };
            LexConInvoiceList CDC = new LexConInvoiceList();
            LexConInvoiceList.init();
            LexConInvoiceList.invoiceCodeSearch(Date.today(), Date.today(), '提交', 'test', 'test1', '0010l00001ajxZ2AAI', '北京', 'ET');
            // CDC.init();
            // System.assertEquals('Test1', CDC.raesList[0].name);
            // System.assertEquals('Test2', CDC.raesList[1].name);
            // CDC.coc.Invoice_status__c = '提交';
            // CDC.invoiceCodeSearch();
            // System.assertEquals(1, CDC.raesList.size());
            // CDC.clearUp();
            // System.assertEquals(2, CDC.raesList.size());
        }
    }
}