Coalesce dashboard results to 0

This commit is contained in:
jordi fita mas 2023-05-16 15:14:20 +02:00
parent ce42880697
commit ef1003a685
1 changed files with 5 additions and 5 deletions

View File

@ -19,11 +19,11 @@ func ServeDashboard(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
conn := getConn(r) conn := getConn(r)
rows := conn.MustQuery(r.Context(), ` rows := conn.MustQuery(r.Context(), `
select to_price(0, decimal_digits) as sales select to_price(0, decimal_digits) as sales
, to_price(invoice.total, decimal_digits) as income , to_price(coalesce(invoice.total, 0), decimal_digits) as income
, to_price(expense.total, decimal_digits) as expenses , to_price(coalesce(expense.total, 0), decimal_digits) as expenses
, to_price(tax.vat, decimal_digits) as vat , to_price(coalesce(tax.vat, 0), decimal_digits) as vat
, to_price(tax.irpf, decimal_digits) as irpf , to_price(coalesce(tax.irpf, 0), decimal_digits) as irpf
, to_price(invoice.total - expense.total - tax.vat + tax.irpf, decimal_digits) as net_income , to_price(coalesce(invoice.total - expense.total - tax.vat + tax.irpf, 0), decimal_digits) as net_income
from company from company
left join ( left join (
select company_id, sum(total)::integer as total select company_id, sum(total)::integer as total