From 25751bdd85da41584ba405c93c9f7c4c5e0f12f7 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Wed, 11 Oct 2023 15:08:20 -0400 Subject: [PATCH] Fix Balance sheet report so it doesn't calculate transfers, transfers use the expense and revenue tables as well. To fix this a transfer always has a vendor_id 0 in the expense table and category_id is always 0 for the revenues table, so dont sum those --- report_balance_sheet.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/report_balance_sheet.php b/report_balance_sheet.php index 6a486798..71b9d593 100644 --- a/report_balance_sheet.php +++ b/report_balance_sheet.php @@ -12,8 +12,8 @@ a.account_notes, a.account_type, COALESCE(SUM(p.payment_amount), 0) AS total_payments, - COALESCE(SUM(r.revenue_amount), 0) AS total_revenues, - COALESCE(SUM(e.expense_amount), 0) AS total_expenses + COALESCE(SUM(CASE WHEN r.revenue_category_id = 0 THEN r.revenue_amount ELSE 0 END), 0) AS total_revenues + COALESCE(SUM(CASE WHEN e.expense_vendor_id = 0 THEN e.expense_amount ELSE 0 END), 0) AS total_expenses FROM accounts a LEFT JOIN payments p ON a.account_id = p.payment_account_id LEFT JOIN revenues r ON a.account_id = r.revenue_account_id