Google sheet - get unique invoice rows as per conditions

Job ID: 30864086

Budget: ₹600 – ₹1,500 INR

I have a Google sheet with about 10000 rows . It's has invoices which are marked as paid and open. Many of them are marked as paid in one row and open on another row (same invoice number). I want to extract only the paid invoices , which also have an open entry and the open invoices which have no paid entry. Also select where paid only is there.
There are rows which are duplicates, these duplicates also need to be removed.

Sample google sheet - https://docs.google.com/spreadsheets/d/12GqMxRzqxpJqIqxL2UEPqZwAdChWFqtsIu150azx7fU/edit?usp=sharing

Partial solution on stack overflow
https://webapps.stackexchange.com/questions/155751/google-sheet-select-rows-of-paid-where-open-and-paid-are-there-and-open-only-and?noredirect=1#comment142152_155751
Related categories: JavaScript Data Processing Excel Google Sheets