Fix bugs and add totals for invoice details and pdf