对公报销冲销数据缺失消息提示

This commit is contained in:
zengweihai 2024-09-28 15:29:03 +08:00
parent 15ce2d2b04
commit a4fd743f93
1 changed files with 30 additions and 16 deletions

View File

@ -107,30 +107,44 @@ public class GenerateSKClickPlugln extends AbstractBillPlugIn implements Plugin
DynamicObject std_entrycostcenter = expenseentry.getDynamicObject("std_entrycostcenter");//获取成本中心 DynamicObject std_entrycostcenter = expenseentry.getDynamicObject("std_entrycostcenter");//获取成本中心
DynamicObject expenseitem = expenseentry.getDynamicObject("expenseitem");//获取费用项目 DynamicObject expenseitem = expenseentry.getDynamicObject("expenseitem");//获取费用项目
BigDecimal expenseamount = expenseentry.getBigDecimal("expenseamount");//获取报销金额 BigDecimal expenseamount = expenseentry.getBigDecimal("expenseamount");//获取报销金额
if (std_entrycostcenter != null && expenseitem != null){//当费用项目和成本中心不为空时 if (std_entrycostcenter != null && expenseitem != null){//当费用明细的费用项目和成本中心不为空时
long ex_centerId = std_entrycostcenter.getLong("id");//成本中心id long ex_centerId = std_entrycostcenter.getLong("id");//成本中心id
long ex_itemId = expenseitem.getLong("id");//费用项目id long ex_itemId = expenseitem.getLong("id");//费用项目id
boolean isSelf = true;//判断该明细是否不存在匹配预付 boolean isSelf = true;//判断该明细是否不存在匹配预付
DynamicObjectCollection writeoffmoney = this.getModel().getEntryEntity("writeoffmoney");//获取冲借款分录 DynamicObjectCollection writeoffmoney = this.getModel().getEntryEntity("writeoffmoney");//获取冲借款分录
for (DynamicObject prepay : writeoffmoney) {//冲借款分录遍历 for (DynamicObject prepay : writeoffmoney) {//冲借款分录遍历
long wr_centerId = prepay.getDynamicObject("std_srcentrycostcenter").getLong("id"); DynamicObject wr_center = prepay.getDynamicObject("std_srcentrycostcenter");//预付成本中心
long wr_itemId = prepay.getDynamicObject("sourceexpenseitem").getLong("id"); DynamicObject wr_item = prepay.getDynamicObject("sourceexpenseitem");//预付费用项目
if (Objects.equals(wr_centerId,ex_centerId) && Objects.equals(wr_itemId,ex_itemId)){//当成本中心和费用项目一致时计算冲销后金额 if(wr_center != null && wr_item != null){
BigDecimal loanamount = prepay.getBigDecimal("loanamount");//获取冲销金额 long wr_centerId = prepay.getDynamicObject("std_srcentrycostcenter").getLong("id");
if (loanamount != null){ long wr_itemId = prepay.getDynamicObject("sourceexpenseitem").getLong("id");
int i = loanamount.compareTo(expenseamount); if (Objects.equals(wr_centerId,ex_centerId) && Objects.equals(wr_itemId,ex_itemId)){//当成本中心和费用项目一致时计算冲销后金额
if (i > 0){//若预付明细的借款余额大于报销金额则冲销后金额为0 BigDecimal loanamount = prepay.getBigDecimal("loanamount");//获取冲销金额
expenseentry.set("shkd_verification",BigDecimal.ZERO); if (loanamount != null){
}else {//冲销后金额 = 报销金额 - 借款金额 int i = loanamount.compareTo(expenseamount);
BigDecimal subtract = expenseamount.subtract(loanamount); if (i > 0){//若预付明细的借款余额大于报销金额则冲销后金额为0
expenseentry.set("shkd_verification",subtract); expenseentry.set("shkd_verification",BigDecimal.ZERO);
}else {//冲销后金额 = 报销金额 - 借款金额
BigDecimal subtract = expenseamount.subtract(loanamount);
expenseentry.set("shkd_verification",subtract);
}
}else {//若预付明细的借款余额为空则冲销后金额为费用明细报销金额本身
expenseentry.set("shkd_verification",expenseamount);
} }
}else {//若预付明细的借款余额为空则冲销后金额为费用明细报销金额本身 isSelf = false;//找到匹配预付
expenseentry.set("shkd_verification",expenseamount); break;
} }
isSelf = false;//找到匹配预付 }else {
break; if(wr_center == null && wr_item == null){
this.getView().showTipNotification("冲预付分录成本中心和费用项目不能为空!");
}else if (wr_center == null){
this.getView().showTipNotification("冲预付分录成本中心不能为空!");
}else {
this.getView().showTipNotification("冲预付分录费用项目不能为空!");
}
} }
} }
if (isSelf){//找不到匹配预付则冲销后金额为费用明细报销金额本身 if (isSelf){//找不到匹配预付则冲销后金额为费用明细报销金额本身
expenseentry.set("shkd_verification",expenseamount); expenseentry.set("shkd_verification",expenseamount);