Ver código fonte

修改bug:
私有应收-跟单,查看明细点不开

jiakai 3 meses atrás
pai
commit
4eba29f45c

+ 38 - 12
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -3569,18 +3569,44 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         log.info("followSettlementDetailExcel:settlementQueryVo=[{}]", JSONUtil.toJsonStr(settlementQueryVo));
         settlementQueryVo.setSystemCode(baseController.getSystemCode());
         Page<InvoiceRecordResult> invoiceRecordResultPage = baseMapper.followSettlementDetailExcel(page, settlementQueryVo);
-        invoiceRecordResultPage.getRecords().forEach(dto -> {
-            if (dto.getInvoiceParty().equals("1")) {
-                dto.setInvoiceParty("我方开票");
-            } else if (dto.getInvoiceParty().equals("2")) {
-                dto.setInvoiceParty("保司开票");
-            }
-            if (dto.getStatus().equals("1")) {
-                dto.setStatus("已结算");
-            } else if (dto.getStatus().equals("0")) {
-                dto.setStatus("未结算");
-            }
-        });
+        List<InvoiceRecordResult> records = invoiceRecordResultPage.getRecords();
+        if(CollUtil.isNotEmpty(records)){
+            Map<String, String> allCompanyHierarchyPaths = esmInsCompanyClient.getAllCompanyHierarchyPaths();
+            records.stream().peek(action->{
+                if (action.getInvoiceParty().equals("1")) {
+                    action.setInvoiceParty("我方开票");
+                } else if (action.getInvoiceParty().equals("2")) {
+                    action.setInvoiceParty("保司开票");
+                }
+                if (action.getStatus().equals("1")) {
+                    action.setStatus("已结算");
+                } else if (action.getStatus().equals("0")) {
+                    action.setStatus("未结算");
+                }
+                String settlementStatusName = Constant.settlementStatusMap.get(Objects.toString(action.getStatus(),""));
+                action.setSettlementStatusName(settlementStatusName);
+                String invoiceRiskTypeName = Constant.invoiceRiskTypeMap.get(Objects.toString(action.getInvoiceRiskType(), ""));
+                action.setAccountsReceivable(invoiceRiskTypeName);
+                action.setInvoiceRiskTypeName(invoiceRiskTypeName);
+                List<InsPlyIncomeInvoiceSettlement> insPlyIncomeInvoiceSettlements = baseMapper.queryInvoiceSettlementByInvoiceId(action.getId());
+                BigDecimal settlementAmount = insPlyIncomeInvoiceSettlements.stream()
+                        .map(InsPlyIncomeInvoiceSettlement::getActualReceivedAmount)
+                        .filter(Objects::nonNull)
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+                BigDecimal receivableSupervisePremium = action.getReceivableSupervisePremium()  != null ? action.getReceivableSupervisePremium(): BigDecimal.ZERO;
+//                BigDecimal overinflatedAmount = action.getOverinflatedAmount() != null? action.getOverinflatedAmount(): BigDecimal.ZERO;
+                // 待结算金额 = 开票金额 - 已收金额
+                BigDecimal remainSettlementAmount = receivableSupervisePremium.subtract(settlementAmount);
+                // 设置已结算的金额
+                action.setSettlementAmount(settlementAmount);
+                // 设置待结算金额
+                action.setRemainSettlementAmount(remainSettlementAmount);
+                action.setCompanyAllName(allCompanyHierarchyPaths.get(Objects.toString(action.getCompanyId(),"")));
+                action.setSettlementStatus(settlementStatusName);
+                // 开票金额
+                action.setReceivableAmount(action.getReceivableSupervisePremium().subtract(action.getOverinflatedAmount()).toString());
+            }).toList();
+        }
         return invoiceRecordResultPage;
     }