You can construct an efficient where clause as a SQL fragment.
def does_not_have_an_incomplete_debit
self.where("not exists
(select null
from debit_invoices di
join debits d on d.id = di.debit_id
where di.invoice_id = invoices.id and
d.completed = false)")
end
Then:
Invoices.for_current_user(current_usser.id).does_not_have_an_incomplete_debit.all