From c937dbc63330117f1e35404d5cb3a23f040429b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sun, 11 Jul 2021 22:27:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8D=95=E6=8D=AE=E5=A4=9A?= =?UTF-8?q?=E8=B4=A6=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsh/erp/constants/ExceptionConstants.java | 4 ++-- .../erp/service/depotHead/DepotHeadService.java | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java index 7b354de1..f25b878e 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java @@ -315,9 +315,9 @@ public class ExceptionConstants { //单据录入-账户不能为空 public static final int DEPOT_HEAD_ACCOUNT_FAILED_CODE = 8500007; public static final String DEPOT_HEAD_ACCOUNT_FAILED_MSG = "结算账户不能为空"; - //单据录入-多账户的金额合计不等于本次付款或本次收款 + //单据录入-请修改多账户的结算金额 public static final int DEPOT_HEAD_MANY_ACCOUNT_FAILED_CODE = 8500008; - public static final String DEPOT_HEAD_MANY_ACCOUNT_FAILED_MSG = "多账户的金额合计不等于本次付款或本次收款"; + public static final String DEPOT_HEAD_MANY_ACCOUNT_FAILED_MSG = "请修改多账户的结算金额"; /** * 单据明细信息 * type = 90 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index 0322654a..45abefcb 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -639,11 +639,11 @@ public class DepotHeadService { depotHead.setAccountIdList(depotHead.getAccountIdList().replace("[", "").replace("]", "").replaceAll("\"", "")); } if(StringUtil.isNotEmpty(depotHead.getAccountMoneyList())) { + //校验多账户的结算金额 String accountMoneyList = depotHead.getAccountMoneyList().replace("[", "").replace("]", "").replaceAll("\"", ""); - //校验多账户的金额合计是否等于本次付款或本次收款 int sum = StringUtil.getArrSum(accountMoneyList.split(",")); - BigDecimal manyAccountSum = BigDecimal.valueOf(sum); - if(manyAccountSum.compareTo(depotHead.getChangeAmount())!=0) { + BigDecimal manyAccountSum = BigDecimal.valueOf(sum).abs(); + if(manyAccountSum.compareTo(depotHead.getChangeAmount().abs())!=0) { throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_MANY_ACCOUNT_FAILED_CODE, String.format(ExceptionConstants.DEPOT_HEAD_MANY_ACCOUNT_FAILED_MSG)); } @@ -712,7 +712,15 @@ public class DepotHeadService { depotHead.setAccountIdList(depotHead.getAccountIdList().replace("[", "").replace("]", "").replaceAll("\"", "")); } if(StringUtil.isNotEmpty(depotHead.getAccountMoneyList())) { - depotHead.setAccountMoneyList(depotHead.getAccountMoneyList().replace("[", "").replace("]", "").replaceAll("\"", "")); + //校验多账户的结算金额 + String accountMoneyList = depotHead.getAccountMoneyList().replace("[", "").replace("]", "").replaceAll("\"", ""); + int sum = StringUtil.getArrSum(accountMoneyList.split(",")); + BigDecimal manyAccountSum = BigDecimal.valueOf(sum).abs(); + if(manyAccountSum.compareTo(depotHead.getChangeAmount().abs())!=0) { + throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_MANY_ACCOUNT_FAILED_CODE, + String.format(ExceptionConstants.DEPOT_HEAD_MANY_ACCOUNT_FAILED_MSG)); + } + depotHead.setAccountMoneyList(accountMoneyList); } try{ depotHeadMapper.updateByPrimaryKeySelective(depotHead);