Refactors some code in InvoiceRepository