优化单据多账户

This commit is contained in:
季圣华
2021-07-11 22:27:55 +08:00
parent fc03578d23
commit c937dbc633
2 changed files with 14 additions and 6 deletions

View File

@@ -315,9 +315,9 @@ public class ExceptionConstants {
//单据录入-账户不能为空 //单据录入-账户不能为空
public static final int DEPOT_HEAD_ACCOUNT_FAILED_CODE = 8500007; public static final int DEPOT_HEAD_ACCOUNT_FAILED_CODE = 8500007;
public static final String DEPOT_HEAD_ACCOUNT_FAILED_MSG = "结算账户不能为空"; public static final String DEPOT_HEAD_ACCOUNT_FAILED_MSG = "结算账户不能为空";
//单据录入-多账户的金额合计不等于本次付款或本次收款 //单据录入-请修改多账户的结算金额
public static final int DEPOT_HEAD_MANY_ACCOUNT_FAILED_CODE = 8500008; 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 * type = 90

View File

@@ -639,11 +639,11 @@ public class DepotHeadService {
depotHead.setAccountIdList(depotHead.getAccountIdList().replace("[", "").replace("]", "").replaceAll("\"", "")); depotHead.setAccountIdList(depotHead.getAccountIdList().replace("[", "").replace("]", "").replaceAll("\"", ""));
} }
if(StringUtil.isNotEmpty(depotHead.getAccountMoneyList())) { if(StringUtil.isNotEmpty(depotHead.getAccountMoneyList())) {
//校验多账户的结算金额
String accountMoneyList = depotHead.getAccountMoneyList().replace("[", "").replace("]", "").replaceAll("\"", ""); String accountMoneyList = depotHead.getAccountMoneyList().replace("[", "").replace("]", "").replaceAll("\"", "");
//校验多账户的金额合计是否等于本次付款或本次收款
int sum = StringUtil.getArrSum(accountMoneyList.split(",")); int sum = StringUtil.getArrSum(accountMoneyList.split(","));
BigDecimal manyAccountSum = BigDecimal.valueOf(sum); BigDecimal manyAccountSum = BigDecimal.valueOf(sum).abs();
if(manyAccountSum.compareTo(depotHead.getChangeAmount())!=0) { if(manyAccountSum.compareTo(depotHead.getChangeAmount().abs())!=0) {
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_MANY_ACCOUNT_FAILED_CODE, throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_MANY_ACCOUNT_FAILED_CODE,
String.format(ExceptionConstants.DEPOT_HEAD_MANY_ACCOUNT_FAILED_MSG)); String.format(ExceptionConstants.DEPOT_HEAD_MANY_ACCOUNT_FAILED_MSG));
} }
@@ -712,7 +712,15 @@ public class DepotHeadService {
depotHead.setAccountIdList(depotHead.getAccountIdList().replace("[", "").replace("]", "").replaceAll("\"", "")); depotHead.setAccountIdList(depotHead.getAccountIdList().replace("[", "").replace("]", "").replaceAll("\"", ""));
} }
if(StringUtil.isNotEmpty(depotHead.getAccountMoneyList())) { 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{ try{
depotHeadMapper.updateByPrimaryKeySelective(depotHead); depotHeadMapper.updateByPrimaryKeySelective(depotHead);