Fix #769 - Order previous invoices by end date descending and id descending

See #769.