Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
fc03578d
Commit
fc03578d
authored
Jul 10, 2021
by
季圣华
Browse files
多账户合计校验是否与本次付款相等
parent
6f839bf7
Changes
3
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java
View file @
fc03578d
...
...
@@ -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
...
...
jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java
View file @
fc03578d
...
...
@@ -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
));
...
...
jshERP-boot/src/main/java/com/jsh/erp/utils/StringUtil.java
View file @
fc03578d
...
...
@@ -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];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment