From 804ac665330a6fc92905c9a8645610f24459a22e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 20 Apr 2018 20:18:49 +1000 Subject: [PATCH] Develop (#2042) fix for incorrect currency displayed in dashboard totals --- app/Http/Controllers/DashboardApiController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/DashboardApiController.php b/app/Http/Controllers/DashboardApiController.php index 0ca7eb6475bc..894a2e3593a9 100644 --- a/app/Http/Controllers/DashboardApiController.php +++ b/app/Http/Controllers/DashboardApiController.php @@ -21,6 +21,7 @@ class DashboardApiController extends BaseAPIController $viewAll = $user->hasPermission('view_all'); $userId = $user->id; $accountId = $user->account->id; + $defaultCurrency = $user->account->currency_id; $dashboardRepo = $this->dashboardRepo; $metrics = $dashboardRepo->totals($accountId, $userId, $viewAll); @@ -44,11 +45,11 @@ class DashboardApiController extends BaseAPIController $data = [ 'id' => 1, 'paidToDate' => $paidToDate->count() && $paidToDate[0]->value ? $paidToDate[0]->value : 0, - 'paidToDateCurrency' => $paidToDate->count() && $paidToDate[0]->currency_id ? $paidToDate[0]->currency_id : 0, + 'paidToDateCurrency' => $paidToDate->count() && $paidToDate[0]->currency_id ? $paidToDate[0]->currency_id : $defaultCurrency, 'balances' => $balances->count() && $balances[0]->value ? $balances[0]->value : 0, - 'balancesCurrency' => $balances->count() && $balances[0]->currency_id ? $balances[0]->currency_id : 0, + 'balancesCurrency' => $balances->count() && $balances[0]->currency_id ? $balances[0]->currency_id : $defaultCurrency, 'averageInvoice' => $averageInvoice->count() && $averageInvoice[0]->invoice_avg ? $averageInvoice[0]->invoice_avg : 0, - 'averageInvoiceCurrency' => $averageInvoice->count() && $averageInvoice[0]->currency_id ? $averageInvoice[0]->currency_id : 0, + 'averageInvoiceCurrency' => $averageInvoice->count() && $averageInvoice[0]->currency_id ? $averageInvoice[0]->currency_id : $defaultCurrency, 'invoicesSent' => $metrics ? $metrics->invoices_sent : 0, 'activeClients' => $metrics ? $metrics->active_clients : 0, 'activities' => $this->createCollection($activities, new ActivityTransformer(), ENTITY_ACTIVITY),