I have to get the receipt id for not paid invoices. Orders has multiple receipts and receipts has invoices. I am using Java 8 stream. From receipts stream, I am able to get only invoices list, but I want to get receipt id for not paid invoices
Here is my code:
List<Invoice> invoicesNotPaid = receipts.stream()
.map(ReceiptsVO::getInvoices)
.flatMap(List::stream)
.map(inv -> Invoice.builder().status(InvoiceStatus.getStatus(inv.getStatus().name())).build())
.filter(Invoice::hasNotBeenPaid).collect(Collectors.toList());
after the final filter I am getting invoices only, I am not able to get the original receipts object reference. I have to do some thing like below, after checking the receipts against not paid invoices.
receipts -> receipt.getReceiptId()
How to get the receipt Id for not paid invoices?