package com.tenwa.flow.fund.flowpayment; import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; import jbo.app.tenwa.calc.LC_FUND_INCOME; import jbo.app.tenwa.calc.LC_FUND_INCOME_TEMP; import jbo.app.tenwa.calc.LC_FUND_PLAN; import jbo.app.tenwa.calc.VI_LC_FUND_PLAN; import jbo.com.tenwa.lease.comm.LC_PAY_CONDTION; import jbo.com.tenwa.lease.comm.LC_PAY_CONDTION_TEMP; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.are.util.StringFunction; import com.tenwa.comm.util.jboutil.DataOperatorUtil; import com.tenwa.lease.flow.comm.service.LeaseFlowBaseService; import com.tenwa.lease.flow.comm.service.ServiceOperatorEnum; import com.tenwa.lease.flow.comm.serviceImp.LeaseFlowBaseServiceImp; import com.tenwa.reckon.util.UUIDUtil; public class FundPayment { private String fundList; private String flowunid; private String equipOverMoney; private String equipAMTID; private String userId; private String orgId; private String planids; private String overmoneys; private String factmoneys; private String feeadjusts; private String returnID; public String getReturnID() { return returnID; } public void setReturnID(String returnID) { this.returnID = returnID; } public String getFactmoneys() { return factmoneys; } public void setFactmoneys(String factmoneys) { this.factmoneys = factmoneys; } public String getFeeadjusts() { return feeadjusts; } public void setFeeadjusts(String feeadjusts) { this.feeadjusts = feeadjusts; } public String getPlanids() { return planids; } public void setPlanids(String planids) { this.planids = planids; } public String getOvermoneys() { return overmoneys; } public void setOvermoneys(String overmoneys) { this.overmoneys = overmoneys; } public String getUserId() { return userId; } public void setUserId(String userId) { this.userId = userId; } public String getOrgId() { return orgId; } public void setOrgId(String orgId) { this.orgId = orgId; } public String getEquipAMTID() { return equipAMTID; } public void setEquipAMTID(String equipAMTID) { this.equipAMTID = equipAMTID; } public String getEquipOverMoney() { return equipOverMoney; } public void setEquipOverMoney(String equipOverMoney) { this.equipOverMoney = equipOverMoney; } public String getFlowunid() { return flowunid; } public void setFlowunid(String flowunid) { this.flowunid = flowunid; } public String getFundList() { return fundList; } public void setFundList(String fundList) { this.fundList = fundList; } public String setDeductMoney(JBOTransaction tx) throws Exception{ try{ BizObject boLFPAMT = JBOFactory.createBizObjectQuery(LC_FUND_PLAN.CLASS_NAME, "id=:id").setParameter("id", equipAMTID).getSingleResult(false); BizObjectManager bomLFIT = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME); String incomeID = UUIDUtil.getUUID(); BigDecimal outOverMoney = new BigDecimal(equipOverMoney); tx.join(bomLFIT); String[] funds = fundList.split("@~"); BigDecimal deductMoney = new BigDecimal(0); for(int i=0;i boLCFI = JBOFactory.createBizObjectQuery(LC_FUND_INCOME.CLASS_NAME, "PLAN_ID=:PLAN_ID and ROLL_BACK='0' and PAY_STATUS<>'apply_return'").setParameter("PLAN_ID", planID) .getResultList(false); List boLCFIT = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and pay_type='pay_type_out' and IS_FLOWING = '0' and ROLL_BACK='0' and PAY_STATUS is null").setParameter("PLAN_ID", planID) .getResultList(false); boLFITOut.setAttributeValue("CHARGE_LIST", boLCFI.size()+boLCFIT.size()+1); boLFITOut.setAttributeValue("FACT_DATE", boLFPAMT.getAttribute("PLAN_DATE").getString()); boLFITOut.setAttributeValue("FACT_MONEY", inOvermoney); boLFITOut.setAttributeValue("FEE_ADJUST", 0); //boLFITOut.setAttributeValue("FACT_OBJECT", boLFPAMT.getAttribute("PAY_OBJ").getString()); boLFITOut.setAttributeValue("APPLYPAY_DATE", boLFP.getAttribute("PLAN_DATE").getString()); boLFITOut.setAttributeValue("APPLY_PERSON", userId); boLFITOut.setAttributeValue("APPLY_DEPT", orgId); boLFITOut.setAttributeValue("MEMO", "µÖ¿ÛÉ豸¿î"); boLFITOut.setAttributeValue("ROLL_BACK", 0); boLFITOut.setAttributeValue("FLOWUNID", flowunid); boLFITOut.setAttributeValue("IS_FLOWING", 0); bomLFIT.saveObject(boLFITOut); BizObject boLFITIn = bomLFIT.newObject(); boLFITIn.setAttributeValue("QUOT_ID", boLFP.getAttribute("QUOT_ID").getString()); boLFITIn.setAttributeValue("CUST_ID", boLFP.getAttribute("CUST_ID").getString()); boLFITIn.setAttributeValue("PROJECT_ID", boLFP.getAttribute("PROJECT_ID").getString()); boLFITIn.setAttributeValue("RELATIVE_ID", incomeID); boLFITIn.setAttributeValue("PROJECT_PLAN_NUMBER", boLFP.getAttribute("PROJECT_PLAN_NUMBER").getString()); boLFITIn.setAttributeValue("CONTRACT_ID", boLFP.getAttribute("CONTRACT_ID").getString()); boLFITIn.setAttributeValue("CONTRACT_PLAN_NUMBER", boLFP.getAttribute("CONTRACT_PLAN_NUMBER").getString()); boLFITIn.setAttributeValue("PAYMENT_NUMBER", boLFP.getAttribute("PAYMENT_NUMBER").getString()); boLFITIn.setAttributeValue("PLAN_ID", planID); boLFITIn.setAttributeValue("PLAN_LIST", boLFP.getAttribute("PLAN_LIST").getString()); boLFITIn.setAttributeValue("PAY_TYPE", boLFP.getAttribute("PAY_TYPE").getString()); boLFITIn.setAttributeValue("FEE_TYPE", boLFP.getAttribute("FEE_TYPE").getString()); boLFITIn.setAttributeValue("SETTLE_METHOD", "settlemethod11"); boLCFI = JBOFactory.createBizObjectQuery(LC_FUND_INCOME.CLASS_NAME, "PLAN_ID=:PLAN_ID and ROLL_BACK='0' and PAY_STATUS<>'apply_return'").setParameter("PLAN_ID", planID) .getResultList(false); boLCFIT = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and IS_FLOWING = '0' and pay_type='pay_type_in' and ROLL_BACK='0' and PAY_STATUS is null").setParameter("PLAN_ID", planID) .getResultList(false); boLFITIn.setAttributeValue("CHARGE_LIST", boLCFI.size()+boLCFIT.size()+1); boLFITIn.setAttributeValue("FACT_DATE", boLFPAMT.getAttribute("PLAN_DATE").getString()); boLFITIn.setAttributeValue("FACT_MONEY", inOvermoney); boLFITIn.setAttributeValue("FEE_ADJUST", 0); //boLFITIn.setAttributeValue("FACT_OBJECT", boLFP.getAttribute("PAY_OBJ").getString()); boLFITIn.setAttributeValue("ROLL_BACK", 0); boLFITIn.setAttributeValue("FLOWUNID", flowunid); boLFITIn.setAttributeValue("IS_FLOWING", 0); bomLFIT.saveObject(boLFITIn); } BizObject boEquipAmt = bomLFIT.newObject(); boEquipAmt.setAttributeValue("ID", incomeID); boEquipAmt.setAttributeValue("QUOT_ID", boLFPAMT.getAttribute("QUOT_ID").getString()); boEquipAmt.setAttributeValue("CUST_ID", boLFPAMT.getAttribute("CUST_ID").getString()); boEquipAmt.setAttributeValue("PROJECT_ID", boLFPAMT.getAttribute("PROJECT_ID").getString()); boEquipAmt.setAttributeValue("PROJECT_PLAN_NUMBER", boLFPAMT.getAttribute("PROJECT_PLAN_NUMBER").getString()); boEquipAmt.setAttributeValue("CONTRACT_ID", boLFPAMT.getAttribute("CONTRACT_ID").getString()); boEquipAmt.setAttributeValue("CONTRACT_PLAN_NUMBER", boLFPAMT.getAttribute("CONTRACT_PLAN_NUMBER").getString()); boEquipAmt.setAttributeValue("PAYMENT_NUMBER", boLFPAMT.getAttribute("PAYMENT_NUMBER").getString()); boEquipAmt.setAttributeValue("PLAN_ID", equipAMTID); boEquipAmt.setAttributeValue("PLAN_LIST", boLFPAMT.getAttribute("PLAN_LIST").getString()); //boEquipAmt.setAttributeValue("FACT_OBJECT", boLFPAMT.getAttribute("PAY_OBJ").getString()); boEquipAmt.setAttributeValue("APPLYPAY_DATE", boLFPAMT.getAttribute("PLAN_DATE").getString()); boEquipAmt.setAttributeValue("APPLY_PERSON", userId); boEquipAmt.setAttributeValue("APPLY_DEPT", orgId); boEquipAmt.setAttributeValue("PAY_TYPE", boLFPAMT.getAttribute("PAY_TYPE").getString()); boEquipAmt.setAttributeValue("FEE_TYPE", boLFPAMT.getAttribute("FEE_TYPE").getString()); boEquipAmt.setAttributeValue("SETTLE_METHOD", "settlemethod6"); List boLCFI = JBOFactory.createBizObjectQuery(LC_FUND_INCOME.CLASS_NAME, "PLAN_ID=:PLAN_ID and ROLL_BACK='0' and PAY_STATUS<>'apply_return'").setParameter("PLAN_ID", equipAMTID) .getResultList(false); List boLCFIT = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and IS_FLOWING = '0' and ROLL_BACK='0' and PAY_STATUS is null").setParameter("PLAN_ID", equipAMTID) .getResultList(false); boEquipAmt.setAttributeValue("CHARGE_LIST", boLCFI.size()+boLCFIT.size()+1); boEquipAmt.setAttributeValue("FACT_DATE", boLFPAMT.getAttribute("PLAN_DATE").getString()); boEquipAmt.setAttributeValue("FACT_MONEY", new BigDecimal(equipOverMoney).subtract(deductMoney)); boEquipAmt.setAttributeValue("FEE_ADJUST", 0); //boEquipAmt.setAttributeValue("FACT_OBJECT", boLFPAMT.getAttribute("PAY_OBJ").getString()); boEquipAmt.setAttributeValue("ROLL_BACK", 0); boEquipAmt.setAttributeValue("FLOWUNID", flowunid); boEquipAmt.setAttributeValue("IS_FLOWING", 0); bomLFIT.saveObject(boEquipAmt); Map fromCondtion = new HashMap<>(); fromCondtion.put("PAYMENT_NUMBER", boLFPAMT.getAttribute("PAYMENT_NUMBER").getString()); fromCondtion.put("FEE_TYPE", boLFPAMT.getAttribute("FEE_TYPE").getString()); fromCondtion.put("PLAN_LIST", boLFPAMT.getAttribute("PLAN_LIST").getString()); Map otherProperty = new HashMap<>(); otherProperty.put("FLOWUNID", flowunid); DataOperatorUtil.copyJBOSet(LC_PAY_CONDTION.CLASS_NAME, fromCondtion,LC_PAY_CONDTION_TEMP.CLASS_NAME, null, otherProperty,null, tx); }catch(Exception e){ e.printStackTrace(); return "ERROR"; } return "SUCCESS"; } public String setEquipAMTPayment(JBOTransaction tx) throws Exception{ try{ BizObject boLFPAMT = JBOFactory.createBizObjectQuery(LC_FUND_PLAN.CLASS_NAME, "id=:id").setParameter("id", equipAMTID).getSingleResult(false); BizObjectManager bomLFIT = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME); tx.join(bomLFIT); BizObject boEquipAmt = bomLFIT.newObject(); boEquipAmt.setAttributeValue("QUOT_ID", boLFPAMT.getAttribute("QUOT_ID").getString()); boEquipAmt.setAttributeValue("CUST_ID", boLFPAMT.getAttribute("CUST_ID").getString()); boEquipAmt.setAttributeValue("PROJECT_ID", boLFPAMT.getAttribute("PROJECT_ID").getString()); boEquipAmt.setAttributeValue("PROJECT_PLAN_NUMBER", boLFPAMT.getAttribute("PROJECT_PLAN_NUMBER").getString()); boEquipAmt.setAttributeValue("CONTRACT_ID", boLFPAMT.getAttribute("CONTRACT_ID").getString()); boEquipAmt.setAttributeValue("CONTRACT_PLAN_NUMBER", boLFPAMT.getAttribute("CONTRACT_PLAN_NUMBER").getString()); boEquipAmt.setAttributeValue("PAYMENT_NUMBER", boLFPAMT.getAttribute("PAYMENT_NUMBER").getString()); boEquipAmt.setAttributeValue("PLAN_ID", equipAMTID); boEquipAmt.setAttributeValue("PLAN_LIST", boLFPAMT.getAttribute("PLAN_LIST").getString()); //boEquipAmt.setAttributeValue("FACT_OBJECT", boLFPAMT.getAttribute("PAY_OBJ").getString()); boEquipAmt.setAttributeValue("APPLYPAY_DATE", boLFPAMT.getAttribute("PLAN_DATE").getString()); boEquipAmt.setAttributeValue("APPLY_PERSON", userId); boEquipAmt.setAttributeValue("APPLY_DEPT", orgId); boEquipAmt.setAttributeValue("PAY_TYPE", boLFPAMT.getAttribute("PAY_TYPE").getString()); boEquipAmt.setAttributeValue("FEE_TYPE", boLFPAMT.getAttribute("FEE_TYPE").getString()); boEquipAmt.setAttributeValue("SETTLE_METHOD", "settlemethod6"); List boLCFI = JBOFactory.createBizObjectQuery(LC_FUND_INCOME.CLASS_NAME, "PLAN_ID=:PLAN_ID and ROLL_BACK='0' and PAY_STATUS<>'apply_return'").setParameter("PLAN_ID", equipAMTID) .getResultList(false); List boLCFIT = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and IS_FLOWING = '0' and ROLL_BACK='0' and PAY_STATUS is null").setParameter("PLAN_ID", equipAMTID) .getResultList(false); boEquipAmt.setAttributeValue("CHARGE_LIST", boLCFI.size()+boLCFIT.size()+1); boEquipAmt.setAttributeValue("FACT_DATE", boLFPAMT.getAttribute("PLAN_DATE").getString()); boEquipAmt.setAttributeValue("FACT_MONEY", new BigDecimal(equipOverMoney)); boEquipAmt.setAttributeValue("FEE_ADJUST", 0); //boEquipAmt.setAttributeValue("FACT_OBJECT", boLFPAMT.getAttribute("PAY_OBJ").getString()); boEquipAmt.setAttributeValue("ROLL_BACK", 0); boEquipAmt.setAttributeValue("FLOWUNID", flowunid); boEquipAmt.setAttributeValue("IS_FLOWING", 0); bomLFIT.saveObject(boEquipAmt); Map fromCondtion = new HashMap<>(); fromCondtion.put("PAYMENT_NUMBER", boLFPAMT.getAttribute("PAYMENT_NUMBER").getString()); fromCondtion.put("FEE_TYPE", boLFPAMT.getAttribute("FEE_TYPE").getString()); fromCondtion.put("PLAN_LIST", boLFPAMT.getAttribute("PLAN_LIST").getString()); Map otherProperty = new HashMap<>(); otherProperty.put("FLOWUNID", flowunid); DataOperatorUtil.copyJBOSet(LC_PAY_CONDTION.CLASS_NAME, fromCondtion,LC_PAY_CONDTION_TEMP.CLASS_NAME, null, otherProperty,null, tx); }catch(Exception e){ e.printStackTrace(); return "ERROR"; } return "SUCCESS"; } public String setFundPayment(JBOTransaction tx) throws Exception{ try{ String[] ids = planids.split("@"); String[] moneys = overmoneys.split("@"); for(int i=0;i boLCFI = JBOFactory.createBizObjectQuery(LC_FUND_INCOME.CLASS_NAME, "PLAN_ID=:PLAN_ID and ROLL_BACK='0' and PAY_STATUS<>'apply_return'").setParameter("PLAN_ID", ids[i]) .getResultList(false); List boLCFIT = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and IS_FLOWING = '0' and ROLL_BACK='0' and PAY_STATUS is null").setParameter("PLAN_ID", ids[i]) .getResultList(false); boLFI.setAttributeValue("CHARGE_LIST", boLCFI.size()+boLCFIT.size()+1); boLFI.setAttributeValue("FACT_DATE", boLFP.getAttribute("PLAN_DATE").getString()); boLFI.setAttributeValue("FACT_MONEY", new BigDecimal(moneys[i])); boLFI.setAttributeValue("FEE_ADJUST", 0); //boLFI.setAttributeValue("FACT_OBJECT", boLFP.getAttribute("PAY_OBJ").getString()); boLFI.setAttributeValue("ROLL_BACK", 0); boLFI.setAttributeValue("FLOWUNID", flowunid); boLFI.setAttributeValue("IS_FLOWING", 0); bomLFIT.saveObject(boLFI); Map fromCondtion = new HashMap<>(); fromCondtion.put("PAYMENT_NUMBER", boLFP.getAttribute("PAYMENT_NUMBER").getString()); fromCondtion.put("FEE_TYPE", boLFP.getAttribute("FEE_TYPE").getString()); fromCondtion.put("PLAN_LIST", boLFP.getAttribute("PLAN_LIST").getString()); Map otherProperty = new HashMap<>(); otherProperty.put("FLOWUNID", flowunid); DataOperatorUtil.copyJBOSet(LC_PAY_CONDTION.CLASS_NAME, fromCondtion,LC_PAY_CONDTION_TEMP.CLASS_NAME, null, otherProperty,null, tx); } }catch(Exception e){ e.printStackTrace(); return "ERROR"; } return "SUCCESS"; } public String updateRelativeData(JBOTransaction tx){ try{ String[] ids = planids.split("¡÷"); String[] fmoneys = factmoneys.split("¡÷"); String[] fadjusts = feeadjusts.split("¡÷"); BizObjectManager bomLFIT = JBOFactory.getBizObjectManager(LC_FUND_INCOME_TEMP.CLASS_NAME); tx.join(bomLFIT); for(int i=0;i boLCFI = JBOFactory.createBizObjectQuery(LC_FUND_INCOME.CLASS_NAME, "PLAN_ID=:PLAN_ID and ROLL_BACK='0' and PAY_STATUS<>'apply_return'").setParameter("PLAN_ID", equipAMTID) .getResultList(false); List boLCFIT = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and IS_FLOWING = '0' and ROLL_BACK='0' and PAY_STATUS is null").setParameter("PLAN_ID", equipAMTID) .getResultList(false); boLFIT.setAttributeValue("CHARGE_LIST", boLCFI.size()+boLCFIT.size()+1); boLFIT.setAttributeValue("FACT_DATE", StringFunction.getToday()); boLFIT.setAttributeValue("ACCOUNTING_DATE", StringFunction.getToday()); boLFIT.setAttributeValue("FACT_MONEY", new BigDecimal(bo.getAttribute("OVERMONEY").getString())); boLFIT.setAttributeValue("FEE_ADJUST", 0); //boLFIT.setAttributeValue("FACT_OBJECT", boLFP.getAttribute("PAY_OBJ").getString()); boLFIT.setAttributeValue("ROLL_BACK", 0); boLFIT.setAttributeValue("FLOWUNID", flowunid); boLFIT.setAttributeValue("IS_FLOWING", 0); bomLFIT.saveObject(boLFIT); } } }catch(Exception e){ e.printStackTrace(); return "ERROR"; } return "SUCCESS"; } }