From e83eade56a180368eff0e0f5733e63ac1e682027 Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Tue, 14 Aug 2018 11:40:16 +0300 Subject: [PATCH] refs #451 Banking -> Account currency issue solved --- app/Http/Controllers/Settings/Currencies.php | 23 +++++++++++-------- .../views/banking/accounts/create.blade.php | 4 +++- .../views/banking/accounts/edit.blade.php | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/Settings/Currencies.php b/app/Http/Controllers/Settings/Currencies.php index d6416e34f..550956d0e 100644 --- a/app/Http/Controllers/Settings/Currencies.php +++ b/app/Http/Controllers/Settings/Currencies.php @@ -270,16 +270,15 @@ class Currencies extends Controller { $json = new \stdClass(); - $account_id = request('account_id'); + $code = request('code'); - if ($account_id) { - $currencies = Currency::enabled()->pluck('name', 'code')->toArray(); + // Get currency object + $currency = Currency::where('code', $code)->first(); - $json->currency_code = Account::where('id', $account_id)->pluck('currency_code')->first(); - $json->currency_name = $currencies[$json->currency_code]; - } + // it should be integer for amount mask + $currency->precision = (int) $currency->precision; - return response()->json($json); + return response()->json($currency); } public function config() @@ -288,9 +287,13 @@ class Currencies extends Controller $code = request('code'); - // Get currency object - $currency = Currency::where('code', $code)->first(); + if ($code) { + $currency = config('money.' . $code); + $currency['symbol_first'] = $currency['symbol_first'] ? 1 : 0; - return response()->json($currency); + $json = (object) $currency; + } + + return response()->json($json); } } diff --git a/resources/views/banking/accounts/create.blade.php b/resources/views/banking/accounts/create.blade.php index eed0f6358..2bc4377da 100644 --- a/resources/views/banking/accounts/create.blade.php +++ b/resources/views/banking/accounts/create.blade.php @@ -80,6 +80,8 @@ opening_balance = $('#opening_balance').maskMoney('unmasked')[0]; + alert(opening_balance); + $("#opening_balance").maskMoney({ thousands : data.thousands_separator, decimal : data.decimal_mark, @@ -91,7 +93,7 @@ $('#opening_balance').val(opening_balance); - $('#opening_balance').trigger('focus'); + $('#opening_balance').trigger('focusout'); } }); }); diff --git a/resources/views/banking/accounts/edit.blade.php b/resources/views/banking/accounts/edit.blade.php index 451fd1b1f..0917015c1 100644 --- a/resources/views/banking/accounts/edit.blade.php +++ b/resources/views/banking/accounts/edit.blade.php @@ -93,7 +93,7 @@ $('#opening_balance').val(opening_balance); - $('#opening_balance').trigger('focus'); + $('#opening_balance').trigger('focusout'); } }); });