多账户合计校验是否与本次付款相等
This commit is contained in:
@@ -315,6 +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 = "多账户的金额合计不等于本次付款或本次收款";
|
||||
/**
|
||||
* 单据明细信息
|
||||
* type = 90
|
||||
|
||||
@@ -622,9 +622,8 @@ public class DepotHeadService {
|
||||
/**处理单据主表数据*/
|
||||
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
|
||||
String subType = depotHead.getSubType();
|
||||
if("零售".equals(subType) || "零售退货".equals(subType)
|
||||
|| "采购".equals(subType) || "采购退货".equals(subType)
|
||||
|| "销售".equals(subType) || "销售退货".equals(subType)) {
|
||||
//结算账户校验
|
||||
if("采购".equals(subType) || "采购退货".equals(subType) || "销售".equals(subType) || "销售退货".equals(subType)) {
|
||||
if (StringUtil.isEmpty(depotHead.getAccountIdList()) && depotHead.getAccountId() == null) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_ACCOUNT_FAILED_CODE,
|
||||
String.format(ExceptionConstants.DEPOT_HEAD_ACCOUNT_FAILED_MSG));
|
||||
@@ -640,7 +639,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);
|
||||
if(manyAccountSum.compareTo(depotHead.getChangeAmount())!=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.insertSelective(depotHead);
|
||||
@@ -694,9 +701,8 @@ public class DepotHeadService {
|
||||
//获取之前的金额数据
|
||||
BigDecimal preTotalPrice = getDepotHead(depotHead.getId()).getTotalPrice().abs();
|
||||
String subType = depotHead.getSubType();
|
||||
if("零售".equals(subType) || "零售退货".equals(subType)
|
||||
|| "采购".equals(subType) || "采购退货".equals(subType)
|
||||
|| "销售".equals(subType) || "销售退货".equals(subType)) {
|
||||
//结算账户校验
|
||||
if("采购".equals(subType) || "采购退货".equals(subType) || "销售".equals(subType) || "销售退货".equals(subType)) {
|
||||
if (StringUtil.isEmpty(depotHead.getAccountIdList()) && depotHead.getAccountId() == null) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_HEAD_ACCOUNT_FAILED_CODE,
|
||||
String.format(ExceptionConstants.DEPOT_HEAD_ACCOUNT_FAILED_MSG));
|
||||
|
||||
@@ -162,6 +162,14 @@ public class StringUtil {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
public static int getArrSum(String[] strings) {
|
||||
int sum = 0;
|
||||
for(int i=0;i<strings.length;i++){
|
||||
sum=sum+ Integer.parseInt(strings[i]);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* String字符串转成List<Long>数据格式
|
||||
* String str = "1,2,3,4,5,6" -> List<Long> listLong [1,2,3,4,5,6];
|
||||
|
||||
Reference in New Issue
Block a user