mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-20 02:01:19 +00:00
Fix #2494
This commit is contained in:
@@ -22,6 +22,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers\Json;
|
namespace FireflyIII\Http\Controllers\Json;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
@@ -62,6 +63,7 @@ class AutoCompleteController extends Controller
|
|||||||
|
|
||||||
// filter the account types:
|
// filter the account types:
|
||||||
$allowedAccountTypes = [AccountType::ASSET, AccountType::EXPENSE, AccountType::REVENUE, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,];
|
$allowedAccountTypes = [AccountType::ASSET, AccountType::EXPENSE, AccountType::REVENUE, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,];
|
||||||
|
$balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,];
|
||||||
$filteredAccountTypes = [];
|
$filteredAccountTypes = [];
|
||||||
foreach ($accountTypes as $type) {
|
foreach ($accountTypes as $type) {
|
||||||
if (in_array($type, $allowedAccountTypes, true)) {
|
if (in_array($type, $allowedAccountTypes, true)) {
|
||||||
@@ -79,11 +81,18 @@ class AutoCompleteController extends Controller
|
|||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($result as $account) {
|
foreach ($result as $account) {
|
||||||
$currency = $repository->getAccountCurrency($account);
|
$nameWithBalance = $account->name;
|
||||||
$currency = $currency ?? $defaultCurrency;
|
$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[] = [
|
$return[] = [
|
||||||
'id' => $account->id,
|
'id' => $account->id,
|
||||||
'name' => $account->name,
|
'name' => $account->name,
|
||||||
|
'name_with_balance' => $nameWithBalance,
|
||||||
'type' => $account->accountType->type,
|
'type' => $account->accountType->type,
|
||||||
'currency_id' => $currency->id,
|
'currency_id' => $currency->id,
|
||||||
'currency_name' => $currency->name,
|
'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"
|
:async-src="accountAutoCompleteURI"
|
||||||
v-model="name"
|
v-model="name"
|
||||||
:target="target"
|
:target="target"
|
||||||
item-key="name"
|
item-key="name_with_balance"
|
||||||
></typeahead>
|
></typeahead>
|
||||||
<ul class="list-unstyled" v-for="error in this.error">
|
<ul class="list-unstyled" v-for="error in this.error">
|
||||||
<li class="text-danger">{{ error }}</li>
|
<li class="text-danger">{{ error }}</li>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<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">
|
<div class="col-sm-4">
|
||||||
<select class="form-control" ref="currency_select" name="foreign_currency[]" @input="handleInput">
|
<select class="form-control" ref="currency_select" name="foreign_currency[]" @input="handleInput">
|
||||||
<option
|
<option
|
||||||
|
|||||||
Reference in New Issue
Block a user