From 97d67fee9d06d2e82a1d53f1a5d0590d89b2e3c1 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Fri, 5 Apr 2019 15:13:47 +0300 Subject: [PATCH] formatting --- app/Models/Banking/Account.php | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/app/Models/Banking/Account.php b/app/Models/Banking/Account.php index 950ed2915..8308b81ca 100644 --- a/app/Models/Banking/Account.php +++ b/app/Models/Banking/Account.php @@ -91,25 +91,11 @@ class Account extends Model // Opening Balance $total = $this->opening_balance; - // Sum invoices - foreach ($this->invoice_payments as $item) { - $total += $item->amount; - } + // Sum Incomes + $total += $this->invoice_payments()->sum('amount') + $this->revenues()->sum('amount'); - // Sum revenues - foreach ($this->revenues as $item) { - $total += $item->amount; - } - - // Subtract bills - foreach ($this->bill_payments as $item) { - $total -= $item->amount; - } - - // Subtract payments - foreach ($this->payments as $item) { - $total -= $item->amount; - } + // Subtract Expenses + $total -= $this->bill_payments()->sum('amount') + $this->payments()->sum('amount'); return $total; }