@isTest
|
private class ConsumableTargetManageBatchTest1 {
|
public static Account hospital;
|
public static Account agency1;
|
public static Account agency2;
|
public static Account agency3;
|
public static String oldAgencyCode;
|
public static String newAgencyCode;
|
public static String oldAgencyId15;
|
public static String newAgencyId15;
|
|
public static Contact contact1;
|
public static Contact contact2;
|
public static User user1;
|
public static User user2;
|
public static User user3;
|
|
public static Agency_Hospital_Link__c a1HPLink;
|
public static Agency_Hospital_Link__c a2HPLink;
|
public static Agency_Hospital_Link__c a3HPLink;
|
|
public static Date monday;
|
public static Id Contact_Agency_RT = Schema.SObjectType.Contact.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
|
static testMethod void testMethod1() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
|
Account hospital = new Account();
|
hospital.RecordTypeId = rectCo[0].Id;
|
hospital.Name = 'NFM007Testhospital';
|
insert hospital;
|
|
// 戦略科室を得る
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = hospital.Id;
|
section.Hospital_Department_Class__c = hospital.Id;
|
section.AgentCode_Ext__c = '9999900';
|
insert section;
|
|
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
// prd1.Category2__c = '本体';
|
prd1.Category3__c = '呼吸科ET';
|
prd1.Category4__c = '活检套装';
|
// prd1.Category5__c = '260SL系列';
|
prd1.Asset_Model_No__c = '1001';
|
prd1.Is_DangerousChemicals__c=false;
|
prd1.Family= 'ET';
|
prd1.Category2__c = '耗材';
|
prd1.Dealer_special_Object__c=false;
|
prd1.Intra_Trade_List_RMB_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_Date2__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date2__c = Date.ValueOf('2023-12-01');
|
|
prd1.Intra_Trade_List_RMB_1__c = 2000;
|
prd1.Intra_Trade_List_RMB_2__c = 2060;
|
prd1.Important_product__c = true;
|
prd1.Important_Rroduct_1GI__c = true;
|
insert prd1;
|
|
|
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prd1.Id);
|
// Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prd2.Id);
|
// Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prd3.Id);
|
insert new Product2__c[] {pro1};
|
Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
|
insert new account[]{myAccount1};
|
|
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 = myAccount1.id;
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
|
Order1.Order_ProType__c = 'ET';
|
Order1.SummonsForDirction__c = '直接销售给医院';
|
insert Order1;
|
|
Consumable_order_details2__c saledet1 = new Consumable_order_details2__c();
|
saledet1.Name = 'OCM_01_001001';
|
// saledet1.Consumable_order_minor__c = Order1.Id;
|
saledet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
saledet1.Bar_Code__c = '0114953170032070111804001082K250BBBBB';
|
saledet1.Consumable_Product__c = pro1.Id;
|
saledet1.Used_account__c = section.Id;
|
saledet1.Delivery_List_RMB__c = 11;
|
saledet1.Box_Piece__c = '盒';
|
saledet1.TracingCode__c = 'BBBBB';
|
saledet1.SerialLotNo__c = '82K';
|
saledet1.Guarantee_period_for_products__c = Date.ValueOf('2023-12-01');
|
saledet1.Sterilization_limit__c = Date.ValueOf('2023-12-01');
|
saledet1.Send_Date__c = null;
|
//saledet1.Dealer_Shipment__c = false;
|
saledet1.Arrive_date__c = null;
|
//saledet1.Dealer_Arrive__c = false;
|
saledet1.Used_date__c = null;
|
//saledet1.Dealer_Saled__c = false;
|
saledet1.Deliver_date__c = Date.ValueOf('2023-12-01');
|
saledet1.Used_date__c =Date.ValueOf('2023-10-01');
|
saledet1.Return_date__c=null;
|
saledet1.Consumable_Sale_order__c = Order1.Id;
|
saledet1.Send_Date__c = Date.ValueOf('2023-11-01');
|
insert saledet1;
|
ConsumableTargetManage__c ctm=new ConsumableTargetManage__c();
|
ctm.OCM_Year__c = 'FY2024';
|
ctm.productType__c='ET耗材';
|
ctm.Hospital__c = saledet1.Hospital_ID__c;
|
ctm.Category3__c = prd1.Category3__c;
|
ctm.Category4__c = prd1.Category4__c;
|
ctm.ConsumableTargetManageKey__c= 'FY2024-'+saledet1.Hospital_ID__c+'-呼吸科ET-'+'活检套装';
|
insert ctm;
|
Daily_Report__c dr = new Daily_Report__c();
|
dr.Reported_Date__c = Date.ValueOf('2023-12-01');
|
dr.Reporter__c = UserInfo.getUserId();
|
dr.OwnerId = UserInfo.getUserId();
|
dr.Status__c='申請中';
|
insert dr;
|
Event__c ec = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.ValueOf('2023-12-01'));
|
// ec.Status__c='申請中';
|
ec.etapp_third_category__c=prd1.Category3__c;
|
ec.etapp_forth_category__c=prd1.Category4__c;
|
insert ec;
|
System.debug('医院ID:');
|
System.debug(saledet1.Hospital_ID__c);String recordIdC = Schema.SObjectType.TrackConsumableSalesForecast__c.getRecordTypeInfosByDeveloperName().get('ConsumableCategory3').getRecordTypeId();
|
|
TrackConsumableSalesForecast__c tcsf=new TrackConsumableSalesForecast__c();
|
|
tcsf.RecordTypeId = recordIdC;
|
tcsf.Consumable_Category1__c=ctm.productType__c;
|
tcsf.HospitalName__c=hospital.Name;
|
tcsf.Hospital__c=ctm.Hospital__c;
|
tcsf.Type__c='ET';
|
tcsf.Consumable_Category2__c=ctm.Category3__c;
|
tcsf.Consumable_Category3__c=ctm.Category4__c;
|
tcsf.SnapshotMonth__c=Date.ValueOf('2023-04-01');
|
insert tcsf;
|
Database.executeBatch(new ConsumableTargetManageBatch1(Date.ValueOf('2023-04-01'),Date.ValueOf('2024-03-31'),false),1);
|
}
|
static testMethod void testMethod2() {
|
|
Oly_TriggerHandler.bypass('DailyReportSetHospitalCount');
|
Oly_TriggerHandler.bypass(ConsumableTargetManageHandler.Class.getName());
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
|
Account hospital = new Account();
|
hospital.RecordTypeId = rectCo[0].Id;
|
hospital.Name = 'NFM007Testhospital';
|
hospital.ET_owner__c=UserInfo.getUserId();
|
insert hospital;
|
|
// 戦略科室を得る
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = hospital.Id;
|
section.Hospital_Department_Class__c = hospital.Id;
|
section.AgentCode_Ext__c = '9999900';
|
insert section;
|
|
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
// prd1.Category2__c = '本体';
|
prd1.Category3__c = '呼吸科ET';
|
prd1.Category4__c = '活检套装';
|
// prd1.Category5__c = '260SL系列';
|
prd1.Asset_Model_No__c = '1001';
|
prd1.Is_DangerousChemicals__c=false;
|
prd1.Family= 'ET';
|
prd1.Category2__c = '耗材';
|
prd1.Dealer_special_Object__c=false;
|
prd1.Intra_Trade_List_RMB_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_Date2__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date2__c = Date.ValueOf('2023-12-01');
|
|
prd1.Intra_Trade_List_RMB_1__c = 2000;
|
prd1.Intra_Trade_List_RMB_2__c = 2060;
|
prd1.Important_product__c = true;
|
prd1.Important_Rroduct_1GI__c = true;
|
insert prd1;
|
|
|
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prd1.Id);
|
// Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prd2.Id);
|
// Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prd3.Id);
|
pro1.Product2__c=prd1.Id;
|
insert new Product2__c[] {pro1};
|
Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
|
insert new account[]{myAccount1};
|
|
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 = myAccount1.id;
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
|
Order1.Order_ProType__c = 'ET';
|
Order1.SummonsForDirction__c = '直接销售给医院';
|
Order1.Order_ForHospital__c = hospital.Id;
|
insert Order1;
|
|
Consumable_order_details2__c saledet1 = new Consumable_order_details2__c();
|
saledet1.Name = 'OCM_01_001001';
|
// saledet1.Consumable_order_minor__c = Order1.Id;
|
saledet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
saledet1.Bar_Code__c = '0114953170032070111804001082K250BBBBB';
|
saledet1.Consumable_Product__c = pro1.Id;
|
saledet1.Used_account__c = section.Id;
|
saledet1.Delivery_List_RMB__c = 11;
|
saledet1.Box_Piece__c = '盒';
|
saledet1.TracingCode__c = 'BBBBB';
|
saledet1.SerialLotNo__c = '82K';
|
saledet1.Guarantee_period_for_products__c = Date.ValueOf('2023-12-01');
|
saledet1.Sterilization_limit__c = Date.ValueOf('2023-12-01');
|
saledet1.Send_Date__c = null;
|
//saledet1.Dealer_Shipment__c = false;
|
saledet1.Arrive_date__c = null;
|
//saledet1.Dealer_Arrive__c = false;
|
//saledet1.Dealer_Saled__c = false;
|
saledet1.Deliver_date__c = Date.ValueOf('2023-12-01');
|
saledet1.Used_date__c =Date.ValueOf('2023-10-01');
|
saledet1.Return_date__c=null;
|
saledet1.Consumable_Sale_order__c = Order1.Id;
|
saledet1.Send_Date__c = Date.ValueOf('2023-12-01');
|
saledet1.Lose_Flag__c=false;
|
|
insert saledet1;
|
|
Consumable_order_details2__c cod=[SELECT Lose_Flag__c,Dealer_Returned__c,Dealer_Saled__c,Product_OutDate__c,Inventory_Status__c,ShipmentAccount__c,Intra_Trade_KRMB__c,Hospital_ID__c
|
,Consumable_Category1__c,Consumable_product__c,Consumable_product__r.Product2__c,Consumable_product__r.Product2__r.ConsumCategory1F__c,Consumable_product__r.Product2__r.ConsumCategory2__c,Consumable_product__r.Product2__r.ConsumCategory3__c
|
from Consumable_order_details2__c limit 1];
|
ConsumableTargetManage__c ctm=new ConsumableTargetManage__c();
|
ctm.OCM_Year__c = 'FY2024';
|
ctm.productType__c='ET耗材';
|
ctm.Hospital__c = cod.Hospital_ID__c;
|
ctm.Category3__c = prd1.Category3__c;
|
ctm.Category4__c = prd1.Category4__c;
|
ctm.ConsumableTargetManageKey__c= 'FY2024-'+saledet1.Hospital_ID__c+'-呼吸科ET-'+'活检套装';
|
insert ctm;
|
Daily_Report__c dr = new Daily_Report__c();
|
dr.Reported_Date__c = Date.ValueOf('2023-12-01');
|
dr.Reporter__c = UserInfo.getUserId();
|
dr.OwnerId = UserInfo.getUserId();
|
dr.Status__c='申請中';
|
insert dr;
|
Event__c ec = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.ValueOf('2023-12-01'));
|
// ec.Status__c='申請中';
|
ec.etapp_third_category__c=prd1.Category3__c;
|
ec.etapp_forth_category__c=prd1.Category4__c;
|
insert ec;
|
System.debug('医院ID:');
|
System.debug(saledet1.Hospital_ID__c);String recordIdC = Schema.SObjectType.TrackConsumableSalesForecast__c.getRecordTypeInfosByDeveloperName().get('ConsumableCategory3').getRecordTypeId();
|
|
TrackConsumableSalesForecast__c tcsf=new TrackConsumableSalesForecast__c();
|
|
tcsf.RecordTypeId = recordIdC;
|
tcsf.Consumable_Category1__c=ctm.productType__c;
|
tcsf.HospitalName__c=hospital.Name;
|
tcsf.Hospital__c=ctm.Hospital__c;
|
tcsf.Type__c='ET';
|
tcsf.Consumable_Category2__c=ctm.Category3__c;
|
tcsf.Consumable_Category3__c=ctm.Category4__c;
|
tcsf.SnapshotMonth__c=Date.ValueOf('2023-05-01');
|
insert tcsf;
|
// System.debug('消耗品明细2===========================================================');
|
// System.debug(cod);
|
// System.debug(cod.Lose_Flag__c);
|
// System.debug(cod.Dealer_Returned__c);
|
// System.debug(cod.Dealer_Saled__c);
|
// System.debug(cod.Product_OutDate__c);
|
// System.debug(cod.Inventory_Status__c);
|
// System.debug(cod.ShipmentAccount__c);
|
// System.debug(cod.Intra_Trade_KRMB__c);
|
// System.debug(cod.Hospital_ID__c);
|
// System.debug(cod.Consumable_product__c);
|
// System.debug(cod.Consumable_product__r.Product2__c);
|
// System.debug(cod.Consumable_product__r.Product2__r.ConsumCategory1F__c);
|
// System.debug(prd1.ConsumCategory1F__c);
|
// System.debug(prd1.ConsumCategory2__c);
|
// System.debug(prd1.ConsumCategory3__c);
|
// System.debug(cod.Consumable_Category1__c+'-'+cod.Consumable_product__r.Product2__r.ConsumCategory2__c+'-'+cod.Consumable_product__r.Product2__r.ConsumCategory3__c+'-'+cod.Hospital_ID__c);
|
// ctm = [SELECT Hospital__c,Category3__c,Category4__c,OCM_Year__c from ConsumableTargetManage__c limit 1];
|
// System.debug(ctm.Hospital__c+'-'+ctm.Category3__c+'-'+ctm.Category4__c+'-'+ctm.OCM_Year__c);
|
Database.executeBatch(new ConsumableTargetManageBatch1(Date.ValueOf('2023-05-01'),Date.ValueOf('2024-03-31'),false),1);
|
Database.executeBatch(new ConsumableTargetManageBatch2(Date.ValueOf('2023-05-01'),Date.ValueOf('2024-03-31'),false),1);
|
}
|
static testMethod void testMethod3() {
|
Oly_TriggerHandler.bypass('DailyReportSetHospitalCount');
|
Oly_TriggerHandler.bypass(ConsumableTargetManageHandler.Class.getName());
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
|
Account hospital = new Account();
|
hospital.RecordTypeId = rectCo[0].Id;
|
hospital.Name = 'NFM007Testhospital';
|
hospital.ET_owner__c=UserInfo.getUserId();
|
insert hospital;
|
|
// 戦略科室を得る
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = hospital.Id;
|
section.Hospital_Department_Class__c = hospital.Id;
|
section.AgentCode_Ext__c = '9999900';
|
insert section;
|
|
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
// prd1.Category2__c = '本体';
|
prd1.Category3__c = '呼吸科ET';
|
prd1.Category4__c = '活检套装';
|
// prd1.Category5__c = '260SL系列';
|
prd1.Asset_Model_No__c = '1001';
|
prd1.Is_DangerousChemicals__c=false;
|
prd1.Family= 'ET';
|
prd1.Category2__c = '耗材';
|
prd1.Dealer_special_Object__c=false;
|
prd1.Intra_Trade_List_RMB_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_Date2__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date2__c = Date.ValueOf('2023-12-01');
|
|
prd1.Intra_Trade_List_RMB_1__c = 2000;
|
prd1.Intra_Trade_List_RMB_2__c = 2060;
|
prd1.Important_product__c = true;
|
prd1.Important_Rroduct_1GI__c = true;
|
insert prd1;
|
|
|
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prd1.Id);
|
// Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prd2.Id);
|
// Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prd3.Id);
|
pro1.Product2__c=prd1.Id;
|
insert new Product2__c[] {pro1};
|
Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
|
insert new account[]{myAccount1};
|
|
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 = myAccount1.id;
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
|
Order1.Order_ProType__c = 'ET';
|
Order1.SummonsForDirction__c = '直接销售给医院';
|
Order1.Order_ForHospital__c = hospital.Id;
|
insert Order1;
|
|
Consumable_order_details2__c saledet1 = new Consumable_order_details2__c();
|
saledet1.Name = 'OCM_01_001001';
|
// saledet1.Consumable_order_minor__c = Order1.Id;
|
saledet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
saledet1.Bar_Code__c = '0114953170032070111804001082K250BBBBB';
|
saledet1.Consumable_Product__c = pro1.Id;
|
saledet1.Used_account__c = section.Id;
|
saledet1.Delivery_List_RMB__c = 11;
|
saledet1.Box_Piece__c = '盒';
|
saledet1.TracingCode__c = 'BBBBB';
|
saledet1.SerialLotNo__c = '82K';
|
saledet1.Guarantee_period_for_products__c = Date.ValueOf('2023-12-01');
|
saledet1.Sterilization_limit__c = Date.ValueOf('2023-12-01');
|
saledet1.Send_Date__c = null;
|
//saledet1.Dealer_Shipment__c = false;
|
saledet1.Arrive_date__c = null;
|
//saledet1.Dealer_Arrive__c = false;
|
//saledet1.Dealer_Saled__c = false;
|
saledet1.Deliver_date__c = Date.ValueOf('2023-12-01');
|
saledet1.Used_date__c =Date.ValueOf('2023-10-01');
|
saledet1.Return_date__c=null;
|
saledet1.Consumable_Sale_order__c = Order1.Id;
|
saledet1.Send_Date__c = Date.ValueOf('2023-11-01');
|
saledet1.Lose_Flag__c=false;
|
|
insert saledet1;
|
|
Consumable_order_details2__c cod=[SELECT Lose_Flag__c,Dealer_Returned__c,Dealer_Saled__c,Product_OutDate__c,Inventory_Status__c,ShipmentAccount__c,Intra_Trade_KRMB__c,Hospital_ID__c
|
,Consumable_Category1__c,Consumable_product__c,Consumable_product__r.Product2__c,Consumable_product__r.Product2__r.ConsumCategory1F__c,Consumable_product__r.Product2__r.ConsumCategory2__c,Consumable_product__r.Product2__r.ConsumCategory3__c
|
from Consumable_order_details2__c limit 1];
|
ConsumableTargetManage__c ctm=new ConsumableTargetManage__c();
|
ctm.OCM_Year__c = 'FY2024';
|
ctm.productType__c='ET耗材';
|
ctm.Hospital__c = cod.Hospital_ID__c;
|
ctm.Category3__c = prd1.Category3__c;
|
ctm.Category4__c = prd1.Category4__c;
|
ctm.ConsumableTargetManageKey__c= saledet1.Hospital_ID__c+'-呼吸科ET-活检套装-FY2024';
|
insert ctm;
|
Daily_Report__c dr = new Daily_Report__c();
|
dr.Reported_Date__c = Date.ValueOf('2023-12-01');
|
dr.Reporter__c = UserInfo.getUserId();
|
dr.OwnerId = UserInfo.getUserId();
|
dr.Status__c='申請中';
|
insert dr;
|
Event__c ec = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.ValueOf('2023-12-01'));
|
// ec.Status__c='申請中';
|
ec.etapp_third_category__c=prd1.Category3__c;
|
ec.etapp_forth_category__c=prd1.Category4__c;
|
insert ec;
|
System.debug('医院ID:');
|
System.debug(saledet1.Hospital_ID__c);String recordIdC = Schema.SObjectType.TrackConsumableSalesForecast__c.getRecordTypeInfosByDeveloperName().get('ConsumableCategory3').getRecordTypeId();
|
|
TrackConsumableSalesForecast__c tcsf=new TrackConsumableSalesForecast__c();
|
|
tcsf.RecordTypeId = recordIdC;
|
tcsf.Consumable_Category1__c=ctm.productType__c;
|
tcsf.HospitalName__c=hospital.Name;
|
tcsf.Hospital__c=ctm.Hospital__c;
|
tcsf.Type__c='ET';
|
tcsf.Consumable_Category2__c=ctm.Category3__c;
|
tcsf.Consumable_Category3__c=ctm.Category4__c;
|
tcsf.SnapshotMonth__c=Date.ValueOf('2023-05-01');
|
insert tcsf;
|
// System.debug('消耗品明细2===========================================================');
|
// System.debug(cod);
|
// System.debug(cod.Lose_Flag__c);
|
// System.debug(cod.Dealer_Returned__c);
|
// System.debug(cod.Dealer_Saled__c);
|
// System.debug(cod.Product_OutDate__c);
|
// System.debug(cod.Inventory_Status__c);
|
// System.debug(cod.ShipmentAccount__c);
|
// System.debug(cod.Intra_Trade_KRMB__c);
|
// System.debug(cod.Hospital_ID__c);
|
// System.debug(cod.Consumable_product__c);
|
// System.debug(cod.Consumable_product__r.Product2__c);
|
// System.debug(cod.Consumable_product__r.Product2__r.ConsumCategory1F__c);
|
// System.debug(prd1.ConsumCategory1F__c);
|
// System.debug(prd1.ConsumCategory2__c);
|
// System.debug(prd1.ConsumCategory3__c);
|
// System.debug(cod.Consumable_Category1__c+'-'+cod.Consumable_product__r.Product2__r.ConsumCategory2__c+'-'+cod.Consumable_product__r.Product2__r.ConsumCategory3__c+'-'+cod.Hospital_ID__c);
|
// ctm = [SELECT Hospital__c,Category3__c,Category4__c,OCM_Year__c from ConsumableTargetManage__c limit 1];
|
// System.debug(ctm.Hospital__c+'-'+ctm.Category3__c+'-'+ctm.Category4__c+'-'+ctm.OCM_Year__c);
|
Database.executeBatch(new ConsumableTargetManageBatch2(Date.ValueOf('2023-05-01'),Date.ValueOf('2024-03-31'),false),1);
|
}
|
static testMethod void testMethod4() {
|
Oly_TriggerHandler.bypass('DailyReportSetHospitalCount');
|
Oly_TriggerHandler.bypass(ConsumableTargetManageHandler.Class.getName());
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
|
Account hospital = new Account();
|
hospital.RecordTypeId = rectCo[0].Id;
|
hospital.Name = 'NFM007Testhospital';
|
hospital.ET_owner__c=UserInfo.getUserId();
|
insert hospital;
|
|
// 戦略科室を得る
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = hospital.Id;
|
section.Hospital_Department_Class__c = hospital.Id;
|
section.AgentCode_Ext__c = '9999900';
|
insert section;
|
|
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
// prd1.Category2__c = '本体';
|
prd1.Category3__c = '呼吸科ET';
|
prd1.Category4__c = '活检套装';
|
// prd1.Category5__c = '260SL系列';
|
prd1.Asset_Model_No__c = '1001';
|
prd1.Is_DangerousChemicals__c=false;
|
prd1.Family= 'ET';
|
prd1.Category2__c = '耗材';
|
prd1.Dealer_special_Object__c=false;
|
prd1.Intra_Trade_List_RMB_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_Date2__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date2__c = Date.ValueOf('2023-12-01');
|
|
prd1.Intra_Trade_List_RMB_1__c = 2000;
|
prd1.Intra_Trade_List_RMB_2__c = 2060;
|
prd1.Important_product__c = true;
|
prd1.Important_Rroduct_1GI__c = true;
|
insert prd1;
|
|
|
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prd1.Id);
|
// Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prd2.Id);
|
// Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prd3.Id);
|
pro1.Product2__c=prd1.Id;
|
insert new Product2__c[] {pro1};
|
Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
|
insert new account[]{myAccount1};
|
|
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 = myAccount1.id;
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
|
Order1.Order_ProType__c = 'ET';
|
Order1.SummonsForDirction__c = '直接销售给医院';
|
Order1.Order_ForHospital__c = hospital.Id;
|
insert Order1;
|
|
Consumable_order_details2__c saledet1 = new Consumable_order_details2__c();
|
saledet1.Name = 'OCM_01_001001';
|
// saledet1.Consumable_order_minor__c = Order1.Id;
|
saledet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
saledet1.Bar_Code__c = '0114953170032070111804001082K250BBBBB';
|
saledet1.Consumable_Product__c = pro1.Id;
|
saledet1.Used_account__c = section.Id;
|
saledet1.Delivery_List_RMB__c = 11;
|
saledet1.Box_Piece__c = '盒';
|
saledet1.TracingCode__c = 'BBBBB';
|
saledet1.SerialLotNo__c = '82K';
|
saledet1.Guarantee_period_for_products__c = Date.ValueOf('2023-12-01');
|
saledet1.Sterilization_limit__c = Date.ValueOf('2023-12-01');
|
saledet1.Send_Date__c = null;
|
//saledet1.Dealer_Shipment__c = false;
|
saledet1.Arrive_date__c = null;
|
//saledet1.Dealer_Arrive__c = false;
|
//saledet1.Dealer_Saled__c = false;
|
saledet1.Deliver_date__c = Date.ValueOf('2023-12-01');
|
saledet1.Used_date__c =Date.ValueOf('2023-10-01');
|
saledet1.Return_date__c=null;
|
saledet1.Consumable_Sale_order__c = Order1.Id;
|
saledet1.Send_Date__c = Date.ValueOf('2023-10-01');
|
saledet1.Lose_Flag__c=false;
|
|
insert saledet1;
|
|
Consumable_order_details2__c cod=[SELECT Lose_Flag__c,Dealer_Returned__c,Dealer_Saled__c,Product_OutDate__c,Inventory_Status__c,ShipmentAccount__c,Intra_Trade_KRMB__c,Hospital_ID__c
|
,Consumable_Category1__c,Consumable_product__c,Consumable_product__r.Product2__c,Consumable_product__r.Product2__r.ConsumCategory1F__c,Consumable_product__r.Product2__r.ConsumCategory2__c,Consumable_product__r.Product2__r.ConsumCategory3__c
|
from Consumable_order_details2__c limit 1];
|
ConsumableTargetManage__c ctm=new ConsumableTargetManage__c();
|
ctm.OCM_Year__c = 'FY2024';
|
ctm.productType__c='ET耗材';
|
ctm.Hospital__c = cod.Hospital_ID__c;
|
ctm.Category3__c = prd1.Category3__c;
|
ctm.Category4__c = prd1.Category4__c;
|
ctm.ConsumableTargetManageKey__c= saledet1.Hospital_ID__c+'-呼吸科ET-活检套装-FY2024';
|
insert ctm;
|
Daily_Report__c dr = new Daily_Report__c();
|
dr.Reported_Date__c = Date.ValueOf('2023-12-01');
|
dr.Reporter__c = UserInfo.getUserId();
|
dr.OwnerId = UserInfo.getUserId();
|
dr.Status__c='申請中';
|
insert dr;
|
Event__c ec = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.ValueOf('2023-12-01'));
|
// ec.Status__c='申請中';
|
ec.etapp_third_category__c=prd1.Category3__c;
|
ec.etapp_forth_category__c=prd1.Category4__c;
|
insert ec;
|
System.debug('医院ID:');
|
System.debug(saledet1.Hospital_ID__c);String recordIdC = Schema.SObjectType.TrackConsumableSalesForecast__c.getRecordTypeInfosByDeveloperName().get('ConsumableCategory3').getRecordTypeId();
|
|
TrackConsumableSalesForecast__c tcsf=new TrackConsumableSalesForecast__c();
|
|
tcsf.RecordTypeId = recordIdC;
|
tcsf.Consumable_Category1__c=ctm.productType__c;
|
tcsf.HospitalName__c=hospital.Name;
|
tcsf.Hospital__c=ctm.Hospital__c;
|
tcsf.Type__c='ET';
|
tcsf.Consumable_Category2__c=ctm.Category3__c;
|
tcsf.Consumable_Category3__c=ctm.Category4__c;
|
tcsf.SnapshotMonth__c=Date.ValueOf('2023-05-01');
|
insert tcsf;
|
// System.debug('消耗品明细2===========================================================');
|
// System.debug(cod);
|
// System.debug(cod.Lose_Flag__c);
|
// System.debug(cod.Dealer_Returned__c);
|
// System.debug(cod.Dealer_Saled__c);
|
// System.debug(cod.Product_OutDate__c);
|
// System.debug(cod.Inventory_Status__c);
|
// System.debug(cod.ShipmentAccount__c);
|
// System.debug(cod.Intra_Trade_KRMB__c);
|
// System.debug(cod.Hospital_ID__c);
|
// System.debug(cod.Consumable_product__c);
|
// System.debug(cod.Consumable_product__r.Product2__c);
|
// System.debug(cod.Consumable_product__r.Product2__r.ConsumCategory1F__c);
|
// System.debug(prd1.ConsumCategory1F__c);
|
// System.debug(prd1.ConsumCategory2__c);
|
// System.debug(prd1.ConsumCategory3__c);
|
// System.debug(cod.Consumable_Category1__c+'-'+cod.Consumable_product__r.Product2__r.ConsumCategory2__c+'-'+cod.Consumable_product__r.Product2__r.ConsumCategory3__c+'-'+cod.Hospital_ID__c);
|
// ctm = [SELECT Hospital__c,Category3__c,Category4__c,OCM_Year__c from ConsumableTargetManage__c limit 1];
|
// System.debug(ctm.Hospital__c+'-'+ctm.Category3__c+'-'+ctm.Category4__c+'-'+ctm.OCM_Year__c);
|
Database.executeBatch(new ConsumableTargetManageBatch2(Date.ValueOf('2023-05-01'),Date.ValueOf('2024-03-31'),false),1);
|
}
|
static testMethod void testMethod5() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
|
Account hospital = new Account();
|
hospital.RecordTypeId = rectCo[0].Id;
|
hospital.Name = 'NFM007Testhospital';
|
hospital.ET_owner__c=UserInfo.getUserId();
|
insert hospital;
|
|
// 戦略科室を得る
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = hospital.Id;
|
section.Hospital_Department_Class__c = hospital.Id;
|
section.AgentCode_Ext__c = '9999900';
|
insert section;
|
|
Account depart2 = new Account();
|
depart2.RecordTypeId = rectDpt[0].Id;
|
depart2.Name = '*';
|
depart2.Department_Name__c = 'TestDepart2';
|
depart2.ParentId = section.Id;
|
depart2.Department_Class__c = section.Id;
|
depart2.Hospital__c = hospital.Id;
|
insert depart2;
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
// prd1.Category2__c = '本体';
|
prd1.Category3__c = '呼吸科ET';
|
prd1.Category4__c = '活检套装';
|
// prd1.Category5__c = '260SL系列';
|
prd1.Asset_Model_No__c = '1001';
|
prd1.Is_DangerousChemicals__c=false;
|
prd1.Family= 'ET';
|
prd1.Category2__c = '耗材';
|
prd1.Dealer_special_Object__c=false;
|
prd1.Intra_Trade_List_RMB_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_Date2__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date2__c = Date.ValueOf('2023-12-01');
|
|
prd1.Intra_Trade_List_RMB_1__c = 2000;
|
prd1.Intra_Trade_List_RMB_2__c = 2060;
|
prd1.Important_product__c = true;
|
prd1.Important_Rroduct_1GI__c = true;
|
insert prd1;
|
|
|
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prd1.Id);
|
// Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prd2.Id);
|
// Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prd3.Id);
|
pro1.Product2__c=prd1.Id;
|
insert new Product2__c[] {pro1};
|
|
Daily_Report__c dr = new Daily_Report__c();
|
dr.Reported_Date__c = Date.ValueOf('2023-12-01');
|
dr.Reporter__c = UserInfo.getUserId();
|
dr.OwnerId = UserInfo.getUserId();
|
dr.Status__c='申請中';
|
insert dr;
|
// Account hospital1 = new Account();
|
// hospital1.RecordTypeId = rectSct[0].Id;
|
// hospital1.Name = 'NFM007Testhospital1';
|
// hospital1.ET_owner__c=UserInfo.getUserId();
|
// hospital1.Parent = hospital;
|
// hospital1.ParentId=hospital.id;
|
// insert hospital1;
|
// Account hospital2 = new Account();
|
// hospital2.RecordTypeId = rectDpt[0].Id;
|
// hospital2.Name = 'NFM007Testhospital2';
|
// hospital2.ET_owner__c=UserInfo.getUserId();
|
// hospital2.Parent = hospital;
|
// hospital2.ParentId=hospital1.id;
|
|
// insert hospital2;
|
Event__c ec = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.ValueOf('2023-12-01'));
|
// ec.Status__c='申請中';
|
ec.Account_ID__c = depart2.id;
|
ec.Purpose_Type__c='不使用';
|
ec.etapp_third_category__c=prd1.Category3__c;
|
ec.etapp_forth_category__c=prd1.Category4__c;
|
|
ec.etapp_third_category2__c='基干';
|
ec.etapp_forth_category2__c='清洗刷';
|
insert ec;
|
ConsumableTargetManage__c ctm=new ConsumableTargetManage__c();
|
ctm.OCM_Year__c = 'FY2024';
|
ctm.productType__c='ET耗材';
|
ctm.Hospital__c = hospital.id;
|
ctm.Category3__c = prd1.Category3__c;
|
ctm.Category4__c = prd1.Category4__c;
|
ctm.ConsumableTargetManageKey__c= hospital.id+'-呼吸科ET-活检套装-FY2024';
|
insert ctm;
|
// System.debug('消耗品明细2===========================================================');
|
// System.debug(cod);
|
// System.debug(cod.Lose_Flag__c);
|
// System.debug(cod.Dealer_Returned__c);
|
// System.debug(cod.Dealer_Saled__c);
|
// System.debug(cod.Product_OutDate__c);
|
// System.debug(cod.Inventory_Status__c);
|
// System.debug(cod.ShipmentAccount__c);
|
// System.debug(cod.Intra_Trade_KRMB__c);
|
// System.debug(cod.Hospital_ID__c);
|
// System.debug(cod.Consumable_product__c);
|
// System.debug(cod.Consumable_product__r.Product2__c);
|
// System.debug(cod.Consumable_product__r.Product2__r.ConsumCategory1F__c);
|
// System.debug(prd1.ConsumCategory1F__c);
|
// System.debug(prd1.ConsumCategory2__c);
|
// System.debug(prd1.ConsumCategory3__c);
|
// System.debug(cod.Consumable_Category1__c+'-'+cod.Consumable_product__r.Product2__r.ConsumCategory2__c+'-'+cod.Consumable_product__r.Product2__r.ConsumCategory3__c+'-'+cod.Hospital_ID__c);
|
// ctm = [SELECT Hospital__c,Category3__c,Category4__c,OCM_Year__c from ConsumableTargetManage__c limit 1];
|
// System.debug(ctm.Hospital__c+'-'+ctm.Category3__c+'-'+ctm.Category4__c+'-'+ctm.OCM_Year__c);
|
Database.executeBatch(new ConsumableTargetManageBatch3(Date.ValueOf('2023-05-01'),Date.ValueOf('2024-03-31'),false),1);
|
Database.executeBatch(new ConsumableTargetManageBatch2(Date.ValueOf('2023-05-01'),Date.ValueOf('2024-03-31'),false,true),1);
|
}
|
static testMethod void testMethod7() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科'];
|
if (rectSct.size() == 0) {
|
return;
|
}
|
List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
|
if (rectDpt.size() == 0) {
|
return;
|
}
|
Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
|
|
Account hospital = new Account();
|
hospital.RecordTypeId = rectCo[0].Id;
|
hospital.Name = 'NFM007Testhospital';
|
hospital.ET_owner__c=UserInfo.getUserId();
|
insert hospital;
|
|
// 戦略科室を得る
|
List<Account> strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI'];
|
Account section = new Account();
|
section.RecordTypeId = rectSct[0].Id;
|
section.Name = '*';
|
section.Department_Class_Label__c = '消化科';
|
section.ParentId = hospital.Id;
|
section.Hospital_Department_Class__c = hospital.Id;
|
section.AgentCode_Ext__c = '9999900';
|
insert section;
|
|
|
|
Product2 prd1 = new Product2();
|
prd1.ProductCode_Ext__c = 'Prd1';
|
prd1.ProductCode = 'Prd1';
|
prd1.Repair_Product_Code__c = 'Prd1_RP';
|
prd1.Name = 'Prd1';
|
prd1.Manual_Entry__c = false;
|
// prd1.Category2__c = '本体';
|
prd1.Category3__c = '呼吸科ET';
|
prd1.Category4__c = '活检套装';
|
// prd1.Category5__c = '260SL系列';
|
prd1.Asset_Model_No__c = '1001';
|
prd1.Is_DangerousChemicals__c=false;
|
prd1.Family= 'ET';
|
prd1.Category2__c = '耗材';
|
prd1.Dealer_special_Object__c=false;
|
prd1.Intra_Trade_List_RMB_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_Date2__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date1__c = Date.ValueOf('2023-12-01');
|
prd1.Intra_Trade_List_RMB_End_Date2__c = Date.ValueOf('2023-12-01');
|
|
prd1.Intra_Trade_List_RMB_1__c = 2000;
|
prd1.Intra_Trade_List_RMB_2__c = 2060;
|
prd1.Important_product__c = true;
|
prd1.Important_Rroduct_1GI__c = true;
|
insert prd1;
|
|
|
|
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prd1.Id);
|
// Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prd2.Id);
|
// Product2__c pro3 = new Product2__c(Name='Pro003',OT_CODE_Text__c='Test003',Product2__c = prd3.Id);
|
pro1.Product2__c=prd1.Id;
|
insert new Product2__c[] {pro1};
|
Account myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =30,RecordTypeId = rectCo[0].Id);
|
insert new account[]{myAccount1};
|
|
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 = myAccount1.id;
|
Order1.RecordTypeid = System.Label.RT_ConOrder_Delivery;
|
Order1.Order_ProType__c = 'ET';
|
Order1.SummonsForDirction__c = '直接销售给医院';
|
Order1.Order_ForHospital__c = hospital.Id;
|
insert Order1;
|
|
Consumable_order_details2__c saledet1 = new Consumable_order_details2__c();
|
saledet1.Name = 'OCM_01_001001';
|
// saledet1.Consumable_order_minor__c = Order1.Id;
|
saledet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
saledet1.Bar_Code__c = '0114953170032070111804001082K250BBBBB';
|
saledet1.Consumable_Product__c = pro1.Id;
|
saledet1.Used_account__c = section.Id;
|
saledet1.Delivery_List_RMB__c = 11;
|
saledet1.Box_Piece__c = '盒';
|
saledet1.TracingCode__c = 'BBBBB';
|
saledet1.SerialLotNo__c = '82K';
|
saledet1.Guarantee_period_for_products__c = Date.ValueOf('2023-12-01');
|
saledet1.Sterilization_limit__c = Date.ValueOf('2023-12-01');
|
saledet1.Send_Date__c = null;
|
//saledet1.Dealer_Shipment__c = false;
|
saledet1.Arrive_date__c = null;
|
//saledet1.Dealer_Arrive__c = false;
|
//saledet1.Dealer_Saled__c = false;
|
saledet1.Deliver_date__c = Date.ValueOf('2023-12-01');
|
saledet1.Used_date__c =Date.ValueOf('2022-10-01');
|
saledet1.Return_date__c=null;
|
saledet1.Consumable_Sale_order__c = Order1.Id;
|
saledet1.Send_Date__c = Date.ValueOf('2022-10-01');
|
saledet1.Lose_Flag__c=false;
|
|
insert saledet1;
|
|
|
Database.executeBatch(new ASPPriceYearBatch2(Date.ValueOf('2023-01-01')),1);
|
}
|
|
|
}
|