mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #2494
This commit is contained in:
parent
2cc7721007
commit
412b914f66
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Json;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
@ -62,6 +63,7 @@ class AutoCompleteController extends Controller
|
||||
|
||||
// filter the account types:
|
||||
$allowedAccountTypes = [AccountType::ASSET, AccountType::EXPENSE, AccountType::REVENUE, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,];
|
||||
$balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,];
|
||||
$filteredAccountTypes = [];
|
||||
foreach ($accountTypes as $type) {
|
||||
if (in_array($type, $allowedAccountTypes, true)) {
|
||||
@ -79,11 +81,18 @@ class AutoCompleteController extends Controller
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($result as $account) {
|
||||
$currency = $repository->getAccountCurrency($account);
|
||||
$currency = $currency ?? $defaultCurrency;
|
||||
$nameWithBalance = $account->name;
|
||||
$currency = $repository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||
|
||||
if (in_array($account->accountType->type, $balanceTypes, true)) {
|
||||
$balance = app('steam')->balance($account, new Carbon);
|
||||
$nameWithBalance = sprintf('%s (%s)', $account->name, app('amount')->formatAnything($currency, $balance, false));
|
||||
}
|
||||
|
||||
$return[] = [
|
||||
'id' => $account->id,
|
||||
'name' => $account->name,
|
||||
'name_with_balance' => $nameWithBalance,
|
||||
'type' => $account->accountType->type,
|
||||
'currency_id' => $currency->id,
|
||||
'currency_name' => $currency->name,
|
||||
|
2
public/v1/js/app.js
vendored
2
public/v1/js/app.js
vendored
File diff suppressed because one or more lines are too long
@ -48,7 +48,7 @@
|
||||
:async-src="accountAutoCompleteURI"
|
||||
v-model="name"
|
||||
:target="target"
|
||||
item-key="name"
|
||||
item-key="name_with_balance"
|
||||
></typeahead>
|
||||
<ul class="list-unstyled" v-for="error in this.error">
|
||||
<li class="text-danger">{{ error }}</li>
|
||||
|
@ -19,7 +19,7 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="form-group" v-bind:class="{ 'has-error': hasError()}" v-if="(this.enabledCurrencies.length > 2 && this.transactionType === 'Deposit') || this.transactionType.toLowerCase() === 'transfer'">
|
||||
<div class="form-group" v-bind:class="{ 'has-error': hasError()}" v-if="null == this.transactionType || null != this.transactionType && (this.enabledCurrencies.length > 2 && this.transactionType === 'Deposit') || this.transactionType.toLowerCase() === 'transfer'">
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control" ref="currency_select" name="foreign_currency[]" @input="handleInput">
|
||||
<option
|
||||
|
Loading…
Reference in New Issue
Block a user