|
|
@@ -1283,22 +1283,20 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
|
|
|
if (feeCenterList.isEmpty()) {
|
|
|
throw new RuntimeException("费用为空,自动生成凭证失败");
|
|
|
}
|
|
|
- BCorps bCorps = null;
|
|
|
- Dept dept = null;
|
|
|
- User user = null;
|
|
|
- BCorps userSrc = null;
|
|
|
Bills billsDetail = null;
|
|
|
AeaBills aeaBillsDetail = null;
|
|
|
CustomsDeclaration customsDeclarationDetail = null;
|
|
|
Amends amendsDetail = null;
|
|
|
String srcBillNo = "";
|
|
|
+ Dept dept = null;
|
|
|
+ User user = null;
|
|
|
+ BCorps userSrc = null;
|
|
|
//查询各业务模块 核算客户,核算部门,核算职员信息
|
|
|
if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
|
|
|
Bills bills = billsMapper.selectById(id);
|
|
|
if (bills != null) {
|
|
|
srcBillNo = bills.getBillNo();
|
|
|
billsDetail = bills;
|
|
|
- bCorps = bCorpsService.getById(bills.getCorpId());
|
|
|
if (ObjectUtils.isNotNull(bills.getAccDept())) {
|
|
|
R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
|
|
|
if (deptR.isSuccess()) {
|
|
|
@@ -1332,7 +1330,6 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
|
|
|
if (bills != null) {
|
|
|
srcBillNo = bills.getBillNo();
|
|
|
aeaBillsDetail = bills;
|
|
|
- bCorps = bCorpsService.getById(bills.getCorpId());
|
|
|
if (ObjectUtils.isNotNull(bills.getAccDept())) {
|
|
|
R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
|
|
|
if (deptR.isSuccess()) {
|
|
|
@@ -1367,7 +1364,6 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
|
|
|
if (bills != null) {
|
|
|
srcBillNo = bills.getBillNo();
|
|
|
customsDeclarationDetail = bills;
|
|
|
- bCorps = bCorpsService.getById(bills.getCorpId());
|
|
|
if (ObjectUtils.isNotNull(bills.getAccDept())) {
|
|
|
R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
|
|
|
if (deptR.isSuccess()) {
|
|
|
@@ -1389,7 +1385,6 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
|
|
|
if (bills != null) {
|
|
|
srcBillNo = bills.getBillNo();
|
|
|
amendsDetail = bills;
|
|
|
- bCorps = bCorpsService.getById(bills.getCorpId());
|
|
|
if (ObjectUtils.isNotNull(bills.getAccDept())) {
|
|
|
R<Dept> deptR = sysClient.getDept(Long.parseLong(bills.getAccDept()));
|
|
|
if (deptR.isSuccess()) {
|
|
|
@@ -1407,6 +1402,7 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
|
|
|
} else {
|
|
|
userSrc = bCorpsService.getById(bills1.getSrcId());
|
|
|
}
|
|
|
+
|
|
|
if ("MM".equals(bills1.getBillType())) {
|
|
|
List<Bills> billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
|
|
|
.select(Bills::getId)
|
|
|
@@ -1479,6 +1475,47 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
|
|
|
if (new BigDecimal("0.00").compareTo(rateDRmb) != 0) {
|
|
|
rateD = rateDRmb.divide(amountDUsd, MathContext.DECIMAL32).setScale(4, RoundingMode.HALF_UP);
|
|
|
}
|
|
|
+ List<Long> corpIds = feeCenterList.stream().map(FeeCenter::getCorpId).collect(Collectors.toList());
|
|
|
+ List<BCorps> bCorpsList = bCorpsService.list(new LambdaQueryWrapper<BCorps>()
|
|
|
+ .eq(BCorps::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BCorps::getIsDeleted, 0)
|
|
|
+ .in(BCorps::getId, corpIds));
|
|
|
+ List<Map<Long, BigDecimal>> mapListCC = new ArrayList<>();
|
|
|
+ List<Long> corpIdCC = feeCenterList.stream().filter(e -> "CNY".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FeeCenter::getCorpId).distinct().collect(Collectors.toList());
|
|
|
+ for (Long item : corpIdCC) {
|
|
|
+ Map<Long, BigDecimal> map = new HashMap<>();
|
|
|
+ map.put(item, feeCenterList.stream().filter(e -> "CNY".equals(e.getCurCode())
|
|
|
+ && "C".equals(e.getDc()) && item.equals(e.getCorpId())).map(FeeCenter::getAmount)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ mapListCC.add(map);
|
|
|
+ }
|
|
|
+ List<Map<Long, BigDecimal>> mapListUC = new ArrayList<>();
|
|
|
+ List<Long> corpIdUC = feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FeeCenter::getCorpId).distinct().collect(Collectors.toList());
|
|
|
+ for (Long item : corpIdUC) {
|
|
|
+ Map<Long, BigDecimal> map = new HashMap<>();
|
|
|
+ map.put(item, feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode())
|
|
|
+ && "C".equals(e.getDc()) && item.equals(e.getCorpId())).map(FeeCenter::getAmount)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ mapListUC.add(map);
|
|
|
+ }
|
|
|
+ List<Map<Long, BigDecimal>> mapListCD = new ArrayList<>();
|
|
|
+ List<Long> corpIdCD = feeCenterList.stream().filter(e -> "CNY".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FeeCenter::getCorpId).distinct().collect(Collectors.toList());
|
|
|
+ for (Long item : corpIdCD) {
|
|
|
+ Map<Long, BigDecimal> map = new HashMap<>();
|
|
|
+ map.put(item, feeCenterList.stream().filter(e -> "CNY".equals(e.getCurCode())
|
|
|
+ && "D".equals(e.getDc()) && item.equals(e.getCorpId())).map(FeeCenter::getAmount)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ mapListCD.add(map);
|
|
|
+ }
|
|
|
+ List<Map<Long, BigDecimal>> mapListUD = new ArrayList<>();
|
|
|
+ List<Long> corpIdUD = feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FeeCenter::getCorpId).distinct().collect(Collectors.toList());
|
|
|
+ for (Long item : corpIdUD) {
|
|
|
+ Map<Long, BigDecimal> map = new HashMap<>();
|
|
|
+ map.put(item, feeCenterList.stream().filter(e -> "USD".equals(e.getCurCode())
|
|
|
+ && "D".equals(e.getDc()) && item.equals(e.getCorpId())).map(FeeCenter::getAmount)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ mapListUD.add(map);
|
|
|
+ }
|
|
|
//创建凭证主表信息
|
|
|
FinVouchers finVouchers = new FinVouchers();
|
|
|
String deptId = "";
|
|
|
@@ -1538,229 +1575,1037 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
|
|
|
.eq(Accounts::getStatus, 0)
|
|
|
.apply("find_in_set(code,'" + accountsCode + "')"));
|
|
|
List<FinVouchersItems> finVouchersItemsList = new ArrayList<>();
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
int count = 0;
|
|
|
- //循环复制凭证明细信息
|
|
|
- for (VoucherTemplate item : voucherTemplateList) {
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ for (int i = 0; i < 8; i++) {
|
|
|
count++;
|
|
|
- FinVouchersItems finVouchersItems = new FinVouchersItems();
|
|
|
- finVouchersItems.setCreateTime(new Date());
|
|
|
- finVouchersItems.setCreateUser(AuthUtil.getUserId());
|
|
|
- finVouchersItems.setCreateUserName(AuthUtil.getUserName());
|
|
|
- if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
- finVouchersItems.setCreateDept(deptId);
|
|
|
- finVouchersItems.setBranchId(branchId);
|
|
|
- finVouchersItems.setCreateDeptName(deptName);
|
|
|
- }
|
|
|
- finVouchersItems.setPid(finVouchers.getId());
|
|
|
- finVouchersItems.setBillNo(finVouchers.getBillNo());
|
|
|
- finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
|
|
|
- finVouchersItems.setVoucherType(finVouchers.getVoucherType());
|
|
|
- finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
|
|
|
- finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
- finVouchersItems.setAccountYear(finVouchers.getAccountYear());
|
|
|
- finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
|
|
|
- finVouchersItems.setAccountDay(finVouchers.getAccountDay());
|
|
|
+ VoucherTemplate item = voucherTemplateList.get(i);
|
|
|
Accounts accounts = accountsList.stream().filter(e -> e.getCode().equals(item.getSubjectCode()))
|
|
|
.findFirst().orElse(null);
|
|
|
//获取模板中科目所对应科目信息并赋值
|
|
|
if (accounts != null) {
|
|
|
- finVouchersItems.setAccountId(accounts.getId());
|
|
|
- finVouchersItems.setAccountCode(accounts.getCode());
|
|
|
- finVouchersItems.setAccountCnName(accounts.getCnName());
|
|
|
- finVouchersItems.setAccountEnName(accounts.getEnName());
|
|
|
- finVouchersItems.setAccountProperty(accounts.getProperty());
|
|
|
- finVouchersItems.setAccountLevel(accounts.getLevel());
|
|
|
- finVouchersItems.setDc(item.getAmountDirection());
|
|
|
- finVouchersItems.setCurCode(item.getCurrencyCode());
|
|
|
- /*判断是否人民币,美元
|
|
|
- * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
- * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
- * 借或贷金额为零时跳过本次循环
|
|
|
- * */
|
|
|
- if ("CNY".equals(item.getCurrencyCode())) {
|
|
|
- finVouchersItems.setExrate(new BigDecimal("1"));
|
|
|
- if ("D".equals(item.getAmountDirection())) {
|
|
|
- if ("D".equals(accounts.getDc())) {
|
|
|
- if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
- finVouchersItems.setAmountDr(amount[count - 1]);
|
|
|
+ if (1 == accounts.getIsCorp() || 1 == accounts.getIsDept() || 1 == accounts.getIsEmpl()) {
|
|
|
+ if (0 == i || 1 == i) {
|
|
|
+ for (Map<Long, BigDecimal> map : mapListCD) {
|
|
|
+ Long key;
|
|
|
+ Iterator<Long> iterator = map.keySet().iterator();
|
|
|
+ if (iterator.hasNext()) {
|
|
|
+ key = iterator.next();
|
|
|
} else {
|
|
|
- continue;
|
|
|
+ key = null;
|
|
|
}
|
|
|
- } else {
|
|
|
- finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(amount[count - 1]));
|
|
|
+ FinVouchersItems finVouchersItems = new FinVouchersItems();
|
|
|
+ finVouchersItems.setCreateTime(new Date());
|
|
|
+ finVouchersItems.setCreateUser(AuthUtil.getUserId());
|
|
|
+ finVouchersItems.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ finVouchersItems.setCreateDept(deptId);
|
|
|
+ finVouchersItems.setBranchId(branchId);
|
|
|
+ finVouchersItems.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ finVouchersItems.setPid(finVouchers.getId());
|
|
|
+ finVouchersItems.setBillNo(finVouchers.getBillNo());
|
|
|
+ finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
|
|
|
+ finVouchersItems.setVoucherType(finVouchers.getVoucherType());
|
|
|
+ finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
|
|
|
+ finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
+ finVouchersItems.setAccountYear(finVouchers.getAccountYear());
|
|
|
+ finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
|
|
|
+ finVouchersItems.setAccountDay(finVouchers.getAccountDay());
|
|
|
+ finVouchersItems.setAccountId(accounts.getId());
|
|
|
+ finVouchersItems.setAccountCode(accounts.getCode());
|
|
|
+ finVouchersItems.setAccountCnName(accounts.getCnName());
|
|
|
+ finVouchersItems.setAccountEnName(accounts.getEnName());
|
|
|
+ finVouchersItems.setAccountProperty(accounts.getProperty());
|
|
|
+ finVouchersItems.setAccountLevel(accounts.getLevel());
|
|
|
+ finVouchersItems.setDc(item.getAmountDirection());
|
|
|
+ finVouchersItems.setCurCode(item.getCurrencyCode());
|
|
|
+ /*判断是否人民币,美元
|
|
|
+ * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
+ * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
+ * 借或贷金额为零时跳过本次循环
|
|
|
+ * */
|
|
|
+ if ("CNY".equals(item.getCurrencyCode())) {
|
|
|
+ finVouchersItems.setExrate(new BigDecimal("1"));
|
|
|
+ if ("D".equals(item.getAmountDirection())) {
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountDr(map.get(key));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountCr(map.get(key));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("D".equals(item.getAmountDirection())) {
|
|
|
+ finVouchersItems.setExrate(rateD);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountDrUsd(map.get(key));
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setExrate(rateC);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountCrUsd(map.get(key));
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //计算借,贷人民币与美金合计人民币金额
|
|
|
+ finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
|
|
|
+ .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
|
|
|
+ finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
|
|
|
+ .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
|
|
|
+ finVouchersItems.setIsCorp(accounts.getIsCorp());
|
|
|
+ //判断是否核算客户 true 向明细中客户字段复制
|
|
|
+ if (1 == finVouchersItems.getIsCorp()) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
|
|
|
+ if (bCorps != null) {
|
|
|
+ finVouchersItems.setCorpId(bCorps.getId());
|
|
|
+ finVouchersItems.setCorpCnName(bCorps.getCnName());
|
|
|
+ finVouchersItems.setCorpEnName(bCorps.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setIsDept(accounts.getIsDept());
|
|
|
+ //判断是否核算部门 true 向明细中部门字段复制
|
|
|
+ if (1 == finVouchersItems.getIsDept()) {
|
|
|
+ if (dept != null) {
|
|
|
+ finVouchersItems.setDeptId(dept.getId());
|
|
|
+ finVouchersItems.setDeptName(dept.getDeptName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setIsEmpl(accounts.getIsEmpl());
|
|
|
+ //判断是否核算职员 true 向明细中职员字段复制
|
|
|
+ if (1 == finVouchersItems.getIsEmpl()) {
|
|
|
+ if (user != null) {
|
|
|
+ finVouchersItems.setEmplId(user.getId());
|
|
|
+ finVouchersItems.setEmplName(user.getName());
|
|
|
+ } else {
|
|
|
+ if (userSrc != null) {
|
|
|
+ finVouchersItems.setEmplId(userSrc.getId());
|
|
|
+ finVouchersItems.setEmplName(userSrc.getCnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setLineNo(count);
|
|
|
+ StringBuilder formulasValue = new StringBuilder();
|
|
|
+ formulasValue.append(" ");
|
|
|
+ String formulasData = item.getAdditionalFormulas();
|
|
|
+ String[] arr = formulasData.split(",");
|
|
|
+ for (String l : arr) {
|
|
|
+ if ("corpCnName".equals(l)) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
|
|
|
+ if (bCorps != null) {
|
|
|
+ formulasValue.append(bCorps.getCnName()).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = Bills.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(billsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(billsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(billsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = AeaBills.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(aeaBillsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
|
|
|
+ "BGAE".equals(checkType) || "BGAI".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = CustomsDeclaration.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
|
|
|
+ "aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = Amends.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(amendsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(amendsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
|
|
|
+ finVouchersItemsList.add(finVouchersItems);
|
|
|
}
|
|
|
- } else {
|
|
|
- if ("D".equals(accounts.getDc())) {
|
|
|
- finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(amount[count - 1]));
|
|
|
- } else {
|
|
|
- if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
- finVouchersItems.setAmountCr(amount[count - 1]);
|
|
|
+ } else if (2 == i || 3 == i) {
|
|
|
+ for (Map<Long, BigDecimal> map : mapListCC) {
|
|
|
+ Long key;
|
|
|
+ Iterator<Long> iterator = map.keySet().iterator();
|
|
|
+ if (iterator.hasNext()) {
|
|
|
+ key = iterator.next();
|
|
|
} else {
|
|
|
- continue;
|
|
|
+ key = null;
|
|
|
+ }
|
|
|
+ FinVouchersItems finVouchersItems = new FinVouchersItems();
|
|
|
+ finVouchersItems.setCreateTime(new Date());
|
|
|
+ finVouchersItems.setCreateUser(AuthUtil.getUserId());
|
|
|
+ finVouchersItems.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ finVouchersItems.setCreateDept(deptId);
|
|
|
+ finVouchersItems.setBranchId(branchId);
|
|
|
+ finVouchersItems.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ finVouchersItems.setPid(finVouchers.getId());
|
|
|
+ finVouchersItems.setBillNo(finVouchers.getBillNo());
|
|
|
+ finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
|
|
|
+ finVouchersItems.setVoucherType(finVouchers.getVoucherType());
|
|
|
+ finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
|
|
|
+ finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
+ finVouchersItems.setAccountYear(finVouchers.getAccountYear());
|
|
|
+ finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
|
|
|
+ finVouchersItems.setAccountDay(finVouchers.getAccountDay());
|
|
|
+ finVouchersItems.setAccountId(accounts.getId());
|
|
|
+ finVouchersItems.setAccountCode(accounts.getCode());
|
|
|
+ finVouchersItems.setAccountCnName(accounts.getCnName());
|
|
|
+ finVouchersItems.setAccountEnName(accounts.getEnName());
|
|
|
+ finVouchersItems.setAccountProperty(accounts.getProperty());
|
|
|
+ finVouchersItems.setAccountLevel(accounts.getLevel());
|
|
|
+ finVouchersItems.setDc(item.getAmountDirection());
|
|
|
+ finVouchersItems.setCurCode(item.getCurrencyCode());
|
|
|
+ /*判断是否人民币,美元
|
|
|
+ * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
+ * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
+ * 借或贷金额为零时跳过本次循环
|
|
|
+ * */
|
|
|
+ if ("CNY".equals(item.getCurrencyCode())) {
|
|
|
+ finVouchersItems.setExrate(new BigDecimal("1"));
|
|
|
+ if ("D".equals(item.getAmountDirection())) {
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountDr(map.get(key));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountCr(map.get(key));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("D".equals(item.getAmountDirection())) {
|
|
|
+ finVouchersItems.setExrate(rateD);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountDrUsd(map.get(key));
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setExrate(rateC);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountCrUsd(map.get(key));
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //计算借,贷人民币与美金合计人民币金额
|
|
|
+ finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
|
|
|
+ .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
|
|
|
+ finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
|
|
|
+ .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
|
|
|
+ finVouchersItems.setIsCorp(accounts.getIsCorp());
|
|
|
+ //判断是否核算客户 true 向明细中客户字段复制
|
|
|
+ if (1 == finVouchersItems.getIsCorp()) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
|
|
|
+ if (bCorps != null) {
|
|
|
+ finVouchersItems.setCorpId(bCorps.getId());
|
|
|
+ finVouchersItems.setCorpCnName(bCorps.getCnName());
|
|
|
+ finVouchersItems.setCorpEnName(bCorps.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setIsDept(accounts.getIsDept());
|
|
|
+ //判断是否核算部门 true 向明细中部门字段复制
|
|
|
+ if (1 == finVouchersItems.getIsDept()) {
|
|
|
+ if (dept != null) {
|
|
|
+ finVouchersItems.setDeptId(dept.getId());
|
|
|
+ finVouchersItems.setDeptName(dept.getDeptName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setIsEmpl(accounts.getIsEmpl());
|
|
|
+ //判断是否核算职员 true 向明细中职员字段复制
|
|
|
+ if (1 == finVouchersItems.getIsEmpl()) {
|
|
|
+ if (user != null) {
|
|
|
+ finVouchersItems.setEmplId(user.getId());
|
|
|
+ finVouchersItems.setEmplName(user.getName());
|
|
|
+ } else {
|
|
|
+ if (userSrc != null) {
|
|
|
+ finVouchersItems.setEmplId(userSrc.getId());
|
|
|
+ finVouchersItems.setEmplName(userSrc.getCnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setLineNo(count);
|
|
|
+ StringBuilder formulasValue = new StringBuilder();
|
|
|
+ formulasValue.append(" ");
|
|
|
+ String formulasData = item.getAdditionalFormulas();
|
|
|
+ String[] arr = formulasData.split(",");
|
|
|
+ for (String l : arr) {
|
|
|
+ if ("corpCnName".equals(l)) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
|
|
|
+ if (bCorps != null) {
|
|
|
+ formulasValue.append(bCorps.getCnName()).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = Bills.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(billsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(billsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(billsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = AeaBills.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(aeaBillsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
|
|
|
+ "BGAE".equals(checkType) || "BGAI".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = CustomsDeclaration.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
|
|
|
+ "aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = Amends.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(amendsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(amendsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
|
|
|
+ finVouchersItemsList.add(finVouchersItems);
|
|
|
}
|
|
|
- }
|
|
|
- } else {
|
|
|
- if ("D".equals(item.getAmountDirection())) {
|
|
|
- finVouchersItems.setExrate(rateD);
|
|
|
- if ("D".equals(accounts.getDc())) {
|
|
|
- if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
- finVouchersItems.setAmountDrUsd(amount[count - 1]);
|
|
|
- finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
|
|
|
+ } else if (4 == i || 5 == i) {
|
|
|
+ for (Map<Long, BigDecimal> map : mapListUD) {
|
|
|
+ Long key;
|
|
|
+ Iterator<Long> iterator = map.keySet().iterator();
|
|
|
+ if (iterator.hasNext()) {
|
|
|
+ key = iterator.next();
|
|
|
} else {
|
|
|
- continue;
|
|
|
+ key = null;
|
|
|
}
|
|
|
- } else {
|
|
|
- finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(amount[count - 1]));
|
|
|
- finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
|
|
|
+ FinVouchersItems finVouchersItems = new FinVouchersItems();
|
|
|
+ finVouchersItems.setCreateTime(new Date());
|
|
|
+ finVouchersItems.setCreateUser(AuthUtil.getUserId());
|
|
|
+ finVouchersItems.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ finVouchersItems.setCreateDept(deptId);
|
|
|
+ finVouchersItems.setBranchId(branchId);
|
|
|
+ finVouchersItems.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ finVouchersItems.setPid(finVouchers.getId());
|
|
|
+ finVouchersItems.setBillNo(finVouchers.getBillNo());
|
|
|
+ finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
|
|
|
+ finVouchersItems.setVoucherType(finVouchers.getVoucherType());
|
|
|
+ finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
|
|
|
+ finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
+ finVouchersItems.setAccountYear(finVouchers.getAccountYear());
|
|
|
+ finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
|
|
|
+ finVouchersItems.setAccountDay(finVouchers.getAccountDay());
|
|
|
+ finVouchersItems.setAccountId(accounts.getId());
|
|
|
+ finVouchersItems.setAccountCode(accounts.getCode());
|
|
|
+ finVouchersItems.setAccountCnName(accounts.getCnName());
|
|
|
+ finVouchersItems.setAccountEnName(accounts.getEnName());
|
|
|
+ finVouchersItems.setAccountProperty(accounts.getProperty());
|
|
|
+ finVouchersItems.setAccountLevel(accounts.getLevel());
|
|
|
+ finVouchersItems.setDc(item.getAmountDirection());
|
|
|
+ finVouchersItems.setCurCode(item.getCurrencyCode());
|
|
|
+ /*判断是否人民币,美元
|
|
|
+ * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
+ * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
+ * 借或贷金额为零时跳过本次循环
|
|
|
+ * */
|
|
|
+ if ("CNY".equals(item.getCurrencyCode())) {
|
|
|
+ finVouchersItems.setExrate(new BigDecimal("1"));
|
|
|
+ if ("D".equals(item.getAmountDirection())) {
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountDr(map.get(key));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountCr(map.get(key));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("D".equals(item.getAmountDirection())) {
|
|
|
+ finVouchersItems.setExrate(rateD);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountDrUsd(map.get(key));
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setExrate(rateC);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountCrUsd(map.get(key));
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //计算借,贷人民币与美金合计人民币金额
|
|
|
+ finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
|
|
|
+ .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
|
|
|
+ finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
|
|
|
+ .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
|
|
|
+ finVouchersItems.setIsCorp(accounts.getIsCorp());
|
|
|
+ //判断是否核算客户 true 向明细中客户字段复制
|
|
|
+ if (1 == finVouchersItems.getIsCorp()) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
|
|
|
+ if (bCorps != null) {
|
|
|
+ finVouchersItems.setCorpId(bCorps.getId());
|
|
|
+ finVouchersItems.setCorpCnName(bCorps.getCnName());
|
|
|
+ finVouchersItems.setCorpEnName(bCorps.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setIsDept(accounts.getIsDept());
|
|
|
+ //判断是否核算部门 true 向明细中部门字段复制
|
|
|
+ if (1 == finVouchersItems.getIsDept()) {
|
|
|
+ if (dept != null) {
|
|
|
+ finVouchersItems.setDeptId(dept.getId());
|
|
|
+ finVouchersItems.setDeptName(dept.getDeptName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setIsEmpl(accounts.getIsEmpl());
|
|
|
+ //判断是否核算职员 true 向明细中职员字段复制
|
|
|
+ if (1 == finVouchersItems.getIsEmpl()) {
|
|
|
+ if (user != null) {
|
|
|
+ finVouchersItems.setEmplId(user.getId());
|
|
|
+ finVouchersItems.setEmplName(user.getName());
|
|
|
+ } else {
|
|
|
+ if (userSrc != null) {
|
|
|
+ finVouchersItems.setEmplId(userSrc.getId());
|
|
|
+ finVouchersItems.setEmplName(userSrc.getCnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setLineNo(count);
|
|
|
+ StringBuilder formulasValue = new StringBuilder();
|
|
|
+ formulasValue.append(" ");
|
|
|
+ String formulasData = item.getAdditionalFormulas();
|
|
|
+ String[] arr = formulasData.split(",");
|
|
|
+ for (String l : arr) {
|
|
|
+ if ("corpCnName".equals(l)) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
|
|
|
+ if (bCorps != null) {
|
|
|
+ formulasValue.append(bCorps.getCnName()).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = Bills.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(billsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(billsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(billsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = AeaBills.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(aeaBillsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
|
|
|
+ "BGAE".equals(checkType) || "BGAI".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = CustomsDeclaration.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
|
|
|
+ "aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = Amends.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(amendsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(amendsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
|
|
|
+ finVouchersItemsList.add(finVouchersItems);
|
|
|
}
|
|
|
- } else {
|
|
|
- finVouchersItems.setExrate(rateC);
|
|
|
- if ("D".equals(accounts.getDc())) {
|
|
|
- finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(amount[count - 1]));
|
|
|
- finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
|
|
|
- } else {
|
|
|
- if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
- finVouchersItems.setAmountCrUsd(amount[count - 1]);
|
|
|
- finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
|
|
|
+ } else if (6 == i || 7 == i) {
|
|
|
+ for (Map<Long, BigDecimal> map : mapListUC) {
|
|
|
+ Long key;
|
|
|
+ Iterator<Long> iterator = map.keySet().iterator();
|
|
|
+ if (iterator.hasNext()) {
|
|
|
+ key = iterator.next();
|
|
|
+ } else {
|
|
|
+ key = null;
|
|
|
+ }
|
|
|
+ FinVouchersItems finVouchersItems = new FinVouchersItems();
|
|
|
+ finVouchersItems.setCreateTime(new Date());
|
|
|
+ finVouchersItems.setCreateUser(AuthUtil.getUserId());
|
|
|
+ finVouchersItems.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ finVouchersItems.setCreateDept(deptId);
|
|
|
+ finVouchersItems.setBranchId(branchId);
|
|
|
+ finVouchersItems.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ finVouchersItems.setPid(finVouchers.getId());
|
|
|
+ finVouchersItems.setBillNo(finVouchers.getBillNo());
|
|
|
+ finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
|
|
|
+ finVouchersItems.setVoucherType(finVouchers.getVoucherType());
|
|
|
+ finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
|
|
|
+ finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
+ finVouchersItems.setAccountYear(finVouchers.getAccountYear());
|
|
|
+ finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
|
|
|
+ finVouchersItems.setAccountDay(finVouchers.getAccountDay());
|
|
|
+ finVouchersItems.setAccountId(accounts.getId());
|
|
|
+ finVouchersItems.setAccountCode(accounts.getCode());
|
|
|
+ finVouchersItems.setAccountCnName(accounts.getCnName());
|
|
|
+ finVouchersItems.setAccountEnName(accounts.getEnName());
|
|
|
+ finVouchersItems.setAccountProperty(accounts.getProperty());
|
|
|
+ finVouchersItems.setAccountLevel(accounts.getLevel());
|
|
|
+ finVouchersItems.setDc(item.getAmountDirection());
|
|
|
+ finVouchersItems.setCurCode(item.getCurrencyCode());
|
|
|
+ /*判断是否人民币,美元
|
|
|
+ * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
+ * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
+ * 借或贷金额为零时跳过本次循环
|
|
|
+ * */
|
|
|
+ if ("CNY".equals(item.getCurrencyCode())) {
|
|
|
+ finVouchersItems.setExrate(new BigDecimal("1"));
|
|
|
+ if ("D".equals(item.getAmountDirection())) {
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountDr(map.get(key));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountCr(map.get(key));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
- continue;
|
|
|
+ if ("D".equals(item.getAmountDirection())) {
|
|
|
+ finVouchersItems.setExrate(rateD);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountDrUsd(map.get(key));
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setExrate(rateC);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(map.get(key)));
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(map.get(key)) != 0) {
|
|
|
+ finVouchersItems.setAmountCrUsd(map.get(key));
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //计算借,贷人民币与美金合计人民币金额
|
|
|
+ finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
|
|
|
+ .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
|
|
|
+ finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
|
|
|
+ .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
|
|
|
+ finVouchersItems.setIsCorp(accounts.getIsCorp());
|
|
|
+ //判断是否核算客户 true 向明细中客户字段复制
|
|
|
+ if (1 == finVouchersItems.getIsCorp()) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
|
|
|
+ if (bCorps != null) {
|
|
|
+ finVouchersItems.setCorpId(bCorps.getId());
|
|
|
+ finVouchersItems.setCorpCnName(bCorps.getCnName());
|
|
|
+ finVouchersItems.setCorpEnName(bCorps.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setIsDept(accounts.getIsDept());
|
|
|
+ //判断是否核算部门 true 向明细中部门字段复制
|
|
|
+ if (1 == finVouchersItems.getIsDept()) {
|
|
|
+ if (dept != null) {
|
|
|
+ finVouchersItems.setDeptId(dept.getId());
|
|
|
+ finVouchersItems.setDeptName(dept.getDeptName());
|
|
|
+ }
|
|
|
}
|
|
|
+ finVouchersItems.setIsEmpl(accounts.getIsEmpl());
|
|
|
+ //判断是否核算职员 true 向明细中职员字段复制
|
|
|
+ if (1 == finVouchersItems.getIsEmpl()) {
|
|
|
+ if (user != null) {
|
|
|
+ finVouchersItems.setEmplId(user.getId());
|
|
|
+ finVouchersItems.setEmplName(user.getName());
|
|
|
+ } else {
|
|
|
+ if (userSrc != null) {
|
|
|
+ finVouchersItems.setEmplId(userSrc.getId());
|
|
|
+ finVouchersItems.setEmplName(userSrc.getCnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setLineNo(count);
|
|
|
+ StringBuilder formulasValue = new StringBuilder();
|
|
|
+ formulasValue.append(" ");
|
|
|
+ String formulasData = item.getAdditionalFormulas();
|
|
|
+ String[] arr = formulasData.split(",");
|
|
|
+ for (String l : arr) {
|
|
|
+ if ("corpCnName".equals(l)) {
|
|
|
+ BCorps bCorps = bCorpsList.stream().filter(e -> e.getId().equals(key)).findFirst().orElse(null);
|
|
|
+ if (bCorps != null) {
|
|
|
+ formulasValue.append(bCorps.getCnName()).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = Bills.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(billsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(billsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(billsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = AeaBills.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(aeaBillsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
|
|
|
+ "BGAE".equals(checkType) || "BGAI".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = CustomsDeclaration.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
|
|
|
+ "aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = Amends.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(amendsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(amendsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
|
|
|
+ finVouchersItemsList.add(finVouchersItems);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- //计算借,贷人民币与美金合计人民币金额
|
|
|
- finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
|
|
|
- .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
|
|
|
- finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
|
|
|
- .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
|
|
|
- finVouchersItems.setIsCorp(accounts.getIsCorp());
|
|
|
- //判断是否核算客户 true 向明细中客户字段复制
|
|
|
- if (1 == finVouchersItems.getIsCorp()) {
|
|
|
- if (bCorps != null) {
|
|
|
- finVouchersItems.setCorpId(bCorps.getId());
|
|
|
- finVouchersItems.setCorpCnName(bCorps.getCnName());
|
|
|
- finVouchersItems.setCorpEnName(bCorps.getEnName());
|
|
|
- }
|
|
|
- }
|
|
|
- finVouchersItems.setIsDept(accounts.getIsDept());
|
|
|
- //判断是否核算部门 true 向明细中部门字段复制
|
|
|
- if (1 == finVouchersItems.getIsDept()) {
|
|
|
- if (dept != null) {
|
|
|
- finVouchersItems.setDeptId(dept.getId());
|
|
|
- finVouchersItems.setDeptName(dept.getDeptName());
|
|
|
- }
|
|
|
- }
|
|
|
- finVouchersItems.setIsEmpl(accounts.getIsEmpl());
|
|
|
- //判断是否核算职员 true 向明细中职员字段复制
|
|
|
- if (1 == finVouchersItems.getIsEmpl()) {
|
|
|
- if (user != null) {
|
|
|
- finVouchersItems.setEmplId(user.getId());
|
|
|
- finVouchersItems.setEmplName(user.getName());
|
|
|
- } else {
|
|
|
- if (userSrc != null) {
|
|
|
- finVouchersItems.setEmplId(userSrc.getId());
|
|
|
- finVouchersItems.setEmplName(userSrc.getCnName());
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ FinVouchersItems finVouchersItems = new FinVouchersItems();
|
|
|
+ finVouchersItems.setCreateTime(new Date());
|
|
|
+ finVouchersItems.setCreateUser(AuthUtil.getUserId());
|
|
|
+ finVouchersItems.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ finVouchersItems.setCreateDept(deptId);
|
|
|
+ finVouchersItems.setBranchId(branchId);
|
|
|
+ finVouchersItems.setCreateDeptName(deptName);
|
|
|
}
|
|
|
- }
|
|
|
- } else {
|
|
|
- throw new RuntimeException("未找到科目信息");
|
|
|
- }
|
|
|
- finVouchersItems.setLineNo(count);
|
|
|
- StringBuilder formulasValue = new StringBuilder();
|
|
|
- formulasValue.append(" ");
|
|
|
- String formulasData = item.getAdditionalFormulas();
|
|
|
- String[] arr = formulasData.split(",");
|
|
|
- for (String i : arr) {
|
|
|
- if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
|
|
|
- try {
|
|
|
- Field field = Bills.class.getDeclaredField(i);
|
|
|
- field.setAccessible(true);
|
|
|
- if (field.getType().equals(Date.class)) {
|
|
|
- if (ObjectUtils.isNotNull(field.get(billsDetail))) {
|
|
|
- String formattedDate = dateFormat.format(field.get(billsDetail));
|
|
|
- formulasValue.append(formattedDate).append(" ");
|
|
|
+ finVouchersItems.setPid(finVouchers.getId());
|
|
|
+ finVouchersItems.setBillNo(finVouchers.getBillNo());
|
|
|
+ finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
|
|
|
+ finVouchersItems.setVoucherType(finVouchers.getVoucherType());
|
|
|
+ finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
|
|
|
+ finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
+ finVouchersItems.setAccountYear(finVouchers.getAccountYear());
|
|
|
+ finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
|
|
|
+ finVouchersItems.setAccountDay(finVouchers.getAccountDay());
|
|
|
+ finVouchersItems.setAccountId(accounts.getId());
|
|
|
+ finVouchersItems.setAccountCode(accounts.getCode());
|
|
|
+ finVouchersItems.setAccountCnName(accounts.getCnName());
|
|
|
+ finVouchersItems.setAccountEnName(accounts.getEnName());
|
|
|
+ finVouchersItems.setAccountProperty(accounts.getProperty());
|
|
|
+ finVouchersItems.setAccountLevel(accounts.getLevel());
|
|
|
+ finVouchersItems.setDc(item.getAmountDirection());
|
|
|
+ finVouchersItems.setCurCode(item.getCurrencyCode());
|
|
|
+ /*判断是否人民币,美元
|
|
|
+ * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
+ * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
+ * 借或贷金额为零时跳过本次循环
|
|
|
+ * */
|
|
|
+ if ("CNY".equals(item.getCurrencyCode())) {
|
|
|
+ finVouchersItems.setExrate(new BigDecimal("1"));
|
|
|
+ if ("D".equals(item.getAmountDirection())) {
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
+ finVouchersItems.setAmountDr(amount[count - 1]);
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountCr(new BigDecimal("0.00").subtract(amount[count - 1]));
|
|
|
}
|
|
|
} else {
|
|
|
- formulasValue.append(field.get(billsDetail)).append(" ");
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- } else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
|
|
|
- try {
|
|
|
- Field field = AeaBills.class.getDeclaredField(i);
|
|
|
- field.setAccessible(true);
|
|
|
- if (field.getType().equals(Date.class)) {
|
|
|
- if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
|
|
|
- String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
|
|
|
- formulasValue.append(formattedDate).append(" ");
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountDr(new BigDecimal("0.00").subtract(amount[count - 1]));
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
+ finVouchersItems.setAmountCr(amount[count - 1]);
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- formulasValue.append(field.get(aeaBillsDetail)).append(" ");
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- } else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
|
|
|
- "BGAE".equals(checkType) || "BGAI".equals(checkType)) {
|
|
|
- try {
|
|
|
- Field field = CustomsDeclaration.class.getDeclaredField(i);
|
|
|
- field.setAccessible(true);
|
|
|
- if (field.getType().equals(Date.class)) {
|
|
|
- if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
|
|
|
- String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
|
|
|
- formulasValue.append(formattedDate).append(" ");
|
|
|
+ } else {
|
|
|
+ if ("D".equals(item.getAmountDirection())) {
|
|
|
+ finVouchersItems.setExrate(rateD);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
+ finVouchersItems.setAmountDrUsd(amount[count - 1]);
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateD));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountCrUsd(new BigDecimal("0.00").subtract(amount[count - 1]));
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateD));
|
|
|
}
|
|
|
} else {
|
|
|
- formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
|
|
|
+ finVouchersItems.setExrate(rateC);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountDrUsd(new BigDecimal("0.00").subtract(amount[count - 1]));
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(rateC));
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
+ finVouchersItems.setAmountCrUsd(amount[count - 1]);
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(rateC));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
}
|
|
|
- } else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
|
|
|
- "aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
|
|
|
- try {
|
|
|
- Field field = Amends.class.getDeclaredField(i);
|
|
|
- field.setAccessible(true);
|
|
|
- if (field.getType().equals(Date.class)) {
|
|
|
- if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
|
|
|
- String formattedDate = dateFormat.format(field.get(amendsDetail));
|
|
|
- formulasValue.append(formattedDate).append(" ");
|
|
|
+ //计算借,贷人民币与美金合计人民币金额
|
|
|
+ finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
|
|
|
+ .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
|
|
|
+ finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
|
|
|
+ .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
|
|
|
+ finVouchersItems.setIsCorp(accounts.getIsCorp());
|
|
|
+ finVouchersItems.setLineNo(count);
|
|
|
+ StringBuilder formulasValue = new StringBuilder();
|
|
|
+ formulasValue.append(" ");
|
|
|
+ String formulasData = item.getAdditionalFormulas();
|
|
|
+ String[] arr = formulasData.split(",");
|
|
|
+ for (String l : arr) {
|
|
|
+ if ("HYCK-DJ".equals(checkType) || "HYJK-DJ".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = Bills.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(billsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(billsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(billsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("KYCK-DJ".equals(checkType) || "KYJK-DJ".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = AeaBills.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(aeaBillsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(aeaBillsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(aeaBillsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("BGSE".equals(checkType) || "BGSI".equals(checkType) ||
|
|
|
+ "BGAE".equals(checkType) || "BGAI".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = CustomsDeclaration.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(customsDeclarationDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(customsDeclarationDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(customsDeclarationDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ } else if ("sea-approve".equals(checkType) || "sia-approve".equals(checkType) ||
|
|
|
+ "aea-approve".equals(checkType) || "aia-approve".equals(checkType)) {
|
|
|
+ try {
|
|
|
+ Field field = Amends.class.getDeclaredField(l);
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.getType().equals(Date.class)) {
|
|
|
+ if (ObjectUtils.isNotNull(field.get(amendsDetail))) {
|
|
|
+ String formattedDate = dateFormat.format(field.get(amendsDetail));
|
|
|
+ formulasValue.append(formattedDate).append(" ");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ formulasValue.append(field.get(amendsDetail)).append(" ");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
- } else {
|
|
|
- formulasValue.append(field.get(amendsDetail)).append(" ");
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
}
|
|
|
+ finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
|
|
|
+ finVouchersItemsList.add(finVouchersItems);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("未找到科目信息");
|
|
|
}
|
|
|
- finVouchersItems.setDescr(item.getStaticValue() + formulasValue);
|
|
|
- finVouchersItemsList.add(finVouchersItems);
|
|
|
}
|
|
|
+
|
|
|
finVouchersItemsService.saveOrUpdateBatch(finVouchersItemsList);
|
|
|
BigDecimal amountDrCNY = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrCNY = new BigDecimal("0.00");
|
|
|
BigDecimal amountDrUSD = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrUSD = new BigDecimal("0.00");
|
|
|
- amountDrCNY = amountDrCNY.add(finVouchersItemsList.stream()
|
|
|
- .filter(e -> "CNY".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FinVouchersItems::getAmountDr)
|
|
|
- .filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ amountDrCNY = amountDrCNY.add(finVouchersItemsList.stream().filter(e -> "CNY".equals(e.getCurCode())
|
|
|
+ && "D".equals(e.getDc())).map(FinVouchersItems::getAmountDr).filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
finVouchers.setAmountDr(amountDrCNY);
|
|
|
- amountCrCNY = amountCrCNY.add(finVouchersItemsList.stream()
|
|
|
- .filter(e -> "CNY".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FinVouchersItems::getAmountCr)
|
|
|
- .filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ amountCrCNY = amountCrCNY.add(finVouchersItemsList.stream().filter(e -> "CNY".equals(e.getCurCode())
|
|
|
+ && "C".equals(e.getDc())).map(FinVouchersItems::getAmountCr).filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
finVouchers.setAmountCr(amountCrCNY);
|
|
|
- amountDrUSD = amountDrUSD.add(finVouchersItemsList.stream()
|
|
|
- .filter(e -> "USD".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FinVouchersItems::getAmountDrUsd)
|
|
|
- .filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ amountDrUSD = amountDrUSD.add(finVouchersItemsList.stream().filter(e -> "USD".equals(e.getCurCode())
|
|
|
+ && "D".equals(e.getDc())).map(FinVouchersItems::getAmountDrUsd).filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
finVouchers.setAmountDrUsd(amountDrUSD);
|
|
|
- amountCrUSD = amountCrUSD.add(finVouchersItemsList.stream()
|
|
|
- .filter(e -> "USD".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FinVouchersItems::getAmountCrUsd)
|
|
|
- .filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ amountCrUSD = amountCrUSD.add(finVouchersItemsList.stream().filter(e -> "USD".equals(e.getCurCode())
|
|
|
+ && "C".equals(e.getDc())).map(FinVouchersItems::getAmountCrUsd).filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
finVouchers.setAmountCrUsd(amountCrUSD);
|
|
|
finVouchers.setAmountDrLoc(amountDrCNY.add(bCurrencyService.converterCny("USD", amountDrUSD, "D", "1")));
|
|
|
finVouchers.setAmountCrLoc(amountCrCNY.add(bCurrencyService.converterCny("USD", amountCrUSD, "C", "1")));
|