diff --git a/app/Services/Chart/ChartService.php b/app/Services/Chart/ChartService.php index 877ab5393a2d..17660ae89df1 100644 --- a/app/Services/Chart/ChartService.php +++ b/app/Services/Chart/ChartService.php @@ -35,12 +35,8 @@ class ChartService $currencies = Client::withTrashed() ->where('company_id', $this->company->id) ->where('is_deleted', 0) - ->distinct(); - - if(!$this->is_admin) - $currencies->where('user_id', $this->user->id); - - $currencies->pluck('settings->currency_id as id'); + ->distinct() + ->pluck('settings->currency_id as id'); /* Push the company currency on also */ $currencies->push((int) $this->company->settings->currency_id); @@ -49,14 +45,8 @@ class ChartService $expense_currencies = Expense::withTrashed() ->where('company_id', $this->company->id) ->where('is_deleted', 0) - ->distinct(); - - - if (!$this->is_admin) { - $expense_currencies->where('user_id', $this->user->id); - } - - $expense_currencies->pluck('currency_id as id'); + ->distinct() + ->pluck('currency_id as id'); /* Merge and filter by unique */ $currencies = $currencies->merge($expense_currencies)->unique(); diff --git a/tests/Unit/Chart/ChartCurrencyTest.php b/tests/Unit/Chart/ChartCurrencyTest.php index 888d5c35f0a1..ed9558d6d79b 100644 --- a/tests/Unit/Chart/ChartCurrencyTest.php +++ b/tests/Unit/Chart/ChartCurrencyTest.php @@ -50,7 +50,7 @@ class ChartCurrencyTest extends TestCase $this->assertDatabaseHas('invoices', ['number' => 'db_record']); - $cs = new ChartService($this->company); + $cs = new ChartService($this->company, $this->user, true); // nlog($cs->getRevenueQuery(now()->subDays(20)->format('Y-m-d'), now()->addDays(100)->format('Y-m-d'))); $data = [ @@ -86,7 +86,7 @@ class ChartCurrencyTest extends TestCase 'settings' => $settings, ]); - $cs = new ChartService($this->company); + $cs = new ChartService($this->company, $this->user, true); $this->assertTrue(is_array($cs->getCurrencyCodes())); @@ -131,7 +131,7 @@ class ChartCurrencyTest extends TestCase ], ]; - $cs = new ChartService($this->company); + $cs = new ChartService($this->company, $this->user, true); // nlog($cs->totals(now()->subYears(10), now()));