refs #392 fixed Account, Vendor, Customer currency issue

This commit is contained in:
cuneytsenturk 2018-06-27 19:43:48 +03:00
parent 896bc1f2b9
commit 68576ffeeb
3 changed files with 47 additions and 5 deletions

View File

@ -219,9 +219,23 @@ class Accounts extends Controller
$account = Account::find($account_id);
// Get currency object
$currency = Currency::where('code', $account->currency_code)->first();
$currency_code = $account->currency_code;
$currency = false;
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
if (array_key_exists($currency_code, $currencies)) {
$currency = true;
}
if (!$currency) {
$currency_code = setting('general.default_currency');
}
// Get currency object
$currency = Currency::where('code', $currency_code)->first();
$account->currency_code = $currency_code;
$account->currency_rate = $currency->rate;
return response()->json($account);

View File

@ -308,9 +308,23 @@ class Vendors extends Controller
$vendor = Vendor::find($vendor_id);
// Get currency object
$currency = Currency::where('code', $vendor->currency_code)->first();
$currency_code = $vendor->currency_code;
$currency = false;
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
if (array_key_exists($currency_code, $currencies)) {
$currency = true;
}
if (!$currency) {
$currency_code = setting('general.default_currency');
}
// Get currency object
$currency = Currency::where('code', $currency_code)->first();
$vendor->currency_code = $currency_code;
$vendor->currency_rate = $currency->rate;
return response()->json($vendor);

View File

@ -344,9 +344,23 @@ class Customers extends Controller
$customer = Customer::find($customer_id);
// Get currency object
$currency = Currency::where('code', $customer->currency_code)->first();
$currency_code = $customer->currency_code;
$currency = false;
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
if (array_key_exists($currency_code, $currencies)) {
$currency = true;
}
if (!$currency) {
$currency_code = setting('general.default_currency');
}
// Get currency object
$currency = Currency::where('code', $currency_code)->first();
$customer->currency_code = $currency_code;
$customer->currency_rate = $currency->rate;
return response()->json($customer);