From 0c4cbd69bd091341343bc8ffcba5b410905082aa Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 31 Mar 2016 17:27:18 +0300 Subject: [PATCH] Merge bug fixes from develop branch --- app/Http/Controllers/ReportController.php | 9 +++++++-- app/Models/TaxRate.php | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index f1feb65b4b..cfb9caadde 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -158,8 +158,10 @@ class ReportController extends BaseController } $records = DB::table($entityType.'s') - ->select(DB::raw('sum(amount) as total, '.$timeframe.' as '.$groupBy)) - ->where('account_id', '=', Auth::user()->account_id) + ->select(DB::raw('sum('.$entityType.'s.amount) as total, '.$timeframe.' as '.$groupBy)) + ->join('clients', 'clients.id', '=', $entityType.'s.client_id') + ->where('clients.is_deleted', '=', false) + ->where($entityType.'s.account_id', '=', Auth::user()->account_id) ->where($entityType.'s.is_deleted', '=', false) ->where($entityType.'s.'.$entityType.'_date', '>=', $startDate->format('Y-m-d')) ->where($entityType.'s.'.$entityType.'_date', '<=', $endDate->format('Y-m-d')) @@ -168,6 +170,9 @@ class ReportController extends BaseController if ($entityType == ENTITY_INVOICE) { $records->where('is_quote', '=', false) ->where('is_recurring', '=', false); + } elseif ($entityType == ENTITY_PAYMENT) { + $records->join('invoices', 'invoices.id', '=', 'payments.invoice_id') + ->where('invoices.is_deleted', '=', false); } $totals = $records->lists('total'); diff --git a/app/Models/TaxRate.php b/app/Models/TaxRate.php index 15c39a7572..cf0a576a8f 100644 --- a/app/Models/TaxRate.php +++ b/app/Models/TaxRate.php @@ -1,5 +1,6 @@