|
|
@@ -361,19 +361,12 @@ public class ClaimServiceImpl extends ServiceImpl<ClaimMapper, Claim> implements
|
|
|
if (jdTenant != null)
|
|
|
{
|
|
|
if (ObjectUtil.isNotEmpty(itemList)){
|
|
|
- String finalAccountName = accountName;
|
|
|
- itemList.forEach(item -> {
|
|
|
- if (!StringUtil.isNotBlank(item.getSubjectName())){
|
|
|
- throw new SecurityException("明细科目名称不能为空");
|
|
|
- }
|
|
|
- try {
|
|
|
- //财务保存凭证
|
|
|
- this.ClaimSaveVoucher(claimOne.getPaymentTime(), finalAccountName, claimOne.getSubjectCode(), item.getSubjectName(),
|
|
|
- item.getAccountingItemsName(), item.getAmount().toString(), item.getExplanation());
|
|
|
- } catch (Exception exception) {
|
|
|
- throw new SecurityException(exception.getMessage());
|
|
|
- }
|
|
|
- });
|
|
|
+ try {
|
|
|
+ //财务保存凭证
|
|
|
+ this.ClaimSaveVoucher(claimOne.getPaymentTime(), accountName, claimOne.getSubjectCode(), itemList, claimOne.getUserName());
|
|
|
+ } catch (Exception exception) {
|
|
|
+ throw new SecurityException(exception.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -384,18 +377,13 @@ public class ClaimServiceImpl extends ServiceImpl<ClaimMapper, Claim> implements
|
|
|
}
|
|
|
|
|
|
//财务生成账单
|
|
|
- public void ClaimSaveVoucher(Date PaymentTime, String accountName, String subjectCode, String subjectName, String corpNumber, String account, String explanation) throws Exception {
|
|
|
+ public void ClaimSaveVoucher(Date PaymentTime, String accountName, String subjectCode, List<ClaimItem> itemList, String userName) throws Exception {
|
|
|
// TODO 临时屏蔽
|
|
|
|
|
|
//非达沃特用户直接返回
|
|
|
if (!"681169".equals(AuthUtil.getTenantId())) {
|
|
|
return;
|
|
|
}
|
|
|
- //如果金额大于0,才生成凭证
|
|
|
- if (new BigDecimal(account).compareTo(BigDecimal.ZERO) < 1) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
//获取token
|
|
|
String token = this.getAccountGroupRequest();
|
|
|
//获取套账url
|
|
|
@@ -429,7 +417,7 @@ public class ClaimServiceImpl extends ServiceImpl<ClaimMapper, Claim> implements
|
|
|
return;
|
|
|
}
|
|
|
//保存凭证
|
|
|
- JdyTool.voucher voucher = toSaleCollectionJinDie(PaymentTime, subjectCode, subjectName, account, corpNumber, jdTenant.getAccountId(), group.getGroupName(), explanation);
|
|
|
+ JdyTool.voucher voucher = toSaleCollectionJinDie(PaymentTime, subjectCode, jdTenant.getAccountId(), group.getGroupName(), itemList, userName);
|
|
|
if (voucher == null) {
|
|
|
throw new SecurityException("获取凭证信息失败");
|
|
|
}
|
|
|
@@ -437,36 +425,49 @@ public class ClaimServiceImpl extends ServiceImpl<ClaimMapper, Claim> implements
|
|
|
}
|
|
|
|
|
|
//金蝶保存凭证测试-生成凭证
|
|
|
- public JdyTool.voucher toSaleCollectionJinDie(Date date,String subjectCode,String subjectNumber, String account,String corpNumber, String accountId, String groupName, String explanation) {
|
|
|
+ public JdyTool.voucher toSaleCollectionJinDie(Date date,String subjectCode, String accountId, String groupName, List<ClaimItem> itemList, String userName) {
|
|
|
JDYitems item = new JDYitems();
|
|
|
item.setDate(new SimpleDateFormat("yyyy-MM-dd").format(date));
|
|
|
List<JDYentries> entriesList = new ArrayList<>();
|
|
|
List<JDYitems> jdYitems = new ArrayList<>();
|
|
|
|
|
|
- //财务借方
|
|
|
- JDYentries d = new JDYentries();
|
|
|
- d.setDc("1");
|
|
|
+ itemList.forEach(claimItem -> {
|
|
|
+ if (!StringUtil.isNotBlank(claimItem.getSubjectName())){
|
|
|
+ throw new SecurityException("明细科目名称不能为空");
|
|
|
+ }
|
|
|
|
|
|
- if (null != subjectNumber && !subjectNumber.equals("")){
|
|
|
- d.setAccount_number(subjectNumber);
|
|
|
- }else {
|
|
|
- throw new SecurityException("科目编码为空");
|
|
|
- }
|
|
|
- d.setExplanation(explanation);
|
|
|
- d.setDebitamount(account);
|
|
|
- entriesList.add(d);
|
|
|
+ if (claimItem.getAmount().compareTo(BigDecimal.ZERO) < 1) {
|
|
|
+ throw new SecurityException("明细金额不能为空或为0");
|
|
|
+ }
|
|
|
+
|
|
|
+ JDYentries d = new JDYentries();
|
|
|
+ d.setDc("1");
|
|
|
+
|
|
|
+ if (null != claimItem.getSubjectName() && !claimItem.getSubjectName().equals("")){
|
|
|
+ d.setAccount_number(claimItem.getSubjectName());
|
|
|
+ }else {
|
|
|
+ throw new SecurityException("科目编码为空");
|
|
|
+ }
|
|
|
+ d.setExplanation(claimItem.getExplanation());
|
|
|
+ d.setDebitamount(claimItem.getAmount().toString());
|
|
|
+ entriesList.add(d);
|
|
|
|
|
|
- //===========辅助核算=================
|
|
|
- List<JDYassist> cList = new ArrayList<>();
|
|
|
+ //===========辅助核算=================
|
|
|
+ List<JDYassist> cList = new ArrayList<>();
|
|
|
|
|
|
- JDYassist jdYassist = new JDYassist();
|
|
|
- jdYassist.setType("bd_employee");
|
|
|
+ JDYassist jdYassist = new JDYassist();
|
|
|
+ jdYassist.setType("bd_employee");
|
|
|
|
|
|
- jdYassist.setNumber(corpNumber);
|
|
|
+ jdYassist.setNumber(claimItem.getAccountingItemsName());
|
|
|
+
|
|
|
+ cList.add(jdYassist);
|
|
|
+ d.setAssist(cList);
|
|
|
+ //===========辅助核算=================
|
|
|
+
|
|
|
+ });
|
|
|
|
|
|
- cList.add(jdYassist);
|
|
|
- d.setAssist(cList);
|
|
|
- //===========辅助核算=================
|
|
|
+ //金额合计
|
|
|
+ String sumAccount = itemList.stream().map(ClaimItem :: getAmount).reduce(BigDecimal.ZERO, BigDecimal::add).toString();
|
|
|
|
|
|
//财务贷方
|
|
|
JDYentries c = new JDYentries();
|
|
|
@@ -477,8 +478,8 @@ public class ClaimServiceImpl extends ServiceImpl<ClaimMapper, Claim> implements
|
|
|
}else {
|
|
|
throw new SecurityException("科目编码为空");
|
|
|
}
|
|
|
- c.setExplanation(explanation);
|
|
|
- c.setCreditamount(account);
|
|
|
+ c.setExplanation(userName + "报销");
|
|
|
+ c.setCreditamount(sumAccount);
|
|
|
entriesList.add(c);
|
|
|
|
|
|
//组装数据
|