From 9872dab2abe1923e5d8989cd688052f2dc5fb415 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 16 May 2023 17:57:28 +1000 Subject: [PATCH] Fixes for chart queries --- app/Services/Chart/ChartService.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Services/Chart/ChartService.php b/app/Services/Chart/ChartService.php index 17660ae89df1..c9a8be50eda7 100644 --- a/app/Services/Chart/ChartService.php +++ b/app/Services/Chart/ChartService.php @@ -35,6 +35,9 @@ class ChartService $currencies = Client::withTrashed() ->where('company_id', $this->company->id) ->where('is_deleted', 0) + ->when(!$this->is_admin, function ($query) { + $query->where('user_id', $this->user->id); + }) ->distinct() ->pluck('settings->currency_id as id'); @@ -45,6 +48,9 @@ class ChartService $expense_currencies = Expense::withTrashed() ->where('company_id', $this->company->id) ->where('is_deleted', 0) + ->when(!$this->is_admin, function ($query) { + $query->where('user_id', $this->user->id); + }) ->distinct() ->pluck('currency_id as id');