借款单优化备用金额逻辑
This commit is contained in:
parent
ed40a8dd8b
commit
995be21b22
|
@ -91,23 +91,33 @@ public class DailyLoanBillSubValidatorOp extends AbstractOperationServicePlugIn
|
||||||
this.addFatalErrorMessage(dataEnt, "您在定额备用金初始化台账里,所以不能使用临时备用金!!");
|
this.addFatalErrorMessage(dataEnt, "您在定额备用金初始化台账里,所以不能使用临时备用金!!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QFilter filter1 = new QFilter("balanceamount", QCP.not_equals, 0);
|
QFilter filter1 = new QFilter("balanceamount", QCP.not_equals, 0);//借款余额
|
||||||
|
filter.and(new QFilter("applier", QCP.equals, applier.getPkValue()));//申请人
|
||||||
DynamicObject er_dailyLoanBill1 = BusinessDataServiceHelper.loadSingle("er_dailyloanbill",
|
DynamicObject er_dailyLoanBill1 = BusinessDataServiceHelper.loadSingle("er_dailyloanbill",
|
||||||
"id", new QFilter[]{filter1});//定额备用金初始台账
|
"id", new QFilter[]{filter1});//借款单
|
||||||
if (er_dailyLoanBill1 != null){
|
if (er_dailyLoanBill1 != null) {
|
||||||
this.addFatalErrorMessage(dataEnt, "您存在未还完的借款!!");
|
this.addFatalErrorMessage(dataEnt, "您存在未还完的借款!!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (impRestType.equals("2")) {
|
} else if (impRestType.equals("2")) {
|
||||||
//项目筹备备用金
|
//项目筹备备用金
|
||||||
QFilter filter = new QFilter("zcgj_entryentity.zcgj_person", QCP.equals, applier.getPkValue());// 可借款人员
|
BigDecimal loanAmount = er_dailyLoanBill.getBigDecimal("loanamount");//借款金额合计
|
||||||
filter.and(new QFilter("zcgj_entryentity.zcgj_isenabled", QCP.equals, true));// 启用
|
|
||||||
filter.and(new QFilter("zcgj_entryentity.zcgj_company", QCP.equals, companyId));// 公司
|
QFilter filter = new QFilter("zcgj_entryentity.zcgj_person", QCP.equals, applier.getPkValue());// 人员
|
||||||
DynamicObject projectReserveFund = BusinessDataServiceHelper.loadSingle("zcgj_projectreservefund",
|
filter.and(new QFilter("zcgj_currentyear", QCP.equals, bizDateYear));//年度
|
||||||
"id", new QFilter[]{filter});//项目筹备备用金公司
|
filter.and(new QFilter("zcgj_persons.fbasedataid", QCP.in, applier.getPkValue()));//项目筹备备用金借款人
|
||||||
if (projectReserveFund == null) {
|
DynamicObject quotaImprestLedger = BusinessDataServiceHelper.loadSingle("zcgj_quotaimprestledger", new QFilter[]{filter});//定额备用金初始台账
|
||||||
this.addFatalErrorMessage(dataEnt, "您未在项目筹备备用金公司里,所以不能使用项目筹备备用金!!");
|
DynamicObjectCollection entryEntityCollection = quotaImprestLedger.getDynamicObjectCollection("zcgj_entryentity");//分录
|
||||||
return;
|
for (DynamicObject entryEntity : entryEntityCollection) {
|
||||||
|
DynamicObject person = entryEntity.getDynamicObject("zcgj_person");//人员
|
||||||
|
DynamicObject zcgj_personType = entryEntity.getDynamicObject("zcgj_persontype");//人员类型
|
||||||
|
if (person.getPkValue().equals(applier.getPkValue()) && zcgj_personType != null && zcgj_personType.getString("number").equals("项目筹备")) {
|
||||||
|
BigDecimal zcgj_remainingquota = entryEntity.getBigDecimal("zcgj_remainingquota");//剩余额度
|
||||||
|
if (zcgj_remainingquota.compareTo(loanAmount) < 0) {
|
||||||
|
this.addFatalErrorMessage(dataEnt, "借款金额超过剩余额度!!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,12 @@ public class LoanSlipReserveFundReverserOp extends AbstractOperationServicePlugI
|
||||||
BigDecimal loanAmount = er_dailyLoanBill.getBigDecimal("loanamount");//借款金额合计
|
BigDecimal loanAmount = er_dailyLoanBill.getBigDecimal("loanamount");//借款金额合计
|
||||||
LocalDate localDate = bizDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
LocalDate localDate = bizDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||||
String bizDateYear = String.valueOf(localDate.getYear());//申请日期年份
|
String bizDateYear = String.valueOf(localDate.getYear());//申请日期年份
|
||||||
QFilter filter = new QFilter("zcgj_entryentity.zcgj_person", QCP.equals, applier.getPkValue());
|
QFilter filter = new QFilter("zcgj_entryentity.zcgj_person", QCP.equals, applier.getPkValue());// 人员
|
||||||
filter.and(new QFilter("zcgj_currentyear", QCP.equals, bizDateYear));
|
filter.and(new QFilter("zcgj_currentyear", QCP.equals, bizDateYear));//年度
|
||||||
DynamicObject quotaImprestLedger = BusinessDataServiceHelper.loadSingle("zcgj_quotaimprestledger", new QFilter[]{filter});//定额备用金初始台账
|
DynamicObject quotaImprestLedger = BusinessDataServiceHelper.loadSingle("zcgj_quotaimprestledger", new QFilter[]{filter});//定额备用金初始台账
|
||||||
|
if (quotaImprestLedger == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
DynamicObjectCollection entryEntityCollection = quotaImprestLedger.getDynamicObjectCollection("zcgj_entryentity");//分录
|
DynamicObjectCollection entryEntityCollection = quotaImprestLedger.getDynamicObjectCollection("zcgj_entryentity");//分录
|
||||||
for (DynamicObject entryEntity : entryEntityCollection) {
|
for (DynamicObject entryEntity : entryEntityCollection) {
|
||||||
DynamicObject person = entryEntity.getDynamicObject("zcgj_person");//人员
|
DynamicObject person = entryEntity.getDynamicObject("zcgj_person");//人员
|
||||||
|
@ -67,7 +70,7 @@ public class LoanSlipReserveFundReverserOp extends AbstractOperationServicePlugI
|
||||||
//撤销、反审核
|
//撤销、反审核
|
||||||
BigDecimal zcgj_usedquota = entryEntity.getBigDecimal("zcgj_usedquota").subtract(er_dailyLoanBill.getBigDecimal("loanamount"));//已使用+借款金额
|
BigDecimal zcgj_usedquota = entryEntity.getBigDecimal("zcgj_usedquota").subtract(er_dailyLoanBill.getBigDecimal("loanamount"));//已使用+借款金额
|
||||||
entryEntity.set("zcgj_usedquota", zcgj_usedquota);//已使用
|
entryEntity.set("zcgj_usedquota", zcgj_usedquota);//已使用
|
||||||
BigDecimal zcgj_remainingquota = entryEntity.getBigDecimal("zcgj_quota").add(entryEntity.getBigDecimal("zcgj_usedquota"));//额度-已使用
|
BigDecimal zcgj_remainingquota = entryEntity.getBigDecimal("zcgj_quota").subtract(entryEntity.getBigDecimal("zcgj_usedquota"));//额度-已使用
|
||||||
entryEntity.set("zcgj_remainingquota", zcgj_remainingquota);//剩余额度
|
entryEntity.set("zcgj_remainingquota", zcgj_remainingquota);//剩余额度
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -76,9 +79,44 @@ public class LoanSlipReserveFundReverserOp extends AbstractOperationServicePlugI
|
||||||
modifiedEntities.add(quotaImprestLedger);
|
modifiedEntities.add(quotaImprestLedger);
|
||||||
}/* else if (impRestType.equals("1")) {
|
}/* else if (impRestType.equals("1")) {
|
||||||
//临时备用金
|
//临时备用金
|
||||||
} else if (impRestType.equals("2")) {
|
}*/ else if (impRestType.equals("2")) {
|
||||||
//项目筹备备用金
|
//项目筹备备用金
|
||||||
}*/
|
DynamicObject applier = er_dailyLoanBill.getDynamicObject("applier");//申请人
|
||||||
|
Date bizDate = er_dailyLoanBill.getDate("bizdate");//申请日期
|
||||||
|
BigDecimal loanAmount = er_dailyLoanBill.getBigDecimal("loanamount");//借款金额合计
|
||||||
|
LocalDate localDate = bizDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||||
|
String bizDateYear = String.valueOf(localDate.getYear());//申请日期年份
|
||||||
|
QFilter filter = new QFilter("zcgj_entryentity.zcgj_person", QCP.equals, applier.getPkValue());// 人员
|
||||||
|
filter.and(new QFilter("zcgj_currentyear", QCP.equals, bizDateYear));//年度
|
||||||
|
filter.and(new QFilter("zcgj_persons.fbasedataid", QCP.in, applier.getPkValue()));//项目筹备备用金借款人
|
||||||
|
DynamicObject quotaImprestLedger = BusinessDataServiceHelper.loadSingle("zcgj_quotaimprestledger", new QFilter[]{filter});//定额备用金初始台账
|
||||||
|
if (quotaImprestLedger == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DynamicObjectCollection entryEntityCollection = quotaImprestLedger.getDynamicObjectCollection("zcgj_entryentity");//分录
|
||||||
|
for (DynamicObject entryEntity : entryEntityCollection) {
|
||||||
|
DynamicObject person = entryEntity.getDynamicObject("zcgj_person");//人员
|
||||||
|
DynamicObject zcgj_personType = entryEntity.getDynamicObject("zcgj_persontype");//人员类型
|
||||||
|
if (person.getPkValue().equals(applier.getPkValue()) && zcgj_personType != null && zcgj_personType.getString("number").equals("项目筹备")) {
|
||||||
|
if (operationKey.equals("submit")) {
|
||||||
|
//提交
|
||||||
|
BigDecimal zcgj_usedquota = entryEntity.getBigDecimal("zcgj_usedquota").add(loanAmount);//已使用+借款金额
|
||||||
|
entryEntity.set("zcgj_usedquota", zcgj_usedquota);//已使用
|
||||||
|
BigDecimal zcgj_quota = entryEntity.getBigDecimal("zcgj_quota");//额度
|
||||||
|
BigDecimal zcgj_remainingquota = zcgj_quota.subtract(entryEntity.getBigDecimal("zcgj_usedquota"));//额度-已使用
|
||||||
|
entryEntity.set("zcgj_remainingquota", zcgj_remainingquota);//剩余额度
|
||||||
|
} else if (operationKey.equals("unsubmit") || operationKey.equals("unaudit")) {
|
||||||
|
//撤销、反审核
|
||||||
|
BigDecimal zcgj_usedquota = entryEntity.getBigDecimal("zcgj_usedquota").subtract(er_dailyLoanBill.getBigDecimal("loanamount"));//已使用+借款金额
|
||||||
|
entryEntity.set("zcgj_usedquota", zcgj_usedquota);//已使用
|
||||||
|
BigDecimal zcgj_remainingquota = entryEntity.getBigDecimal("zcgj_quota").subtract(entryEntity.getBigDecimal("zcgj_usedquota"));//额度-已使用
|
||||||
|
entryEntity.set("zcgj_remainingquota", zcgj_remainingquota);//剩余额度
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modifiedEntities.add(quotaImprestLedger);
|
||||||
|
}
|
||||||
if (!modifiedEntities.isEmpty()) {
|
if (!modifiedEntities.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
SaveServiceHelper.save(modifiedEntities.toArray(new DynamicObject[0]));
|
SaveServiceHelper.save(modifiedEntities.toArray(new DynamicObject[0]));
|
||||||
|
|
Loading…
Reference in New Issue