Commit c937dbc6 authored by 季圣华's avatar 季圣华
Browse files

优化单据多账户

parent fc03578d
......@@ -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
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment