From d92f7fadc028e23bc3fc4ec74d8e6552a33c1653 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 20 Oct 2016 18:14:54 +0300 Subject: [PATCH] Fix for currency symbol --- app/Libraries/Utils.php | 6 +++++- app/Models/Account.php | 6 +++++- app/Ninja/Repositories/ClientRepository.php | 2 +- app/Ninja/Repositories/InvoiceRepository.php | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 6fd5b9e97c28..332cc9d980d0 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -354,7 +354,7 @@ class Utils return $data->first(); } - public static function formatMoney($value, $currencyId = false, $countryId = false, $decorator = CURRENCY_DECORATOR_SYMBOL) + public static function formatMoney($value, $currencyId = false, $countryId = false, $decorator = false) { $value = floatval($value); @@ -362,6 +362,10 @@ class Utils $currencyId = Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY); } + if (!$decorator) { + $decorator = Session::get(SESSION_CURRENCY_DECORATOR, CURRENCY_DECORATOR_SYMBOL); + } + if (!$countryId && Auth::check()) { $countryId = Auth::user()->account->country_id; } diff --git a/app/Models/Account.php b/app/Models/Account.php index 7025faf1a528..5de849746192 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -438,7 +438,7 @@ class Account extends Eloquent * @param bool $hideSymbol * @return string */ - public function formatMoney($amount, $client = null, $decorator = CURRENCY_DECORATOR_SYMBOL) + public function formatMoney($amount, $client = null, $decorator = false) { if ($client && $client->currency_id) { $currencyId = $client->currency_id; @@ -456,6 +456,10 @@ class Account extends Eloquent $countryId = false; } + if ( ! $decorator) { + $decorator = $this->show_currency_code ? CURRENCY_DECORATOR_CODE : CURRENCY_DECORATOR_SYMBOL; + } + return Utils::formatMoney($amount, $currencyId, $countryId, $decorator); } diff --git a/app/Ninja/Repositories/ClientRepository.php b/app/Ninja/Repositories/ClientRepository.php index d1a2d77df101..21ee40a435e9 100644 --- a/app/Ninja/Repositories/ClientRepository.php +++ b/app/Ninja/Repositories/ClientRepository.php @@ -31,7 +31,7 @@ class ClientRepository extends BaseRepository ->where('clients.account_id', '=', \Auth::user()->account_id) ->where('contacts.is_primary', '=', true) ->where('contacts.deleted_at', '=', null) - ->whereRaw('(clients.name != "" or contacts.first_name != "" or contacts.last_name != "" or contacts.email != "")') // filter out buy now invoices + //->whereRaw('(clients.name != "" or contacts.first_name != "" or contacts.last_name != "" or contacts.email != "")') // filter out buy now invoices ->select( DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'), DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'), diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 1b7cb59ab9ac..1f637464158a 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -50,7 +50,7 @@ class InvoiceRepository extends BaseRepository ->where('contacts.deleted_at', '=', null) ->where('invoices.is_recurring', '=', false) ->where('contacts.is_primary', '=', true) - ->whereRaw('(clients.name != "" or contacts.first_name != "" or contacts.last_name != "" or contacts.email != "")') // filter out buy now invoices + //->whereRaw('(clients.name != "" or contacts.first_name != "" or contacts.last_name != "" or contacts.email != "")') // filter out buy now invoices ->select( DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'), DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'),