| | |
| | | } |
| | | |
| | | 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())); |
| | | } |
| | | |
| | |
| | | * @param supplierId 供应商编号 |
| | | */ |
| | | private void validateInvoiceForPayment(Long invoiceId, Long supplierId) { |
| | | // 未关联来票时跳过校验(付款单允许不关联来票) |
| | | if (invoiceId == null) { |
| | | return; |
| | | } |
| | | // 1. 校验来票存在 |
| | | ErpPurchaseInvoiceDO invoice = invoiceService.getPurchaseInvoice(invoiceId); |
| | | if (invoice == null) { |
| | |
| | | * @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); |