mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 22:21:42 +00:00
Expand search with negated search options
This commit is contained in:
@@ -72,6 +72,26 @@ trait AccountCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* These accounts must not be included.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function excludeAccounts(Collection $accounts): GroupCollectorInterface
|
||||
{
|
||||
if ($accounts->count() > 0) {
|
||||
$accountIds = $accounts->pluck('id')->toArray();
|
||||
$this->query->whereNotIn('source.account_id', $accountIds);
|
||||
$this->query->whereNotIn('destination.account_id', $accountIds);
|
||||
|
||||
app('log')->debug(sprintf('GroupCollector: excludeAccounts: %s', implode(', ', $accountIds)));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define which accounts can be part of the source and destination transactions.
|
||||
*
|
||||
@@ -95,6 +115,29 @@ trait AccountCollection
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define which accounts can NOT be part of the source and destination transactions.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return GroupCollectorInterface
|
||||
*/
|
||||
public function setNotAccounts(Collection $accounts): GroupCollectorInterface
|
||||
{
|
||||
if ($accounts->count() > 0) {
|
||||
$accountIds = $accounts->pluck('id')->toArray();
|
||||
$this->query->where(
|
||||
static function (EloquentBuilder $query) use ($accountIds) {
|
||||
$query->whereNotIn('source.account_id', $accountIds);
|
||||
$query->whereNotIn('destination.account_id', $accountIds);
|
||||
}
|
||||
);
|
||||
//app('log')->debug(sprintf('GroupCollector: setAccounts: %s', implode(', ', $accountIds)));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Both source AND destination must be in this list of accounts.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user