Coalesce individual dashboard results to 0 when computing net income
This commit is contained in:
parent
ef1003a685
commit
f68aba1387
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue