| | |
| | | User myUser_test; |
| | | Account myAccount1; |
| | | Account myAccount2; |
| | | User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()]; |
| | | 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 = '販売店' |
| | | ]; |
| | | 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 = '病院' |
| | | ]; |
| | | 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', |
| | | Dealer_discount__c = 10, |
| | | RecordTypeId = rectCo[0].Id |
| | | ); |
| | | myAccount2 = new Account( |
| | | Name = 'testaccount002', |
| | | Dealer_discount__c = 20, |
| | | RecordTypeId = rectHos[0].Id |
| | | ); |
| | | myAccount1 = new Account(Name='testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id ); |
| | | myAccount2 = new Account(Name='testaccount002',Dealer_discount__c =20,RecordTypeId = rectHos[0].Id ); |
| | | insert myAccount1; |
| | | insert myAccount2; |
| | | Contact core = new Contact( |
| | | email = 'jplumber@salesforce.com', |
| | | firstname = 'Joe', |
| | | lastname = 'Plumber', |
| | | accountid = myAccount1.id |
| | | ); |
| | | 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', |
| | | UserPro_Type__c = 'ENG', |
| | | Work_Location__c = '北京' |
| | | ); |
| | | 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', UserPro_Type__c='ENG', Work_Location__c='北京'); |
| | | insert myUser_test; |
| | | } |
| | | System.runAs(myUser_test) { |
| | | //产品信息 |
| | | Product2 prod01 = new Product2( |
| | | Name = 'Test01', |
| | | ProductCode = 'Test01', |
| | | Asset_Model_No__c = 'Test01', |
| | | SFDA_Status__c = '有効', |
| | | Dealer_special_Object__c = true, |
| | | Packing_list_manual__c = 1, |
| | | Manual_Entry__c = false |
| | | ); |
| | | Product2 prod02 = new Product2( |
| | | Name = 'Test02', |
| | | ProductCode = 'Test02', |
| | | Asset_Model_No__c = 'Test02', |
| | | SFDA_Status__c = '有効', |
| | | Dealer_special_Object__c = true, |
| | | Packing_list_manual__c = 1, |
| | | Manual_Entry__c = false |
| | | ); |
| | | Product2 prod03 = new Product2( |
| | | Name = 'Test03', |
| | | ProductCode = 'Test03', |
| | | Asset_Model_No__c = 'Test03', |
| | | SFDA_Status__c = '有効', |
| | | Dealer_special_Object__c = true, |
| | | Packing_list_manual__c = 1, |
| | | Manual_Entry__c = false |
| | | ); |
| | | Product2 prod04 = new Product2( |
| | | Name = 'Test04', |
| | | ProductCode = 'Test04', |
| | | Asset_Model_No__c = 'Test04', |
| | | SFDA_Status__c = '有効', |
| | | Dealer_special_Object__c = true, |
| | | Packing_list_manual__c = 2, |
| | | Manual_Entry__c = false |
| | | ); |
| | | Product2 prod05 = new Product2( |
| | | Name = 'Test05', |
| | | ProductCode = 'Test05', |
| | | Asset_Model_No__c = 'Test05', |
| | | SFDA_Status__c = '有効', |
| | | Dealer_special_Object__c = true, |
| | | Packing_list_manual__c = 1, |
| | | Manual_Entry__c = false |
| | | ); |
| | | Product2 prod06 = new Product2( |
| | | Name = 'Test06', |
| | | ProductCode = 'Test06', |
| | | Asset_Model_No__c = 'Test06', |
| | | SFDA_Status__c = '有効', |
| | | Dealer_special_Object__c = true, |
| | | Packing_list_manual__c = 1, |
| | | Manual_Entry__c = false |
| | | ); |
| | | insert new List<Product2>{ |
| | | prod01, |
| | | prod02, |
| | | prod03, |
| | | prod04, |
| | | prod05, |
| | | prod06 |
| | | }; |
| | | Product2__c pro1 = new Product2__c( |
| | | Name = 'Pro001', |
| | | OT_CODE_Text__c = 'Test001', |
| | | Product2__c = prod01.Id |
| | | ); |
| | | Product2__c pro2 = new Product2__c( |
| | | Name = 'Pro002', |
| | | OT_CODE_Text__c = 'Test002', |
| | | Product2__c = prod02.Id |
| | | ); |
| | | Product2__c pro3 = new Product2__c( |
| | | Name = 'Pro004', |
| | | OT_CODE_Text__c = 'Test004', |
| | | Product2__c = prod03.Id |
| | | ); |
| | | Product2__c pro4 = new Product2__c( |
| | | Name = 'Pro005', |
| | | OT_CODE_Text__c = 'Test005', |
| | | Product2__c = prod04.Id |
| | | ); |
| | | Product2__c pro5 = new Product2__c( |
| | | Name = 'Pro003', |
| | | OT_CODE_Text__c = 'Test003', |
| | | Product2__c = prod05.Id |
| | | ); |
| | | Product2__c pro6 = new Product2__c( |
| | | Name = 'Pro006', |
| | | OT_CODE_Text__c = 'Test006', |
| | | Product2__c = prod06.Id |
| | | ); |
| | | insert new List<Product2__c>{ pro4, pro5, pro6, pro1, pro2, pro3 }; |
| | | Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=1,Manual_Entry__c = false); |
| | | Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=1,Manual_Entry__c = false); |
| | | Product2 prod03 = new Product2(Name='Test03',ProductCode='Test03',Asset_Model_No__c = 'Test03',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=1,Manual_Entry__c = false); |
| | | Product2 prod04 = new Product2(Name='Test04',ProductCode='Test04',Asset_Model_No__c = 'Test04',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=2,Manual_Entry__c = false); |
| | | Product2 prod05 = new Product2(Name='Test05',ProductCode='Test05',Asset_Model_No__c = 'Test05',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=1,Manual_Entry__c = false); |
| | | Product2 prod06 = new Product2(Name='Test06',ProductCode='Test06',Asset_Model_No__c = 'Test06',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=1,Manual_Entry__c = false); |
| | | insert new Product2[] {prod01, prod02,prod03,prod04, prod05, prod06}; |
| | | Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id); |
| | | Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id); |
| | | Product2__c pro3 = new Product2__c(Name='Pro004',OT_CODE_Text__c='Test004',Product2__c = prod03.Id); |
| | | Product2__c pro4 = new Product2__c(Name='Pro005',OT_CODE_Text__c='Test005',Product2__c = prod04.Id); |
| | | Product2__c pro5 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prod05.Id); |
| | | Product2__c pro6 = new Product2__c(Name='Pro006',OT_CODE_Text__c='Test006',Product2__c = prod06.Id); |
| | | insert new Product2__c[] {pro4, pro5,pro6,pro1, pro2, pro3}; |
| | | //发票 |
| | | Consumable_order__c invoiceorder = new Consumable_order__c(); |
| | | invoiceorder.Name = 'invoice02'; |
| | |
| | | |
| | | //出库单信息 |
| | | //出库单 |
| | | Consumable_order__c testList1 = new Consumable_order__c( |
| | | Name = 'Test1', |
| | | Summons_Sale_Status__c = '出货', |
| | | SummonsStatus_c__c = '已完成', |
| | | SummonsForDirction__c = '直接销售给医院', |
| | | Order_status__c = '草案中', |
| | | Order_type__c = '传票', |
| | | Dealer_info__c = myAccount1.Id, |
| | | ConInvoice_Code__c = invoiceorder.id |
| | | ); |
| | | Consumable_order__c testList2 = new Consumable_order__c( |
| | | Name = 'Test2', |
| | | Summons_Sale_Status__c = '出货', |
| | | SummonsStatus_c__c = '已完成', |
| | | SummonsForDirction__c = '直接销售给医院', |
| | | Order_status__c = '已提交', |
| | | Order_type__c = '传票', |
| | | Dealer_info__c = myAccount1.Id, |
| | | ConInvoice_Code__c = invoiceorder.id |
| | | ); |
| | | Consumable_order__c testList1 = new Consumable_order__c(Name='Test1',Summons_Sale_Status__c='出货',SummonsStatus_c__c='已完成',SummonsForDirction__c='直接销售给医院',Order_status__c='草案中',Order_type__c='传票',Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id); |
| | | Consumable_order__c testList2 = new Consumable_order__c(Name='Test2',Summons_Sale_Status__c='出货',SummonsStatus_c__c='已完成',SummonsForDirction__c='直接销售给医院',Order_status__c='已提交',Order_type__c='传票',Dealer_info__c=myAccount1.Id,ConInvoice_Code__c = invoiceorder.id); |
| | | TestList1.Order_date__c = Date.today().addDays(2); |
| | | TestList2.Order_date__c = Date.today().addDays(2); |
| | | TestList1.Order_date__c = Date.today(); |
| | | TestList2.Deliver_date__c = Date.today(); |
| | | insert new List<Consumable_order__c>{ testList1, testList2 }; |
| | | insert new Consumable_order__c[]{testList1,testList2}; |
| | | |
| | | List<Consumable_Orderdetails__c> invoiceList = new List<Consumable_Orderdetails__c>(); |
| | | //发票明细1 |
| | |
| | | orderdet3.Invoiced_Count__c = 3; |
| | | codList.add(orderdet3); |
| | | |
| | | |
| | | Consumable_orderdetails__c orderdet4 = new Consumable_orderdetails__c(); |
| | | orderdet4.Name = 'Test1_0010031'; |
| | | orderdet4.Consumable_order__c = testList1.Id; |
| | |
| | | LexConInvoicedetailsController.init(testList1.Id, invoiceorder.Id); |
| | | //序列化Json |
| | | |
| | | |
| | | System.Test.startTest(); |
| | | System.debug( |
| | | '===>数据' + |
| | | LexConInvoicedetailsController.consumableorderdetails1Records |
| | | ); |
| | | System.debug('===>数据'+LexConInvoicedetailsController.consumableorderdetails1Records); |
| | | List<LexConInvoicedetailsController.ConsumableorderdetailsInfo> inList = LexConInvoicedetailsController.consumableorderdetails1Records; |
| | | LexConInvoicedetailsController.save( |
| | | JSON.serialize( |
| | | LexConInvoicedetailsController.consumableorderdetails1Records |
| | | ), |
| | | invoiceorder.Id, |
| | | testList1.Id |
| | | ); |
| | | LexConInvoicedetailsController.save(JSON.serialize(LexConInvoicedetailsController.consumableorderdetails1Records),invoiceorder.Id,testList1.Id); |
| | | |
| | | List<LexConInvoicedetailsController.ConsumableorderdetailsInfo> inList1 = new List<LexConInvoicedetailsController.ConsumableorderdetailsInfo>(); |
| | | for ( |
| | | LexConInvoicedetailsController.ConsumableorderdetailsInfo ass : inList |
| | | ) { |
| | | for(LexConInvoicedetailsController.ConsumableorderdetailsInfo ass:inList){ |
| | | ass.check = true; |
| | | ass.invoiceCount = 1; |
| | | ass.esd.Invoice_Unit__c = '个'; |
| | | inList1.add(ass); |
| | | } |
| | | LexConInvoicedetailsController.save( |
| | | JSON.serialize(inList1), |
| | | invoiceorder.Id, |
| | | testList1.Id |
| | | ); |
| | | LexConInvoicedetailsController.save(JSON.serialize(inList1),invoiceorder.Id,testList1.Id); |
| | | System.Test.stopTest(); |
| | | |
| | | } |
| | | } |
| | | } |