Skip to content

Firefly III: a personal finances manager

Fix https://github.com/orgs/firefly-iii/discussions/11879

James Colef6ea517b5d99
diff --git a/.ci/phpstan.neon b/.ci/phpstan.neon
index b34338d95d..99cbb3039e 100644
--- a/.ci/phpstan.neon
+++ b/.ci/phpstan.neon
@@ -14,10 +14,6 @@ parameters:
enabled: false
noNullableReturnTypeDeclaration:
enabled: false
- privateInFinalClass:
- enabled: false
- noIsset:
- enabled: false
finalInAbstractClass:
enabled: false
noConstructorParameterWithDefaultValue:
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 154e91886e..a1e1c01af3 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -687,6 +687,31 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
return $dbQuery->take($limit)->get(['accounts.*']);
}
+ public function searchAccountIncludingInactive(string $query, array $types, int $limit): Collection
+ {
+ $dbQuery = $this->user
+ ->accounts()
+ ->orderBy('accounts.order', 'ASC')
+ ->orderBy('accounts.account_type_id', 'ASC')
+ ->orderBy('accounts.name', 'ASC')
+ ->with(['accountType'])
+ ;
+ if ('' !== $query) {
+ // split query on spaces just in case:
+ $parts = explode(' ', $query);
+ foreach ($parts as $part) {
+ $search = sprintf('%%%s%%', $part);
+ $dbQuery->whereLike('name', $search);
+ }
+ }
+ if (0 !== count($types)) {
+ $dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
+ $dbQuery->whereIn('account_types.type', $types);
+ }
+
+ return $dbQuery->take($limit)->get(['accounts.*']);
+ }
+
public function searchAccountNr(string $query, array $types, int $limit): Collection
{
$dbQuery = $this->user
diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php
index 4513fc4bfb..29bb186bdb 100644
--- a/app/Repositories/Account/AccountRepositoryInterface.php
+++ b/app/Repositories/Account/AccountRepositoryInterface.php
@@ -155,6 +155,7 @@ interface AccountRepositoryInterface
public function resetAccountOrder(): void;
public function searchAccount(string $query, array $types, int $limit): Collection;
+ public function searchAccountIncludingInactive(string $query, array $types, int $limit): Collection;
public function searchAccountNr(string $query, array $types, int $limit): Collection;
diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php
index 9ffdb42500..bcc87cc10d 100644
--- a/app/Support/Search/OperatorQuerySearch.php
+++ b/app/Support/Search/OperatorQuerySearch.php
@@ -487,7 +487,7 @@ class OperatorQuerySearch implements SearchInterface
// search direction: for destination accounts
if (SearchDirection::DESTINATION === $searchDirection) { // destination
- // destination can be
+ // the destination account can be
$searchTypes = [
AccountTypeEnum::ASSET->value,
AccountTypeEnum::MORTGAGE->value,
@@ -530,7 +530,7 @@ class OperatorQuerySearch implements SearchInterface
}
// get accounts:
- $accounts = $this->accountRepository->searchAccount($value, $searchTypes, 1337);
+ $accounts = $this->accountRepository->searchAccountIncludingInactive($value, $searchTypes, 1337);
if (0 === $accounts->count() && false === $prohibited) {
Log::warning('Found zero accounts, search for non existing account, NO results will be returned.');
$this->collector->findNothing();