mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-04-29 11:03:00 +00:00
This commit is contained in:
@@ -14,10 +14,6 @@ parameters:
|
||||
enabled: false
|
||||
noNullableReturnTypeDeclaration:
|
||||
enabled: false
|
||||
privateInFinalClass:
|
||||
enabled: false
|
||||
noIsset:
|
||||
enabled: false
|
||||
finalInAbstractClass:
|
||||
enabled: false
|
||||
noConstructorParameterWithDefaultValue:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user