gaoluyang
2 天以前 bd5825f42960b67c23c69fc23c8aa5339cc4d084
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/service/finance/ErpFinancePaymentServiceImpl.java
@@ -160,7 +160,10 @@
    }
    private void calculateTotalPrice(ErpFinancePaymentDO payment, List<ErpFinancePaymentItemDO> paymentItems) {
        payment.setTotalPrice(getSumValue(paymentItems, ErpFinancePaymentItemDO::getPaymentPrice, BigDecimal::add, BigDecimal.ZERO));
        // 合计付款允许用户手动修改,未传时再按付款明细汇总
        if (payment.getTotalPrice() == null) {
            payment.setTotalPrice(getSumValue(paymentItems, ErpFinancePaymentItemDO::getPaymentPrice, BigDecimal::add, BigDecimal.ZERO));
        }
        payment.setPaymentPrice(payment.getTotalPrice().subtract(payment.getDiscountPrice()));
    }
@@ -349,6 +352,10 @@
     * @param supplierId 供应商编号
     */
    private void validateInvoiceForPayment(Long invoiceId, Long supplierId) {
        // 未关联来票时跳过校验(付款单允许不关联来票)
        if (invoiceId == null) {
            return;
        }
        // 1. 校验来票存在
        ErpPurchaseInvoiceDO invoice = invoiceService.getPurchaseInvoice(invoiceId);
        if (invoice == null) {
@@ -373,6 +380,10 @@
     * @param oldPaymentPrice 更新场景下,该付款单自身当前的付款金额(用于排除自身),创建场景传 null
     */
    private void validatePaymentPriceExceedsInvoiceRemaining(Long invoiceId, BigDecimal paymentPrice, BigDecimal oldPaymentPrice) {
        // 未关联来票时无剩余可付金额可校验
        if (invoiceId == null) {
            return;
        }
        ErpPurchaseInvoiceDO invoice = invoiceService.getPurchaseInvoice(invoiceId);
        BigDecimal paidPrice = financePaymentMapper.selectPaymentPriceMapByInvoiceId(List.of(invoiceId))
                .getOrDefault(invoiceId, BigDecimal.ZERO);