From 30fb36ff8b66f06ac9f4bfc775ff983d8d33b7e8 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 5 Jul 2024 23:36:28 +1000 Subject: [PATCH] Discounts should be removed from invoice totals not added --- app/Models/Account.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Account.php b/app/Models/Account.php index 07ccf5c..ec497b7 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -258,8 +258,8 @@ class Account extends Model implements IDs DB::raw('SUM(discount) AS _discount'), DB::raw('SUM(item_total) AS _item_total'), DB::raw('SUM(payment_fees) AS _payment_fee'), - DB::raw('ROUND(CAST(SUM(item_total)-SUM(COALESCE(discount,0))+COALESCE(invoices.discount_amt,0) AS NUMERIC),2) AS _total'), - DB::raw('ROUND(CAST(SUM(item_total)-SUM(COALESCE(discount,0))+COALESCE(invoices.discount_amt,0)-SUM(payments) AS NUMERIC),2) AS _balance'), + DB::raw('ROUND(CAST(SUM(item_total)-SUM(COALESCE(discount,0))-COALESCE(invoices.discount_amt,0) AS NUMERIC),2) AS _total'), + DB::raw('ROUND(CAST(SUM(item_total)-SUM(COALESCE(discount,0))-COALESCE(invoices.discount_amt,0)-SUM(payments) AS NUMERIC),2) AS _balance'), 'invoices.due_at', 'invoices.created_at', ])