package com.tenwa.leasing.serviceImpl.voucher; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import com.tenwa.comm.util.jboutil.DataOperatorUtil; //import jbo.app.CREATE_VOUCHER_STATUS; //import jbo.app.VOUCHER_HELP; import jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT; //import jbo.com.tenwa.entity.contract.CONTRACT_CHANGE_INFO_TEMP; //import jbo.com.tenwa.entity.contract.CONTRACT_INFO; //import jbo.com.tenwa.entity.contract.CONTRACT_SIGNATORY; //import jbo.com.tenwa.entity.contract.CONTRACT_SUPPLIER_INFO; //import jbo.com.tenwa.fund.entity.charge.CONTRACT_FUND_FUND_CHARGE; //import jbo.com.tenwa.rent.entity.rent.C1_FUND_RENT_PLAN; //import jbo.lc.CONTRACT_CONDITION; import jbo.sys.USER_INFO; import com.amarsoft.app.als.sys.tools.DateTool; import com.amarsoft.app.als.sys.tools.DateUtil; import com.amarsoft.app.als.sys.tools.JBOHelper; import com.amarsoft.app.util.StringUtil; import com.amarsoft.are.A3Exception; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.BizObjectQuery; import com.amarsoft.are.jbo.JBOException; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.are.util.conf.Configuration; import com.amarsoft.awe.Configure; import com.amarsoft.awe.control.model.AWEConfigure; import com.tenwa.leasing.service.voucher.CreateVoucherService; import com.tenwa.leasing.service.voucher.VoucherToV8Service; import com.tenwa.reckon.util.Conn; import com.tenwa.reckon.util.Tools; import com.tenwa.util.VoucherUtil; public class CreateVoucherServiceImpl implements CreateVoucherService { private VoucherToV8Service voucherToV8Service=new VoucherToV8Impl(); public String control_; public CreateVoucherServiceImpl() throws Exception{ Configure con = Configure.getInstance(); this.control_ = con.getParameter("VoucherSwitch"); //AWEConfigure c = new AWEConfigure("/WEB-INF/etc/a3web.xml"); //this.control_ = c.getParameter("VoucherSwitch"); //BizObject bo = JBOHelper.querySingle(VOUCHER_HELP.CLASS_NAME, "select o.IS_CREATE_VOUCHER from o where o.id = 'control_voucher_create'"); //if(bo!=null){ //this.control_ = bo.getAttribute("IS_CREATE_VOUCHER").toString(); //} } //收款 BOOKMARK @SuppressWarnings("unchecked") public void createVoucher_collection(String flow_unid,BizObject CurUser,JBOTransaction tx) throws Exception { //凭证生成开关 if("true".equals(control_)){ Map condtion=new HashMap(); condtion.put("flow_unid", flow_unid); BizObject flow= DataOperatorUtil.getSingleJBO(FLOW_BUSSINESS_OBJECT.CLASS_NAME, condtion, tx); String contract_id=flow.getAttribute("contract_id").toString(); Map headMap = new HashMap(); headMap.put("contract_id",contract_id); headMap.put("moduleName", "收款"); //根据contract_id查询contract_info表的contract_number,前面的查询条件的contract_id是contract_info表的主键id // BizObjectManager bm2 = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO"); // BizObjectQuery bq2 = bm2.createQuery("select * from O where id=:Contract_id"); // bq2.setParameter("Contract_id", contract_id); // BizObject bos2 = bq2.getSingleResult(false); //String contract_number = bos2.getAttribute("contract_number").toString();//业务合同号 //根据contract_id查询contract_info表的leas_form,前面的查询条件的contract_id是contract_info表的主键id BizObjectManager bm3 = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO"); BizObjectQuery bq3 = bm3.createQuery("select * from O where id=:Contract_id"); bq3.setParameter("Contract_id", contract_id); BizObject bos3 = bq3.getSingleResult(false); String leas_form = bos3.getAttribute("leas_form").toString();//租赁形式 //根据flow_unid和contract_id获取contract_fund_fund_charge_temp表的accounting_date(会计处理日)、fact_money(收支金额) BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.com.tenwa.fund.entity.charge.CONTRACT_FUND_FUND_CHARGE_TEMP"); BizObjectQuery bq = bm.createQuery("select * from O where flow_unid=:Flow_unid and contract_id=:Contract_id"); bq.setParameter("Flow_unid", flow_unid); bq.setParameter("Contract_id", contract_id); List bos = bq.getResultList(false); String fact_object = null;//收支对象 String accounting_date = null;//会计处理日 String fact_date = null;//收支日期 String fact_date_handling = null;//手续费收支日期 String accounting_date_handling = null;//手续费会计处理日 String fact_date_caution = null;//保证金收支日期 String accounting_date_caution = null;//保证金会计处理日 String fact_date_service = null;//咨询服务费收支日期 String accounting_date_service = null;//咨询服务费会计处理日 BigDecimal taxrate = BigDecimal.ZERO; BigDecimal totalMoney= BigDecimal.ZERO;//总金额 List> list = new ArrayList>(); boolean is_handling_charge_money = false; boolean is_first_payment = false; boolean is_return_amt = false; boolean is_norminal_price = false; boolean is_caution_money = false; boolean is_service_money = false; BigDecimal handling_charge_money = BigDecimal.ZERO;//手续费 // BigDecimal first_payment = BigDecimal.ZERO;//首付款 // BigDecimal return_amt = BigDecimal.ZERO;//厂商返利 // BigDecimal norminal_price = BigDecimal.ZERO;//留购价款 BigDecimal caution_money = BigDecimal.ZERO;//保证金 BigDecimal service_money = BigDecimal.ZERO;//咨询服务费 BigDecimal handling_charge_money_tax = BigDecimal.ZERO;//手续费税金 // BigDecimal first_payment_tax = BigDecimal.ZERO;//首付款税金 // BigDecimal return_amt_tax = BigDecimal.ZERO;//厂商返利税金 // BigDecimal norminal_price_tax = BigDecimal.ZERO;//留购价款税金 if(bos == null || bos.size() == 0){ return; }else{ for(int i=0;i condtion=new HashMap(); condtion.put("flow_unid", flow_unid); BizObject flow=DataOperatorUtil.getSingleJBO(FLOW_BUSSINESS_OBJECT.CLASS_NAME, condtion, tx); String contract_id=flow.getAttribute("contract_id").toString(); Map headMap = new HashMap(); headMap.put("contract_id",contract_id); headMap.put("moduleName", "租金回笼"); //根据contract_id查询contract_info表的contract_number,前面的查询条件的contract_id是contract_info表的主键id // BizObjectManager bm2 = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO"); // BizObjectQuery bq2 = bm2.createQuery("select * from O where id=:Contract_id"); // bq2.setParameter("Contract_id", contract_id); // BizObject bos2 = bq2.getSingleResult(false); // String contract_number = bos2.getAttribute("contract_number").toString();//合同号、业务合同号 //根据flow_unid和contract_id查询contract_fund_rent_plan_temp表获取总期数 // BizObjectManager bm3 = JBOFactory.getBizObjectManager("jbo.com.tenwa.rent.entity.rent.CONTRACT_FUND_RENT_PLAN_TEMP"); // BizObjectQuery bq3 = bm3.createQuery("select * from O where flow_unid=:Flow_unid and contract_id=:Contract_id"); // bq3.setParameter("Flow_unid", flow_unid); // bq3.setParameter("Contract_id", contract_id); // List bos3 = bq3.getResultList(false); // int totalList = bos3.size();//总期数 //根据flow_unid和contract_id获取contract_fund_rent_income_temp表的accounting_date(会计处理日)、rent(回笼租金) BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.com.tenwa.rent.entity.rent.CONTRACT_FUND_RENT_INCOME_TEMP"); //因联合两张表查询,所以将要查询的字段详细列出(多表查询只能这么查询) BizObjectQuery bq = bm.createQuery("select O.hire_date,O.penalty,O.interest,O.corpus,O.rent,O.hire_object,O.accounting_date,rp.rent_list from O,jbo.com.tenwa.rent.entity.rent.CONTRACT_FUND_RENT_PLAN rp where O.PLAN_ID=rp.id and O.flow_unid=:Flow_unid and O.contract_id=:Contract_id"); bq.setParameter("Flow_unid", flow_unid); bq.setParameter("Contract_id", contract_id); List bos = bq.getResultList(false); //根据contract_id查询contract_info表的leas_form,这里的contract_id是contract_info表的主键id BizObject bo = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO") .createQuery("select * from O where id=:Id") .setParameter("Id", contract_id) .getSingleResult(false); String leas_form = bo.getAttribute("leas_form").toString(); BigDecimal totalMoney = BigDecimal.ZERO; BigDecimal taxrate = BigDecimal.ZERO; BigDecimal tax = BigDecimal.ZERO; int rent_list = 0; String hire_object = null; BigDecimal rent = BigDecimal.ZERO;//租金 BigDecimal corpus = BigDecimal.ZERO;//本金 BigDecimal interest = BigDecimal.ZERO;//利息 BigDecimal penalty = BigDecimal.ZERO;//罚息 List> list = new ArrayList>();//租金list List> list1 = new ArrayList>(); //罚息list String accounting_date = null; String str = null; String lessor =null;//供应商id String client = null;//承租人id String clientname = null;//承租人名称 String hire_date = null;//回笼日期 //根据contract_id获取contract_signatory表的lessor(出租人,设备购买者),client(承租人) BizObjectManager bm4 = JBOFactory.getBizObjectManager("CONTRACT_SIGNATORY.CLASS_NAME"); BizObjectQuery bq4 = bm4.createQuery("select * from O where contract_id=:contract_id"); bq4.setParameter("contract_id", contract_id); BizObject bo4 = bq4.getSingleResult(false); lessor = bo4.getAttribute("lessor").toString(); client = bo4.getAttribute("client").toString(); BizObjectManager bm5 = JBOFactory.getBizObjectManager("jbo.app.CUSTOMER_INFO"); BizObjectQuery bq5 = bm5.createQuery("select * from O where customerid=:client"); bq5.setParameter("client", client); BizObject bo5 = bq5.getSingleResult(false); clientname = bo5.getAttribute("customername").toString();//承租人名称 if(bos == null || bos.size() == 0){ return; }else{ for(int i=0;i(换成)——> 营业外收入--滞纳金收入 计算逻辑: VoucherUtil.Credit(list1, "罚息收入", "nonoperating_income_late_fee_income", Tools.formatNumberDoubleTwo(penalty.subtract(penalty.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate)).toString()), accounting_date,hire_date); //贷 应交税费——应交增值税(销项税额) 计算逻辑:税金 VoucherUtil.Credit(list1, "罚息收入", "tax_payable_substituted_money", Tools.formatNumberDoubleTwo(penalty.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate).toString()), accounting_date,hire_date); //生成罚息凭证 voucherToV8Service.saveV8Message(headMap, list1, CurUser,tx); list1.clear(); }else if("BLYW".equals(leas_form)){ //摘要 *月*日收+承租人名称+罚息收入 //借 银行存款 计算逻辑:罚息收入 VoucherUtil.Debit(list1, hire_date.substring(5,7)+"月"+hire_date.substring(8)+"日收"+clientname+"罚息收入", "cash_in_bank", Tools.formatNumberDoubleTwo(penalty.toString()), accounting_date,hire_date); //贷 营业外收入--滞纳金收入 计算逻辑: VoucherUtil.Credit(list1, hire_date.substring(5,7)+"月"+hire_date.substring(8)+"日收"+clientname+"罚息收入", "nonoperating_income_late_fee_income", Tools.formatNumberDoubleTwo(penalty.subtract(penalty.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate)).toString()), accounting_date,hire_date); //贷 应交税费——应交增值税(销项税额) 计算逻辑:税金 VoucherUtil.Credit(list1, hire_date.substring(5,7)+"月"+hire_date.substring(8)+"日收"+clientname+"罚息收入", "tax_payable_substituted_money", Tools.formatNumberDoubleTwo(penalty.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate).toString()), accounting_date,hire_date); //生成罚息凭证 voucherToV8Service.saveV8Message(headMap, list1, CurUser,tx); list1.clear(); } } } //生成租金凭证 //voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); //list.clear(); //生成罚息凭证 //voucherToV8Service.saveV8Message(headMap, list1, CurUser,tx); //list1.clear(); } } } //实际投放 public void createVoucher_fundpayequipt(String flow_unid,BizObject CurUser, JBOTransaction tx) throws Exception { //凭证生成开关 if("true".equals(control_)){ Double b = 0.0; Map condtion=new HashMap(); condtion.put("flow_unid", flow_unid); BizObject flow=DataOperatorUtil.getSingleJBO(FLOW_BUSSINESS_OBJECT.CLASS_NAME, condtion, tx); String contract_id=flow.getAttribute("contract_id").toString(); Map headMap = new HashMap(); headMap.put("contract_id",contract_id); headMap.put("moduleName", "实际投放"); //根据contract_id查询contract_info表的contract_number,前面的查询条件的contract_id是contract_info表的主键id BizObjectManager bm2 = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO"); BizObjectQuery bq2 = bm2.createQuery("select * from O where id=:Contract_id"); bq2.setParameter("Contract_id", contract_id); BizObject bos2 = bq2.getSingleResult(false); @SuppressWarnings("unused") String contract_number = bos2.getAttribute("contract_number").toString();//合同号、业务合同号 //根据contract_id查询contract_fund_rent_plan表的租金 BizObjectManager bm6 = JBOFactory.getBizObjectManager("CONTRACT_FUND_RENT_PLAN.CLASS_NAME"); BizObjectQuery bq6 = bm6.createQuery("select * from O where Contract_id=:Contract_id"); bq6.setParameter("Contract_id", contract_id); List bos6 = bq6.getResultList(false); if(bos6 != null && bos6.size() > 0){ for(int j=0;j bos = bq.getResultList(false); //根据contract_id查询contract_info表的leas_form,这里的contract_id是contract_info表的主键id BizObject bo = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO") .createQuery("select * from O where id=:Id") .setParameter("Id", contract_id) .getSingleResult(false); String leas_form = bo.getAttribute("leas_form").toString(); List> list = new ArrayList>(); BigDecimal all_rent = new BigDecimal(b);//总租金(本金+利息) BigDecimal contract_equip_amt = BigDecimal.ZERO;//合同信息中的设备款 BigDecimal clean_lease_money = BigDecimal.ZERO;//融资额 BigDecimal totalMoney = BigDecimal.ZERO;//总投放金额=本次投放的总设备款 BigDecimal fact_money = BigDecimal.ZERO;//投放金额 BigDecimal already_pay_money = BigDecimal.ZERO;//已经投放总金额 BigDecimal fact_pay_money = BigDecimal.ZERO;//实际支付金额 BigDecimal equip_amt = BigDecimal.ZERO;//实际投放中的设备款 BigDecimal return_amt = BigDecimal.ZERO;//厂商返利 BigDecimal caution_money = BigDecimal.ZERO;//保证金 BigDecimal first_payment = BigDecimal.ZERO;//首付款 BigDecimal return_amt_tax = BigDecimal.ZERO;//返利销项税 BigDecimal handling_money = BigDecimal.ZERO;//手续费 BigDecimal consultation_money = BigDecimal.ZERO;//咨询费 BigDecimal quality_guarantee_deposit = BigDecimal.ZERO;//质保金 BigDecimal nominal_price = BigDecimal.ZERO;//留购价款=残值转让 BigDecimal equip_end_value = BigDecimal.ZERO;//期末余值 BigDecimal all_collection_money = BigDecimal.ZERO;//全部应收款 BigDecimal taxrate = BigDecimal.ZERO; String fact_object = null;//收支对象 String accounting_date = null;//会计处理日 String fact_date = null;//收支日期 String equip_amt_accounting_date = null;//设备款会计处理日 String equip_amt_fact_date = null;//设备款收支日期 String first_payment_accounting_date = null;//首付款会计处理日 String first_payment_fact_date = null;//首付款收支日期 String caution_money_accounting_date = null;//保证金会计处理日 String caution_money_fact_date = null;//保证金收支日期 String consultation_money_accounting_date = null;//咨询费会计处理日 String consultation_money_fact_date = null;//咨询费收支日期 String handling_money_accounting_date = null;//手续费会计处理日 String handling_money_fact_date = null;//手续费收支日期 String seller = null;//供应商id String sellername = null;//供应商名称 String seller_vou = null;//凭证供应商id String lessor = null;//出租方名称 String client = null;//承租人id String clientname = null;//承租人名称 String charge_list = null; String deduction_first_payment = null;//首付款内扣 String equip_type = "feetype10";//租赁的费用类型是设备款 if("SHHZ".equals(leas_form)){ equip_type = "feetype21";//保理的费用类型是应收账款 } int quality_guarantee_time = 0;//质保金期限 ,单位:月 boolean is_equip_amt = false;//是否设备款 boolean is_return_amt = false;//是否厂商返利 boolean is_caution_money = false;//是否保证金 boolean is_first_payment = false;//是否首付款 boolean is_handling_money = false;//是否手续费 boolean is_consultation_money = false;//是否咨询费 boolean is_quality_guarantee_deposit =false;//是否质保金 boolean is_nominal_price = false;//是否留购价款 boolean is_deduction_first_payment = false;//是否首付款内扣 boolean is_equip_end_value = false;//是否期末余值 boolean is_fact_pay_equip = false;//是否实际支付的设备款==payfund6-电汇 //根据contract_id获取contract_signatory表的lessor(出租人,设备购买者),client(承租人) BizObjectManager bm4 = JBOFactory.getBizObjectManager("CONTRACT_SIGNATORY.CLASS_NAME"); BizObjectQuery bq4 = bm4.createQuery("select * from O where contract_id=:contract_id"); bq4.setParameter("contract_id", contract_id); BizObject bo4 = bq4.getSingleResult(false); lessor = bo4.getAttribute("lessor").toString(); client = bo4.getAttribute("client").toString(); BizObjectManager bm5 = JBOFactory.getBizObjectManager("jbo.app.CUSTOMER_INFO"); BizObjectQuery bq5 = bm5.createQuery("select * from O where customerid=:client"); bq5.setParameter("client", client); BizObject bo5 = bq5.getSingleResult(false); clientname = bo5.getAttribute("customername").toString();//承租人名称 //根据contract_id,fee_type获取contract_fund_fund_charge表中是否已经投放过 List list1 = JBOHelper.queryList("CONTRACT_FUND_FUND_CHARGE.CLASS_NAME", "select * from o where o.contract_id=:contract_id and o.fee_type=:fee_type", contract_id,equip_type); if(list1.size()>0){ for (int i = 0; i < list1.size(); i++) {//得到投放记录的总投资金额 already_pay_money = already_pay_money.add(new BigDecimal(list1.get(i).getAttribute("fact_money").toString())); } } //根据contract_id获取contract_supplier_info 表的供应商 BizObject sup = JBOHelper.querySingle("CONTRACT_SUPPLIER_INFO.CLASS_NAME", "SELECT ci.customername FROM o ,jbo.app.CUSTOMER_INFO ci WHERE ci.customerid=o.seller AND o.contract_id=:contract_id", contract_id); if(sup!=null)sellername = sup.getAttribute("customername").getString(); //根据contract_id查询contract_condition表的clean_lease_money 融资额 BizObjectManager bm7 = JBOFactory.getBizObjectManager("CONTRACT_CONDITION.CLASS_NAME"); BizObjectQuery bq7 = bm7.createQuery("select * from O where contract_id=:contract_id"); bq7.setParameter("contract_id", contract_id); BizObject bo7 = bq7.getSingleResult(false); if(bo7==null){ return; }else{ quality_guarantee_time = bo7.getAttribute("quality_guarantee_time").getInt(); deduction_first_payment = bo7.getAttribute("deduction_first_payment").getString(); if("Y".equals(deduction_first_payment)){is_deduction_first_payment = true;} contract_equip_amt = new BigDecimal(bo7.getAttribute("equip_amt").toString()); clean_lease_money = new BigDecimal(bo7.getAttribute("clean_lease_money").toString()); } if(bos == null || bos.size() == 0){ return; }else{ for(int i=0;i24){//质保金期限两年以上,质保金为借 长期应收款 all_collection_money = all_collection_money.add(quality_guarantee_deposit);//(+质保金) } //借:长期应收款-应收租赁项目款 计算逻辑:租金总计=租金+首付款+留购价款 (+质保金) VoucherUtil.DebitFundPayEquip(list, "结转"+clientname+"未实现融资收益","long_receivable_leasing_project_money", Tools.formatNumberDoubleTwo(all_collection_money.toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); if(quality_guarantee_time>24){ //贷:融资租赁资产-直租 计算逻辑:设备款-不含税 VoucherUtil.CreditFundPayEquip(list, "结转"+clientname+"未实现融资收益","leasing_property_direct_lease",Tools.formatNumberDoubleTwo(contract_equip_amt.subtract(contract_equip_amt.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate)).toString()),equip_amt_accounting_date,equip_amt_fact_date,seller_vou); }else{ //贷:融资租赁资产-直租 计算逻辑:设备款-质保金 VoucherUtil.CreditFundPayEquip(list, "结转"+clientname+"未实现融资收益","leasing_property_direct_lease",Tools.formatNumberDoubleTwo(contract_equip_amt.subtract(contract_equip_amt.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate)).subtract(quality_guarantee_deposit).toString()),equip_amt_accounting_date,equip_amt_fact_date,seller_vou); } //贷:未实现融资收益-未实现融资收益 计算逻辑:利息收入=租金总额—设备款(不含税)—待缴税金+留购价款 VoucherUtil.CreditFundPayEquip(list, "结转"+clientname+"未实现融资收益","unconfirmed_financing_income_financing_income",Tools.formatNumberDoubleTwo(all_collection_money.subtract(contract_equip_amt.subtract(contract_equip_amt.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate))).subtract(all_rent.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate)).toString()),accounting_date,accounting_date,seller_vou); //贷:未实现租赁收益-增值税 计算逻辑:销项税金暂记账户:租金合计/1.17*0.17 VoucherUtil.CreditFundPayEquip(list, "结转"+clientname+"未实现融资收益","unconfirmed_lease_income_added-value_tax",Tools.formatNumberDoubleTwo((all_rent.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate)).toString()),accounting_date,accounting_date,seller_vou); //生成凭证-一条摘要对应一条凭证信息 voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); list.clear();//生成凭证后清空 //摘要 收+承租人名称+第一期租金(互抵部分) //首付款内扣,抵租金 if(is_deduction_first_payment){ //借 应付账款 VoucherUtil.DebitFundPayEquip(list, "收"+clientname+"第一期租金(互抵部分)","account_payables" , Tools.formatNumberDoubleTwo(first_payment.toString()), first_payment_accounting_date,first_payment_fact_date,seller_vou); //贷:长期应收款-应收租赁项目款 VoucherUtil.CreditFundPayEquip(list, "收"+clientname+"第一期租金(互抵部分)","long_receivable_leasing_project_money", Tools.formatNumberDoubleTwo(first_payment.toString()), first_payment_accounting_date,first_payment_fact_date,seller_vou); if(quality_guarantee_time<=24){//质保金期限在两年以内为应付账款 //借 应付账款 VoucherUtil.DebitFundPayEquip(list, "收"+clientname+"第一期租金(互抵部分)","account_payables" , Tools.formatNumberDoubleTwo(quality_guarantee_deposit.toString()), accounting_date,accounting_date,seller_vou); //贷:长期应收款-应收租赁项目款 VoucherUtil.CreditFundPayEquip(list, "收"+clientname+"第一期租金(互抵部分)","long_receivable_leasing_project_money", Tools.formatNumberDoubleTwo(quality_guarantee_deposit.toString()),accounting_date, accounting_date,seller_vou); } //借 未实现租赁收益——增值税 计算逻辑:第一期租金发票 VoucherUtil.DebitFundPayEquip(list, "收"+clientname+"第一期租金(互抵部分)","unconfirmed_lease_income_added-value_tax" , Tools.formatNumberDoubleTwo((first_payment.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate)).toString()), first_payment_accounting_date,first_payment_fact_date,seller_vou); //贷 应交税费——应交增值税——销项税 计算逻辑:第一期租金/1.17*0.17 VoucherUtil.CreditFundPayEquip(list, "收"+clientname+"第一期租金(互抵部分)","tax_payable_substituted_money",Tools.formatNumberDoubleTwo((first_payment.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate)).toString()),first_payment_accounting_date,first_payment_fact_date,seller_vou); //生成凭证-一条摘要对应一条凭证信息 voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); list.clear();//生成凭证后清空 } }else{//有投放记录 //借 应付账款 VoucherUtil.DebitFundPayEquip(list, "支"+clientname+"项目融资租赁设备款("+lessor+")","account_payables" , Tools.formatNumberDoubleTwo(totalMoney.toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); //贷 银行存款 VoucherUtil.CreditFundPayEquip(list, "支"+clientname+"项目融资租赁设备款("+lessor+")","cash_in_bank", Tools.formatNumberDoubleTwo(totalMoney.toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); //生成凭证-一条摘要对应一条凭证信息 voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); list.clear();//生成凭证后清空 } }else if("SHHZ".equals(leas_form)){ //回租 //没有投放记录 if(already_pay_money.equals(totalMoney)){//因是先入正式表,在生成凭证,故本次投放金额=已经投放过的金额 ,就是第一次投放 //摘要:支+承租人名称+项目融资租赁设备款 // 借:融资租赁资产-回租 VoucherUtil.DebitFundPayEquip(list, "支"+clientname+"项目融资租赁设备款","leasing_property_leaseback", Tools.formatNumberDoubleTwo(contract_equip_amt.toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); // 贷:银行存款 计算逻辑:本次付款金额 VoucherUtil.CreditFundPayEquip(list, "支"+clientname+"项目融资租赁设备款","cash_in_bank",Tools.formatNumberDoubleTwo(fact_pay_money.toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); // 贷:应付账款 计算逻辑:设备款-本次付款-保证金-咨询费-手续费 BigDecimal account_payables = contract_equip_amt.subtract(fact_pay_money).subtract(caution_money).subtract(consultation_money).subtract(handling_money); VoucherUtil.CreditFundPayEquip(list, "支"+clientname+"项目融资租赁设备款","account_payables",Tools.formatNumberDoubleTwo(account_payables.toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); // 贷:其他应付款-项目保证金 VoucherUtil.CreditFundPayEquip(list, "支"+clientname+"项目融资租赁设备款","other_payables_caution_money",Tools.formatNumberDoubleTwo(caution_money.toString()),caution_money_accounting_date,caution_money_fact_date,seller_vou); // 贷:主营业务收入-咨询费收入 不含税咨询费 VoucherUtil.CreditFundPayEquip(list, "支"+clientname+"项目融资租赁设备款","main_income_consulting_income",Tools.formatNumberDoubleTwo(consultation_money.subtract(consultation_money.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate)).toString()),consultation_money_accounting_date,consultation_money_fact_date,seller_vou); // 贷:应交税费-应交增值税(销项税额) 计算逻辑:咨询费/1.17*0.17 VoucherUtil.CreditFundPayEquip(list, "支"+clientname+"项目融资租赁设备款","tax_payable_substituted_money",Tools.formatNumberDoubleTwo(consultation_money.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate).toString()),consultation_money_accounting_date,consultation_money_fact_date,seller_vou); // 贷:预收账款-手续费 VoucherUtil.CreditFundPayEquip(list, "支"+clientname+"项目融资租赁设备款","advance_handling_charge_money",Tools.formatNumberDoubleTwo(handling_money.toString()),handling_money_accounting_date,handling_money_fact_date,seller_vou); //生成凭证-一条摘要对应一条凭证信息 voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); list.clear();//生成凭证后清空 //摘要:结转+承租人名称+未实现融资收益 // 借:长期应收款-应收租赁项目款 计算逻辑:租金总计=租金总额+残值转让+首付款(内扣) VoucherUtil.DebitFundPayEquip(list, "结转"+clientname+"未实现融资收益","long_receivable_leasing_project_money", Tools.formatNumberDoubleTwo(all_rent.add(nominal_price).add(first_payment).toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); // 贷:融资租赁资产——回租 计算逻辑:设备款 VoucherUtil.CreditFundPayEquip(list, "结转"+clientname+"未实现融资收益","leasing_property_leaseback",Tools.formatNumberDoubleTwo(contract_equip_amt.toString()),equip_amt_accounting_date,equip_amt_fact_date,seller_vou); // 贷:未实现融资收益-未实现融资收益 计算逻辑:(租金总额 — 设备款) VoucherUtil.CreditFundPayEquip(list, "结转"+clientname+"未实现融资收益","unconfirmed_financing_income_financing_income",Tools.formatNumberDoubleTwo(all_rent.add(nominal_price).add(first_payment).subtract(contract_equip_amt).toString()),equip_amt_accounting_date,equip_amt_fact_date,seller_vou); //生成凭证-一条摘要对应一条凭证信息 voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); list.clear();//生成凭证后清空 //摘要 收+承租人名称+第一期租金(互抵) //首付款内扣,抵租金 if(is_deduction_first_payment){ //借 应付账款 计算逻辑:无钱进账 VoucherUtil.DebitFundPayEquip(list, "收"+clientname+"第一期租金(互抵)","account_payables", "0.00", first_payment_accounting_date,first_payment_fact_date,seller_vou); //贷 长期应收款—— 应收租赁项目款 VoucherUtil.CreditFundPayEquip(list, "收"+clientname+"第一期租金(互抵)","long_receivable_leasing_project_money","0.00",first_payment_accounting_date,first_payment_fact_date,seller_vou); //生成凭证-一条摘要对应一条凭证信息 voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); list.clear();//生成凭证后清空 } }else{//有投放记录 //借 应付账款 VoucherUtil.DebitFundPayEquip(list, "支"+clientname+"项目融资租赁设备款","account_payables" , Tools.formatNumberDoubleTwo(totalMoney.toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); //贷 银行存款 VoucherUtil.CreditFundPayEquip(list, "支"+clientname+"项目融资租赁设备款","cash_in_bank", Tools.formatNumberDoubleTwo(totalMoney.toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); //生成凭证-一条摘要对应一条凭证信息 voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); list.clear();//生成凭证后清空 } }else if("BLYW".equals(leas_form)){ //摘要 支+承租人名称+项目融资租赁设备款+(设备购买方名称) //借 应收账款 摘要:支+承租人名称+项目融资租赁设备款+(设备购买方名称) 计算逻辑:不含税设备款 VoucherUtil.DebitFundPayEquip(list, "支"+clientname+"项目融资租赁设备款"+(sellername==null?"":"("+sellername+")"), "account_receivable_factoring_principal", Tools.formatNumberDoubleTwo(contract_equip_amt.subtract(contract_equip_amt.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate)).toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); //借 长期应收款——应收保理业务本金 计算逻辑:进项税额 VoucherUtil.DebitFundPayEquip(list, "支"+clientname+"项目融资租赁设备款"+(sellername==null?"":"("+sellername+")"), "long_receivable_factoring_principal", Tools.formatNumberDoubleTwo(contract_equip_amt.divide(taxrate.add(BigDecimal.ONE),2).multiply(taxrate).toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); //贷 银行存款 计算逻辑:实际支付的款项 VoucherUtil.CreditFundPayEquip(list,"支"+clientname+"项目融资租赁设备款"+(sellername==null?"":"("+sellername+")"), "cash_in_bank", Tools.formatNumberDoubleTwo(contract_equip_amt.toString()), equip_amt_accounting_date,equip_amt_fact_date,seller_vou); //生成凭证-一条摘要对应一条凭证信息 voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); list.clear();//生成凭证后清空 } } } } //合同起租 public void createVoucher_contractonhire(String flow_unid,BizObject CurUser, JBOTransaction tx) throws Exception { //凭证生成开关 if("true".equals(control_)){ Map condtion=new HashMap(); condtion.put("flow_unid", flow_unid); BizObject flow=DataOperatorUtil.getSingleJBO(FLOW_BUSSINESS_OBJECT.CLASS_NAME, condtion, tx); String contract_id=flow.getAttribute("contract_id").toString(); Map headMap = new HashMap(); headMap.put("contract_id",contract_id); headMap.put("moduleName", "合同起租"); //根据contract_id查询contract_info表的contract_number,前面的查询条件的contract_id是contract_info表的主键id BizObjectManager bm2 = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO"); BizObjectQuery bq2 = bm2.createQuery("select * from O where id=:Contract_id"); bq2.setParameter("Contract_id", contract_id); BizObject bos2 = bq2.getSingleResult(false); String contract_number = bos2.getAttribute("contract_number").toString();//业务合同号 //根据contract_id查询contract_info表的leas_form,这里的contract_id是contract_info表的主键id BizObject bo = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO") .createQuery("select * from O where id=:Id") .setParameter("Id", contract_id) .getSingleResult(false); String leas_form = bo.getAttribute("leas_form").toString(); //根据flow_unid和contract_id获取contract_fund_fund_plan_temp表的accounting_date(会计处理日)、fact_money(收支金额) BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.com.tenwa.fund.entity.charge.CONTRACT_FUND_FUND_PLAN_TEMP"); BizObjectQuery bq = bm.createQuery("select * from O where flow_unid=:Flow_unid and contract_id=:Contract_id"); bq.setParameter("Flow_unid", flow_unid); bq.setParameter("Contract_id", contract_id); List bos = bq.getResultList(false); BigDecimal taxrate = BigDecimal.ZERO; BigDecimal equip_amt = BigDecimal.ZERO;//设备款 BigDecimal return_amt = BigDecimal.ZERO;//返利 BigDecimal norminal_price = BigDecimal.ZERO;//留购款 BigDecimal first_payment = BigDecimal.ZERO;//首付款 BigDecimal handling_charge_money = BigDecimal.ZERO;//手续费 BigDecimal rent_total = BigDecimal.ZERO;//租金总额 BigDecimal interest = BigDecimal.ZERO;//利息 BigDecimal tax = BigDecimal.ZERO;//进项税 BigDecimal lease_property = BigDecimal.ZERO;//融资性租赁财产(倒减) BigDecimal lease_form1_property = BigDecimal.ZERO;//直租--融资租赁财产(倒减) BigDecimal taxMoney = BigDecimal.ZERO;//税金 boolean is_equip_amt = false;//是否设备款 boolean is_return_amt = false;//是否返利 boolean is_norminal_price = false;//是否留购款 boolean is_first_payment = false;//是否首付款 boolean is_handling_charge_money = false; List> list = new ArrayList>(); Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); String accounting_date = sdf.format(date); String equip_type = "feetype10";//租赁的费用类型是设备款 if("SHHZ".equals(leas_form)){ equip_type = "feetype21";//保理的费用类型是应收账款 } if(bos == null || bos.size() == 0){ return; }else{ for(int i=0;i bo1 = JBOFactory.getBizObjectManager("jbo.com.tenwa.rent.entity.rent.C1_FUND_RENT_PLAN") .createQuery("select * from O where flow_unid=:Flow_unid and contract_id=:Contract_id") .setParameter("Flow_unid", flow_unid).setParameter("Contract_id", contract_id) .getResultList(false); for(int j=0;j condtion=new HashMap(); condtion.put("flow_unid", flow_unid); BizObject flow=DataOperatorUtil.getSingleJBO(FLOW_BUSSINESS_OBJECT.CLASS_NAME, condtion, tx); String contract_id=flow.getAttribute("contract_id").toString(); Map headMap = new HashMap(); headMap.put("contract_id",contract_id); headMap.put("moduleName", "付款"); //根据contract_id查询contract_info表的contract_number,前面的查询条件的contract_id是contract_info表的主键id BizObjectManager bm2 = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO"); BizObjectQuery bq2 = bm2.createQuery("select * from O where id=:Contract_id"); bq2.setParameter("Contract_id", contract_id); BizObject bos2 = bq2.getSingleResult(false); String contract_number = bos2.getAttribute("contract_number").toString();//合同号、业务合同号 //根据contract_id查询contract_info表的leas_form,这里的contract_id是contract_info表的主键id BizObject bo = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO") .createQuery("select * from O where id=:Id") .setParameter("Id", contract_id) .getSingleResult(false); String leas_form = bo.getAttribute("leas_form").toString(); //根据flow_unid和contract_id获取contract_fund_fund_charge_temp表的accounting_date(会计处理日)、fact_money(收支金额) BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.com.tenwa.fund.entity.charge.CONTRACT_FUND_FUND_CHARGE_TEMP"); BizObjectQuery bq = bm.createQuery("select * from O where flow_unid=:Flow_unid and contract_id=:Contract_id"); bq.setParameter("Flow_unid", flow_unid); bq.setParameter("Contract_id", contract_id); List bos = bq.getResultList(false); List> list = new ArrayList>(); BigDecimal totalMoney = BigDecimal.ZERO; BigDecimal deduction_caution_money = BigDecimal.ZERO;//抵扣保证金 BigDecimal return_caution_money = BigDecimal.ZERO;//退还保证金 String accounting_date = null;//会计处理日 String client = null;//承租人id String clientname = null;//承租人名称 String fact_date = "";//付款日期 String accounting_date_return = null;//退还保证金会计处理日 boolean is_deduction_caution_money = false;//是否抵扣保证金 boolean is_return_caution_money = false;//是否退换保证金 //根据contract_id获取contract_signatory表的client(承租人) BizObjectManager bm4 = JBOFactory.getBizObjectManager("CONTRACT_SIGNATORY.CLASS_NAME"); BizObjectQuery bq4 = bm4.createQuery("select * from O where contract_id=:contract_id"); bq4.setParameter("contract_id", contract_id); BizObject bo4 = bq4.getSingleResult(false); client = bo4.getAttribute("client").toString(); BizObjectManager bm5 = JBOFactory.getBizObjectManager("jbo.app.CUSTOMER_INFO"); BizObjectQuery bq5 = bm5.createQuery("select * from O where customerid=:client"); bq5.setParameter("client", client); BizObject bo5 = bq5.getSingleResult(false); clientname = bo5.getAttribute("customername").toString();//承租人名称 if(bos == null || bos.size() == 0){ return; }else{ for(int i=0;i condtion=new HashMap(); condtion.put("flow_unid", flow_unid); BizObject flow=DataOperatorUtil.getSingleJBO(FLOW_BUSSINESS_OBJECT.CLASS_NAME, condtion, tx); String contract_id=flow.getAttribute("contract_id").toString(); Map headMap = new HashMap(); headMap.put("contract_id",contract_id); headMap.put("moduleName", "期末保证金抵扣"); //根据contract_id查询contract_info表的contract_number,前面的查询条件的contract_id是contract_info表的主键id BizObjectManager bm2 = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO"); BizObjectQuery bq2 = bm2.createQuery("select * from O where id=:Contract_id"); bq2.setParameter("Contract_id", contract_id); BizObject bos2 = bq2.getSingleResult(false); String contract_number = bos2.getAttribute("contract_number").toString();//合同号、业务合同号 //根据flow_unid和contract_id获取contract_fund_rent_income_temp表的accounting_date(会计处理日)、rent(回笼租金) BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.com.tenwa.rent.entity.rent.CONTRACT_FUND_RENT_INCOME_TEMP"); BizObjectQuery bq = bm.createQuery("select * from O where flow_unid=:Flow_unid and contract_id=:Contract_id"); bq.setParameter("Flow_unid", flow_unid); bq.setParameter("Contract_id", contract_id); List bos = bq.getResultList(false); //根据contract_id查询contract_info表的leas_form,这里的contract_id是contract_info表的主键id BizObject bo = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO") .createQuery("select * from O where id=:Id") .setParameter("Id", contract_id) .getSingleResult(false); String leas_form = bo.getAttribute("leas_form").toString(); BigDecimal totalMoney = BigDecimal.ZERO; BigDecimal rent = BigDecimal.ZERO; BigDecimal interest = BigDecimal.ZERO; BigDecimal penalty = BigDecimal.ZERO; BigDecimal taxrate = BigDecimal.ZERO; BigDecimal all_rent = BigDecimal.ZERO;//本次回笼租金总额 String client = null;//承租人id String clientname = null;//承租人名称 String hire_date = "";//回笼日期 List> list = new ArrayList>(); String accounting_date = null; String hire_object = null; //根据contract_id获取contract_signatory表的client(承租人) BizObjectManager bm4 = JBOFactory.getBizObjectManager("CONTRACT_SIGNATORY.CLASS_NAME"); BizObjectQuery bq4 = bm4.createQuery("select * from O where contract_id=:contract_id"); bq4.setParameter("contract_id", contract_id); BizObject bo4 = bq4.getSingleResult(false); client = bo4.getAttribute("client").toString(); BizObjectManager bm5 = JBOFactory.getBizObjectManager("jbo.app.CUSTOMER_INFO"); BizObjectQuery bq5 = bm5.createQuery("select * from O where customerid=:client"); bq5.setParameter("client", client); BizObject bo5 = bq5.getSingleResult(false); clientname = bo5.getAttribute("customername").toString();//承租人名称 if(bos == null || bos.size() == 0){ return; }else{ for(int i=0;i condtion=new HashMap(); condtion.put("flow_unid", flow_unid); BizObject flow=DataOperatorUtil.getSingleJBO(FLOW_BUSSINESS_OBJECT.CLASS_NAME, condtion, tx); String contract_id=flow.getAttribute("contract_id").toString(); Map headMap = new HashMap(); headMap.put("contract_id",contract_id); if("租金计划变更流程".equals(flow_name)){ headMap.put("moduleName", "租金计划变更"); }else if("调息流程".equals(flow_name)){ headMap.put("moduleName", "调息"); }else if("合同中途中止流程".equals(flow_name)){ headMap.put("moduleName", "合同中途中止"); } //根据contract_id查询contract_info表的contract_number,前面的查询条件的contract_id是contract_info表的主键id // BizObjectManager bm2 = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO"); // BizObjectQuery bq2 = bm2.createQuery("select * from O where id=:Contract_id"); // bq2.setParameter("Contract_id", contract_id); // BizObject bos2 = bq2.getSingleResult(false); // String contract_number = bos2.getAttribute("contract_number").toString();//合同号、业务合同号 //根据contract_id查询contract_info表的leas_form,这里的contract_id是contract_info表的主键id String leas_form = ""; if(!"调息流程".equals(flow_name)){ BizObject bo = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO") .createQuery("select * from O where id=:Id") .setParameter("Id", contract_id) .getSingleResult(false); leas_form = bo.getAttribute("leas_form").toString(); } BigDecimal old_all_penalty = BigDecimal.ZERO;//原总利息 BigDecimal now_all_penalty = BigDecimal.ZERO;//现总利息 BigDecimal penalty_differential = BigDecimal.ZERO;//利息差 String change_date = "";//会计处理日暂用变更时间 List> list = new ArrayList>(); //合同中途中止 或 租金计划变更 if("合同中途中止".equals(flow_name)||"租金计划变更流程".equals(flow_name)){ //根据contract_id 获取CONTRACT_FUND_RENT_PLAN表中的业务利息------原利息信息 BizObjectManager bm1 = JBOFactory.getBizObjectManager("jbo.com.tenwa.rent.entity.rent.CONTRACT_FUND_RENT_PLAN"); BizObjectQuery bq1 = bm1.createQuery("select * from O where contract_id=:Contract_id"); bq1.setParameter("Contract_id", contract_id); List bos1 = bq1.getResultList(false); if(bos1 != null || bos1.size() > 0){ for (int i = 0; i < bos1.size(); i++) { old_all_penalty = old_all_penalty.add(new BigDecimal(bos1.get(i).getAttribute("INTEREST_BUSINESS").toString())); } } //根据flow_unid 获取 CONTRACT_CHANGE_INFO_TEMP 中的变更时间 BizObject biz = JBOHelper.querySingle("jbo.com.tenwa.entity.contract.CONTRACT_CHANGE_INFO_TEMP", "select * from o where o.flow_unid=:flow_unid", flow_unid); if(biz!=null)change_date = biz.getAttribute("change_date").getString(); //根据flow_unid 获取C1_FUND_RENT_PLAN表中的业务利息--------现利息信息 BizObjectManager bm3 = JBOFactory.getBizObjectManager("jbo.com.tenwa.rent.entity.rent.C1_FUND_RENT_PLAN"); BizObjectQuery bq3 = bm3.createQuery("select * from O where flow_unid=:flow_unid"); bq3.setParameter("flow_unid", flow_unid); List bos3 = bq3.getResultList(false); if(bos3 != null || bos3.size() > 0){ for (int i = 0; i < bos3.size(); i++) { now_all_penalty = now_all_penalty.add(new BigDecimal(bos3.get(i).getAttribute("INTEREST_BUSINESS").toString())); } } penalty_differential = now_all_penalty.subtract(old_all_penalty); if(penalty_differential.compareTo(BigDecimal.ZERO)!=0){//利息差不等于0 if("RZZL".equals(leas_form)){ //摘要 变更 //借 未实现融资收益-未实现融资收益 计算逻辑:利息差 VoucherUtil.Debit(list, "变更", "unconfirmed_financing_income_financing_income",Tools.formatNumberDoubleTwo(penalty_differential.toString()) , change_date, change_date); //贷 长期应收款-应收租赁项目款 VoucherUtil.Credit(list, "变更", "long_receivable_leasing_project_money", Tools.formatNumberDoubleTwo(penalty_differential.toString()), change_date, change_date); }else if("SHHZ".equals(leas_form)){ //摘要 变更 //借 未实现融资收益-未实现融资收益 计算逻辑:利息差 VoucherUtil.Debit(list, "变更", "unconfirmed_financing_income_financing_income",Tools.formatNumberDoubleTwo(penalty_differential.toString()) , change_date, change_date); //贷 长期应收款-应收租赁项目款 VoucherUtil.Credit(list, "变更", "long_receivable_leasing_project_money", Tools.formatNumberDoubleTwo(penalty_differential.toString()), change_date, change_date); }else if("BLYW".equals(leas_form)){ //暂无 } voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); } } //调息 if("调息流程".equals(flow_name)){ List list1 = JBOHelper.queryList("C1_FUND_RENT_PLAN", "SELECT SUM(o.INTEREST_BUSINESS)-SUM(p.INTEREST_BUSINESS), o.contract_id FROM o LEFT JOIN jbo.com.tenwa.rent.entity.rent.CONTRACT_FUND_RENT_PLAN p ON p.contract_id=o.contract_id AND p.rent_list=o.rent_list WHERE o.flow_unid='"+flow_unid+"' GROUP BY o.contract_id"); if(list1 == null || list1.size() == 0){ return; }else{ for (int i = 0; i < list1.size(); i++) { penalty_differential = new BigDecimal(list1.get(i).getAttribute("SUM(o.INTEREST_BUSINESS)-SUM(p.INTEREST_BUSINESS)").getString()); contract_id = list1.get(i).getAttribute("contract_id").getString(); headMap.put("contract_id", contract_id); BizObject bo = JBOHelper.querySingle("CONTRACT_INFO", "select * from O where id=:Id", contract_id); if(bo!=null)leas_form = bo.getAttribute("leas_form").toString(); change_date = DateTool.getToday("yyyy/MM/dd");//当前日期 if(penalty_differential.compareTo(BigDecimal.ZERO)!=0){//利息差不等于0 if("RZZL".equals(leas_form)){ //摘要 变更 //借 未实现融资收益-未实现融资收益 计算逻辑:利息差 VoucherUtil.Debit(list, "变更", "unconfirmed_financing_income_financing_income",Tools.formatNumberDoubleTwo(penalty_differential.toString()) , change_date, change_date); //贷 长期应收款-应收租赁项目款 VoucherUtil.Credit(list, "变更", "long_receivable_leasing_project_money", Tools.formatNumberDoubleTwo(penalty_differential.toString()), change_date, change_date); }else if("SHHZ".equals(leas_form)){ //摘要 变更 //借 未实现融资收益-未实现融资收益 计算逻辑:利息差 VoucherUtil.Debit(list, "变更", "unconfirmed_financing_income_financing_income", Tools.formatNumberDoubleTwo(penalty_differential.toString()) , change_date, change_date); //贷 长期应收款-应收租赁项目款 VoucherUtil.Credit(list, "变更", "long_receivable_leasing_project_money", Tools.formatNumberDoubleTwo(penalty_differential.toString()), change_date, change_date); }else if("BLYW".equals(leas_form)){ //暂无 } } voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); } } } /*//租金计划变更流程 if("租金计划变更流程".equals(flow_name)){ //根据contract_id 获取CONTRACT_FUND_RENT_PLAN表中的业务利息------原利息信息 BizObjectManager bm1 = JBOFactory.getBizObjectManager("jbo.com.tenwa.rent.entity.rent.CONTRACT_FUND_RENT_PLAN"); BizObjectQuery bq1 = bm1.createQuery("select * from O where contract_id=:Contract_id"); bq1.setParameter("Contract_id", contract_id); List bos1 = bq1.getResultList(false); if(bos1 != null || bos1.size() > 0){ for (int i = 0; i < bos1.size(); i++) { old_all_penalty = old_all_penalty.add(new BigDecimal(bos1.get(i).getAttribute("INTEREST_BUSINESS").toString())); } } //根据flow_unid 获取 CONTRACT_CHANGE_INFO_TEMP 中的变更时间 BizObject biz = JBOHelper.querySingle(CONTRACT_CHANGE_INFO_TEMP.CLASS_NAME, "select * from o where o.flow_unid=:flow_unid", flow_unid); if(biz!=null)change_date = biz.getAttribute("change_date").getString(); //根据flow_unid 获取C1_FUND_RENT_PLAN表中的业务利息--------现利息信息 BizObjectManager bm3 = JBOFactory.getBizObjectManager("jbo.com.tenwa.rent.entity.rent.C1_FUND_RENT_PLAN"); BizObjectQuery bq3 = bm3.createQuery("select * from O where flow_unid=:flow_unid"); bq3.setParameter("flow_unid", flow_unid); List bos3 = bq3.getResultList(false); if(bos3 != null || bos3.size() > 0){ for (int i = 0; i < bos3.size(); i++) { now_all_penalty = now_all_penalty.add(new BigDecimal(bos3.get(i).getAttribute("INTEREST_BUSINESS").toString())); } } penalty_differential = old_all_penalty.subtract(now_all_penalty); if("RZZL".equals(leas_form)){ //摘要 变更 //借 未实现利息收益——未实现利息收益 计算逻辑:利息差 VoucherUtil.Debit(list, "变更", "unconfirmed_interest_income_interest_income",Tools.formatNumberDoubleTwo(penalty_differential.toString()) , change_date); //贷 长期应收款-应收融资租赁款——客户 VoucherUtil.Credit(list, "变更", "long_receivable_leasing_money_cust", Tools.formatNumberDoubleTwo(penalty_differential.toString()), change_date); }else if("SHHZ".equals(leas_form)){ //摘要 变更 //借 未实现租赁收益——未实现租赁收益 计算逻辑:利息差 VoucherUtil.Debit(list, "变更", "unconfirmed_lease_income_lease_income", Tools.formatNumberDoubleTwo(penalty_differential.toString()) , change_date); //贷 长期应收款-应收租赁项目款 VoucherUtil.Credit(list, "变更", "long_receivable_leasing_project_money", Tools.formatNumberDoubleTwo(penalty_differential.toString()), change_date); }else if("BLYW".equals(leas_form)){ //暂无 } }*/ } } //月末计提 public void createVoucher_rentmonth(String contract_id,String handling_fee,String interest,String account_date ,BizObject CurUser, JBOTransaction tx) throws Exception { //生成凭证开关 if("true".equals(control_)){ HashMap headMap = new HashMap(); List> list = new ArrayList>(); headMap.put("contract_id", contract_id); headMap.put("moduleName", "月末计提"); BigDecimal handling_ = new BigDecimal(handling_fee);//手续费 BigDecimal interest_ = new BigDecimal(interest);//利息 BigDecimal tax = new BigDecimal(0.17);// BigDecimal taxrate = tax.divide(tax.add(BigDecimal.ONE),2);//税率 String leas_form = null;//租赁形式 String clientname = null;//承租人名称 String project_name = null;//项目名称 BizObject bo = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO") .createQuery("select c.customername ,o.leas_form,o.project_name from O,jbo.app.CUSTOMER_INFO C where o.cust_id=c.customerid and id=:Id") .setParameter("Id", contract_id) .getSingleResult(false); if(bo!=null) { leas_form = bo.getAttribute("leas_form").toString(); clientname = bo.getAttribute("customername").toString(); project_name = bo.getAttribute("project_name").toString(); } if(CurUser==null){//月末计提没有当前用户,故给空字符串 CurUser = new BizObject(USER_INFO.CLASS_NAME); } if("RZZL".equals(leas_form)){ //摘要 确认+承租人名称+项目+本月租赁利息收入 if(interest_.compareTo(BigDecimal.ZERO)==1){ //借 未实现融资收益-未实现融资收益 计算逻辑 利息收入 VoucherUtil.Debit(list, "确认"+clientname+"项目本月租赁利息收入", "unconfirmed_financing_income_financing_income", Tools.formatNumberDoubleTwo(interest_.toString()), account_date, account_date); //贷 租赁收入——直租收入 计算逻辑 利息 VoucherUtil.Credit(list, "确认"+clientname+"项目本月租赁利息收入", "lease_income_direct_lease_income", Tools.formatNumberDoubleTwo(interest_.toString()), account_date, account_date); voucherToV8Service.saveV8Message(headMap, list, CurUser, tx); list.clear(); } //摘要 确认+承租人名称+项目+本月租赁手续费收入 if(handling_.compareTo(BigDecimal.ZERO)==1){ //借 预收账款——手续费 计算逻辑 不含税手续费 VoucherUtil.Debit(list, "确认"+clientname+"项目本月租赁手续费收入", "advance_handling_charge_money", Tools.formatNumberDoubleTwo(handling_.multiply(taxrate).toString()), account_date, account_date); //贷 主营业务收入——手续费收入 计算逻辑 不含税手续费 VoucherUtil.Credit(list, "确认"+clientname+"项目本月租赁手续费收入", "main_income_handling_income", Tools.formatNumberDoubleTwo(handling_.multiply(taxrate).toString()), account_date, account_date); voucherToV8Service.saveV8Message(headMap, list, CurUser, tx); list.clear(); } }else if("SHHZ".equals(leas_form)){ //摘要 确认+承租人名称+项目+本月租赁利息收入 if(interest_.compareTo(BigDecimal.ZERO)==1){ //借 未实现融资收益-未实现融资收益 计算逻辑 利息收入 VoucherUtil.Debit(list, "确认"+clientname+"项目本月租赁利息收入", "unconfirmed_financing_income_financing_income", Tools.formatNumberDoubleTwo(interest_.toString()), account_date, account_date); //贷 租赁收入——回租收入 计算逻辑 利息 VoucherUtil.Credit(list, "确认"+clientname+"项目本月租赁利息收入", "lease_income_leaseback_income", Tools.formatNumberDoubleTwo(interest_.toString()), account_date, account_date); voucherToV8Service.saveV8Message(headMap, list, CurUser, tx); list.clear(); } //摘要 确认+承租人名称+项目+本月租赁手续费收入 if(handling_.compareTo(BigDecimal.ZERO)==1){ //借 预收账款——手续费 计算逻辑 手续费 VoucherUtil.Debit(list, "确认"+clientname+"项目本月租赁手续费收入", "advance_handling_charge_money", Tools.formatNumberDoubleTwo(handling_.toString()), account_date, account_date); //贷 主营业务收入——手续费收入 计算逻辑 手续费 VoucherUtil.Credit(list, "确认"+clientname+"项目本月租赁手续费收入", "main_income_handling_income", Tools.formatNumberDoubleTwo(handling_.toString()), account_date, account_date); voucherToV8Service.saveV8Message(headMap, list, CurUser, tx); list.clear(); } }else if("BLYW".equals(leas_form)){ //摘要 确认+承租人名称+项目+本月租赁利息收入 if(interest_.compareTo(BigDecimal.ZERO)==1){ //借 应收利息 计算逻辑 利息收入 VoucherUtil.Debit(list, "确认"+clientname+"项目本月租赁利息收入", "interest_receivable", Tools.formatNumberDoubleTwo(interest_.toString()), account_date, account_date); //贷 利息收入——保理利息收入 计算逻辑 利息 VoucherUtil.Credit(list, "确认"+clientname+"项目本月租赁利息收入", "interest_income_factoring", Tools.formatNumberDoubleTwo(interest_.toString()), account_date, account_date); voucherToV8Service.saveV8Message(headMap, list, CurUser, tx); list.clear(); } //摘要 确认+承租人名称+项目+本月租赁手续费收入 if(handling_.compareTo(BigDecimal.ZERO)==1){ //借 预收账款——手续费 计算逻辑 不含税手续费 VoucherUtil.Debit(list, "确认"+clientname+"项目本月租赁手续费收入", "advance_handling_charge_money", Tools.formatNumberDoubleTwo(handling_.multiply(taxrate).toString()), account_date, account_date); //贷 主营业务收入——手续费收入 计算逻辑 不含税手续费 VoucherUtil.Credit(list, "确认"+clientname+"项目本月租赁手续费收入", "main_income_handling_income", Tools.formatNumberDoubleTwo(handling_.multiply(taxrate).toString()), account_date, account_date); voucherToV8Service.saveV8Message(headMap, list, CurUser, tx); list.clear(); } } } } //成本均摊 public void createVoucher_costSharing(BigDecimal interest,BigDecimal handling, BizObject CurUser,Map paraMap, JBOTransaction tx) throws Exception { //生成凭证开关 // if("true".equals(control_)){ // HashMap headMap = new HashMap(); // List> listVoucher = new ArrayList>(); // String bill_id = paraMap.get("bill_id");//借款借据号 // String accured_month = paraMap.get("accured_month");//计提月份 // String loan_contract_id = paraMap.get("loan_contract_id");//借款合同号 // headMap.put("moduleName", bill_id+"-成本均摊"); // headMap.put("voucherType","costSharing"); // headMap.put("loan_contract_id", loan_contract_id); // headMap.put("bill_id", bill_id); // headMap.put("accured_month", accured_month); // List> listMap = new ArrayList>(); // BigDecimal allOverCorpus = BigDecimal.ZERO;//所有合同的剩余未还本金,即分配比例时的分母值 // Calendar cal = Calendar.getInstance(); // BigDecimal days = new BigDecimal(cal.getActualMaximum(Calendar.DATE));//当前月份的天数 // // Conn conn = new Conn(); // //new_sql加了是否参与成本均摊及均摊截止日期限制 // String new_sql = "SELECT * from o where o.contract_status>30 AND o.contract_status<100 " // + "AND NVL(o.is_cost,'Y')='Y' AND v.to_char(v.SYSDATE,'yyyy/mm/dd')<=nvl(cost_end_date,v.to_char(v.SYSDATE,'yyyy/mm/dd'))"; // String old_sql = "select * from o where o.contract_status>30 AND o.contract_status<100"; // List listC = JBOHelper.queryList("CONTRACT_INFO.CLASS_NAME", new_sql); // for (int i = 0; i < listC.size(); i++) { // Map map = new HashMap();//放map:合同编号,对应的分子(分配比例的分子:未还本金*天数) // String contract_id = listC.get(i).getAttribute("id").toString();//contract_info 表的id // String sql = "SELECT (a.corpus - nvl(b.corpus,0))over_corpus,nvl(b.corpus,0)AS income_corpus FROM " // + "(SELECT SUM(corpus)corpus FROM contract_fund_rent_income income WHERE income.contract_id=? " // + "AND to_date(substr(income.hire_date,0,7),'YYYY-MM')> list = conn.executeQuery(sql, contract_id,contract_id); // BigDecimal over_corpus = BigDecimal.ZERO;//截止当前期剩余未还本金 // // //1、2、3种情况 // if(list.size()>0){//list.size()==1 // if("0".equals(list.get(0).get("income_corpus"))){//1、已回笼本金为0,则未回笼本金==over_corpus 分配比例的分子:未还本金*本月天数 // // over_corpus = new BigDecimal(StringUtil.nullToString(list.get(0).get("over_corpus"), "0")); // map.put(contract_id, over_corpus.multiply(days)); // listMap.add(map); // allOverCorpus = allOverCorpus.add(over_corpus.multiply(days)); // }else{//本金有回笼记录 // // over_corpus = new BigDecimal(StringUtil.nullToString(list.get(0).get("over_corpus"), "0")); // // if(over_corpus.compareTo(BigDecimal.ZERO)==0){ // continue;//剩余未回笼本金为0,则不对该合同进行均摊 // } // //查询当期有没有回笼的本金项 // String sql1 = "SELECT * FROM contract_fund_rent_income t WHERE t.contract_id=? " // + " AND t.roll_back IS NULL AND SUBSTR(t.hire_date,0,7)=to_char(Sysdate,'yyyy/MM') ORDER BY t.hire_date"; // List> list1 = conn.executeQuery(sql1, contract_id); // if(list1.size()==0){//2、当期没有回笼的本金,则未回笼本金==over_corpus // map.put(contract_id, over_corpus.multiply(days)); // listMap.add(map); // allOverCorpus = allOverCorpus.add(over_corpus.multiply(days)); // continue; // }else{//3、当期有回笼的本金, // int day1 = 0, day2 = 0; // BigDecimal money1 =BigDecimal.ZERO, money2 = BigDecimal.ZERO;//money2=分配规则的分子部分的值 ,即 未还本金*天数... // for (int j = 0; j < list1.size(); j++) { // day2 = Integer.parseInt(list1.get(j).get("hire_date").substring(8, 9));//回笼日期 // money1 = new BigDecimal(list1.get(j).get("corpus").toString());//回笼本金 // money2 = money2.add(over_corpus.multiply(new BigDecimal(day2-day1)));// // over_corpus = over_corpus.subtract(money1); // day1 = day2; // } // map.put(contract_id, money2); // listMap.add(map); // allOverCorpus = allOverCorpus.add(money2); // } // } // } // } // // BigDecimal costMoney_interest = BigDecimal.ZERO;//每个项目的利息均摊金额 // BigDecimal costMoney_handling = BigDecimal.ZERO;//每个项目的手续费均摊金额 // BigDecimal already_interest = BigDecimal.ZERO;//已经分摊的利息 // BigDecimal already_handling = BigDecimal.ZERO;//已经分摊的手续费 // BigDecimal already_costRate = BigDecimal.ZERO;//已经分摊的比例 // BigDecimal costRate = BigDecimal.ZERO;//均摊比例 // BigDecimal proj_money = BigDecimal.ZERO;//每个项目的未还本金*天数 // //BigDecimal b = BigDecimal.ZERO;//测试均摊总值是否与成本相等 // String contract_id = null;//合同编号 // //String leas_form = null;//租赁形式 // //遍历得到每个合同的分配比例,生成成本均摊 // for (int i = 0; i < listMap.size(); i++) { // for (Map.Entry j : listMap.get(i).entrySet()) { // contract_id = j.getKey(); // proj_money = j.getValue(); // costRate = proj_money.divide(allOverCorpus,6,BigDecimal.ROUND_HALF_UP);//均摊比例=(未还本金*天数/所有合同的 未还本金*天数) // costMoney_interest = costRate.multiply(interest).divide(new BigDecimal("1"),2,BigDecimal.ROUND_HALF_UP);//保留两位小数,四舍五入 // costMoney_handling = costRate.multiply(handling).divide(new BigDecimal("1"),2,BigDecimal.ROUND_HALF_UP);//保留两位小数,四舍五入 // if(i==listMap.size()-1){//最后一个合同的均摊金额=总金额-已分摊金额 (避免出现均摊后的总金额超过要均摊的金额),比例=1-已分摊比例 // costRate = BigDecimal.ONE.subtract(already_costRate); // costMoney_interest = interest.subtract(already_interest); // costMoney_handling = handling.subtract(already_handling); // } // already_interest = already_interest.add(costMoney_interest); // already_handling = already_handling.add(costMoney_handling); // already_costRate = already_costRate.add(costRate); // //headMap.put("contract_id", contract_id); // //摘要:成本均摊 // //interest均摊总利息、handling均摊总手续费、costRate每个合同均摊比例,这三个字段应该存起来 // if(costMoney_interest.compareTo(BigDecimal.ZERO)==1){ // //借 主营业务成本——租赁成本——利息支出 // VoucherUtil.DebitCostSharing(listVoucher, "成本均摊", "main_biz_cost_lease_cost_interest_pay", Tools.formatNumberDoubleTwo(costMoney_interest.toString()), // DateUtil.getToday(), DateUtil.getToday(),contract_id,Tools.formatNumberDoubleTwo(interest.toString()),Tools.formatNumberDoubleTwo(handling.toString()),Tools.formatNumberDoubleTwo(costRate.toString())); // //贷 应付利息 // VoucherUtil.CreditCostSharing(listVoucher, "成本均摊", "interest_payables", Tools.formatNumberDoubleTwo(costMoney_interest.toString()), // DateUtil.getToday(), DateUtil.getToday(),contract_id,Tools.formatNumberDoubleTwo(interest.toString()),Tools.formatNumberDoubleTwo(handling.toString()),Tools.formatNumberDoubleTwo(costRate.toString())); // } // if(costMoney_handling.compareTo(BigDecimal.ZERO)==1){ // //借 主营业务成本——租赁成本——手续费支出 // VoucherUtil.DebitCostSharing(listVoucher, "成本均摊", "main_biz_cost_lease_cost_handling_pay", Tools.formatNumberDoubleTwo(costMoney_handling.toString()), // DateUtil.getToday(), DateUtil.getToday(),contract_id,Tools.formatNumberDoubleTwo(interest.toString()),Tools.formatNumberDoubleTwo(handling.toString()),Tools.formatNumberDoubleTwo(costRate.toString())); // //贷 其他应付款-单位 // VoucherUtil.CreditCostSharing(listVoucher, "成本均摊", "other_payables_company", Tools.formatNumberDoubleTwo(costMoney_handling.toString()), // DateUtil.getToday(), DateUtil.getToday(),contract_id,Tools.formatNumberDoubleTwo(interest.toString()),Tools.formatNumberDoubleTwo(handling.toString()),Tools.formatNumberDoubleTwo(costRate.toString())); // // } // // // //System.out.println(costMoney); // //b = b.add(costMoney); // } // } // // voucherToV8Service.saveV8Message(headMap, listVoucher, CurUser, tx); // listVoucher.clear(); // headMap.remove(contract_id); // //System.out.println(b); // conn.close(); // } } //确认收入(分摊) public void createVoucher_confirmincome(String start_time,String end_time,BizObject CurUser, JBOTransaction tx) throws Exception { Map headMap = new HashMap(); headMap.put("moduleName", "确认收入(分摊)"); //查询contract_fund_rent_income表 BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.com.tenwa.rent.entity.rent.CONTRACT_FUND_RENT_INCOME"); BizObjectQuery bq = bm.createQuery("select * from O where accounting_date >= :accounting_date_start and accounting_date <= :accounting_date_end"); bq.setParameter("accounting_date_start", start_time); bq.setParameter("accounting_date_end", end_time); List bos = bq.getResultList(false); List> list = new ArrayList>(); String id = null;//contract_fund_rent_income_temp表的主键id String contract_id = null; String contract_number = null;//业务合同号 BigDecimal interest = BigDecimal.ZERO; String accounting_date = null; Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); String curDate = sdf.format(date); if(bos == null || bos.size() == 0){ return; }else{ for(int i=0;i headMap = new HashMap(); headMap.put("moduleName", "分摊汇总"); //查询voucher_help表 BizObjectManager bm = JBOFactory.getBizObjectManager("jbo.app.VOUCHER_HELP"); BizObjectQuery bq = bm.createQuery("select * from O where date_ >= :date_start and date_ <= :date_end order by fee_type"); bq.setParameter("date_start", start_time); bq.setParameter("date_end", end_time); List bos = bq.getResultList(false); List> list = new ArrayList>(); String id = null;//voucher_help表的主键id String create_voucher_status_id = null;//create_voucher_status的主键id String contract_id = null; String contract_number = null;//业务合同号 String planorincome_id = null;//计划或实收id BigDecimal norminal_price = BigDecimal.ZERO;//留购价 BigDecimal money = BigDecimal.ZERO;//金额 String money_type = null;//金额类型 String fee_type = null;//费用类型 String is_create_voucher = null;//是否生成过凭证 String accounting_date = null; Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); String curDate = sdf.format(date); if(bos == null || bos.size() == 0){ return; }else{ for(int i=0;i= :date_start and accounting_date <= :date_end and fee_type = 'feetype4'"); bq1.setParameter("date_start", start_time); bq1.setParameter("date_end", end_time); List bos1 = bq1.getResultList(false); if(bos1 == null){ return; }else{ for(int i=0;i boList,BizObject CurUser, JBOTransaction tx) throws Exception { BigDecimal totalMoney = BigDecimal.ZERO; String contract_number = null;//业务合同号 String contract_id = null; String str = null; StringBuilder sb = new StringBuilder(); String plan_list = null; BigDecimal rent = BigDecimal.ZERO; BigDecimal interest = BigDecimal.ZERO; BigDecimal taxrate = BigDecimal.ZERO; BigDecimal tax = BigDecimal.ZERO; BigDecimal rate = new BigDecimal(0.17); String hire_object = null; BigDecimal penalty = BigDecimal.ZERO; List> list = new ArrayList>(); String accounting_date = null; Map headMap = new HashMap(); if(boList == null || boList.size() == 0){ return; }else{ for(int i=0;i bos3 = bq3.getResultList(false); int totalList = bos3.size();//总期数 //根据contract_id查询contract_info表的leas_form,这里的contract_id是contract_info表的主键id BizObject bo = JBOFactory.getBizObjectManager("jbo.com.tenwa.entity.contract.CONTRACT_INFO") .createQuery("select * from O where id=:Id") .setParameter("Id", contract_id) .getSingleResult(false); String leas_form = bo.getAttribute("leas_form").toString(); contract_number = bo.getAttribute("contract_number").toString(); str = "第" + totalList + "-" +plan_list; if(sb.length() == 0){ sb.append(str); }else{ sb.append(","+str); } //判断合同为直租还是回租--直租:金额=租金/(1+0.17)*0.17 回租:金额=利息/(1+0.06)*0.06 //直租--RZZL 回租--SHHZ if("RZZL".equals(leas_form)){ taxrate = new BigDecimal(0.17); tax = rent.divide((taxrate.add(new BigDecimal(1))),2).multiply(taxrate); }else if("SHHZ".equals(leas_form)){ taxrate = new BigDecimal(0.06); tax = interest.divide((taxrate.add(new BigDecimal(1))),2).multiply(taxrate); } totalMoney = totalMoney.add(rent).add(penalty); } headMap.put("contract_id",contract_id); headMap.put("moduleName", "批量核销复核"); // 总的借(所有贷之和) // 借:银行存款 VoucherUtil.Debit(list, "收到"+contract_number+sb.toString()+"期租金","cash_in_bank", Tools.formatNumberDoubleTwo(totalMoney.toString()), accounting_date, accounting_date); // 含税金的贷 // 贷:长期应收款-应收融资租赁款 VoucherUtil.Credit(list, "收到"+contract_number+str+"期租金","long_receivable_leasing_money",Tools.formatNumberDoubleTwo(rent.toString()), accounting_date,accounting_date); if(penalty.compareTo(BigDecimal.ZERO) == 1){ // 贷:应收账款 VoucherUtil.Credit(list, hire_object+contract_number+"罚息","account_receivable",Tools.formatNumberDoubleTwo(penalty.toString()), accounting_date,accounting_date); } if(tax.compareTo(BigDecimal.ZERO) == 1){ // 不含税金的借、贷 // 借:未确认融资租赁税金 VoucherUtil.Debit(list, contract_number+"确认销项税","unconfirmed_taxmoney", Tools.formatNumberDoubleTwo(tax.toString()), accounting_date, accounting_date); // 贷:应交税金-应交增值税-销项税 VoucherUtil.Credit(list, contract_number+"确认销项税","tax_payable_substituted_money",Tools.formatNumberDoubleTwo(tax.toString()), accounting_date,accounting_date); } if(penalty.compareTo(BigDecimal.ZERO) == 1){ // 不含税金的借、贷 // 借:应收账款 VoucherUtil.Debit(list, contract_number+"罚息收入确认","account_receivable", Tools.formatNumberDoubleTwo(penalty.toString()), accounting_date, accounting_date); // 贷:主营业务收入-租赁收入 VoucherUtil.Credit(list, contract_number+"罚息收入确认","main_income_leasing_profit",Tools.formatNumberDoubleTwo((penalty.subtract(penalty.divide(rate.add(new BigDecimal(1)),2))).toString()), accounting_date,accounting_date); // 贷:应交税费 VoucherUtil.Credit(list, contract_number+"罚息收入确认","tax_payable",Tools.formatNumberDoubleTwo(penalty.divide(rate.add(new BigDecimal(1)),2).toString()), accounting_date,accounting_date); } voucherToV8Service.saveV8Message(headMap, list, CurUser,tx); } } //定时任务自动合同起租 public void createVoucher_contractonhireauto(List boList,BizObject CurUser,JBOTransaction tx) throws Exception { String id = null;//contract_info表的主键id String contract_number = null;//业务合同号 String flow_unid = null; String leas_form = null;//租赁形式 BigDecimal taxrate = BigDecimal.ZERO; BigDecimal equip_amt = BigDecimal.ZERO;//设备款 BigDecimal return_amt = BigDecimal.ZERO;//返利 BigDecimal norminal_price = BigDecimal.ZERO;//留购款 BigDecimal first_payment = BigDecimal.ZERO;//首付款 BigDecimal handling_charge_money = BigDecimal.ZERO;//手续费 BigDecimal rent_total = BigDecimal.ZERO;//租金总额 BigDecimal interest = BigDecimal.ZERO;//利息 BigDecimal tax = BigDecimal.ZERO;//进项税 BigDecimal lease_property = BigDecimal.ZERO;//融资性租赁财产(倒减) BigDecimal lease_form1_property = BigDecimal.ZERO;//直租--融资租赁财产(倒减) BigDecimal taxMoney = BigDecimal.ZERO;//税金 boolean is_equip_amt = false;//是否设备款 boolean is_return_amt = false;//是否返利 boolean is_norminal_price = false;//是否留购款 boolean is_first_payment = false;//是否首付款 boolean is_handling_charge_money = false; List> list = new ArrayList>(); Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); String accounting_date = sdf.format(date); Map headMap = new HashMap(); if(boList.size() > 0){ for(int i=0;i bos1 = bq1.getResultList(false); if(!(bos1.size() == 0)){ for(int j=0;j bo1 = JBOFactory.getBizObjectManager("jbo.com.tenwa.rent.entity.rent.C1_FUND_RENT_PLAN") .createQuery("select * from O where contract_id=:Contract_id and flow_unid=:Flow_unid") .setParameter("Contract_id", id).setParameter("Flow_unid", flow_unid) .getResultList(false); for(int k=0;k param) { } }