Skip to content

Commit

Permalink
get currency account, customer and vendor issues solved
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Jul 2, 2018
1 parent 26ac0ac commit 61262a5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
23 changes: 12 additions & 11 deletions app/Http/Controllers/Banking/Accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,25 +211,26 @@ public function destroy(Account $account)

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
Expand Down
23 changes: 14 additions & 9 deletions app/Http/Controllers/Expenses/Vendors.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,21 +304,26 @@ public function export()

public function currency()
{
$vendor_id = request('vendor_id');
$vendor_id = (int) request('vendor_id');

if (empty($vendor_id)) {
return response()->json([]);
}

$vendor = Vendor::find($vendor_id);

$currency_code = $vendor->currency_code;
if (empty($vendor)) {
return response()->json([]);
}

$currency = false;
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
$currency_code = setting('general.default_currency');

if (array_key_exists($currency_code, $currencies)) {
$currency = true;
}
if (isset($vendor->currency_code)) {
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();

if (!$currency) {
$currency_code = setting('general.default_currency');
if (array_key_exists($vendor->currency_code, $currencies)) {
$currency_code = $vendor->currency_code;
}
}

// Get currency object
Expand Down
23 changes: 14 additions & 9 deletions app/Http/Controllers/Incomes/Customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,21 +340,26 @@ public function export()

public function currency()
{
$customer_id = request('customer_id');
$customer_id = (int) request('customer_id');

if (empty($customer_id)) {
return response()->json([]);
}

$customer = Customer::find($customer_id);

$currency_code = $customer->currency_code;
if (empty($customer)) {
return response()->json([]);
}

$currency = false;
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();
$currency_code = setting('general.default_currency');

if (array_key_exists($currency_code, $currencies)) {
$currency = true;
}
if (isset($customer->currency_code)) {
$currencies = Currency::enabled()->pluck('name', 'code')->toArray();

if (!$currency) {
$currency_code = setting('general.default_currency');
if (array_key_exists($customer->currency_code, $currencies)) {
$currency_code = $customer->currency_code;
}
}

// Get currency object
Expand Down

0 comments on commit 61262a5

Please sign in to comment.