@isTest public with sharing class CurrentFYMoneyTmsBatchTest { @TestSetup private static void init() { // 戦略科室を得る Address_Level__c address = new Address_Level__c(Level1_Code__c = 'CN-01',Name='北京市'); insert address; // 病院を作る Account hospital = new Account(); hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Agency'].id; hospital.Name = 'test hospital'; hospital.Is_Active__c = '有效'; hospital.TradeComplianceStatus__c = '警示名单'; hospital.State_Master__c = address.Id; hospital.Aim_Price__c = 41421421; hospital.Agent_Ref__c = '001C8000002Se9aIAC'; hospital.ParentId = '001C8000002Se9aIAC'; hospital.ET_SP_Dealer__c = true; insert hospital; Oly_TriggerHandler.bypass('ConsumableAssetHander'); Oly_TriggerHandler.bypass('Oly_TriggerHandler'); Oly_TriggerHandler.bypass('ConsumableAssetUp'); Consumable_order_details2__c saledet1 = new Consumable_order_details2__c(); saledet1.Name = 'OCM_01_001001'; saledet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery; saledet1.Bar_Code__c = '0114953170032070111804001082K250BBBBB'; saledet1.Used_account__c = hospital.Id; saledet1.Delivery_List_RMB__c = 11; saledet1.Box_Piece__c = '盒'; saledet1.TracingCode__c = 'BBBBB'; saledet1.SerialLotNo__c = '82K'; saledet1.Intra_Trade_List_RMB__c = 32142; saledet1.Guarantee_period_for_products__c = Date.today().addDays(5); saledet1.Sterilization_limit__c = Date.today().addDays(5); saledet1.Send_Date__c = null; saledet1.Arrive_date__c = Date.today().addDays(5); saledet1.Used_date__c = null; saledet1.Used_Account_Type__c = '契約'; saledet1.Deliver_date__c = Date.today().addDays(10); insert saledet1; Consumable_order_details2__c saledet3 = new Consumable_order_details2__c(); saledet3.Name = 'OCM_01_0010012'; saledet3.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery; saledet3.Bar_Code__c = '0114953170032070111804001082K250BBBBA'; saledet3.Used_account__c = hospital.Id; saledet3.Delivery_List_RMB__c = 11; saledet3.Box_Piece__c = '盒'; saledet3.TracingCode__c = 'BBBBB'; saledet3.SerialLotNo__c = '82K'; saledet3.Intra_Trade_List_RMB__c = 321342; saledet3.Guarantee_period_for_products__c = Date.today().addDays(5); saledet3.Sterilization_limit__c = Date.today().addDays(5); saledet3.Send_Date__c = null; saledet3.Arrive_date__c = Date.today().addDays(5); saledet3.Used_date__c = null; saledet3.Used_Account_Type__c = '販売店'; saledet3.Deliver_date__c = Date.today().addMonths(3); insert saledet3; Consumable_order_details2__c saledet4 = new Consumable_order_details2__c(); saledet4.Name = 'OCM_01_0010012'; saledet4.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery; saledet4.Bar_Code__c = '0114953170032070111804001082K250BBBBA'; saledet4.Used_account__c = hospital.Id; saledet4.Delivery_List_RMB__c = 11; saledet4.Box_Piece__c = '盒'; saledet4.TracingCode__c = 'BBBBB'; saledet4.SerialLotNo__c = '82K'; saledet4.Intra_Trade_List_RMB__c = 321342; saledet4.Guarantee_period_for_products__c = Date.today().addDays(5); saledet4.Sterilization_limit__c = Date.today().addDays(5); saledet4.Send_Date__c = null; saledet4.Arrive_date__c = Date.today().addDays(5); saledet4.Used_date__c = null; saledet4.Used_Account_Type__c = '販売店'; saledet4.Deliver_date__c = Date.today().addMonths(4); insert saledet4; Consumable_order_details2__c saledet5 = new Consumable_order_details2__c(); saledet5.Name = 'OCM_01_0010012'; saledet5.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery; saledet5.Bar_Code__c = '0114953170032070111804001082K250BBBBA'; saledet5.Used_account__c = hospital.Id; saledet5.Delivery_List_RMB__c = 11; saledet5.Box_Piece__c = '盒'; saledet5.TracingCode__c = 'BBBBB'; saledet5.SerialLotNo__c = '82K'; saledet5.Intra_Trade_List_RMB__c = 321342; saledet5.Guarantee_period_for_products__c = Date.today().addDays(5); saledet5.Sterilization_limit__c = Date.today().addDays(5); saledet5.Send_Date__c = null; saledet5.Arrive_date__c = Date.today().addDays(5); saledet5.Used_date__c = null; saledet5.Used_Account_Type__c = '販売店'; saledet5.Deliver_date__c = Date.today().addMonths(5); insert saledet5; Consumable_order_details2__c saledet6 = new Consumable_order_details2__c(); saledet6.Name = 'OCM_01_0010012'; saledet6.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery; saledet6.Bar_Code__c = '0114953170032070111804001082K250BBBBA'; saledet6.Used_account__c = hospital.Id; saledet6.Delivery_List_RMB__c = 11; saledet6.Box_Piece__c = '盒'; saledet6.TracingCode__c = 'BBBBB'; saledet6.SerialLotNo__c = '82K'; saledet6.Intra_Trade_List_RMB__c = 321342; saledet6.Guarantee_period_for_products__c = Date.today().addDays(5); saledet6.Sterilization_limit__c = Date.today().addDays(5); saledet6.Send_Date__c = null; saledet6.Arrive_date__c = Date.today().addDays(5); saledet6.Used_date__c = null; saledet6.Used_Account_Type__c = '販売店'; saledet6.Deliver_date__c = Date.today().addMonths(6); insert saledet6; } static testMethod void testInitOTwo(){ Account acc = [select id,name ,OCM_man_province_HP__c from Account limit 1]; Dealer_ConsumableManage__c dc = new Dealer_ConsumableManage__c(); dc.Dealer_Name__c = acc.id; dc.TMS_Key__c = acc.id+'-'+'ET'+'-'+'FY2024'+'-'+acc.OCM_man_province_HP__c; dc.ET_ENG__c = 'ET'; dc.FY__c = 'FY2024'; upsert dc; Database.executeBatch(new CurrentFYMoneyTmsBatch(),200); } }