mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Revamp multi-account report.
This commit is contained in:
@@ -88,6 +88,41 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find account with same name OR same IBAN or both, but not the same type or ID.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function expandWithDoubles(Collection $accounts): Collection
|
||||
{
|
||||
$result = new Collection;
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$byName = $this->user->accounts()->where('name', $account->name)
|
||||
->where('id', '!=', $account->id)->first();
|
||||
if (null !== $byName) {
|
||||
$result->push($account);
|
||||
$result->push($byName);
|
||||
continue;
|
||||
}
|
||||
if (null !== $account->iban) {
|
||||
$byIban = $this->user->accounts()->where('iban', $account->iban)
|
||||
->where('id', '!=', $account->id)->first();
|
||||
if (null !== $byIban) {
|
||||
$result->push($account);
|
||||
$result->push($byIban);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$result->push($account);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $number
|
||||
* @param array $types
|
||||
|
Reference in New Issue
Block a user