| | |
| | | .map(PurchaseLedger::getId) |
| | | .filter(Objects::nonNull) |
| | | .flatMap(id -> salesLedgerProductMapper.selectList( |
| | | new QueryWrapper<SalesLedgerProduct>().eq("sales_ledger_id", id) |
| | | new QueryWrapper<SalesLedgerProduct>().eq("sales_ledger_id", id).eq("type",2) |
| | | ).stream()) |
| | | .collect(Collectors.toList()); |
| | | payableAmount = salesLedgerProducts.stream() |
| | |
| | | @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; |
| | | } |
| | | |
| | | /** |
| | | * 查询付款登记列表分页 |
| | | * |
| | | * @param paymentRegistrationDto 付款登记 |
| | | * @return 付款登记集合 |
| | | */ |
| | | @Override |
| | | public IPage<PaymentRegistrationDto> paymentHistoryListPage(Page page, PaymentRegistrationDto paymentRegistrationDto) { |
| | | return paymentRegistrationMapper.paymentHistoryListPage(page, paymentRegistrationDto); |
| | | } |
| | | |
| | | // 批量查询采购台账(当月) |