mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for chart queries
This commit is contained in:
parent
9668f6ceb7
commit
a66c9cc046
@ -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();
|
||||
|
@ -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()));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user