@isTest
|
private class SaleOrderControllerTest {
|
|
static testMethod void myUnitTest() {
|
// TO DO: implement unit test
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
|
RecordType hosCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
Account olympus = new Account(RecordTypeId = hosCo.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
|
insert olympus;
|
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;
|
//订单
|
|
system.runAs(MyUser_Test){
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12);
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12);
|
insert new Product2[]{prod01,prod02};
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Consumable_order__c Order1 = new Consumable_order__c();
|
Order1.Name = 'OCM_01_001';
|
Order1.Order_status__c = '批准';
|
Order1.Order_type__c = '订单';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Dealer_Info__c = myAccount2.Id;
|
insert Order1;
|
|
//在库 盒
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001002';
|
Orderdet1.Consumable_order_minor__c = Order1.Id;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Bar_Code__c = '11111250AAAAA';
|
Orderdet1.Arrive_date__c = Date.today();
|
Orderdet1.Consumable_Product__c = pro1.Id;
|
Orderdet1.Box_Piece__c = '盒';
|
Orderdet1.TracingCode__c = 'AAAAA';
|
//未到货
|
Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
|
Orderdet2.Name = 'OCM_02_001002';
|
Orderdet2.Consumable_order_minor__c = Order1.Id;
|
Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet2.Bar_Code__c = '22222250BBBBB';
|
Orderdet2.Consumable_Product__c = pro2.Id;
|
Orderdet2.Box_Piece__c = '盒';
|
Orderdet2.TracingCode__c = 'BBBBB';
|
//销售
|
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.Bar_Code__c = '33333250CCCCC';
|
Orderdet3.Consumable_Product__c = pro1.Id;
|
Orderdet3.Used_date__c = Date.today();
|
Orderdet3.Send_Date__c = Date.today();
|
Orderdet3.Arrive_date__c = Date.today();
|
Orderdet3.Box_Piece__c = '盒';
|
Orderdet3.TracingCode__c = 'CCCCC';
|
|
//在库 个
|
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.Bar_Code__c = '44444250DDDDD';
|
Orderdet4.Consumable_Product__c = pro1.Id;
|
Orderdet4.Arrive_date__c = Date.today();
|
Orderdet4.Box_Piece__c = '个';
|
Orderdet4.TracingCode__c = 'DDDDD';
|
|
Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
|
Orderdet5.Name = 'OCM_01_001004';
|
Orderdet5.Consumable_order_minor__c = Order1.Id;
|
Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery ;
|
Orderdet5.Bar_Code__c = '55555250EEEEE';
|
Orderdet5.Consumable_Product__c = pro1.Id;
|
Orderdet5.Arrive_date__c = Date.today();
|
Orderdet5.TracingCode__c = 'EEEEE';
|
insert new Consumable_order_details2__c[] {Orderdet1,Orderdet2,Orderdet3,Orderdet4,Orderdet5};
|
|
Consumable_order__c zsd01 = new Consumable_order__c();
|
zsd01.Name = 'ZSD_01_001';
|
zsd01.Order_type__c = '传票';
|
zsd01.SummonsStatus_c__c ='已完成';
|
zsd01.Order_type__c = '订单';
|
zsd01.RecordTypeid = System.Label.RT_ConOrder_Order;
|
zsd01.Summons_Sale_Status__c = '销售';
|
zsd01.Outbound_Date__c = Date.today();
|
zsd01.IsShipment__c = true;
|
insert zsd01;
|
|
Consumable_orderdetails__c Orderdet6 = new Consumable_orderdetails__c();
|
Orderdet6.Name = 'ZSD_01_001001';
|
Orderdet6.Consumable_order__c = zsd01.Id;
|
Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail1_Order ;
|
Orderdet6.Consumable_Count__c = 12;
|
Orderdet6.Consumable_Product__c = pro1.Id;
|
//Orderdet6.Unitprice_To_agency__c = 1;
|
Orderdet6.Delivery_List_RMB__c = 1;
|
Orderdet6.Shipment_Count__c = 1;
|
Orderdet6.Box_Piece__c = '个';
|
insert Orderdet6;
|
|
Consumable_orderdetails__c Orderdetc6 = new Consumable_orderdetails__c();
|
Orderdetc6.Name = 'ZSD_01_001001';
|
Orderdetc6.Consumable_order__c = zsd01.Id;
|
Orderdetc6.RecordTypeId = System.Label.RT_ConOrderDetail1_Order;
|
Orderdetc6.Consumable_Count__c = 12;
|
Orderdetc6.Consumable_Product__c = pro2.Id;
|
//Orderdetc6.Unitprice_To_agency__c = 1;
|
Orderdetc6.Delivery_List_RMB__c = 1;
|
Orderdetc6.Shipment_Count__c = 1;
|
Orderdetc6.Box_Piece__c = '盒';
|
insert Orderdetc6;
|
|
PageReference page = new PageReference('/apex/SaleOrder?Esetid=' + zsd01.Id);
|
System.Test.setCurrentPage(page);
|
SaleOrderController Controller = new SaleOrderController();
|
//初始化测试
|
System.Test.startTest();
|
Controller.init();
|
//排序
|
Controller.barcode = '';
|
Controller.SearchPro();
|
Controller.barcode = '11111250AAAAA\n22222250BBBBB\n33333250CCCCC\n44444250DDDDD\n55555250EEEEE\n666666\n777777\naaa';
|
Controller.SearchPro();
|
|
Controller.ProdElivery();
|
Controller.ProSale();
|
Controller.ProS();
|
System.Test.stopTest();
|
}
|
}
|
|
static testMethod void ArriveOrdertest() {
|
// TO DO: implement unit test
|
StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
|
RecordType hosCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
Account olympus = new Account(RecordTypeId = hosCo.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
|
insert olympus;
|
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;
|
//订单
|
|
system.runAs(MyUser_Test){
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12);
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12);
|
insert new Product2[]{prod01,prod02};
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Consumable_order__c Order1 = new Consumable_order__c();
|
Order1.Name = 'OCM_01_001';
|
Order1.Order_status__c = '批准';
|
Order1.Order_type__c = '订单';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Dealer_Info__c = myAccount2.Id;
|
insert Order1;
|
|
Consumable_order__c Order2 = new Consumable_order__c();
|
Order2.Name = 'OCM_02_001';
|
Order2.Order_status__c = '批准';
|
Order2.Order_type__c = '订单';
|
Order2.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order2.Dealer_Info__c = myAccount2.Id;
|
insert Order2;
|
|
|
Consumable_order__c Order3 = new Consumable_order__c();
|
Order3.Name = 'OCM_02_005';
|
Order3.Order_status__c = '批准';
|
Order3.Order_type__c = '传票';
|
Order3.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order3.Arrive_Order__c= Order1.Id;
|
Order3.Dealer_Info__c = myAccount2.Id;
|
Order3.SummonsForDirction__c ='直接销售给医院';
|
Order3.IsShipment__c = true;
|
insert Order3;
|
|
//订单明细
|
|
//all
|
Consumable_order_details2__c Orderdet = new Consumable_order_details2__c();
|
Orderdet.Name = 'OCM_01_001001';
|
Orderdet.Consumable_Product__c = pro1.Id;
|
Orderdet.Consumable_order_minor__c = Order1.Id;
|
Orderdet.Consumable_ZS_order__c = Order3.Id;
|
Orderdet.Consumable_Return_order__c = Order1.Id;
|
Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet.RemoveBox_No__c = 3;
|
Orderdet.Bar_Code__c = '1111111111250AAAAA';
|
Orderdet.Arrive_date__c = Date.today();
|
Orderdet.Delivery_List_RMB__c = 11.11;
|
Orderdet.Box_Piece__c = '个';
|
Orderdet.TracingCode__c = 'AAAAA';
|
Orderdet.Sterilization_limit__c = Date.today().addDays(-1);
|
|
//发货
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.Consumable_Product__c = pro1.Id;
|
Orderdet1.Consumable_order_minor__c = Order1.Id;
|
Orderdet1.Consumable_ZS_order__c = Order3.Id;
|
Orderdet1.Consumable_Return_order__c = Order1.Id;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.RemoveBox_No__c = 3;
|
Orderdet1.Bar_Code__c = '2222222222250BBBBB';
|
Orderdet1.Arrive_date__c = Date.today();
|
Orderdet1.Return_reason__c = null;
|
Orderdet1.Return_date__c = null;
|
Orderdet1.Delivery_List_RMB__c = 11.11;
|
Orderdet1.Box_Piece__c = '个';
|
Orderdet1.TracingCode__c = 'BBBBB';
|
Orderdet1.Sterilization_limit__c = Date.today().addDays(-1);
|
//销售
|
Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
|
Orderdet2.Name = 'OCM_01_001002';
|
Orderdet2.Consumable_order_minor__c = Order3.Id;
|
Orderdet2.Consumable_Shipment_order__c = Order3.Id;
|
Orderdet2.Consumable_Sale_order__c = Order3.Id;
|
Orderdet2.Consumable_ZS_order__c = Order3.Id;
|
Orderdet2.Consumable_Return_order__c = Order3.Id;
|
Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet2.RemoveBox_No__c = 3;
|
Orderdet2.Bar_Code__c = '3333333333250CCCCC';
|
Orderdet2.Consumable_Product__c = pro1.Id;
|
Orderdet2.Send_Date__c = Date.today().addDays(-1);
|
Orderdet2.Return_reason__c = null;
|
//Orderdet2.Unitprice_To_agency__c = 11.11;
|
Orderdet2.Return_date__c = null;
|
Orderdet2.Delivery_List_RMB__c = 11;
|
Orderdet2.Box_Piece__c = '盒';
|
Orderdet2.TracingCode__c = 'CCCCC';
|
Orderdet2.Arrive_date__c = Date.today();
|
Orderdet2.Sterilization_limit__c = Date.today().addDays(-1);
|
//销售
|
Consumable_order_details2__c Orderdet9 = new Consumable_order_details2__c();
|
Orderdet9.Name = 'OCM_01_001002';
|
Orderdet9.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet9.RemoveBox_No__c = 3;
|
Orderdet9.Bar_Code__c = '4444444444250DDDDD';
|
Orderdet9.Consumable_Product__c = pro1.Id;
|
Orderdet9.Arrive_date__c = Date.today();
|
Orderdet9.Used_date__c = Date.today();
|
Orderdet9.Box_Piece__c = '个';
|
Orderdet9.TracingCode__c = 'DDDDD';
|
//出库
|
Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
|
Orderdet3.Name = 'OCM_01_001003';
|
Orderdet3.Consumable_order_minor__c = Order1.Id;
|
Orderdet3.Consumable_Shipment_order__c = Order1.Id;
|
Orderdet3.Consumable_order_minor__c = null;
|
Orderdet3.Consumable_Sale_order__c = null;
|
Orderdet3.Consumable_ZS_order__c = Order1.Id;
|
Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet3.Bar_Code__c = '5555555555250EEEEE';
|
Orderdet3.Consumable_Product__c = pro1.Id;
|
Orderdet3.Send_Date__c = Date.today();
|
Orderdet3.Box_Piece__c = '盒';
|
Orderdet3.Return_date__c= null;
|
Orderdet3.Lose_Flag__c = true;
|
Orderdet3.TracingCode__c = 'EEEEE';
|
|
//到货
|
Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
|
Orderdet4.Name = 'OCM_01_001004';
|
Orderdet4.Consumable_order_minor__c = null;
|
Orderdet4.Consumable_Sale_order__c = null;
|
Orderdet4.Consumable_ZS_order__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 = '6666666666250FFFFF';
|
Orderdet4.Consumable_Product__c = pro1.Id;
|
Orderdet4.Arrive_date__c = Date.today();
|
Orderdet4.Box_Piece__c = '个';
|
Orderdet4.TracingCode__c = 'FFFFF';
|
//发货
|
Consumable_order_details2__c Orderdet5 = new Consumable_order_details2__c();
|
Orderdet5.Name = 'OCM_02_001001';
|
Orderdet5.Consumable_order_minor__c = Order2.Id;
|
Orderdet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet5.Bar_Code__c = '7777777777250GGGGG';
|
Orderdet5.Consumable_Product__c = pro1.Id;
|
Orderdet5.Deliver_date__c = Date.today();
|
Orderdet5.RemoveBox_No__c = 3;
|
Orderdet5.Box_Piece__c = '盒';
|
Orderdet5.TracingCode__c = 'GGGGG';
|
|
|
Consumable_order_details2__c Orderdet6 = new Consumable_order_details2__c();
|
Orderdet6.Name = 'OCM_02_001001';
|
Orderdet6.Consumable_order_minor__c = Order2.Id;
|
Orderdet6.Consumable_ZS_order__c = Order2.Id;
|
Orderdet6.Consumable_Return_order__c = Order2.Id;
|
Orderdet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet6.Bar_Code__c = '8888888888250HHHHH';
|
Orderdet6.Consumable_Product__c = pro1.Id;
|
Orderdet6.Arrive_date__c = Date.today();
|
Orderdet6.RemoveBox_No__c = 3;
|
Orderdet6.Sterilization_limit__c = Date.today().addDays(-2);
|
Orderdet6.TracingCode__c = 'HHHHH';
|
|
insert new Consumable_order_details2__c[] {Orderdet,Orderdet1, Orderdet2,Orderdet3,Orderdet4,Orderdet5,Orderdet6,Orderdet9};
|
|
PageReference page = new PageReference('/apex/SaleOrder?Esetid=' + Order3.Id);
|
System.Test.setCurrentPage(page);
|
SaleOrderController Controller = new SaleOrderController();
|
//初始化测试
|
System.Test.startTest();
|
Controller.init();
|
//排序
|
Controller.barcode = '';
|
Controller.SearchPro();
|
Controller.barcode = '1111111111250AAAAA\n2222222222250BBBBB\n3333333333250CCCCC\n4444444444250DDDDD\n5555555555250EEEEE\n6666666666250FFFFF\n7777777777250GGGGG\n8888888888250HHHHH';
|
Controller.SearchPro();
|
System.Test.stopTest();
|
|
}
|
}
|
|
static testMethod void ProdEliverytest() {
|
// TO DO: implement unit test
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
|
RecordType hosCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
Account olympus = new Account(RecordTypeId = hosCo.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
|
insert olympus;
|
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;
|
//订单
|
|
system.runAs(MyUser_Test){
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12);
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12);
|
insert new Product2[]{prod01,prod02};
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
Consumable_order__c Order1 = new Consumable_order__c();
|
Order1.Name = 'OCM_01_001';
|
Order1.Order_status__c = '批准';
|
Order1.Order_type__c = '订单';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Dealer_Info__c = myAccount2.Id;
|
insert Order1;
|
|
Consumable_order__c Order2 = new Consumable_order__c();
|
Order2.Name = 'OCM_02_001';
|
Order2.Order_status__c = '批准';
|
Order2.Order_type__c = '订单';
|
Order2.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order2.Dealer_Info__c = myAccount2.Id;
|
insert Order2;
|
|
Consumable_order__c Order4 = new Consumable_order__c();
|
Order4.Name = 'OCM_02_002';
|
Order4.Order_status__c = '批准';
|
Order4.Order_type__c = '订单';
|
Order4.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order4.Dealer_Info__c = myAccount2.Id;
|
Order4.Arrive_Order__c =Order1.id;
|
Order4.IsShipment__c = true;
|
insert Order4;
|
|
|
Consumable_order__c Order3 = new Consumable_order__c();
|
Order3.Name = 'OCM_02_005';
|
Order3.Order_status__c = '取消';
|
Order3.Order_type__c = '返品';
|
Order3.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order3.Dealer_Info__c = myAccount2.Id;
|
insert Order3;
|
//订单明细
|
//all
|
Consumable_order_details2__c Orderdet = new Consumable_order_details2__c();
|
Orderdet.Name = 'OCM_01_001001';
|
Orderdet.Consumable_Product__c = pro1.Id;
|
Orderdet.Consumable_order_minor__c = Order1.Id;
|
Orderdet.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet.RemoveBox_No__c = 3;
|
Orderdet.Bar_Code__c = '11111250AAAAA';
|
Orderdet.Arrive_date__c = Date.today();
|
Orderdet.Delivery_List_RMB__c = 11.11;
|
Orderdet.TracingCode__c = 'AAAAA';
|
|
//发货
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.Consumable_Product__c = pro1.Id;
|
Orderdet1.Consumable_order_minor__c = Order1.Id;
|
Orderdet1.Consumable_ZS_order__c = Order4.Id;
|
Orderdet1.Consumable_Return_order__c = null;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.RemoveBox_No__c = 3;
|
Orderdet1.Bar_Code__c = '22222250BBBBB';
|
Orderdet1.Arrive_date__c = Date.today();
|
Orderdet1.Delivery_List_RMB__c = 11.11;
|
Orderdet1.Box_Piece__c = '个';
|
Orderdet1.TracingCode__c = 'BBBBB';
|
//销售
|
Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
|
Orderdet2.Name = 'OCM_01_001002';
|
Orderdet2.Consumable_order_minor__c = Order1.Id;
|
Orderdet2.Consumable_Sale_order__c = Order4.Id;
|
Orderdet2.Consumable_ZS_order__c = Order4.Id;
|
Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet2.RemoveBox_No__c = 3;
|
Orderdet2.Bar_Code__c = '33333250CCCCC';
|
Orderdet2.Consumable_Product__c = pro1.Id;
|
//Orderdet2.Unitprice_To_agency__c = 11.11;
|
Orderdet2.Delivery_List_RMB__c = 11;
|
Orderdet2.Used_date__c = Date.today();
|
Orderdet2.Box_Piece__c = '盒';
|
Orderdet2.TracingCode__c = 'CCCCC';
|
|
//出库
|
Consumable_order_details2__c Orderdet3 = new Consumable_order_details2__c();
|
Orderdet3.Name = 'OCM_01_001003';
|
Orderdet3.Consumable_order_minor__c = Order1.Id;
|
Orderdet3.Consumable_Shipment_order__c = Order1.Id;
|
Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet3.Bar_Code__c = '44444250DDDDD';
|
Orderdet3.Consumable_Product__c = pro1.Id;
|
Orderdet3.Send_Date__c = Date.today();
|
Orderdet3.Box_Piece__c = '盒';
|
Orderdet3.TracingCode__c = 'DDDDD';
|
//到货
|
Consumable_order_details2__c Orderdet4 = new Consumable_order_details2__c();
|
Orderdet4.Name = 'OCM_01_001004';
|
Orderdet4.Consumable_order_minor__c =Order3.id;
|
Orderdet4.Consumable_Return_order__c = null;
|
Orderdet4.Consumable_Sale_order__c =null;
|
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 = '55555250EEEEE';
|
Orderdet4.Consumable_Product__c = pro1.Id;
|
Orderdet4.Arrive_date__c = Date.today();
|
Orderdet4.Box_Piece__c = '盒';
|
Orderdet4.TracingCode__c = 'EEEEE';
|
|
insert new Consumable_order_details2__c[] {Orderdet,Orderdet1, Orderdet2,Orderdet3,Orderdet4};
|
|
Consumable_order__c zsd01 = new Consumable_order__c();
|
zsd01.Name = 'ZSD_01_001';
|
zsd01.Order_type__c = '传票';
|
zsd01.SummonsStatus_c__c ='已完成';
|
zsd01.Order_type__c = '订单';
|
zsd01.RecordTypeid = System.Label.RT_ConOrder_Order;
|
zsd01.Summons_Sale_Status__c = '销售';
|
zsd01.Outbound_Date__c = Date.today();
|
zsd01.IsShipment__c = true;
|
insert zsd01;
|
|
Consumable_orderdetails__c Orderdetc6 = new Consumable_orderdetails__c();
|
Orderdetc6.Name = 'ZSD_01_001001';
|
Orderdetc6.Consumable_order__c = zsd01.Id;
|
Orderdetc6.RecordTypeId = System.Label.RT_ConOrderDetail1_Order ;
|
Orderdetc6.Consumable_Count__c = 12;
|
Orderdetc6.Consumable_Product__c = pro1.Id;
|
//Orderdetc6.Unitprice_To_agency__c = 1;
|
Orderdetc6.Delivery_List_RMB__c = 1;
|
Orderdetc6.Shipment_Count__c = 1;
|
Orderdetc6.Box_Piece__c = '盒';
|
insert Orderdetc6;
|
|
PageReference page = new PageReference('/apex/SaleOrder?Esetid=' + zsd01.Id);
|
System.Test.setCurrentPage(page);
|
page.setRedirect(true);
|
|
SaleOrderController Controller = new SaleOrderController();
|
//初始化测试
|
System.Test.startTest();
|
Controller.init();
|
Controller.barcode = null;
|
Controller.SearchPro();
|
//排序
|
Controller.barcode = '11111250AAAAA\n22222250BBBBB\n33333250CCCCC\n44444250DDDDD\n55555250EEEEE';
|
Controller.SearchPro();
|
|
/*System.assertEquals('OCM_01_001001', controller.ConsumableorderdetailsRecordserror[0].orderdetails2.Name);
|
System.assertEquals('OCM_01_001002', controller.ConsumableorderdetailsRecordserror[1].orderdetails2.Name);
|
System.assertEquals('OCM_01_001003', controller.ConsumableorderdetailsRecordserror[2].orderdetails2.Name);
|
System.assertEquals('OCM_01_001004', controller.ConsumableorderdetailsRecordserror[3].orderdetails2.Name);*/
|
Controller.ProdElivery();
|
Controller.ProSale();
|
Controller.ProS();
|
System.Test.stopTest();
|
}
|
}
|
|
|
static testMethod void ProdErrortest() {
|
// TO DO: implement unit test
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
|
RecordType hosCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
Account olympus = new Account(RecordTypeId = hosCo.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
|
insert olympus;
|
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;
|
//订单
|
|
system.runAs(MyUser_Test){
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12);
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12);
|
Product2 prod03 = new Product2(Name='Test03',ProductCode='Test03',Asset_Model_No__c = 'Test03',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c=12);
|
insert new Product2[]{prod01,prod02,prod03};
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
|
Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prod03.Id);
|
insert new Product2__c[] {pro1, pro2,pro3};
|
//出库单
|
Consumable_order__c Order1 = new Consumable_order__c();
|
Order1.Name = 'OCM_01_001';
|
Order1.Order_status__c = '批准';
|
Order1.Order_type__c = '传票';
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Order;
|
Order1.Dealer_Info__c = myAccount2.Id;
|
Order1.SummonsForDirction__c ='直接销售给医院';
|
Order1.IsShipment__c = true;
|
insert Order1;
|
//明细1
|
Consumable_orderdetails__c Orderdet1 = new Consumable_orderdetails__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.Consumable_order__c = Order1.Id;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail1_Order ;
|
Orderdet1.Consumable_Count__c = 12;
|
Orderdet1.Consumable_Product__c = pro1.Id;
|
//Orderdet1.Unitprice_To_agency__c = 1;
|
Orderdet1.Delivery_List_RMB__c = 1;
|
Orderdet1.Shipment_Count__c = 1;
|
Orderdet1.Box_Piece__c = '盒';
|
insert Orderdet1;
|
Consumable_orderdetails__c Orderdet2 = new Consumable_orderdetails__c();
|
Orderdet2.Name = 'OCM_01_001002';
|
Orderdet2.Consumable_order__c = Order1.Id;
|
Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail1_Order ;
|
Orderdet2.Consumable_Count__c = 12;
|
Orderdet2.Consumable_Product__c = pro2.Id;
|
//Orderdet2.Unitprice_To_agency__c = 1;
|
Orderdet2.Delivery_List_RMB__c = 1;
|
Orderdet2.Shipment_Count__c = 1;
|
Orderdet2.Box_Piece__c = '盒';
|
insert Orderdet2;
|
Consumable_orderdetails__c Orderdet3 = new Consumable_orderdetails__c();
|
Orderdet3.Name = 'OCM_01_001002';
|
Orderdet3.Consumable_order__c = Order1.Id;
|
Orderdet3.RecordTypeId = System.Label.RT_ConOrderDetail1_Order ;
|
Orderdet3.Consumable_Count__c = 12;
|
Orderdet3.Consumable_Product__c = pro3.Id;
|
//Orderdet3.Unitprice_To_agency__c = 1;
|
Orderdet3.Delivery_List_RMB__c = 1;
|
Orderdet3.Shipment_Count__c = 1;
|
Orderdet3.Box_Piece__c = '个';
|
insert Orderdet3;
|
|
//明细2
|
Consumable_order_details2__c Orderdets1 = new Consumable_order_details2__c();
|
Orderdets1.Name = 'OCM_01_0010001';
|
Orderdets1.Consumable_order_minor__c = Order1.Id;
|
Orderdets1.Consumable_ZS_order__c = Order1.Id;
|
Orderdets1.Consumable_Return_order__c = null;
|
Orderdets1.Consumable_Sale_order__c =null;
|
Orderdets1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdets1.Bar_Code__c = '11111250AAAAA';
|
Orderdets1.Consumable_Product__c = pro1.Id;
|
Orderdets1.Arrive_date__c = Date.today();
|
Orderdets1.RemoveBox_No__c = 3;
|
Orderdets1.Delivery_List_RMB__c = 11.11;
|
Orderdets1.Box_Piece__c = '盒';
|
Orderdets1.Sterilization_limit__c = Date.today().addDays(-1);
|
Orderdets1.TracingCode__c = 'AAAAA';
|
|
Consumable_order_details2__c Orderdets2 = new Consumable_order_details2__c();
|
Orderdets2.Name = 'OCM_01_0010002';
|
Orderdets2.Consumable_order_minor__c = Order1.Id;
|
Orderdets2.Consumable_ZS_order__c = Order1.Id;
|
Orderdets2.Consumable_Return_order__c = null;
|
Orderdets2.Consumable_Sale_order__c =null;
|
Orderdets2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdets2.Bar_Code__c = '22222250BBBBB';
|
Orderdets2.Consumable_Product__c = pro2.Id;
|
Orderdets2.Arrive_date__c = Date.today();
|
Orderdets2.RemoveBox_No__c = 3;
|
Orderdets2.Delivery_List_RMB__c = 11.11;
|
Orderdets2.Box_Piece__c = '个';
|
Orderdets2.Sterilization_limit__c = Date.today().addDays(-1);
|
Orderdets1.TracingCode__c = 'BBBBB';
|
|
Consumable_order_details2__c Orderdets3 = new Consumable_order_details2__c();
|
Orderdets3.Name = 'OCM_01_0010003';
|
Orderdets3.Consumable_order_minor__c = Order1.Id;
|
Orderdets3.Consumable_ZS_order__c = Order1.Id;
|
Orderdets3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdets3.Bar_Code__c = '33333250CCCCC';
|
Orderdets3.Consumable_Product__c = pro3.Id;
|
Orderdets3.Arrive_date__c = Date.today();
|
Orderdets3.RemoveBox_No__c = 3;
|
Orderdets3.Delivery_List_RMB__c = 11.11;
|
Orderdets3.Box_Piece__c = '盒';
|
Orderdets3.Sterilization_limit__c = Date.today().addDays(-1);
|
Orderdets3.TracingCode__c = 'CCCCC';
|
//未到货
|
Consumable_order_details2__c Orderdets4 = new Consumable_order_details2__c();
|
Orderdets4.Name = 'OCM_01_0010001';
|
Orderdets4.Consumable_order_minor__c = Order1.Id;
|
Orderdets4.Consumable_ZS_order__c = Order1.Id;
|
Orderdets4.Consumable_Return_order__c = null;
|
Orderdets4.Consumable_Sale_order__c =null;
|
Orderdets4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdets4.Bar_Code__c = '44444250DDDDD';
|
Orderdets4.Consumable_Product__c = pro1.Id;
|
Orderdets4.Box_Piece__c = '盒';
|
Orderdets4.Sterilization_limit__c = Date.today().addDays(-1);
|
Orderdets4.TracingCode__c = 'DDDDD';
|
|
Consumable_order_details2__c Orderdets5 = new Consumable_order_details2__c();
|
Orderdets5.Name = 'OCM_01_0010003';
|
Orderdets5.Consumable_order_minor__c = Order1.Id;
|
Orderdets5.Consumable_ZS_order__c = Order1.Id;
|
Orderdets5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdets5.Bar_Code__c = '33333250EEEEE';
|
Orderdets5.Consumable_Product__c = pro3.Id;
|
Orderdets5.Arrive_date__c = Date.today();
|
Orderdets5.RemoveBox_No__c = 3;
|
Orderdets5.Delivery_List_RMB__c = 11.11;
|
Orderdets5.Box_Piece__c = '个';
|
Orderdets5.Sterilization_limit__c = Date.today().addDays(-1);
|
Orderdets5.TracingCode__c = 'EEEEE';
|
|
insert new Consumable_order_details2__c[] {Orderdets1,Orderdets2,Orderdets3,Orderdets4,Orderdets5};
|
|
|
PageReference page = new PageReference('/apex/SaleOrder?Esetid=' + Order1.Id);
|
System.Test.setCurrentPage(page);
|
page.setRedirect(true);
|
|
SaleOrderController Controller = new SaleOrderController();
|
//初始化测试
|
System.Test.startTest();
|
Controller.init();
|
//排序
|
Controller.barcode = '11111250AAAAA\n22222250BBBBB\n33333250CCCCC\n44444250DDDDD\n33333250EEEEE';
|
Controller.SearchPro();
|
// System.assertEquals(1, controller.ConsumableorderdetailsRecordserror.size());
|
Controller.ProdElivery();
|
Controller.ProSale();
|
Controller.ProS();
|
Controller.testUtil();
|
System.Test.stopTest();
|
}
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|