From 4a58f7f3eb13292f2d8032b69dd598e8fc778570 Mon Sep 17 00:00:00 2001 From: yuxueliang0813 <407010292@qq.com> Date: Fri, 9 May 2025 18:29:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E8=B4=A6=E5=A4=84=E7=90=86=E8=B4=A6?= =?UTF-8?q?=E6=89=A3=E5=92=8C=E5=B0=BE=E5=B7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operate/ClearAccountBillOperation.java | 22 ++++++++- .../operate/ClearDetailBillOperation.java | 48 +++++++++++++++---- .../plugin/operate/VoucherAuditOperation.java | 9 +++- .../fi/webapi/PayreceiptQueryControler.java | 1 + 4 files changed, 67 insertions(+), 13 deletions(-) diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearAccountBillOperation.java b/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearAccountBillOperation.java index 84b934b..65eeca1 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearAccountBillOperation.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearAccountBillOperation.java @@ -532,6 +532,7 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//日期格式化工具 String companyCode = prinfo.getDynamicObject("org").getString("number"); DynamicObject customerinfo = prinfo.getDynamicObject("shjh_customer");//客户对象 + String customerCode = customerinfo.getString("number"); IS_HEADER.put("BUKRS",companyCode);//公司代码 IS_HEADER.put("BLART","AB");//凭证类型-清账凭证 //业务日期来源于收款单的流水交易日期,如果日期为空,则使用单据创建日期 @@ -550,8 +551,25 @@ public class ClearAccountBillOperation extends AbstractOperationServicePlugIn im DynamicObject userinfo = BusinessDataServiceHelper.loadSingleFromCache(RequestContext.get().getCurrUserId(), userName); String oauser = userinfo.getString("shjh_oauser"); IS_HEADER.put("USNAM",oauser);//用户名 - //----------------处理详细入参(清账不需要items参数)---------------------- - String customerCode = customerinfo.getString("number"); + //----------------处理详细入参(有账扣或尾差需要items参数)---------------------- + BigDecimal deductionamount = prinfo.getBigDecimal("shjh_deductionamount");//账扣 + BigDecimal diffamount = prinfo.getBigDecimal("shjh_diffamount");//尾差 + if(deductionamount != null && deductionamount.signum() != 0){ + //账扣:1122020700应收账款-集团外-账扣费用(带清账客户往来编码) + JSONObject zkitem = new JSONObject(); + zkitem.put("HKONT", "1122020700");//科目编号 + zkitem.put("KUNNR", customerCode);//客户编号 + zkitem.put("DMBTR", deductionamount.toString());//账扣金额 正数对应借方,负数对应贷方 + IT_ITEM.add(zkitem); + } + if(diffamount != null && diffamount.signum() != 0){ + //尾差:1122020100 应收账款-集团外-产品款(带1001226客户编码) + JSONObject wcitem = new JSONObject(); + wcitem.put("HKONT", "1122020100");//科目编号 + wcitem.put("KUNNR", "1001226");//客户编号 + wcitem.put("DMBTR", diffamount.toString());//尾差金额 正数对应借方,负数对应贷方 + IT_ITEM.add(wcitem); + } // customerCode = "1005004";//上海禾诗家化妆品有限公司 -- 仅测试 //----------------处理清账数据入参---------------------- DynamicObjectCollection docolls = prinfo.getDynamicObjectCollection("shjh_details"); diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearDetailBillOperation.java b/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearDetailBillOperation.java index 94cfff0..c185d3a 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearDetailBillOperation.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/operate/ClearDetailBillOperation.java @@ -65,7 +65,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp // } //校验本次核销金额填写是否有误,防止在正数行填写负数,在负数行中填写正数 if(checkEntryAmount(prinfo)){ - e.setCancelMessage(billno+"分录本次核销金额填写有误,合计等于0,负数金额合计的绝对值小于等于未清金额,才允许提交"); + e.setCancelMessage(billno+"分录本次核销或账扣尾差金额填写有误,合计等于0,分录负数金额合计的绝对值小于等于未清金额,才允许提交"); e.setCancel(true); } //判断对应的清账单是否已提交,如果是,则不允许提交此明细单 @@ -124,6 +124,14 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp } } } + BigDecimal a2 = prinfo.getBigDecimal("shjh_deductionamount");//账扣金额 + BigDecimal a3 = prinfo.getBigDecimal("shjh_diffamount");//尾差金额 + if(a2 != null){ + entrytotal = entrytotal.add(a2); + } + if(a3 != null){ + entrytotal = entrytotal.add(a3); + } if(entrytotal.signum() != 0){ return true; } @@ -214,6 +222,15 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp } } + private DynamicObject getClearEntryInfo(DynamicObjectCollection cleardoc, String detailEntryId){ + for (DynamicObject bankinfo : cleardoc) { + if(detailEntryId.equals(bankinfo.getString("shjh_e_detailentryid"))){ + return bankinfo; + } + } + return null; + } + private String reWriteClearBill(DynamicObject detailBillInfo){ //根据清账明细单反写清账单-新增 String clearBillid = detailBillInfo.getString("shjh_clearbillid"); @@ -230,11 +247,16 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp DynamicObjectCollection detaildoc = detailBillInfo.getDynamicObjectCollection("shjh_details"); //清账单分录 DynamicObjectCollection cleardoc = clearBillInfo.getDynamicObjectCollection("shjh_details"); - DynamicObject detailEntryInfo; - DynamicObject clearEntryInfo; + DynamicObject detailEntryInfo;//清账明细单分录对象 + DynamicObject clearEntryInfo;//清账单分录对象 for (int i = 0; i < detaildoc.size(); i++) { detailEntryInfo = detaildoc.get(i); - clearEntryInfo = cleardoc.addNew(); + //先根据清账单分录集合查找清账单分录对象是否存在,不存在则新增 + clearEntryInfo = getClearEntryInfo(cleardoc,detailEntryInfo.getString("id")); + if(clearEntryInfo == null){ + clearEntryInfo = cleardoc.addNew(); + } + clearEntryInfo.set("shjh_e_pzh",detailEntryInfo.getString("shjh_e_pzh"));//凭证号 clearEntryInfo.set("shjh_e_pzlx",detailEntryInfo.getString("shjh_e_pzlx"));//凭证类型 clearEntryInfo.set("shjh_e_pzhh",detailEntryInfo.getString("shjh_e_pzhh"));//凭证行项目号 @@ -264,7 +286,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp detailBillInfo.getBigDecimal("shjh_diffamount")); clearBillInfo.set("shjh_diffamount",q2); //获取清账单收款金额 - BigDecimal q3 =clearBillInfo.getBigDecimal("shjh_receamount"); + BigDecimal q3 = clearBillInfo.getBigDecimal("shjh_receamount"); //获取清账单的本次核销金额合计 BigDecimal entrytotal = BigDecimal.ZERO; BigDecimal entrynegatetotal = BigDecimal.ZERO;//获取清账单中对应的已认领收款金额 @@ -281,7 +303,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp // } // //已认领收款金额=本次核销金额合计-账扣-尾差 // clearBillInfo.set("shjh_claimamount", entrytotal.subtract(q1).subtract(q2)); - //已认领收款金额 + //已认领收款金额=分录负数金额合计的绝对值 clearBillInfo.set("shjh_claimamount", entrynegatetotal.abs()); //未认领收款金额=收款金额-已认领收款金额 clearBillInfo.set("shjh_unclaimamount", q3.subtract(clearBillInfo.getBigDecimal("shjh_claimamount"))); @@ -320,14 +342,18 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp //清账单分录 DynamicObjectCollection cleardoc = clearBillInfo.getDynamicObjectCollection("shjh_details"); DynamicObject clearEntryInfo; - BigDecimal entrytotal = BigDecimal.ZERO; +// BigDecimal entrytotal = BigDecimal.ZERO; + BigDecimal entrynegatetotal = BigDecimal.ZERO; for (int i = cleardoc.size()-1; i >=0; i--) { clearEntryInfo = cleardoc.get(i); if(idsets.contains(clearEntryInfo.getString("shjh_e_detailentryid"))){ cleardoc.remove(clearEntryInfo); - }else{ - entrytotal = entrytotal.add(clearEntryInfo.getBigDecimal("shjh_e_cursettle"));//累计分录本次核销金额 + }else if(clearEntryInfo.getBigDecimal("shjh_e_cursettle").signum() == -1){ + entrynegatetotal = entrynegatetotal.add(clearEntryInfo.getBigDecimal("shjh_e_cursettle")); } +// else{ +// entrytotal = entrytotal.add(clearEntryInfo.getBigDecimal("shjh_e_cursettle"));//累计分录本次核销金额 +// } } //处理清账单账扣 BigDecimal q1 = JhzjUtils.reduceTwoAmount(clearBillInfo.getBigDecimal("shjh_deductionamount"), @@ -338,7 +364,9 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp detailBillInfo.getBigDecimal("shjh_diffamount")); clearBillInfo.set("shjh_diffamount",q2); //已认领收款金额=本次核销金额合计-账扣-尾差 - clearBillInfo.set("shjh_claimamount", entrytotal.subtract(q1).subtract(q2)); +// clearBillInfo.set("shjh_claimamount", entrytotal.subtract(q1).subtract(q2)); + //已认领收款金额=分录负数金额合计的绝对值 + clearBillInfo.set("shjh_claimamount", entrynegatetotal.abs()); //未认领收款金额=收款金额-已认领收款金额 clearBillInfo.set("shjh_unclaimamount", JhzjUtils.reduceTwoAmount(clearBillInfo.getBigDecimal("shjh_receamount"), clearBillInfo.getBigDecimal("shjh_claimamount"))); diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/operate/VoucherAuditOperation.java b/main/java/shjh/jhzj7/fi/fi/plugin/operate/VoucherAuditOperation.java index fd67f87..5ae743c 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/operate/VoucherAuditOperation.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/operate/VoucherAuditOperation.java @@ -7,7 +7,6 @@ import kd.bos.entity.operate.result.OperateErrorInfo; import kd.bos.entity.operate.result.OperationResult; import kd.bos.entity.plugin.AbstractOperationServicePlugIn; import kd.bos.entity.plugin.args.AfterOperationArgs; -import kd.bos.entity.validate.ErrorLevel; import kd.bos.logging.Log; import kd.bos.logging.LogFactory; import kd.bos.servicehelper.BusinessDataServiceHelper; @@ -58,6 +57,10 @@ public class VoucherAuditOperation extends AbstractOperationServicePlugIn implem logger.info("执行收款单 pushvoucher 成功,单据编号:" + bizbillinfo.getString("billno")); } else { logger.error(operResult.getMessage()); + List allErrorInfo = operResult.getAllErrorInfo(); + for (OperateErrorInfo errorInfo : allErrorInfo) { + this.operationResult.addErrorInfo(errorInfo); + } } }else if(paybillName.equals(sourcebilltype)){ bizbillinfo = BusinessDataServiceHelper.loadSingle(sourcebillid,paybillName); @@ -82,6 +85,10 @@ public class VoucherAuditOperation extends AbstractOperationServicePlugIn implem logger.info("执行预提记账处理单 sendvoucher 成功,单据编号:" + bizbillinfo.getString("billno")); } else { logger.error(operResult.getMessage()); + List allErrorInfo = operResult.getAllErrorInfo(); + for (OperateErrorInfo errorInfo : allErrorInfo) { + this.operationResult.addErrorInfo(errorInfo); + } } } } diff --git a/main/java/shjh/jhzj7/fi/fi/webapi/PayreceiptQueryControler.java b/main/java/shjh/jhzj7/fi/fi/webapi/PayreceiptQueryControler.java index eeeb54b..3b39fd2 100644 --- a/main/java/shjh/jhzj7/fi/fi/webapi/PayreceiptQueryControler.java +++ b/main/java/shjh/jhzj7/fi/fi/webapi/PayreceiptQueryControler.java @@ -79,6 +79,7 @@ public class PayreceiptQueryControler { q1 = addFilterIfNotEmpty(q1, "shjh_fkentryid", fkEntryID);//费控单据分录ID q1 = addFilterIfNotEmpty(q1, "entry.shjh_fkdjbh", fkBillNumber);//费控单据编号-外部系统单号 q1 = addFilterIfNotEmpty(q1, "shjh_credentialnum", voucherNum);//付款凭证号 + q1 = addFilterIfNotEmpty(q1, "shjh_sapfiscalyear", voucherYear);//付款凭证年份 DynamicObject paybill = BusinessDataServiceHelper.loadSingle(paybillName, new QFilter[]{q1}); if (null == paybill) { return handleErrorAndReturn("查询失败:付款单不存在", fkEntryID, jsonBodyString,apiResultExt);