@isTest public class DBMCHPNLPPDFControllerTest { static testMethod void testDecide_02() { User u3 = new User(); u3.LastName = '_サンブリッジ'; u3.FirstName = 'う'; u3.Alias = 'う'; u3.Email = 'olympusTest03@sunbridge.com'; u3.Username = 'olympusTest03@sunbridge.com'; u3.CommunityNickname = 'う'; u3.IsActive = true; u3.EmailEncodingKey = 'ISO-2022-JP'; u3.TimeZoneSidKey = 'Asia/Tokyo'; u3.LocaleSidKey = 'ja_JP'; u3.LanguageLocaleKey = 'ja'; u3.ProfileId = System.Label.ProfileId_SystemAdmin; // u3.Job_Category__c = '销售推广'; u3.Job_Category__c = '销售服务'; u3.Province__c = '北京市'; u3.Use_Start_Date__c = Date.today().addMonths(-6); insert u3; system.runAs(u3) { ControllerUtil.EscapeNFM001Trigger = true; // 客户 Account hospital = new Account(); // 记录类型ID // 01210000000QemGAAS hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; // 客户名 hospital.Name = 'test hospita/l'; insert hospital; // 戦略科室を得る List strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_GI']; // 客户 Account dep = new Account(); // 01210000000Qfm7AAC // 记录类型ID dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_GI'].id; // 客户名 dep.Name = 'test de/p'; dep.ParentId = strategicDep[0].Id; // 战略科室分类 dep.Department_Class__c = strategicDep[0].Id; // 医院 dep.Hospital__c = hospital.Id; insert dep; // 产品 Product2 productA = new Product2( // 产品名称 Name='テスト商品', // 维修合同报价 Maintenance_Price_Year__c = 12000, // 手动登录区分 Manual_Entry__c = false ); insert productA; // 维修合同 Maintenance_Contract__c contract = new Maintenance_Contract__c(); // 合同名 contract.Name = 'tect contract'; // 医院 contract.Hospital__c = hospital.Id; // 科室分类 contract.Department_Class__c = strategicDep[0].Id; // 科室 contract.Department__c = dep.Id; // 主担当者(查找用户) contract.Service_Contract_Staff__c = u3.Id; // 第一次计划付款金额 contract.Payment_Plan_Sum_First__c = 1; insert contract; // 维修合同报价 Maintenance_Contract_Estimate__c contactEsti1 = new Maintenance_Contract_Estimate__c( // 报价编码 Name = 'contract estimate 1', // 合同开始预定日 Contract_Esti_Start_Date__c = Date.today(), // 合同月数 Contract_Range__c = 2, // 合同(维修合同) Maintenance_Contract__c = contract.Id ); // 维修合同报价 Maintenance_Contract_Estimate__c contactEsti2 = new Maintenance_Contract_Estimate__c( Name = 'contract estimate 2', Contract_Esti_Start_Date__c = Date.today().addMonths(6), Contract_Range__c = 3, Maintenance_Contract__c = contract.Id ); insert new Maintenance_Contract_Estimate__c[] {contactEsti1, contactEsti2}; // 打包合同 MaintanceContractPack__c MP = new MaintanceContractPack__c( Name = 'testmp', Contract_Type__c = '上限合同', SalesOfficeCode_selection__c='北京RC' ); insert MP; // 维修合同 Maintenance_Contract__c testMC = new Maintenance_Contract__c(); // 绑定维修合同和打包合同的关系 testMC.MaintanceContractPack__c=MP.id; testMC.Name = 'test1'; testMC.Service_Contract_Staff__c = u3.id ; testMC.Payment_Plan_Sum_First__c = 5020.00; testMc.Payment_Plan_Date_First__c = Date.Today(); testMC.Small_Repair_Time__c = '7'; testMC.Big_Repair_Time__c = '15'; testMC.Live_Technical_Support_Time__c = '24'; testMC.Engineer_Name__c = 'test'; testMC.Phone_Number__c ='1234'; testMC.Tour_Check__c = '0'; testMC.Inspection_Time__c = '0'; testMC.Dedust__c = '0'; testMC.Department__c = dep.Id; testMC.Negotiate_Mean__c = '1'; testMC.Estimation_Id__c = contactEsti1.id; testMC.First_Party_Contract_Number__c = '1'; testMC.Second_Party_Contract_Number__c = '2'; testMC.Term_Of_Payment__c = '多次付款'; testMC.one_off_payment_agreed_period__c = '15'; testMC.Contract_Amount__c = 15.00; testMC.Total_Contract_Amount_In_Words__c = '十五元整'; // testMC.Total_Contract_Amount_In_Words__c = '6'; testMC.Payment_Plan_Sum_First_in_Word__c = '十五元整'; testMC.SalesOfficeCode_selection__c = '沈阳RC'; testMC.Management_Code__c = '1234'; testMC.Total_Payment_Time__c = '3'; testMC.Contract_Start_Date__c = Date.today().addMonths(6); testMC.Contract_End_Date__c = Date.today().addMonths(7); upsert testMC; MP.Total_Payment_Time__c='5'; MP.Payment_Plan_Sum_First_in_Word__c='十万八千六百元'; MP.Payment_Plan_Sum_Second_in_Word__c='二十万八千六百元'; MP.Payment_Plan_Sum_Third_in_Word__c='三十万八千六百元'; MP.Payment_Plan_Sum_Forth_in_Word__c='四十万八千六百元'; MP.Payment_Plan_Sum_Fifth_in_Word__c='五十万八千六百元'; MP.Payment_Plan_Sum_Sixth_in_Word__c='六十万八千六百元'; MP.Total_FieldRequest_quotation_In_Words__c='八百八十八万三千六百四十元'; MP.Payment_Plan_Sum_First__c=123123.12; MP.Payment_Plan_Sum_Second__c=12312.34; MP.Payment_Plan_Sum_Third__c=11234.23; MP.Payment_Plan_Sum_Forth__c=123412.21; MP.Payment_Plan_Sum_Fifth__c=12312312; MP.Payment_Plan_Sum_Sixth__c=123123.12; MP.Contract_Amount__c=12312.12; upsert MP; PageReference page = new PageReference('/apex/NewDBMCHPNLPPDF?id=' + MP.Id); System.Test.setCurrentPage(page); NewDBMCHPNLPPDFController testController = new NewDBMCHPNLPPDFController(); testController.init(); } } }