GWY
2022-05-21 a3460549533111815e7f73d6cef601a58031525d
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
@isTest
private class SBG017WebServiceTest {
    static String  setdata(){
        Id pricebookId = Test.getStandardPricebookId();
        Pricebook2 pricebook = new Pricebook2(
            Name = 'BS',
            isActive = true
        );
        insert pricebook;
        Product2 product1 = new Product2();
        product1.Name = 'product1';
        Product2 product2 = new Product2();
        product2.Name = 'product2';
        Product2 product3 = new Product2();
        product3.Name = 'product3';
        insert new Product2[] {product1,product2,product3};
        PricebookEntry standardPrice1 = new PricebookEntry(
            Pricebook2Id = pricebookId,
            Product2Id = product1.Id,
            UnitPrice = 0,
            IsActive = true
        );
        PricebookEntry standardPrice2 = new PricebookEntry(
            Pricebook2Id = pricebookId,
            Product2Id = product2.Id,
            UnitPrice = 0,
            IsActive = true
        );
        PricebookEntry standardPrice3 = new PricebookEntry(
            Pricebook2Id = pricebookId,
            Product2Id = product3.Id,
            UnitPrice = 0,
            IsActive = true
        );
        insert new PricebookEntry[] {standardPrice1,standardPrice2,standardPrice3};
        PricebookEntry entry1 = new PricebookEntry( Pricebook2Id=pricebook.Id, Product2Id=product1.Id);
        entry1.UnitPrice = 0;
        entry1.IsActive = true;
        entry1.UseStandardPrice = false;
        entry1.CurrencyIsoCode = 'CNY';
        PricebookEntry entry2 = new PricebookEntry( Pricebook2Id=pricebook.Id, Product2Id=product2.Id);
        entry2.UnitPrice = 0;
        entry2.IsActive = true;
        entry2.UseStandardPrice = false;
        entry2.CurrencyIsoCode = 'CNY';
        PricebookEntry entry3 = new PricebookEntry( Pricebook2Id=pricebook.Id, Product2Id=product3.Id);
        entry3.UnitPrice = 0;
        entry3.IsActive = true;
        entry3.UseStandardPrice = false;
        entry3.CurrencyIsoCode = 'CNY';
        insert new PricebookEntry[] {entry1,entry2,entry3};
        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; 
        Date day1 = Date.today();
        List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
        // 有预定下单日
        Opportunity opp = new Opportunity();
        opp.Name = 'test opp';
        opp.AccountId = accIE.Id;
        opp.RecordTypeId = rectOpp[0].Id;
        opp.OwnerId = UserInfo.getUserId();
        opp.StageName = 'Prospect Created';
        opp.CurrencyIsoCode = 'CNY';
        opp.ProductSegment__c = 'IE';
        opp.CloseDate = Date.today();
        opp.NewInquiryDate__c = Date.today().addDays(-2);
        opp.ExpectedOrderDate__c = Date.today().addDays(2);
        opp.ApprovalStatus_D__c = 'Pass';
        opp.LeadSource = 'LeadSource_D__c';
        opp.BudgetAmount__c = 111;
        opp.CancelReasonText__c = 'Cancel_Reason_Text_D__c';
        opp.CancelReason__c = 'Cancel_reason_D__c';
        opp.CompetitorCompany__c = 'Competitor_Company_D__c';
        opp.Competitor_Product__c = 'Competitor_Product_D__c';
        opp.Competitor_Product2__c = 'Competitor_Product2_D__c';
        opp.Competitor_Product3__c = 'Competitor_Product3_D__c';
        opp.Competitor_Product4__c = 'Competitor_Product4_D__c';
        opp.Competitor_Product5__c = 'Competitor_Product5_D__c';
        opp.Competitor_Product6__c = 'Competitor_Product6_D__c';
        opp.Competitor_Product7__c = 'Competitor_Product7_D__c';
        opp.Competitor_Product8__c = 'Competitor_Product8_D__c';
        opp.CompetitorProductCode__c = 'Competitor_Product_Code_D__c';
        opp.CompetitorProductCode2__c = 'Competitor_Product_Code2_D__c';
        opp.CompetitorProductCode3__c = 'Competitor_Product_Code3_D__c';
        opp.CompetitorProductCode4__c = 'Competitor_Product_Code4_D__c';
        opp.CompetitorProductCode5__c = 'Competitor_Product_Code5_D__c';
        opp.CompetitorProductCode6__c = 'Competitor_Product_Code6_D__c';
        opp.CompetitorProductCode7__c = 'Competitor_Product_Code7_D__c';
        opp.CompetitorProductCode8__c = 'Competitor_Product_Code8_D__c';
        opp.DealerSalesStaffName__c = 'Dealer_Sales_Staff_Name_D__c';
        opp.DealerService__c = 'Dealer_Service_D__c';
        opp.ExpectedDeliveryDate__c = day1;
        opp.InquiryResult__c = 'InquiryResultD__c';
        //opp.InquiryResultCancel__c = day1;
        //opp.InquiryResultLost__c = day1;
        opp.InquiryResultOrder__c = day1;
        opp.LostAmount__c = 111;
        opp.LostCompetitorProduct__c = 'Lost_competitor_product_D__c';
        opp.LostReasonText__c = 'LostReasonText_D__c';
        opp.LostReason__c = 'Lostreason_D__c';
        opp.Phase1Date__c = day1;
        opp.Phase2Date__c = day1;
        opp.Phase3Date__c = day1;
        opp.SalesChannel__c = 'Sales_Channel_D__c';
        opp.SubDealer__c = 'Sub_Dealer_D__c';
        opp.TradeType__c = 'Trade_Type_D__c';
        //opp.Machine_Parts__c = 'Machine_Parts_D__c';
        //opp.SpecialDeliveryAddress__c = 'SpecialDeliveryAddress_D__c';
        //opp.ForeignTradeCompany__c = 'ForeignTradeCompany_D__c';
        insert opp;
        OpportunityLineItem oli = new OpportunityLineItem();
        oli.OpportunityId = opp.Id;
        oli.Quantity = 2;
        oli.UnitPrice = 111;
        oli.Description = 'test';
        oli.PricebookEntryId = entry1.Id;
        insert oli;
        List<RecordType> rectOrder = [select id from RecordType where IsActive = true and SobjectType = 'Order'];
        Order odr = new Order(
            Name = '',
            Status = 'Draft',
            AccountId = accIE.Id,
            ApproveStatus__c = 'Draft',
            OpportunityId = opp.Id,
            EffectiveDate = Date.today(),
            RecordTypeId = '01228000000NJt6'
        );
        insert odr;
        Delivery__c de1 = new Delivery__c();
        de1.SSBD_Contract__c = odr.Id;
        insert de1;
        Opportunity ordd = [Select InquiryNumber__c,Id,Name From Opportunity];
        return ordd.InquiryNumber__c;
    }
 
 
    @isTest static void test_method_1() {
        String SAP = setdata();
        System.debug(SAP);
        SBG017WebService.GeData GeData = new SBG017WebService.GeData();
        GeData.SAPQuotationCode = '123';
        GeData.OpportunityCode = SAP;
        GeData.StockAnswer = '123';
        SBG017WebService.GeDatas datas = new SBG017WebService.GeDatas();
        datas.GeData = new List<SBG017WebService.GeData>();
        datas.GeData.add(GeData);
        datas.Monitoring = new NFMUtil.Monitoring();
        SBG017WebService.SBG017(datas);
    }
 
    @isTest static void test_method_2() {
        String SAP = setdata();
        System.debug(SAP);
        SBG017WebService.GeData GeData = new SBG017WebService.GeData();
        GeData.SAPQuotationCode = '123';
        GeData.OpportunityCode = '';
        GeData.StockAnswer = '123';
        SBG017WebService.GeDatas datas = new SBG017WebService.GeDatas();
        datas.GeData = new List<SBG017WebService.GeData>();
        datas.GeData.add(GeData);
        datas.Monitoring = new NFMUtil.Monitoring();
        SBG017WebService.SBG017(datas);
    }
 
    @isTest static void test_method_3() {
        String SAP = setdata();
        System.debug(SAP);
        SBG017WebService.GeData GeData = new SBG017WebService.GeData();
        GeData.SAPQuotationCode = '123';
        GeData.OpportunityCode = SAP;
        GeData.StockAnswer = '';
        SBG017WebService.GeDatas datas = new SBG017WebService.GeDatas();
        datas.GeData = new List<SBG017WebService.GeData>();
        datas.GeData.add(GeData);
        datas.Monitoring = new NFMUtil.Monitoring();
        SBG017WebService.SBG017(datas);
    }
 
    @isTest static void test_method_4() {
        String SAP = setdata();
        System.debug(SAP);
        SBG017WebService.GeData GeData = new SBG017WebService.GeData();
        GeData.SAPQuotationCode = '';
        GeData.OpportunityCode = SAP;
        GeData.StockAnswer = '123';
        SBG017WebService.GeDatas datas = new SBG017WebService.GeDatas();
        datas.GeData = new List<SBG017WebService.GeData>();
        datas.GeData.add(GeData);
        datas.Monitoring = new NFMUtil.Monitoring();
        SBG017WebService.SBG017(datas);
    }
 
 
    @isTest static void test_method_5() {
        String SAP = setdata();
        System.debug(SAP);
        SBG017WebService.GeData GeData = new SBG017WebService.GeData();
        GeData.SAPQuotationCode = '123';
        GeData.OpportunityCode = '123';
        GeData.StockAnswer = '123';
        SBG017WebService.GeDatas datas = new SBG017WebService.GeDatas();
        datas.GeData = new List<SBG017WebService.GeData>();
        datas.GeData.add(GeData);
        datas.Monitoring = new NFMUtil.Monitoring();
        SBG017WebService.SBG017(datas);
    }
 
}