buli
2022-04-26 5835379ec30b1667c4e522db9d294c9b7bb8633a
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
@isTest
private class SBG007TriggerHandlerTest
{
    //add sushanhu for pipl 20220415
    @testSetup
    static void makaDate(){
        TestDataUtility.CreatePIPolicyConfiguration();
    }
    //add sushanhu for pipl 20220415
//    static testMethod void itShould(){
//        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
//        Account accIE = new Account(
//            Name = '*',
//            RecordTypeId = rectIE[0].Id,
//            OwnerId = UserInfo.getUserId(),
//            DivisionName__c='Customer IE',
//            FacilityName__c='abc',
//            PostCode__c = '123456'
//        );
//        insert accIE;
//PriceBook2 pricebook =new PriceBook2(
//            Name = 'IE',
//            ProductSegment__c = 'IE',
//            TradeType__c = 'Taxation',
//            SalesChannel__c = 'direct',
//            MachineParts__c = 'Machine'
//        );
//        insert pricebook;
 
//        List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
//        Opportunity opp = new Opportunity(
//            Name = 'test opp',
//            the_Upload_of_quotation_number__c = 'test1',
//            AccountId = accIE.Id,
//            RecordTypeId = rectOpp[0].Id,
//            OwnerId = UserInfo.getUserId(),
//            StageName = 'Prospect Created',
//            CancelReason__c = 'Inquiry repeat',
//            Cancel_reason_D__c = 'Inquiry repeat',
//            CurrencyIsoCode = 'CNY',
//            ProductSegment__c = 'IE',
//            CloseDate = Date.today(),
//            NewInquiryDate__c = Date.today().addDays(-2),
//            ExpectedOrderDate__c = Date.today().addDays(2),
//            TradeType__c = 'Taxation',
//            SalesChannel__c = 'direct',
//            Machine_Parts__c = 'Machine'
//        );
//        insert opp;                
//         List<OpportunityLineItem> oppLiList = [select Id, Quantity, PricebookEntry.ProductCode, OpportunityId
//                                           from OpportunityLineItem where Opportunity.Id = :opp.Id ];
//        OpportunityLineItem oppLineItem = new OpportunityLineItem(
            
//            Quantity = 1,
//            //PricebookEntry.ProductCode='11',
//            OpportunityId= opp.Id
//        );
        
        
//        opp.the_Upload_of_quotation_number__c = 'test2';
//        upsert opp;
        
 
        
        
 
//        // SBG007より、送信しないこと
//           System.assertEquals('', SBG007TriggerHandler.debug_msg);
 
//    }
 
    static testMethod void itShould2(){
        
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        Account accIE = new Account(
            Name = '*',
            RecordTypeId = rectIE[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c='Customer IE',
            FacilityName__c='abc',
            PostCode__c = '123456'
        );
 
        insert accIE;
        //PriceBook2 pricebook =new PriceBook2(
        //    Name = 'IE',
        //    ProductSegment__c = 'IE',
        //    TradeType__c = 'Taxation',
        //    SalesChannel__c = 'direct',
        //    MachineParts__c = 'Machine'
        //);
        //insert pricebook;
 
        Pricebook2 pricebook = new Pricebook2(
            Name = 'IE',
            ProductSegment__c = 'IE',
            TradeType__c = 'Taxation',
            SalesChannel__c = 'direct',
            MachineParts__c = 'Machine',
            isActive = true
        );
        insert pricebook;
        List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
        Opportunity opp = new Opportunity(
            Name = 'test opp',
            the_Upload_of_quotation_number__c = 'test1',
            AccountId = accIE.Id,
            RecordTypeId = rectOpp[0].Id,
            OwnerId = UserInfo.getUserId(),
            StageName = 'Prospect Created',
            CancelReason__c = 'Inquiry repeat',
            Cancel_reason_D__c = 'Inquiry repeat',
            CurrencyIsoCode = 'CNY',
            ProductSegment__c = 'IE',
            CloseDate = Date.today(),
            NewInquiryDate__c = Date.today().addDays(-2),
            ExpectedOrderDate__c = Date.today().addDays(2),
            TradeType__c = 'Taxation',
            SalesChannel__c = 'direct',
            Machine_Parts__c = 'Machine',
            Pricebook2Id = pricebook.Id
        );
        insert opp;
 
         Quote quo = new Quote(
            //Name = 'quo',
            //OpportunityId = opp.Id,
            //SetName1__c = 'setname01',
            //SetQty1__c = 1,
            //Pricebook2Id = pricebook.Id
            Name = 'quo',
            OpportunityId = opp.Id,
            Pricebook2Id = pricebook.Id,
            SetName1__c = 'setname1',
            SetQty1__c = 1,
            SetName2__c = 'setname2',
            SetQty2__c = 2,
            Custom_Price_Total_Text__c = 1000
            //IsSyncing = true
        );
        insert quo;
 
        opp.SyncedQuoteId = quo.Id;
        update opp;
 
        List<productSet__c>  insertproductSets = new  List<productSet__c>();
        productSet__c proSet1 = new productSet__c();
        proSet1.Code__c = 'IXP-7P2';
        proSet1.Name = 'IXP-7P2';
        proSet1.IsValid__c = true;
        proSet1.Name = 'IXP-7P2';
        insertproductSets.add(proSet1);
        productSet__c proSet2 = new productSet__c();
        proSet2.Code__c = 'IXP-7P1SC';
        proSet2.Name = 'IXP-7P1SC';
        proSet2.IsValid__c = true;
        proSet2.Name = 'IXP-7P1SC';
        insertproductSets.add(proSet2);
        productSet__c proSet3 = new productSet__c();
        proSet3.Code__c = 'IXSP-T7LED';
        proSet3.Name = 'IXSP-T7LED';
        proSet3.IsValid__c = true;
        proSet3.Name = 'IXSP-T7LED';
        insertproductSets.add(proSet3);
 
 
        insert insertproductSets;
 
        Product2 product3 = new Product2();
        product3.Name = 'product3';
        product3.ProductCode = 'product3';
        product3.Product_ECCode__c = 'product3';
        product3.IsActive = true;
 
        insert product3;
 
        PricebookEntry entry1 = new PricebookEntry(
            Pricebook2Id = pricebook.Id,
            Product2Id = product3.Id,
            UnitPrice = 0,
            IsActive = true,
            UseStandardPrice = false
            //CurrencyIsoCode = 'CNY'
        );
 
        DecideQuoteProductSet__c dqps = new DecideQuoteProductSet__c();
 
        dqps.DecideProductSet__c = proSet1.Id ;
        dqps.DecideProductSetCount__c = 4;
        dqps.DecideOpportunity__c = opp.Id;
        dqps.DecideQuote__c = quo.Id;
 
        insert dqps;
                
         List<OpportunityLineItem> oppLiList = [select Id, Quantity, PricebookEntry.ProductCode, OpportunityId
                                           from OpportunityLineItem where Opportunity.Id = :opp.Id ];
        //OpportunityLineItem oppLineItem = new OpportunityLineItem(
            
        //    Quantity = 1,
        //    //PricebookEntry.ProductCode='11',
        //    OpportunityId= opp.Id,
        //    PricebookEntryId = entry1.Id,
        //     UnitPrice = 10
        //     //,
        //     //PricebookEntryId = entry1.Id,
        //);
        //OpportunityLineItem oppLineItem1 = new OpportunityLineItem(
            
        //    Quantity = 1,
        //    //PricebookEntry.ProductCode='11',
        //    OpportunityId= opp.Id,
        //    OLISingleProduct__c = true,
        //    PricebookEntryId = entry1.Id,
        //    UnitPrice = 10
        //);
        //insert new OpportunityLineItem[] {oppLineItem,oppLineItem1};
        
 
        OpportunityLineItem oli1 = new OpportunityLineItem(
            OpportunityId = opp.Id,
            //PricebookEntryId = entry1.Id,
            Quantity = 10,
            UnitPrice = 10,
            Product2Id = product3.Id 
        );
        OpportunityLineItem oli2 = new OpportunityLineItem(
            OpportunityId = opp.Id,
            //PricebookEntryId = entry1.Id,
            Quantity = 20,
            UnitPrice = 20,
            Product2Id = product3.Id 
        );
        //insert new OpportunityLineItem[] {oli1, oli2};
        opp.the_Upload_of_quotation_number__c = 'test2';
        upsert opp;
        
 
        
        
 
        // SBG007より、送信しないこと
           System.assertEquals('', SBG007TriggerHandler.debug_msg);
 
    }
   
    static testMethod void itShould1(){
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Log__c = '{"GeDatas":{"Monitoring":{"TransmissionDateTime":"202108250938","Text":"","Tag":"MSGH","Sender":"8405","Receiver":"1330","NumberOfRecord":"1","MessageType":"SBG027","MessageGroupNumber":"20210000465499"},"GeData":[{"ZNMPA":"N","TradeType":"Taxation","SpecialWarranty":null,"SpecialDeliveryAddress":"3000002093,C-2018-72066","ServiceFee":null,"SalesChannel":"41","SalesAccountCode":"76002795","PurposeOfAdvice":null,"ProductSegment":"BS","PaymentCondition":"ZZTT","Other3":"null,null","Other2":"跨省份合作项目","Other1":"test,dealer","OrderCode":"00050193","OpportunityCode":"O-2021-115172","OlympusPriceBeforeDiscount":null,"OlympusContractPrices":729412.00,"MachineParts":"Machine","GeDataDetails":[{"ItemQuantity":20,"ItemCode":"000000000006498300","DetailLine":10},{"ItemQuantity":20,"ItemCode":"N2664900","DetailLine":20}],"ForeignTradeCompany":null,"EndUser":"C-2016-25119","Discount":49.00,"DeliveryDate":"20210825","DealerSalesStaffName":"a","DealerCode":"3000002093","CoopAgentPCT":"50","CoopAgent":"A-2021-120990"}]}}';
        insert iflog;
        SBG007TriggerHandler.execute(iflog,null);
    }   
 
}