See the view "de.metas.fresh".C_Invoice_Candidate_DocTypeInvoice_V and its comment.
"de.metas.fresh".C_Invoice_Candidate_DocTypeInvoice_V