get currency account, customer and vendor issues solved

This commit is contained in:
cuneytsenturk
2018-07-02 14:13:20 +03:00
parent 26ac0acf61
commit 61262a5d4b
3 changed files with 42 additions and 31 deletions

View File

@ -211,25 +211,26 @@ class Accounts extends Controller
public function currency()
{
$account_id = request('account_id');
$account_id = (int) request('account_id');
if (empty($account_id)) {
$account_id = setting('general.default_account');
return response()->json([]);
}
$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 (empty($account)) {
return response()->json([]);
}
if (!$currency) {
$currency_code = setting('general.default_currency');
$currency_code = setting('general.default_currency');
if (isset($account->currency_code)) {
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
if (array_key_exists($account->currency_code, $currencies)) {
$currency_code = $account->currency_code;
}
}
// Get currency object