8 天以前 77bbe488ca8aa21d81a4f8f4fcef205fd890ef83
src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -97,6 +97,9 @@
    @Override
    public int insertPaymentRegistration(PaymentRegistration paymentRegistration) {
        PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(paymentRegistration.getPurchaseLedgerId());
        if(purchaseLedger == null){
            throw new RuntimeException("关联采购台账不存在");
        }
        SalesLedger salesLedger = salesLedgerMapper.selectOne(new QueryWrapper<SalesLedger>().
                eq("sales_contract_no", purchaseLedger.getSalesContractNo()));
//        if (salesLedger == null) {
@@ -220,10 +223,10 @@
                            new QueryWrapper<SalesLedgerProduct>().eq("sales_ledger_id", id).eq("type",2)
                    ).stream())
                    .collect(Collectors.toList());
            payableAmount = salesLedgerProducts.stream()
                    .map(SalesLedgerProduct::getTaxInclusiveTotalPrice)
                    .filter(Objects::nonNull)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
//            payableAmount = salesLedgerProducts.stream()
//                    .map(SalesLedgerProduct::getTaxInclusiveTotalPrice)
//                    .filter(Objects::nonNull)
//                    .reduce(BigDecimal.ZERO, BigDecimal::add);
            // 来票金额计算
            List<TicketRegistration> ticketRegistrations = purchaseLedgers.stream()
@@ -247,6 +250,11 @@
                    .map(PaymentRegistration::getCurrentPaymentAmount)
                    .filter(Objects::nonNull)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
            // 核心过滤逻辑:当paymentAmount和invoiceAmount同时为0时,跳过该记录
            if (BigDecimal.ZERO.compareTo(paymentAmount) == 0 && BigDecimal.ZERO.compareTo(invoiceAmount) == 0) {
                continue; // 跳过当前供应商,不加入结果集
            }
            // 详情分页处理
            detailPageNum = detailPageNum != null ? detailPageNum : 1;
@@ -301,6 +309,8 @@
            result.add(res);
        }
        // 修正总条数:过滤后需要重新计算总条数
        resultPage.setTotal(result.size());
        resultPage.setRecords(result);
        return resultPage;
    }
@@ -373,13 +383,14 @@
        // 应付总金额金额计算
        BigDecimal amountTotal = BigDecimal.ZERO;
        if(CollectionUtils.isNotEmpty(paymentRecordList)) {
            // 核心分组求和逻辑
            Map<LocalDate, List<PaymentHistoryRecordVo>> dateListMap = paymentRecordList.stream().collect(
                                                                        Collectors.groupingBy(
                                                                                PaymentHistoryRecordVo::getHappenTime,
                                                                                LinkedHashMap::new,
                                                                                Collectors.toList()
                                                                        )
                                                                        );
                    Collectors.groupingBy(
                            PaymentHistoryRecordVo::getHappenTime,
                            LinkedHashMap::new,
                            Collectors.toList()
                    )
            );
            for (LocalDate localDate : dateListMap.keySet()) {
                BigDecimal currentPaymentAmount = BigDecimal.ZERO;
                BigDecimal invoiceAmount = BigDecimal.ZERO;