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)
|
join currency using (currency_code)
|
||||||
group by decimal_digits
|
group by decimal_digits
|
||||||
`, where), args...)
|
`, where), args...)
|
||||||
if err := row.Scan(&page.SumAmount, &page.SumTotal); err != nil {
|
if notFoundErrorOrPanic(row.Scan(&page.SumAmount, &page.SumTotal)) {
|
||||||
panic(err)
|
page.SumAmount = "0.0"
|
||||||
|
page.SumTotal = "0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
row = conn.QueryRow(ctx, fmt.Sprintf(`
|
row = conn.QueryRow(ctx, fmt.Sprintf(`
|
||||||
|
@ -180,8 +181,8 @@ func (page *expensesIndexPage) mustComputeExpensesTotalAmount(ctx context.Contex
|
||||||
group by decimal_digits
|
group by decimal_digits
|
||||||
`, where), args...)
|
`, where), args...)
|
||||||
var taxes [][]string
|
var taxes [][]string
|
||||||
if err := row.Scan(&taxes); err != nil {
|
if notFoundErrorOrPanic(row.Scan(&taxes)) {
|
||||||
panic(err)
|
// well, nothing to do
|
||||||
}
|
}
|
||||||
page.SumTaxes = make(map[string]string)
|
page.SumTaxes = make(map[string]string)
|
||||||
for _, tax := range taxes {
|
for _, tax := range taxes {
|
||||||
|
|
Loading…
Reference in New Issue