Filtering undef invoices in update and adding a new on_transactions hook