Use indexes and cache to make search on amounts faster
This optimization relies on the idea that few invoices should stay in the states where the amount cache fields are empty. It splits the search query in two parts: one on the cached fields, the other on the computation with the invoice lines (and tax lines when it applies).
Fix #11919 (closed)