Coalesce dashboard results to 0
This commit is contained in:
parent
ce42880697
commit
ef1003a685
|
@ -19,11 +19,11 @@ func ServeDashboard(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
|
|||
conn := getConn(r)
|
||||
rows := conn.MustQuery(r.Context(), `
|
||||
select to_price(0, decimal_digits) as sales
|
||||
, to_price(invoice.total, decimal_digits) as income
|
||||
, to_price(expense.total, decimal_digits) as expenses
|
||||
, to_price(tax.vat, decimal_digits) as vat
|
||||
, to_price(tax.irpf, decimal_digits) as irpf
|
||||
, to_price(invoice.total - expense.total - tax.vat + tax.irpf, decimal_digits) as net_income
|
||||
, to_price(coalesce(invoice.total, 0), decimal_digits) as income
|
||||
, to_price(coalesce(expense.total, 0), decimal_digits) as expenses
|
||||
, to_price(coalesce(tax.vat, 0), decimal_digits) as vat
|
||||
, to_price(coalesce(tax.irpf, 0), decimal_digits) as irpf
|
||||
, to_price(coalesce(invoice.total - expense.total - tax.vat + tax.irpf, 0), decimal_digits) as net_income
|
||||
from company
|
||||
left join (
|
||||
select company_id, sum(total)::integer as total
|
||||
|
|
Loading…
Reference in New Issue