When creating invoices and credit notes wrap it in a transaction