Fix for currency symbol

This commit is contained in:
Hillel Coren 2016-10-20 18:14:54 +03:00
parent 4c5b4d5164
commit d92f7fadc0
4 changed files with 12 additions and 4 deletions

View File

@ -354,7 +354,7 @@ class Utils
return $data->first(); 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); $value = floatval($value);
@ -362,6 +362,10 @@ class Utils
$currencyId = Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY); $currencyId = Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY);
} }
if (!$decorator) {
$decorator = Session::get(SESSION_CURRENCY_DECORATOR, CURRENCY_DECORATOR_SYMBOL);
}
if (!$countryId && Auth::check()) { if (!$countryId && Auth::check()) {
$countryId = Auth::user()->account->country_id; $countryId = Auth::user()->account->country_id;
} }

View File

@ -438,7 +438,7 @@ class Account extends Eloquent
* @param bool $hideSymbol * @param bool $hideSymbol
* @return string * @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) { if ($client && $client->currency_id) {
$currencyId = $client->currency_id; $currencyId = $client->currency_id;
@ -456,6 +456,10 @@ class Account extends Eloquent
$countryId = false; $countryId = false;
} }
if ( ! $decorator) {
$decorator = $this->show_currency_code ? CURRENCY_DECORATOR_CODE : CURRENCY_DECORATOR_SYMBOL;
}
return Utils::formatMoney($amount, $currencyId, $countryId, $decorator); return Utils::formatMoney($amount, $currencyId, $countryId, $decorator);
} }

View File

@ -31,7 +31,7 @@ class ClientRepository extends BaseRepository
->where('clients.account_id', '=', \Auth::user()->account_id) ->where('clients.account_id', '=', \Auth::user()->account_id)
->where('contacts.is_primary', '=', true) ->where('contacts.is_primary', '=', true)
->where('contacts.deleted_at', '=', null) ->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( ->select(
DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'), DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'),
DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'), DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'),

View File

@ -50,7 +50,7 @@ class InvoiceRepository extends BaseRepository
->where('contacts.deleted_at', '=', null) ->where('contacts.deleted_at', '=', null)
->where('invoices.is_recurring', '=', false) ->where('invoices.is_recurring', '=', false)
->where('contacts.is_primary', '=', true) ->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( ->select(
DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'), DB::raw('COALESCE(clients.currency_id, accounts.currency_id) currency_id'),
DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'), DB::raw('COALESCE(clients.country_id, accounts.country_id) country_id'),