@isTest
|
private class summonsCreatControllerTest {
|
//到货订单——>指示单
|
static testMethod void summonsCreatTest_newarrive(){
|
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
|
insert myAccount2;
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
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;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
system.runAs(MyUser_Test){
|
//奥林巴斯订单
|
Consumable_order__c createId = new Consumable_order__c();
|
createId.Name = 'testMing';
|
createId.Order_status__c = '批准';
|
createId.Deliver_date__c = Date.today();
|
createId.Dealer_Info__c = myAccount2.Id;
|
createId.RecordTypeid = System.Label.RT_ConOrder_Delivery;
|
createId.Invoice_status__c = '提交';
|
insert createId;
|
|
//经销商到货单
|
|
Consumable_order__c arriveOrder = new Consumable_order__c();
|
arriveOrder.Name = 'testArrive';
|
arriveOrder.Order_status__c = '批准';
|
arriveOrder.Deliver_date__c = Date.today();
|
arriveOrder.Dealer_Info__c = myAccount2.Id;
|
arriveOrder.Arrive_Order__c = createId.id;
|
//arriveOrder.Order_ForDealer__c = agency1.id;
|
//Order_ForHospital__c = hosp1.id;
|
arriveOrder.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
insert arriveOrder;
|
|
Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c();
|
createDetail.name = 'Too001';
|
createDetail.Consumable_Product__c = pro1.id;
|
createDetail.Intra_Trade_List_RMB__c = 999.00;
|
createDetail.Consumable_count__c = 1;
|
createDetail.Consumable_order__c = createId.id;
|
createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
|
insert createDetail;
|
createDetail = new Consumable_orderdetails__c();
|
createDetail.name = 'Too002';
|
createDetail.Consumable_Product__c = pro2.id;
|
createDetail.Consumable_order__c = createId.id;
|
createDetail.Intra_Trade_List_RMB__c = 999.00;
|
createDetail.Consumable_count__c = 1;
|
createDetail.RecordTypeid = System.Label.RT_ConOrderDetail1_Order;
|
|
insert createDetail;
|
|
Consumable_order_details2__c createDetail2 = new Consumable_order_details2__c();
|
createDetail2.name = 'Too003';
|
createDetail2.Consumable_Product__c = pro1.id;
|
createDetail2.Consumable_order_minor__c = createId.id;
|
createDetail2.Consumable_Arrived_order__c = arriveOrder.id;
|
createDetail2.Bar_Code__c = '11111';
|
createDetail2.Sterilization_limit__c = Date.today().addDays(1);
|
createDetail2.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
|
createDetail2.Arrive_date__c = Date.today().addDays(1);
|
createDetail2.Send_Date__c = null;
|
createDetail2.Used_date__c = null;
|
createDetail2.Lose_Flag__c = false;
|
createDetail2.Box_Piece__c = '盒';
|
insert createDetail2;
|
Consumable_order_details2__c createDetail3 = new Consumable_order_details2__c();
|
createDetail3.name = 'Too004';
|
createDetail3.Consumable_Product__c = pro2.id;
|
createDetail3.Consumable_order_minor__c = createId.id;
|
createDetail3.Consumable_Arrived_order__c = arriveOrder.id;
|
createDetail3.Bar_Code__c = '22222';
|
createDetail3.Sterilization_limit__c = Date.today().addDays(1);
|
createDetail3.RecordTypeid = System.Label.RT_ConOrderDetail2_Delivery;
|
createDetail3.Arrive_date__c = Date.today().addDays(1);
|
createDetail3.Send_Date__c = null;
|
createDetail3.Used_date__c = null;
|
createDetail3.Lose_Flag__c = false;
|
createDetail3.Box_Piece__c = '盒';
|
insert createDetail3;
|
|
PageReference page = new PageReference('/apex/summonsCreat?arriveorder=' + arriveOrder.id+'&KeyWords=statusEdit');
|
page.setRedirect(true);
|
System.Test.setCurrentPage(page);
|
summonsCreatController conTest = new summonsCreatController();
|
System.Test.startTest();
|
conTest.init();
|
conTest.SortLimited();
|
// System.assertEquals(2, conTest.pageRecords.size());
|
conTest.pageRecords.sort();
|
|
//page = new PageReference('/apex/summonsCreat?arriveorder=' + arriveOrder.id+'&KeyWords=statusEdit');
|
//page.setRedirect(true);
|
//System.Test.setCurrentPage(page);
|
//conTest = new summonsCreatController();
|
//conTest.init();
|
//conTest.SortLimited();
|
//System.assertEquals(2, conTest.pageRecords.size());
|
//conTest.pageRecords.sort();
|
System.Test.stopTest();
|
}
|
}
|
|
static testMethod void summonsCreatTest_new(){
|
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
|
insert myAccount2;
|
|
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;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Account agency1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
Account agency2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {agency1, agency2};
|
|
Dealer_elationship__c dealerelationship = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency1.id);
|
Dealer_elationship__c dealerelationship1 = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency2.id);
|
insert new Dealer_elationship__c[] {dealerelationship, dealerelationship1};
|
|
Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {hosp1, hosp2};
|
Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
insert new Agency_Hospital_Link__c[] {agencyHospitalLink1, agencyHospitalLink2};
|
system.runAs(MyUser_Test){
|
summonsCreatController conTest = new summonsCreatController();
|
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.SummonsForDirction__c = '直接销售给医院';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Onchange_order__c =true;
|
Order1.Invoice_status__c = '提交';
|
Order1.Order_ProType__c = 'ET';
|
insert Order1;
|
|
Consumable_order__c Order2 = new Consumable_order__c();
|
Order2.Name = 'OCMtest';
|
Order2.Order_status__c = '批准';
|
Order2.Order_type__c = '到货';
|
Order2.Dealer_Info__c = myAccount2.Id;
|
Order2.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
Order2.Invoice_status__c = '提交';
|
Order2.Order_ProType__c = 'ET';
|
insert Order2;
|
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
//Orderdet1.Consumable_order_minor__c = Order1.Id;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet1.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet1.Bar_Code__c = '11111';
|
Orderdet1.Consumable_product__c = pro1.Id;
|
Orderdet1.Arrive_date__c = Date.today().addDays(1);
|
Orderdet1.Send_Date__c = null;
|
Orderdet1.Used_date__c = null;
|
Orderdet1.Lose_Flag__c = false;
|
Orderdet1.Box_Piece__c = '盒';
|
|
Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
|
Orderdet2.Name = 'OCM_01_001002';
|
//Orderdet2.Consumable_order_minor__c = Order1.Id;
|
Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet2.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet2.Consumable_Sale_order__c = Order1.Id;
|
Orderdet2.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet2.Bar_Code__c = '22222';
|
Orderdet2.Consumable_product__c = pro2.Id;
|
Orderdet2.Arrive_date__c = Date.today().addDays(1);
|
Orderdet2.Send_Date__c = null;
|
Orderdet2.Used_date__c = null;
|
Orderdet2.Lose_Flag__c = false;
|
Orderdet2.Box_Piece__c = '盒';
|
|
Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
|
Orderdet3.Name = 'OCM_01_001003';
|
// Orderdet3.Consumable_order_minor__c = Order1.Id;
|
Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet3.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet3.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet3.Bar_Code__c = '33333';
|
Orderdet3.Consumable_product__c = pro2.Id;
|
Orderdet3.Arrive_date__c = Date.today().addDays(1);
|
Orderdet3.Send_Date__c = null;
|
Orderdet3.Used_date__c = null;
|
Orderdet3.Lose_Flag__c = false;
|
Orderdet3.Box_Piece__c ='盒';
|
|
Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
|
Orderdet4.Name = 'OCM_01_001004';
|
//Orderdet4.Consumable_order_minor__c = Order1.Id;
|
Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet4.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet4.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet4.Bar_Code__c = '44444';
|
Orderdet4.Consumable_product__c = pro2.Id;
|
Orderdet4.Arrive_date__c = Date.today().addDays(1);
|
Orderdet4.Send_Date__c = null;
|
Orderdet4.Used_date__c = null;
|
Orderdet4.Lose_Flag__c = false;
|
Orderdet4.Box_Piece__c = '个';
|
System.Test.startTest();
|
insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4};
|
|
PageReference page = new PageReference('/apex/summonsCreat');
|
page.setRedirect(true);
|
System.Test.setCurrentPage(page);
|
|
conTest.init();
|
conTest.size = 3;
|
conTest.refreshPageSize();
|
System.assertEquals(2, conTest.pageRecords.size());
|
//system.assertEquals(3,conTest.orderForHospitalOpts.size());
|
conTest.save();
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.save();
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.SecondDealer = agency1.id;
|
conTest.coc.Order_ForDealer__c = agency1.id;
|
conTest.coc.Order_ForHospital__c = hosp1.id;
|
conTest.coc.Summons_Sale_Status__c = '出货';
|
conTest.coc.Order_ForCustomerText__c = 'fuke';
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 1;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c = 1;
|
conTest.pageRecords[1].check=true;
|
conTest.pageRecords[1].orderdetails1.Consumable_count__c = 1;
|
conTest.pageRecords[1].orderdetails1.Delivery_List_RMB__c = 1;
|
conTest.save();
|
|
|
|
conTest.pageRecords.sort();
|
System.assertEquals(2, conTest.consumableorderdetailsCount);
|
System.assertEquals(0, conTest.consumableorderdetails2Count);
|
page = new PageReference('/apex/summonsCreat?ESetid='+Order1.id);
|
page.setRedirect(true);
|
System.Test.setCurrentPage(page);
|
conTest.init();
|
|
conTest.HospitalInfo = hosp1.id;
|
conTest.SecondDealer = agency1.id;
|
conTest.coc.Order_ForDealer__c = agency1.id;
|
conTest.coc.Order_ForHospital__c = hosp1.id;
|
conTest.save();
|
System.Test.stopTest();
|
|
}
|
}
|
|
/*
|
static testMethod void summonsCreatTest_EditOrder(){
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
|
insert myAccount2;
|
|
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;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {hosp1, hosp2};
|
Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
insert new Agency_Hospital_Link__c[] {agencyHospitalLink1, agencyHospitalLink2};
|
|
system.runAs(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.SummonsForDirction__c = '直接销售给医院';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
insert Order1;
|
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.Consumable_order_minor__c = Order1.Id;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet1.Bar_Code__c = '11111';
|
Orderdet1.Consumable_product__c = pro1.Id;
|
Orderdet1.Box_Piece__c = '盒';
|
Orderdet1.Sterilization_limit__c = Date.today();
|
|
Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
|
Orderdet2.Name = 'OCM_01_001002';
|
Orderdet2.Consumable_order_minor__c = Order1.Id;
|
Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet2.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet2.Consumable_Sale_order__c = Order1.Id;
|
Orderdet2.Bar_Code__c = '22222';
|
Orderdet2.Consumable_product__c = pro2.Id;
|
Orderdet2.Box_Piece__c = '个';
|
Orderdet2.Sterilization_limit__c = Date.today();
|
Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
|
Orderdet3.Name = 'OCM_01_001003';
|
Orderdet3.Consumable_order_minor__c = Order1.Id;
|
Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet3.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet3.Bar_Code__c = '33333';
|
Orderdet3.Consumable_product__c = pro2.Id;
|
Orderdet3.Box_Piece__c = '盒';
|
Orderdet3.Sterilization_limit__c = Date.today();
|
Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
|
Orderdet4.Name = 'OCM_01_001004';
|
Orderdet4.Consumable_order_minor__c = Order1.Id;
|
Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet4.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet4.Bar_Code__c = '44444';
|
Orderdet4.Consumable_product__c = pro1.Id;
|
Orderdet4.Box_Piece__c = '盒';
|
Orderdet4.Sterilization_limit__c = Date.today();
|
Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
|
Orderdet5.Name = 'OCM_01_001005';
|
Orderdet5.Consumable_order_minor__c = Order1.Id;
|
Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet5.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet5.Bar_Code__c = '55555';
|
Orderdet5.Consumable_product__c = pro2.Id;
|
Orderdet5.Box_Piece__c = '盒';
|
Orderdet5.Sterilization_limit__c = Date.today();
|
insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4,Orderdet5};
|
//指示单
|
Consumable_order__c createId = new Consumable_order__c();
|
createId.Name = 'testMing';
|
createId.Summons_Sale_Status__c= '出货';
|
createId.SummonsStatus_c__c = '批准';
|
createId.SummonsForDirction__c ='销售给二级经销商';
|
createId.Order_type__c = '传票';
|
createId.Order_date__c = date.today();
|
createId.RecordTypeid = System.Label.RT_ConOrder_Order;
|
insert createId;
|
Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c();
|
createDetail.Name = 'Too001';
|
createDetail.Consumable_Product__c = pro1.id;
|
createDetail.Dealer_Custom_Price__c = 999.00;
|
createDetail.Consumable_count__c = 1;
|
createDetail.Consumable_order__c = createId.id;
|
createDetail = new Consumable_orderdetails__c();
|
createDetail.Name = 'Too003';
|
createDetail.Consumable_Product__c = pro1.id;
|
createDetail.Dealer_Custom_Price__c = 999.00;
|
createDetail.Consumable_count__c = 1;
|
createDetail.Consumable_order__c = createId.id;
|
createDetail.Shipment_Count__c=1;
|
createDetail.Intra_Trade_List_RMB__c = 1;
|
createDetail.Delivery_List_RMB__c = 1;
|
createDetail.Box_Piece__c = '盒';
|
//createDetail.Unitprice_To_agency__c= 1;
|
createDetail.Dealer_Custom_Price__c = 1;
|
createDetail.Delivery_List_RMB__c =1;
|
insert createDetail;
|
createDetail = new Consumable_orderdetails__c();
|
createDetail.name = 'Too002';
|
createDetail.Consumable_Product__c = pro2.id;
|
createDetail.Dealer_Custom_Price__c = 999.00;
|
createDetail.Consumable_count__c = 1;
|
createDetail.Consumable_order__c = createId.id;
|
createDetail.Box_Piece__c = '个';
|
insert createDetail;
|
PageReference page = new PageReference('/apex/summonsCreat?ESetid='+createId.id);
|
page.setRedirect(true);
|
System.Test.setCurrentPage(page);
|
summonsCreatController conTest = new summonsCreatController();
|
System.Test.startTest();
|
conTest.init();
|
System.assertEquals(2, conTest.pageRecords.size());
|
//conTest.sortKey = '0';
|
//conTest.SortLimited();
|
System.assertEquals('Pro001', conTest.pageRecords[0].Prod.Name);
|
System.assertEquals('Pro002', conTest.pageRecords[1].Prod.Name);
|
//conTest.SortStore();
|
conTest.setEditAble();
|
//system.assertEquals(3,conTest.orderForHospitalOpts.size());
|
conTest.pageRecords[0].check = true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c = '盒';
|
conTest.pageRecords[1].check = true;
|
conTest.pageRecords[1].orderdetails1.Dealer_Custom_Price__c = 233.00;
|
conTest.pageRecords[1].orderdetails1.Consumable_count__c = 1;
|
conTest.pageRecords[1].orderdetails1.Box_Piece__c = '个';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.save();
|
|
conTest.GoodsDelivery();
|
conTest.approval();
|
//conTest.PraseToPDF();
|
conTest.pageRecords.sort();
|
System.Test.stopTest();
|
}
|
}*/
|
static testMethod void summonsCreatTest_Other(){
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
|
insert myAccount2;
|
|
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;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Account agency1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
Account agency2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {agency1, agency2};
|
|
Dealer_elationship__c dealerelationship = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency1.id);
|
Dealer_elationship__c dealerelationship1 = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency2.id);
|
insert new Dealer_elationship__c[] {dealerelationship, dealerelationship1};
|
|
Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {hosp1, hosp2};
|
Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
insert new Agency_Hospital_Link__c[] {agencyHospitalLink1, agencyHospitalLink2};
|
system.runAs(MyUser_Test){
|
summonsCreatController conTest = new summonsCreatController();
|
|
PageReference page = new PageReference('/apex/summonsCreat');
|
System.Test.setCurrentPage(page);
|
|
Consumable_order__c Testcoc = new Consumable_order__c();
|
List<Consumable_order__c> qs = New List<Consumable_order__c>();
|
qs=[select Order_ForHospital__c From Consumable_order__c where Order_ForHospital__c !=null];
|
system.debug('测试机'+qs);
|
Testcoc.Order_ForHospital__c = myAccount2.id;
|
Product2__c proG = new Product2__c(Name='Too001',OT_CODE_Text__c='Test001');
|
insert proG;
|
Product2__c ProH = new Product2__c(Name='Too002',OT_CODE_Text__c='Test002');
|
insert ProH;
|
Consumable_order__c createId = new Consumable_order__c();
|
createId.Name = 'testMing';
|
createId.Summons_Sale_Status__c= '出货';
|
createId.SummonsStatus_c__c = '出库单已打印';
|
createId.SummonsForDirction__c ='医院试用';
|
createId.Order_type__c = '传票';
|
createId.RecordTypeid = System.Label.RT_ConOrder_Order;
|
insert createId;
|
Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c();
|
createDetail.name = 'Too001';
|
createDetail.Consumable_Product__c = proG.id;
|
createDetail.Dealer_Custom_Price__c = 999.00;
|
createDetail.Consumable_count__c = 1;
|
createDetail.Consumable_order__c = createId.id;
|
createDetail.Shipment_Count__c=1;
|
createDetail.Intra_Trade_List_RMB__c = 1;
|
createDetail.Delivery_List_RMB__c = 1;
|
createDetail.Box_Piece__c = '盒';
|
//createDetail.Unitprice_To_agency__c= 1;
|
createDetail.Dealer_Custom_Price__c = 1;
|
insert createDetail;
|
|
page = new PageReference('/apex/summonsCreat?ESetid='+createId.id);
|
page.setRedirect(true);
|
System.Test.setCurrentPage(page);
|
conTest = new summonsCreatController();
|
System.Test.startTest();
|
conTest.init();
|
conTest.coc.SummonsStatus_c__c = '批准';
|
conTest.PraseToPDF();
|
conTest.SortLimited();
|
conTest.GoodsDelivery();
|
conTest.init();
|
System.Test.stopTest();
|
}
|
}
|
static testMethod void summonsCreatTest_after(){
|
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
|
insert myAccount2;
|
|
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;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
//Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {hosp1};
|
Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
//Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
insert new Agency_Hospital_Link__c[] {agencyHospitalLink1};
|
|
system.runAs(MyUser_Test){
|
//到货订单
|
|
Consumable_order__c Order1 = new Consumable_order__c();
|
Order1.Name = 'testArrive';
|
Order1.Order_status__c = '批准';
|
Order1.Deliver_date__c = Date.today();
|
Order1.Dealer_Info__c = myAccount2.Id;
|
//arriveOrder.Arrive_Order__c = createId.id;
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
insert Order1;
|
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet1.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet1.Bar_Code__c = '11111';
|
Orderdet1.Consumable_product__c = pro1.Id;
|
Orderdet1.Arrive_date__c = Date.today().addDays(1);
|
Orderdet1.Send_Date__c = null;
|
Orderdet1.Used_date__c = null;
|
Orderdet1.Lose_Flag__c = false;
|
Orderdet1.Box_Piece__c = '盒';
|
|
Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
|
Orderdet4.Name = 'OCM_01_001004';
|
Orderdet4.Consumable_order_minor__c = Order1.Id;
|
Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet4.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet4.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet4.Bar_Code__c = '44444';
|
Orderdet4.Consumable_product__c = pro2.Id;
|
Orderdet4.Arrive_date__c = Date.today().addDays(1);
|
Orderdet4.Send_Date__c = null;
|
Orderdet4.Used_date__c = null;
|
Orderdet4.Lose_Flag__c = false;
|
Orderdet4.Box_Piece__c = '个';
|
insert new Consumable_order_details2__c[] {Orderdet1,Orderdet4};
|
|
Consumable_order__c createId = new Consumable_order__c();
|
createId.Name = 'testMing';
|
createId.Summons_Sale_Status__c= '出货';
|
createId.SummonsStatus_c__c = '草案中';
|
createId.SummonsForDirction__c ='医院试用';
|
createId.Order_type__c = '传票';
|
createId.RecordTypeid = System.Label.RT_ConOrder_Order;
|
//createId.Order_ForDealer__c = agency1.id;
|
createId.Order_ForHospital__c = hosp1.id;
|
createId.Order_ForCustomerText__c = 'test';
|
insert createId;
|
Consumable_orderdetails__c createDetail = new Consumable_orderdetails__c();
|
createDetail.name = 'Too001';
|
createDetail.Dealer_Custom_Price__c = 999.00;
|
createDetail.Shipment_Count__c = 1;
|
createDetail.Box_Piece__c = '盒';
|
createDetail.Consumable_Product__c = pro1.id;
|
createDetail.Consumable_order__c = createId.id;
|
insert createDetail;
|
createDetail = new Consumable_orderdetails__c();
|
createDetail.name = 'Too002';
|
createDetail.Consumable_Product__c = pro2.id;
|
createDetail.Consumable_order__c = createId.id;
|
createDetail.Dealer_Custom_Price__c = 999.00;
|
createDetail.Shipment_Count__c = 1;
|
createDetail.Box_Piece__c = '个';
|
insert createDetail;
|
PageReference page = new PageReference('/apex/summonsCreat?ESetid='+createId.id + '&KeyWords=Redirect');
|
page.setRedirect(true);
|
System.Test.setCurrentPage(page);
|
summonsCreatController conTest = new summonsCreatController();
|
System.Test.startTest();
|
conTest.init();
|
conTest.save();
|
conTest.approval();
|
conTest.DelConsumable();
|
conTest.pageRecords.sort();
|
conTest.SortLimited();
|
System.Test.stopTest();
|
}
|
}
|
|
static testMethod void Test_withArriveorder(){
|
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
|
insert myAccount2;
|
|
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;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
//Account agency1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
//Account agency2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
//insert new Account[] {agency1, agency2};
|
|
//Dealer_elationship__c dealerelationship = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency1.id);
|
//Dealer_elationship__c dealerelationship1 = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency2.id);
|
//insert new Dealer_elationship__c[] {dealerelationship, dealerelationship1};
|
|
Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {hosp1, hosp2};
|
Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
insert new Agency_Hospital_Link__c[] {agencyHospitalLink1, agencyHospitalLink2};
|
|
system.runAs(MyUser_Test){
|
summonsCreatController conTest = new summonsCreatController();
|
Consumable_order__c Order2 = new Consumable_order__c();
|
Order2.Name = 'OCMtest';
|
Order2.Order_status__c = '批准';
|
Order2.Order_type__c = '到货';
|
Order2.Dealer_Info__c = myAccount2.Id;
|
Order2.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
Order2.Order_ProType__c = 'ET';
|
insert Order2;
|
|
Consumable_order__c Order1 = new Consumable_order__c();
|
Order1.Name = 'OCM_01_001';
|
Order1.Order_status__c = '批准';
|
Order1.Order_type__c = '传票';
|
Order1.Arrive_Order__c = Order2.Id;
|
Order1.Dealer_Info__c = myAccount2.Id;
|
Order1.SummonsForDirction__c = '直接销售给医院';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Order_ProType__c = 'ET';
|
insert Order1;
|
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.Consumable_order_minor__c = Order1.Id;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet1.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet1.Bar_Code__c = '11111';
|
Orderdet1.Consumable_product__c = pro1.Id;
|
Orderdet1.Arrive_date__c = Date.today().addDays(1);
|
Orderdet1.Send_Date__c = null;
|
Orderdet1.Used_date__c = null;
|
Orderdet1.Lose_Flag__c = false;
|
Orderdet1.Box_Piece__c = '盒';
|
Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
|
Orderdet2.Name = 'OCM_01_001002';
|
Orderdet2.Consumable_order_minor__c = Order1.Id;
|
Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet2.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet2.Consumable_Sale_order__c = Order1.Id;
|
Orderdet2.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet2.Bar_Code__c = '22222';
|
Orderdet2.Consumable_product__c = pro2.Id;
|
Orderdet2.Arrive_date__c = Date.today().addDays(1);
|
Orderdet2.Send_Date__c = null;
|
Orderdet2.Used_date__c = null;
|
Orderdet2.Lose_Flag__c = false;
|
Orderdet2.Box_Piece__c = '盒';
|
Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
|
Orderdet3.Name = 'OCM_01_001003';
|
Orderdet3.Consumable_order_minor__c = Order1.Id;
|
Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet3.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet3.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet3.Bar_Code__c = '33333';
|
Orderdet3.Consumable_product__c = pro1.Id;
|
Orderdet3.Arrive_date__c = Date.today().addDays(1);
|
Orderdet3.Send_Date__c = null;
|
Orderdet3.Used_date__c = null;
|
Orderdet3.Lose_Flag__c = false;
|
Orderdet3.Box_Piece__c = '盒';
|
Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
|
Orderdet4.Name = 'OCM_01_001004';
|
Orderdet4.Consumable_order_minor__c = Order1.Id;
|
Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet4.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet4.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet4.Bar_Code__c = '44444';
|
Orderdet4.Consumable_product__c = pro2.Id;
|
Orderdet4.Arrive_date__c = Date.today().addDays(1);
|
Orderdet4.Send_Date__c = null;
|
Orderdet4.Used_date__c = null;
|
Orderdet4.Lose_Flag__c = false;
|
Orderdet4.Box_Piece__c = '个';
|
insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4};
|
System.Test.startTest();
|
conTest.init();
|
//system.assertEquals(3,conTest.orderForHospitalOpts.size());
|
conTest.searchConsumableorderdetails();
|
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForDealerText__c = 'test二级经销商001';
|
conTest.coc.Summons_Sale_Status__c = '出货';
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[1].check=true;
|
conTest.pageRecords[1].orderdetails1.Dealer_Custom_Price__c = 233.00;
|
conTest.pageRecords[1].orderdetails1.Consumable_count__c = 10;
|
conTest.save();
|
conTest.SortLimited();
|
conTest.pageRecords.sort();
|
conTest.DelConsumable();
|
conTest.FilesUpload();
|
conTest.init();
|
System.Test.stopTest();
|
}
|
}
|
|
static testMethod void Test_save(){
|
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
|
insert myAccount2;
|
|
|
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;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
//Account agency1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
//Account agency2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
//insert new Account[] {agency1, agency2};
|
|
//Dealer_elationship__c dealerelationship = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency1.id);
|
//Dealer_elationship__c dealerelationship1 = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency2.id);
|
//insert new Dealer_elationship__c[] {dealerelationship, dealerelationship1};
|
|
Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {hosp1, hosp2};
|
Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
insert new Agency_Hospital_Link__c[] {agencyHospitalLink1, agencyHospitalLink2};
|
|
system.runAs(MyUser_Test){
|
summonsCreatController conTest = new summonsCreatController();
|
Consumable_order__c Order2 = new Consumable_order__c();
|
Order2.Name = 'OCMtest';
|
Order2.Order_status__c = '批准';
|
Order2.Order_type__c = '到货';
|
Order2.Dealer_Info__c = myAccount2.Id;
|
Order2.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
Order2.Order_ProType__c = 'ET';
|
insert Order2;
|
|
Consumable_order__c Order1 = new Consumable_order__c();
|
Order1.Name = 'OCM_01_001';
|
Order1.Order_status__c = '批准';
|
Order1.Order_type__c = '传票';
|
Order1.Arrive_Order__c = Order2.Id;
|
Order1.Dealer_Info__c = myAccount2.Id;
|
Order1.SummonsForDirction__c = '直接销售给医院';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Order_ProType__c = 'ET';
|
insert Order1;
|
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.Consumable_order_minor__c = Order1.Id;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet1.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet1.Bar_Code__c = '11111';
|
Orderdet1.Consumable_product__c = pro1.Id;
|
Orderdet1.Arrive_date__c = Date.today().addDays(1);
|
Orderdet1.Send_Date__c = null;
|
Orderdet1.Used_date__c = null;
|
Orderdet1.Lose_Flag__c = false;
|
Orderdet1.Box_Piece__c = '盒';
|
insert new Consumable_order_details2__c[] {Orderdet1};
|
System.Test.startTest();
|
conTest.init();
|
//system.assertEquals(3,conTest.orderForHospitalOpts.size());
|
conTest.searchConsumableorderdetails();
|
|
//必须输入二级经销商或经销商(录入)
|
contest.SecondDealer=null;
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForDealerText__c = null;
|
conTest.coc.Summons_Sale_Status__c = '出货';
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
contest.SecondDealer='123';
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.Summons_Sale_Status__c = '出货';
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
contest.SecondDealer='123';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
//互相调货
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = null;
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = 'neike';
|
contest.SecondDealer='123';
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '医院试用';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.HospitalInfo = hosp1.id;
|
contest.SecondDealer='123';
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
//正常save
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c=1000;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='盒';
|
conTest.save();
|
|
conTest.pageRecords[0].check=false;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =null;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='个';
|
conTest.save();
|
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =null;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='个';
|
conTest.save();
|
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =0;
|
conTest.coc.SummonsForDirction__c ='销售给二级经销商';
|
conTest.save();
|
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =1000;
|
conTest.coc.SummonsForDirction__c ='互相调货';
|
//conTest.pageRecords[0].orderdetails1.Unitprice_To_agency__c=10;
|
//conTest.pageRecords[0].orderdetails1.Unitprice_To_agency__c=20;
|
conTest.save();
|
conTest.approval();
|
conTest.pageRecords.sort();
|
conTest.init();
|
System.Test.stopTest();
|
|
}
|
}
|
|
static testMethod void summonsCreatSearchTest(){
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true
|
,Category3__c = 'CDS',Category4__c = 'OER',Category5__c = '其它');
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true
|
,Category3__c = 'ENT',Category4__c = 'Celon',Category5__c = 'Celon');
|
Product2 prod03 = new Product2(Name='Test03',ProductCode='Test03',Asset_Model_No__c = 'Test03',SFDA_Status__c = '有効',Dealer_special_Object__c = true
|
,Category3__c = 'US',Category4__c = 'ALOKA',Category5__c = '体外超声');
|
Product2 prod04 = new Product2(Name='Test04',ProductCode='Test04',Asset_Model_No__c = 'Test04',SFDA_Status__c = '有効',Dealer_special_Object__c = true
|
,Category3__c = 'OCS',Category4__c = '附属品',Category5__c = 'OCS');
|
Product2 prod05 = new Product2(Name='Test05',ProductCode='Test05',Asset_Model_No__c = 'Test05',SFDA_Status__c = '有効',Dealer_special_Object__c = true
|
,Category3__c = '光源',Category4__c = 'CLV',Category5__c = 'S45');
|
insert new Product2[] {prod01, prod02, prod03, prod04, prod05};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
|
insert myAccount2;
|
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;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro4 = new Product2__c(Name='Pro004',OT_CODE_Text__c='Test004',Product2__c = prod04.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro5 = new Product2__c(Name='Pro005',OT_CODE_Text__c='Test005',Product2__c = prod05.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1,pro2, pro3,pro4, pro5};
|
|
//Account agency1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
//Account agency2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
//insert new Account[] {agency1, agency2};
|
|
//Dealer_elationship__c dealerelationship = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency1.id);
|
//Dealer_elationship__c dealerelationship1 = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency2.id);
|
//insert new Dealer_elationship__c[] {dealerelationship, dealerelationship1};
|
|
//Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
//Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
//insert new Account[] {hosp1, hosp2};
|
//Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
//Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
//insert new Agency_Hospital_Link__c[] {agencyHospitalLink1};
|
|
system.runAs(MyUser_Test){
|
summonsCreatController ScTest = new summonsCreatController();
|
System.Test.startTest();
|
ScTest.init();
|
|
ScTest.category3 = 'CDS';
|
ScTest.categoryAllload();
|
system.assertEquals(2,ScTest.category4OptionList.size());
|
ScTest.category4 = 'OER';
|
ScTest.categoryload();
|
system.assertEquals(2,ScTest.category5OptionList.size());
|
|
ScTest.category3 = 'OCS';
|
ScTest.categoryAllload();
|
system.assertEquals(2,ScTest.category4OptionList.size());
|
ScTest.category4 = '附属品';
|
ScTest.categoryload();
|
system.assertEquals(2,ScTest.category5OptionList.size());
|
|
|
ScTest.category3 = 'ENT';
|
ScTest.categoryAllload();
|
system.assertEquals(2,ScTest.category4OptionList.size());
|
ScTest.category4 = 'Celon';
|
ScTest.categoryload();
|
system.assertEquals(2,ScTest.category5OptionList.size());
|
|
ScTest.category3 = 'US';
|
ScTest.categoryAllload();
|
system.assertEquals(2,ScTest.category4OptionList.size());
|
ScTest.category4 = 'ALOKA';
|
ScTest.categoryload();
|
system.assertEquals(2,ScTest.category5OptionList.size());
|
|
ScTest.category3 = '光源';
|
ScTest.categoryAllload();
|
system.assertEquals(2,ScTest.category4OptionList.size());
|
ScTest.category5 = '其它';
|
ScTest.SortLimited();
|
System.Test.stopTest();
|
}
|
}
|
|
static testMethod void Test_ArriveOrder(){
|
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id ,AgentCode_Ext__c = '9999900');
|
insert myAccount2;
|
|
|
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;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Account agency1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
//Account agency2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {agency1};
|
|
//Dealer_elationship__c dealerelationship = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency1.id);
|
//Dealer_elationship__c dealerelationship1 = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency2.id);
|
//insert new Dealer_elationship__c[] {dealerelationship, dealerelationship1};
|
|
Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
//Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {hosp1};
|
Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
//Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
insert new Agency_Hospital_Link__c[] {agencyHospitalLink1};
|
|
system.runAs(MyUser_Test){
|
Consumable_order__c DaoHuo = new Consumable_order__c();
|
DaoHuo.Name = 'OCMtest';
|
DaoHuo.Order_status__c = '批准';
|
DaoHuo.Order_type__c = '到货';
|
|
DaoHuo.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
insert DaoHuo;
|
|
Consumable_order__c Order1 = new Consumable_order__c();
|
Order1.Name = 'OCM_01_001';
|
Order1.Order_status__c = '批准';
|
Order1.Order_type__c = '传票';
|
Order1.SummonsForDirction__c = '直接销售给医院';
|
Order1.Dealer_Info__c = myAccount2.Id;
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Arrive_Order__c = DaoHuo.id;
|
Order1.Order_ForHospital__c = hosp1.id;
|
Order1.Order_ForCustomerText__c = 'test';
|
//Order1.Onchange_order__c =true;
|
Order1.SummonsStatus_c__c = '草案中';
|
insert Order1;
|
|
Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c();
|
Orderdet1.name = 'Too001';
|
Orderdet1.Consumable_Product__c = pro1.id;
|
Orderdet1.Consumable_order__c = Order1.id;
|
Orderdet1.Shipment_Count__c=1;
|
Orderdet1.Delivery_List_RMB__c = 1;
|
Orderdet1.Box_Piece__c = '盒';
|
insert Orderdet1;
|
|
Consumable_order_details2__c Orderdet12 = new Consumable_order_details2__c();
|
Orderdet12.Name = 'OCM_01_001002';
|
Orderdet12.Consumable_Sale_order__c = Order1.Id;
|
Orderdet12.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet12.Consumable_Arrived_order__c = DaoHuo.Id;
|
Orderdet12.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet12.Bar_Code__c = '222222';
|
Orderdet12.Consumable_Product__c = pro1.Id;
|
Orderdet12.Arrive_date__c = Date.today().addDays(1);
|
//Orderdet12.Send_Date__c = null;
|
//Orderdet12.Used_date__c = null;
|
//Orderdet12.Lose_Flag__c = false;
|
Orderdet12.Box_Piece__c = '盒';
|
|
Consumable_order_details2__c Orderdet13 = new Consumable_order_details2__c();
|
Orderdet13.Name = 'OCM_01_0010202';
|
Orderdet13.Consumable_Sale_order__c = Order1.Id;
|
Orderdet13.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet13.Consumable_Arrived_order__c = DaoHuo.Id;
|
Orderdet13.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet13.Bar_Code__c = '2222222';
|
Orderdet13.Consumable_Product__c = pro1.Id;
|
Orderdet13.Arrive_date__c = Date.today().addDays(1);
|
|
Orderdet13.Box_Piece__c = '盒';
|
|
|
insert new Consumable_order_details2__c[] {Orderdet12,Orderdet13};
|
PageReference page = new PageReference('/apex/summonsCreat?ESetid='+Order1.id+'&KeyWords=Redirect');
|
page.setRedirect(true);
|
System.Test.setCurrentPage(page);
|
summonsCreatController conTest = new summonsCreatController();
|
System.Test.startTest();
|
conTest.init();
|
|
conTest.coc.SummonsForDirction__c = '医院试用';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = 'test';
|
// system.assertEquals(1,conTest.pageRecords.size());
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.SecondDealer = agency1.id;
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = null;
|
// system.assertEquals(1,conTest.pageRecords.size());
|
conTest.save();
|
|
conTest.coc.SummonsStatus_c__c = '批准';
|
conTest.init();
|
System.Test.stopTest();
|
}
|
}
|
|
static testMethod void summonsCreatTest_save(){
|
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
|
insert myAccount2;
|
|
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;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Account agency1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
Account agency2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {agency1, agency2};
|
|
Dealer_elationship__c dealerelationship = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency1.id);
|
Dealer_elationship__c dealerelationship1 = new Dealer_elationship__c(Dealer_principal__c = myAccount2.id,Dealer_subordinate__c = agency2.id);
|
insert new Dealer_elationship__c[] {dealerelationship, dealerelationship1};
|
|
Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {hosp1, hosp2};
|
Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
insert new Agency_Hospital_Link__c[] {agencyHospitalLink1, agencyHospitalLink2};
|
system.runAs(MyUser_Test){
|
summonsCreatController conTest = new summonsCreatController();
|
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.SummonsForDirction__c = '直接销售给医院';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Onchange_order__c =true;
|
Order1.Invoice_status__c = '提交';
|
Order1.Order_ProType__c = 'ET';
|
insert Order1;
|
|
Consumable_order__c Order2 = new Consumable_order__c();
|
Order2.Name = 'OCMtest';
|
Order2.Order_status__c = '批准';
|
Order2.Order_type__c = '到货';
|
Order2.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
Order2.Invoice_status__c = '提交';
|
Order2.Order_ProType__c = 'ET';
|
insert Order2;
|
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
//Orderdet1.Consumable_order_minor__c = Order1.Id;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet1.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet1.Bar_Code__c = '11111';
|
Orderdet1.Consumable_product__c = pro1.Id;
|
Orderdet1.Arrive_date__c = Date.today().addDays(1);
|
Orderdet1.Send_Date__c = null;
|
Orderdet1.Used_date__c = null;
|
Orderdet1.Lose_Flag__c = false;
|
Orderdet1.Box_Piece__c = '盒';
|
|
Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
|
Orderdet2.Name = 'OCM_01_001002';
|
//Orderdet2.Consumable_order_minor__c = Order1.Id;
|
Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet2.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet2.Consumable_Sale_order__c = Order1.Id;
|
Orderdet2.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet2.Bar_Code__c = '22222';
|
Orderdet2.Consumable_product__c = pro2.Id;
|
Orderdet2.Arrive_date__c = Date.today().addDays(1);
|
Orderdet2.Send_Date__c = null;
|
Orderdet2.Used_date__c = null;
|
Orderdet2.Lose_Flag__c = false;
|
Orderdet2.Box_Piece__c = '盒';
|
|
Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
|
Orderdet3.Name = 'OCM_01_001003';
|
// Orderdet3.Consumable_order_minor__c = Order1.Id;
|
Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet3.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet3.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet3.Bar_Code__c = '33333';
|
Orderdet3.Consumable_product__c = pro2.Id;
|
Orderdet3.Arrive_date__c = Date.today().addDays(1);
|
Orderdet3.Send_Date__c = null;
|
Orderdet3.Used_date__c = null;
|
Orderdet3.Lose_Flag__c = false;
|
Orderdet3.Box_Piece__c ='盒';
|
|
Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
|
Orderdet4.Name = 'OCM_01_001004';
|
//Orderdet4.Consumable_order_minor__c = Order1.Id;
|
Orderdet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet4.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet4.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet4.Bar_Code__c = '44444';
|
Orderdet4.Consumable_product__c = pro2.Id;
|
Orderdet4.Arrive_date__c = Date.today().addDays(1);
|
Orderdet4.Send_Date__c = null;
|
Orderdet4.Used_date__c = null;
|
Orderdet4.Lose_Flag__c = false;
|
Orderdet4.Box_Piece__c = '个';
|
System.Test.startTest();
|
insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2,Orderdet3,Orderdet4};
|
|
PageReference page = new PageReference('/apex/summonsCreat');
|
page.setRedirect(true);
|
System.Test.setCurrentPage(page);
|
|
conTest.init();
|
conTest.size = 3;
|
conTest.refreshPageSize();
|
System.assertEquals(2, conTest.pageRecords.size());
|
//system.assertEquals(3,conTest.orderForHospitalOpts.size());
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.HospitalName ='Testhosp';
|
//conTest.SecondDealer = agency1.id;
|
conTest.coc.Order_ForDealer__c = agency1.id;
|
conTest.coc.Order_ForHospital__c = hosp1.id;
|
conTest.coc.Summons_Sale_Status__c = '出货';
|
conTest.coc.Order_ForCustomerText__c = 'fuke';
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 1;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c = null;
|
conTest.pageRecords[1].check=true;
|
conTest.pageRecords[1].orderdetails1.Consumable_count__c = 1;
|
conTest.pageRecords[1].orderdetails1.Delivery_List_RMB__c = null;
|
conTest.save();
|
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 1;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c = 100;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].boxnumber =5;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c ='盒';
|
conTest.pageRecords[1].check=true;
|
conTest.pageRecords[1].orderdetails1.Consumable_count__c = 1;
|
conTest.pageRecords[1].boxnumber =5;
|
conTest.pageRecords[1].orderdetails1.Delivery_List_RMB__c = 200;
|
conTest.pageRecords[1].orderdetails1.Box_Piece__c ='盒';
|
conTest.save();
|
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 1;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c = 100;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].Piecenumber = 5;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c ='个';
|
conTest.pageRecords[1].check=true;
|
conTest.pageRecords[1].orderdetails1.Consumable_count__c = 1;
|
conTest.pageRecords[1].Piecenumber = 5;
|
conTest.pageRecords[1].orderdetails1.Delivery_List_RMB__c = 200;
|
conTest.pageRecords[1].orderdetails1.Box_Piece__c ='个';
|
conTest.save();
|
System.Test.stopTest();
|
|
}
|
}
|
|
//add by rentx 2021-01-18 start
|
static testMethod void testMethod01(){
|
|
Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET Email)'];
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
|
insert myAccount2;
|
|
|
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',UserPro_Type__c='ENG', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
|
insert MyUser_Test;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {hosp1, hosp2};
|
Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
insert new Agency_Hospital_Link__c[] {agencyHospitalLink1, agencyHospitalLink2};
|
|
system.runAs(MyUser_Test){
|
summonsCreatController conTest = new summonsCreatController();
|
Consumable_order__c Order2 = new Consumable_order__c();
|
Order2.Name = 'OCMtest';
|
Order2.Order_status__c = '批准';
|
Order2.Order_type__c = '到货';
|
Order2.Dealer_Info__c = myAccount2.Id;
|
Order2.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
Order2.Order_ProType__c = 'ENG';
|
insert Order2;
|
|
Consumable_order__c Order1 = new Consumable_order__c();
|
Order1.Name = 'OCM_01_001';
|
Order1.Order_status__c = '批准';
|
Order1.Order_type__c = '传票';
|
Order1.Arrive_Order__c = Order2.Id;
|
Order1.Dealer_Info__c = myAccount2.Id;
|
Order1.SummonsForDirction__c = '直接销售给医院';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Order_ProType__c = 'ENG';
|
Order1.orderPattern__c = 'hospitalorder';
|
Order1.OutPattern__c = true;
|
insert Order1;
|
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.Consumable_order_minor__c = Order1.Id;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet1.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet1.Bar_Code__c = '11111';
|
Orderdet1.Consumable_product__c = pro1.Id;
|
Orderdet1.Arrive_date__c = Date.today();
|
Orderdet1.Send_Date__c = null;
|
Orderdet1.Used_date__c = null;
|
Orderdet1.Lose_Flag__c = false;
|
Orderdet1.Box_Piece__c = '盒';
|
Orderdet1.Return_date__c = null;
|
Orderdet1.Cancellation_Flag__c = false;
|
insert new Consumable_order_details2__c[] {Orderdet1};
|
System.Test.startTest();
|
conTest.outOutPattern = 'ishos';
|
conTest.init();
|
conTest.searchConsumableorderdetails();
|
|
List<Consumable_order_details2__c> irderlist2 = [select Id, Bar_Code__c, Name, Inventory_date__c, Consumable_Product__c, Consumable_Product__r.Asset_Model_No__c, Recordtypeid, Box_Piece__c,ProductPacking_list_manual__c,hospitalSpecialOffer__c FROM Consumable_order_details2__c];
|
|
//必须输入二级经销商或经销商(录入)
|
contest.SecondDealer=null;
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForDealerText__c = null;
|
conTest.coc.Summons_Sale_Status__c = '出货';
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
contest.SecondDealer='123';
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.Summons_Sale_Status__c = '出货';
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
contest.SecondDealer='123';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
//互相调货
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = null;
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = 'neike';
|
contest.SecondDealer='123';
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '医院试用';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.HospitalInfo = hosp1.id;
|
contest.SecondDealer='123';
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
|
//建一条医院特价产品
|
hospitalprice__c hc = new hospitalprice__c();
|
hc.hospital__c = hosp1.Id;
|
hc.product__c = pro1.Id;
|
hc.aph__c = '12332';
|
hc.account__c = myAccount2.Id;
|
insert hc;
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.coc.Order_ForDealerTextID__c = myAccount2.Id;
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c= 0-1;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c = 1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='盒';
|
conTest.pageRecords[0].hospitalSpecialOffer = true;
|
conTest.save();
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.coc.Order_ForDealerTextID__c = myAccount2.Id;
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c=null;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='盒';
|
conTest.pageRecords[0].hospitalSpecialOffer = true;
|
conTest.save();
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.coc.Order_ForDealerTextID__c = myAccount2.Id;
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c=1000;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c=null;
|
conTest.pageRecords[0].hospitalSpecialOffer = true;
|
conTest.save();
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.coc.Order_ForDealerTextID__c = myAccount2.Id;
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c=1000;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =111;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='盒';
|
conTest.pageRecords[0].hospitalSpecialOffer = true;
|
conTest.save();
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.coc.Order_ForDealerTextID__c = myAccount2.Id;
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c=1000;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =111;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='盒';
|
conTest.save();
|
|
|
//正常save
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c=1000;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='盒';
|
conTest.save();
|
|
conTest.pageRecords[0].check=false;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =null;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='个';
|
conTest.save();
|
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =null;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='个';
|
conTest.save();
|
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =0;
|
conTest.coc.SummonsForDirction__c ='销售给二级经销商';
|
conTest.save();
|
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =1000;
|
conTest.coc.SummonsForDirction__c ='互相调货';
|
conTest.save();
|
conTest.approval();
|
conTest.pageRecords.sort();
|
|
conTest.outOutPattern = 'nothos';
|
conTest.init();
|
conTest.SortLimited();
|
|
conTest.coc.Arrive_Order__c = null;
|
conTest.init();
|
conTest.sortKey = '1';
|
conTest.SortLimited();
|
|
System.Test.stopTest();
|
|
}
|
}
|
|
static testMethod void testMethod02(){
|
|
Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET Email)'];
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
|
insert myAccount2;
|
|
|
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',UserPro_Type__c='ENG', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
|
insert MyUser_Test;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {hosp1, hosp2};
|
Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
insert new Agency_Hospital_Link__c[] {agencyHospitalLink1, agencyHospitalLink2};
|
|
system.runAs(MyUser_Test){
|
|
summonsCreatController conTest = new summonsCreatController();
|
Consumable_order__c Order2 = new Consumable_order__c();
|
Order2.Name = 'OCMtest';
|
Order2.Order_status__c = '批准';
|
Order2.Order_type__c = '到货';
|
Order2.Dealer_Info__c = myAccount2.Id;
|
Order2.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
Order2.Order_ProType__c = 'ENG';
|
insert Order2;
|
|
Consumable_order__c Order1 = new Consumable_order__c();
|
Order1.Name = 'OCM_01_001';
|
Order1.Order_status__c = '批准';
|
Order1.Order_type__c = '传票';
|
Order1.Arrive_Order__c = Order2.Id;
|
Order1.Dealer_Info__c = myAccount2.Id;
|
Order1.SummonsForDirction__c = '直接销售给医院';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Order_ProType__c = 'ENG';
|
Order1.orderPattern__c = 'hospitalorder';
|
Order1.OutPattern__c = true;
|
insert Order1;
|
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.Consumable_order_minor__c = Order1.Id;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet1.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet1.Bar_Code__c = '11111';
|
Orderdet1.Consumable_product__c = pro1.Id;
|
Orderdet1.Arrive_date__c = Date.today();
|
Orderdet1.Send_Date__c = null;
|
Orderdet1.Used_date__c = null;
|
Orderdet1.Lose_Flag__c = false;
|
Orderdet1.Box_Piece__c = '盒';
|
Orderdet1.Return_date__c = null;
|
Orderdet1.Cancellation_Flag__c = false;
|
insert new Consumable_order_details2__c[] {Orderdet1};
|
System.Test.startTest();
|
conTest.outOutPattern = 'ishos';
|
conTest.init();
|
conTest.searchConsumableorderdetails();
|
|
List<Consumable_order_details2__c> irderlist2 = [select Id, Bar_Code__c, Name, Inventory_date__c, Consumable_Product__c, Consumable_Product__r.Asset_Model_No__c, Recordtypeid, Box_Piece__c,ProductPacking_list_manual__c,hospitalSpecialOffer__c FROM Consumable_order_details2__c];
|
|
//必须输入二级经销商或经销商(录入)
|
contest.SecondDealer=null;
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForDealerText__c = null;
|
conTest.coc.Summons_Sale_Status__c = '出货';
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
contest.SecondDealer='123';
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.Summons_Sale_Status__c = '出货';
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
contest.SecondDealer='123';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
//互相调货
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = null;
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = 'neike';
|
contest.SecondDealer='123';
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '医院试用';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.HospitalInfo = hosp1.id;
|
contest.SecondDealer='123';
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
|
PageReference page = new PageReference('/apex/summonsCreat?ESetid='+Order1.id+'&KeyWords=Redirect');
|
page.setRedirect(true);
|
System.Test.setCurrentPage(page);
|
conTest.init();
|
page = new PageReference('/apex/summonsCreat?ESetid='+Order2.id);
|
page.setRedirect(true);
|
System.Test.setCurrentPage(page);
|
conTest.init();
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c=1000;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =11111;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='盒';
|
conTest.save();
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c=1000;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =0;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='盒';
|
conTest.save();
|
|
//正常save
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c=1000;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='盒';
|
conTest.save();
|
|
conTest.pageRecords[0].check=false;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =null;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='个';
|
conTest.save();
|
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =null;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='个';
|
conTest.save();
|
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =0;
|
conTest.coc.SummonsForDirction__c ='销售给二级经销商';
|
conTest.save();
|
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =1000;
|
conTest.coc.SummonsForDirction__c ='互相调货';
|
conTest.save();
|
conTest.approval();
|
conTest.pageRecords.sort();
|
|
conTest.outOutPattern = 'nothos';
|
conTest.init();
|
conTest.SortLimited();
|
|
conTest.coc.Arrive_Order__c = null;
|
conTest.init();
|
|
conTest.GoodsDelivery();
|
conTest.seteditAble();
|
|
System.Test.stopTest();
|
|
}
|
}
|
|
static testMethod void testMethod03(){
|
|
Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET Email)'];
|
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 = '病院'];
|
if (rectHos.size() == 0) {
|
return;
|
}
|
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,SFDA_Approbation_No__c = 'Test001',Packing_list_manual__c = 1,SFDA_Expiration_Date__c= Date.today());
|
insert new Product2[] {prod01, prod02};
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '9999900');
|
insert myAccount2;
|
|
|
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',UserPro_Type__c='ENG', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
|
insert MyUser_Test;
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id,OwnerId = MyUser_Test.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id,OwnerId = MyUser_Test.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Account hosp1 = new Account(name='Testhosp001',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
Account hosp2 = new Account(name='Testhosp002',Dealer_discount__c =10,RecordTypeId = rectHos[0].Id,ownerId=MyUser_Test.Id);
|
insert new Account[] {hosp1, hosp2};
|
Agency_Hospital_Link__c agencyHospitalLink1 = new Agency_Hospital_Link__c(Hospital__c = hosp1.id,Agency__c = myAccount2.id);
|
Agency_Hospital_Link__c agencyHospitalLink2 = new Agency_Hospital_Link__c(Hospital__c = hosp2.id,Agency__c = myAccount2.id);
|
insert new Agency_Hospital_Link__c[] {agencyHospitalLink1, agencyHospitalLink2};
|
|
system.runAs(MyUser_Test){
|
summonsCreatController conTest = new summonsCreatController();
|
Consumable_order__c Order2 = new Consumable_order__c();
|
Order2.Name = 'OCMtest';
|
Order2.Order_status__c = '批准';
|
Order2.Order_type__c = '到货';
|
Order2.Dealer_Info__c = myAccount2.Id;
|
Order2.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
Order2.Order_ProType__c = 'ENG';
|
insert Order2;
|
|
Consumable_order__c Order1 = new Consumable_order__c();
|
Order1.Name = 'OCM_01_001';
|
Order1.Order_status__c = '批准';
|
Order1.Order_type__c = '传票';
|
Order1.Arrive_Order__c = Order2.Id;
|
Order1.Dealer_Info__c = myAccount2.Id;
|
Order1.SummonsForDirction__c = '直接销售给医院';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Order_ProType__c = 'ENG';
|
Order1.orderPattern__c = 'hospitalorder';
|
Order1.OutPattern__c = true;
|
insert Order1;
|
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.Consumable_order_minor__c = Order1.Id;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet1.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet1.Bar_Code__c = '11111';
|
Orderdet1.Consumable_product__c = pro1.Id;
|
Orderdet1.Arrive_date__c = Date.today();
|
Orderdet1.Send_Date__c = null;
|
Orderdet1.Used_date__c = null;
|
Orderdet1.Lose_Flag__c = false;
|
Orderdet1.Box_Piece__c = '盒';
|
Orderdet1.Return_date__c = null;
|
Orderdet1.Cancellation_Flag__c = false;
|
|
Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
|
Orderdet2.Name = 'OCM_01_0010011';
|
Orderdet2.Consumable_order_minor__c = Order1.Id;
|
Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet2.Consumable_Arrived_order__c = Order1.Id;
|
Orderdet2.Sterilization_limit__c = Date.today().addDays(1);
|
Orderdet2.Bar_Code__c = '111111';
|
Orderdet2.Consumable_product__c = pro1.Id;
|
Orderdet2.Arrive_date__c = Date.today();
|
Orderdet2.Send_Date__c = null;
|
Orderdet2.Used_date__c = null;
|
Orderdet2.Lose_Flag__c = false;
|
Orderdet2.Box_Piece__c = '个';
|
Orderdet2.Return_date__c = null;
|
Orderdet2.Cancellation_Flag__c = false;
|
|
insert new Consumable_order_details2__c[] {Orderdet1,Orderdet2 };
|
System.Test.startTest();
|
conTest.outOutPattern = 'ishos';
|
conTest.init();
|
conTest.searchConsumableorderdetails();
|
|
List<Consumable_order_details2__c> irderlist2 = [select Id, Bar_Code__c, Name, Inventory_date__c, Consumable_Product__c, Consumable_Product__r.Asset_Model_No__c, Recordtypeid, Box_Piece__c,ProductPacking_list_manual__c,hospitalSpecialOffer__c FROM Consumable_order_details2__c];
|
|
//必须输入二级经销商或经销商(录入)
|
contest.SecondDealer=null;
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForDealerText__c = null;
|
conTest.coc.Summons_Sale_Status__c = '出货';
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
contest.SecondDealer='123';
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.Summons_Sale_Status__c = '出货';
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
contest.SecondDealer='123';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForDealerText__c = '123';
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.save();
|
|
//互相调货
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = '123';
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = null;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.coc.Order_ForDealerText__c = null;
|
conTest.coc.SummonsForDirction__c = '互相调货';
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = 'neike';
|
contest.SecondDealer='123';
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '医院试用';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '销售给二级经销商';
|
conTest.HospitalInfo = hosp1.id;
|
contest.SecondDealer='123';
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.HospitalName = hosp1.Name;
|
conTest.coc.Order_ForCustomerText__c = null;
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '直接销售给医院';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.HospitalName = hosp1.Name;
|
conTest.coc.Order_ForCustomerText__c = '耳鼻喉科';
|
conTest.SecondDealer = '123';
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '医院试用';
|
conTest.HospitalInfo = hosp1.id;
|
conTest.HospitalName = hosp1.Name;
|
conTest.coc.Order_ForCustomerText__c = '';
|
conTest.save();
|
|
conTest.coc.SummonsForDirction__c = '';
|
conTest.save();
|
|
//建一条医院特价产品
|
hospitalprice__c hc = new hospitalprice__c();
|
hc.hospital__c = hosp1.Id;
|
hc.product__c = pro1.Id;
|
hc.aph__c = '12332';
|
hc.account__c = myAccount2.Id;
|
insert hc;
|
|
|
//正常save
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = hosp1.Id;
|
conTest.HospitalName = hosp1.Name;
|
conTest.coc.Order_ForCustomerText__c = '耳鼻喉科';
|
conTest.coc.SummonsForDirction__c = '医院试用';
|
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c= -1;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='盒';
|
conTest.pageRecords[0].hospitalSpecialOffer = true;
|
conTest.save();
|
|
conTest.SecondDealer = null;
|
conTest.HospitalInfo = hosp1.Id;
|
conTest.HospitalName = hosp1.Name;
|
conTest.coc.Order_ForCustomerText__c = '耳鼻喉科';
|
conTest.coc.SummonsForDirction__c = '医院试用';
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c=1000;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='盒';
|
conTest.pageRecords[0].hospitalSpecialOffer = true;
|
conTest.save();
|
|
conTest.pageRecords[0].check=false;
|
conTest.pageRecords[0].orderdetails1.Dealer_Custom_Price__c = 666.00;
|
conTest.pageRecords[0].orderdetails1.Consumable_count__c = 10;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =null;
|
conTest.pageRecords[0].orderdetails1.Shipment_Count__c =1;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='个';
|
conTest.save();
|
|
conTest.pageRecords[0].check=true;
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =null;
|
conTest.pageRecords[0].orderdetails1.Box_Piece__c='个';
|
conTest.save();
|
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =0;
|
conTest.coc.SummonsForDirction__c ='医院试用';
|
conTest.save();
|
|
conTest.pageRecords[0].orderdetails1.Delivery_List_RMB__c =1000;
|
conTest.coc.SummonsForDirction__c ='医院试用';
|
conTest.save();
|
conTest.approval();
|
conTest.pageRecords.sort();
|
|
conTest.outOutPattern = 'ishos';
|
conTest.init();
|
conTest.SortLimited();
|
|
conTest.coc.Arrive_Order__c = null;
|
conTest.init();
|
conTest.SortLimited();
|
conTest.category1 = '01';
|
conTest.category3 = '光源';
|
conTest.category4 = 'CLV';
|
conTest.category5 = 'S45';
|
conTest.searchConsumableorderdetails();
|
|
conTest.coc.SummonsForDirction__c = '医院试用';
|
conTest.coc.SummonsStatus_c__c = '草案中';
|
conTest.GoodsDelivery();
|
|
|
|
System.Test.stopTest();
|
|
}
|
}
|
|
|
}
|