Added total for invoices, also handling for nil values