Coalesce individual dashboard results to 0 when computing net income

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

View File

@ -23,7 +23,7 @@ func ServeDashboard(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
, to_price(coalesce(expense.total, 0), decimal_digits) as expenses , to_price(coalesce(expense.total, 0), decimal_digits) as expenses
, to_price(coalesce(tax.vat, 0), decimal_digits) as vat , to_price(coalesce(tax.vat, 0), decimal_digits) as vat
, to_price(coalesce(tax.irpf, 0), decimal_digits) as irpf , 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 , to_price(coalesce(invoice.total, 0) - coalesce(expense.total, 0) - coalesce(tax.vat, 0) + coalesce(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