/**********************************************************************
 * vivek2020-03-26
 *
*************************************************************************/
@isTest(SeeAllData = true)
public class ConsumableOrderDetail2Test {
    static testMethod void testInsert(){
    	List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
        if (rectCo.size() == 0) {
            return;
        }
        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 = '有効',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);
        // Contact core = new Contact(email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountid = myAccount2.id);
        // insert core;
        // user 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');
        // insert MyUser_Test;
        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;
        insert  Order1;
        //Consumable_order__c coc = [select Dealer_Info__r.name from Consumable_order__c where Id =:Order1.Id];
        //system.assertEquals('qeee',coc.Dealer_Info__r.name);

        //订单明细
        //fahuo
        Consumable_orderdetails__c Orderdet = new Consumable_orderdetails__c();
        Orderdet.Name = 'OCM_01_001001';
        Orderdet.Consumable_order__c = Order1.Id;
        Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
        Orderdet.Consumable_Product__c = pro1.Id;
        Orderdet.Consumable_count__c = 4;
        insert Orderdet;

        //发货明细
        //fahuo
        Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
        Orderdet1.Name = 'OCM_01_001001';
        Orderdet1.Consumable_order_minor__c = Order1.Id;
        Orderdet1.Consumable_Product__c = pro1.Id;
        Orderdet1.Asset_Model_No__c = 'Pro001';
        Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        Orderdet1.Box_Piece__c ='盒';
        Orderdet1.Bar_Code__c = '01049531702003111115120017181000105ZK250BXJRF';
        Orderdet1.Used_account__c = myAccount2.Id;
        insert Orderdet1;
    }
}