refs #392 fixed Account, Vendor, Customer currency issue
This commit is contained in:
parent
896bc1f2b9
commit
68576ffeeb
@ -218,10 +218,24 @@ class Accounts extends Controller
|
||||
}
|
||||
|
||||
$account = Account::find($account_id);
|
||||
|
||||
$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', $account->currency_code)->first();
|
||||
$currency = Currency::where('code', $currency_code)->first();
|
||||
|
||||
$account->currency_code = $currency_code;
|
||||
$account->currency_rate = $currency->rate;
|
||||
|
||||
return response()->json($account);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user