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
@isTest
private class Consumabledet2upjuBatchTest {
    static testMethod void testMethod1() {
 
        // TO DO: implement unit test
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证'];
 
        StaticParameter.ConsumableAssetHanderTrigger = true;
 
        Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
        insert myAccount2;
        Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',JANCODE__c = '04953170200311',Dealer_special_Object__c = true);
        insert new Product2[]{prod01};
        Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
        insert new Product2__c[] {pro1};
        //订单
        Consumable_order__c Order1 = new Consumable_order__c();
        Order1.Name = 'OCM_01_001';
        Order1.Order_status__c = '批准';
        Order1.Order_type__c = '订单';
        Order1.Dealer_Info__c = myAccount2.Id;
        Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
        Order1.Total_num__c = 3;
        Order1.OrderNumber_arrived__c =1;
        Order1.Delivery_detail_count__c=1;
        Order1.Order_ProType__c = 'ET';
        insert  Order1;
 
        // 调货单
        Consumable_order__c Order3 = new Consumable_order__c();
        Order3.Name = 'OCM_02_005';
        Order3.Order_status__c = '批准';
        Order3.Order_type__c = '传票';
        Order3.RecordTypeid = System.Label.RT_ConOrder_Order;
        Order3.Arrive_Order__c=  Order1.Id; 
        Order3.Order_ForDealerText__c = myAccount2.Name;
        Order3.Dealer_Info__c = myAccount2.Id;
        Order3.SummonsForDirction__c ='互相调货';
        insert  Order3;
 
        //发货明细
        //到货正确信息
        Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
        Orderdet1.Name = 'OCM-150P-001002';
        Orderdet1.Consumable_order_minor__c = Order1.Id;
        Orderdet1.Consumable_Arrived_order__c = Order1.Id;
        Orderdet1.Consumable_Product__c = pro1.Id;
        Orderdet1.Asset_Model_No__c = 'Test01';
        Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        Orderdet1.TracingCode__c = 'BXJRA';
        Orderdet1.SerialLotNo__c = '5ZK';
        Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRA';
        Orderdet1.Arrive_date__c = Date.today();
        Orderdet1.Consumable_Shipment_order__c = Order3.Id;
        Orderdet1.Send_Date__c = Date.today();
 
        //发货明细
        //到货正确信息
        Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
        Orderdet2.Name = 'OCM-150P-001002';
        Orderdet2.Consumable_order_minor__c = Order1.Id;
        Orderdet2.Consumable_Arrived_order__c = Order1.Id;
        Orderdet2.Consumable_Product__c = pro1.Id;
        Orderdet2.Asset_Model_No__c = 'Test01';
        Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        Orderdet2.TracingCode__c = 'BXJRB';
        Orderdet2.SerialLotNo__c = '5ZK';
        Orderdet2.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRB';
        Orderdet2.Consumable_Shipment_order__c = Order3.Id;
        Orderdet2.Send_Date__c = Date.today();
        Orderdet2.Arrive_date__c = Date.today();
 
 
        //发货明细
        //到货正确信息
        Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
        Orderdet3.Name = 'OCM-150P-001002';
        Orderdet3.Consumable_order_minor__c = Order1.Id;
        Orderdet3.Consumable_Arrived_order__c = Order1.Id;
        Orderdet3.Consumable_Product__c = pro1.Id;
        Orderdet3.Asset_Model_No__c = 'Test01';
        Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        Orderdet3.TracingCode__c = 'BXJRB';
        Orderdet3.SerialLotNo__c = '5ZK';
        Orderdet3.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRB';
        Orderdet3.Arrive_date__c = Date.today();
        Orderdet3.Consumable_Shipment_order__c = Order3.Id;
        Orderdet3.Send_Date__c = Date.today();
 
 
        //发货明细
        //到货正确信息
        Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
        Orderdet4.Name = 'OCM-150P-001002';
        Orderdet4.Consumable_order_minor__c = Order1.Id;
        Orderdet4.Consumable_Arrived_order__c = Order1.Id;
        Orderdet4.Consumable_Product__c = pro1.Id;
        Orderdet4.Asset_Model_No__c = 'Test01';
        Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        Orderdet4.TracingCode__c = 'BXJRB';
        Orderdet4.SerialLotNo__c = '5ZK';
        Orderdet4.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRB';
        Orderdet4.Arrive_date__c = Date.today();
        Orderdet4.Consumable_Shipment_order__c = Order3.Id;
        Orderdet4.Send_Date__c = Date.today();
 
        //发货明细
        //到货正确信息
        Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
        Orderdet5.Name = 'OCM-150P-001002';
        Orderdet5.Consumable_Arrived_order__c = Order1.Id;
        Orderdet5.Consumable_Product__c = pro1.Id;
        Orderdet5.Asset_Model_No__c = 'Test01';
        Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        Orderdet5.TracingCode__c = 'BXJRC';
        Orderdet5.SerialLotNo__c = '5ZK';
        Orderdet5.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRC';
        Orderdet5.Arrive_date__c = Date.today();
        Orderdet5.Dealer_Info_IF__c = myAccount2.Id;
        Orderdet5.Consumable_Shipment_order__c = Order3.Id;
        Orderdet5.Send_Date__c = Date.today();
 
 
        insert new Consumable_order_details2__c[] {Orderdet1,Orderdet2,Orderdet3,Orderdet4,Orderdet5};
 
        System.Test.StartTest();
        List<String> testid = new List<String>();
        testid.add('BXJRB');
        Id execBTId = Database.executeBatch(new Consumabledet2upjuBatch(null), 10);
        //Id execBTId = Database.executeBatch(new Consumabledet2up(null), 2);
        System.Test.StopTest();
        Consumable_order_details2__c cod1 = [select Id,Agency_Transfer__c,Transfer_Time__c from Consumable_order_details2__c WHERE Id = :Orderdet1.Id];
        System.assertEquals(true, cod1.Agency_Transfer__c);
        System.assertEquals(1, cod1.Transfer_Time__c);
        
    }
}