src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -363,20 +363,46 @@ @Override public List<PaymentHistoryRecordVo> getPaymentRecordList(Long supplierId) { List<PaymentHistoryRecordVo> paymentRecordList = paymentRegistrationMapper.getPaymentRecordList(supplierId); if(!CollectionUtils.isEmpty(paymentRecordList)) { // 应付金额计算 BigDecimal amountTotal = BigDecimal.ZERO; for (PaymentHistoryRecordVo paymentHistoryRecordVo : paymentRecordList) { if(paymentHistoryRecordVo.getType() == 0){ amountTotal = amountTotal.subtract(paymentHistoryRecordVo.getCurrentPaymentAmount()); } if(paymentHistoryRecordVo.getType() == 1){ amountTotal = amountTotal.add(paymentHistoryRecordVo.getInvoiceAmount()); } List<PaymentHistoryRecordVo> result = new ArrayList<>(); // 应付总金额金额计算 BigDecimal amountTotal = BigDecimal.ZERO; if(CollectionUtils.isNotEmpty(paymentRecordList)) { Map<LocalDate, List<PaymentHistoryRecordVo>> dateListMap = paymentRecordList.stream().collect( Collectors.groupingBy( PaymentHistoryRecordVo::getHappenTime, LinkedHashMap::new, Collectors.toList() ) ); BigDecimal amountDateTotal = BigDecimal.ZERO; for (LocalDate localDate : dateListMap.keySet()) { BigDecimal currentPaymentAmount = BigDecimal.ZERO; BigDecimal invoiceAmount = BigDecimal.ZERO; BigDecimal currentDateTotal = BigDecimal.ZERO; List<PaymentHistoryRecordVo> paymentHistoryRecordVos = dateListMap.get(localDate); // 计算当天汇款数 currentPaymentAmount = paymentHistoryRecordVos.stream() .filter(item ->item.getType() == 0) .map(PaymentHistoryRecordVo::getCurrentPaymentAmount) .reduce(BigDecimal.ZERO,BigDecimal::add); // 计算今天来票数 invoiceAmount = paymentHistoryRecordVos.stream() .filter(item ->item.getType() == 1) .map(PaymentHistoryRecordVo::getInvoiceAmount) .reduce(BigDecimal.ZERO,BigDecimal::add); // 计算当日汇总 currentDateTotal = currentDateTotal.add(invoiceAmount).subtract(currentPaymentAmount); PaymentHistoryRecordVo paymentHistoryRecordVo = new PaymentHistoryRecordVo(); paymentHistoryRecordVo.setHappenTime(localDate); paymentHistoryRecordVo.setCurrentPaymentAmount(currentPaymentAmount); paymentHistoryRecordVo.setInvoiceAmount(invoiceAmount); amountTotal = amountTotal.add(currentDateTotal); paymentHistoryRecordVo.setPayableAmount(amountTotal); result.add(paymentHistoryRecordVo); } } return paymentRecordList; return result; } // 批量查询采购台账(当月) src/main/java/com/ruoyi/sales/service/impl/InvoiceRegistrationServiceImpl.java
@@ -10,9 +10,8 @@ import com.ruoyi.sales.dto.InvoiceRegistrationProductDto; import com.ruoyi.sales.dto.SalesLedgerDto; import com.ruoyi.sales.excel.InvoiceRegisAndProductExcelDto; import com.ruoyi.sales.mapper.InvoiceRegistrationMapper; import com.ruoyi.sales.mapper.InvoiceRegistrationProductMapper; import com.ruoyi.sales.mapper.SalesLedgerProductMapper; import com.ruoyi.sales.mapper.*; import com.ruoyi.sales.pojo.InvoiceLedger; import com.ruoyi.sales.pojo.InvoiceRegistration; import com.ruoyi.sales.pojo.InvoiceRegistrationProduct; import com.ruoyi.sales.pojo.SalesLedgerProduct; @@ -41,6 +40,9 @@ @Autowired private SalesLedgerProductMapper salesLedgerProductMapper; @Autowired private InvoiceLedgerMapper invoiceLedgerMapper; /** * 开票登记记录新增 * @param salesLedgerDto @@ -56,6 +58,7 @@ invoiceRegistration.setSalesLedgerId(salesLedgerDto.getId().intValue()); invoiceRegistrationMapper.insert(invoiceRegistration); List<SalesLedgerProduct> productData = salesLedgerDto.getProductData(); BigDecimal invoiceAmountTotal = BigDecimal.ZERO; if(CollectionUtils.isNotEmpty(productData)){ for (SalesLedgerProduct productDatum : productData) { // 如果开票数为0 跳过 @@ -63,6 +66,7 @@ if(null != currentInvoiceNum && BigDecimal.ZERO.compareTo(currentInvoiceNum) == 0){ continue; } invoiceAmountTotal = invoiceAmountTotal.add(currentInvoiceNum); InvoiceRegistrationProduct invoiceRegistrationProduct = new InvoiceRegistrationProduct(); BeanUtils.copyProperties(productDatum, invoiceRegistrationProduct); invoiceRegistrationProduct.setId(null); @@ -73,6 +77,11 @@ invoiceRegistrationProduct.setSalesLedgerProductId(productDatum.getId().intValue()); invoiceRegistrationProductMapper.insert(invoiceRegistrationProduct); salesLedgerProductMapper.updateById(productDatum); // 新增一条开票台账数据 InvoiceLedger invoiceLedger = new InvoiceLedger(); invoiceLedger.setInvoiceRegistrationProductId(invoiceRegistrationProduct.getId()); invoiceLedger.setInvoiceTotal(invoiceRegistrationProduct.getInvoiceAmount()); invoiceLedgerMapper.insert(invoiceLedger); } } }