Avoid panic error when there is no expense to compute the sum of
This commit is contained in:
parent
ef215f1e6e
commit
4e831d94db
|
@ -158,8 +158,9 @@ func (page *expensesIndexPage) mustComputeExpensesTotalAmount(ctx context.Contex
|
|||
join currency using (currency_code)
|
||||
group by decimal_digits
|
||||
`, where), args...)
|
||||
if err := row.Scan(&page.SumAmount, &page.SumTotal); err != nil {
|
||||
panic(err)
|
||||
if notFoundErrorOrPanic(row.Scan(&page.SumAmount, &page.SumTotal)) {
|
||||
page.SumAmount = "0.0"
|
||||
page.SumTotal = "0.0"
|
||||
}
|
||||
|
||||
row = conn.QueryRow(ctx, fmt.Sprintf(`
|
||||
|
@ -180,8 +181,8 @@ func (page *expensesIndexPage) mustComputeExpensesTotalAmount(ctx context.Contex
|
|||
group by decimal_digits
|
||||
`, where), args...)
|
||||
var taxes [][]string
|
||||
if err := row.Scan(&taxes); err != nil {
|
||||
panic(err)
|
||||
if notFoundErrorOrPanic(row.Scan(&taxes)) {
|
||||
// well, nothing to do
|
||||
}
|
||||
page.SumTaxes = make(map[string]string)
|
||||
for _, tax := range taxes {
|
||||
|
|
Loading…
Reference in New Issue