[Answered ]-How can I find all the invoices that has at least 5 transactions and all the latest 5 transactions are in status 'paid'?

1👍

You can combine window function to find five latest transactions for the invoice.

And use django-cte to filter the result.

Leave a comment