More narrow result for popup. [skip ci]

This commit is contained in:
James Cole 2016-05-19 13:38:12 +02:00
parent b22dd29835
commit 04dee404c0

View File

@ -216,11 +216,14 @@ class ReportController extends Controller
$account = $repository->find(intval($attributes['accountId']));
$types = [TransactionType::DEPOSIT, TransactionType::TRANSFER];
$journals = $repository->journalsInPeriod(new Collection([$account]), $types, $attributes['startDate'], $attributes['endDate']);
$destinations = $attributes['accounts']->pluck('id')->toArray();
// filter for transfers and withdrawals FROM the given $account
$journals = $journals->filter(
function (TransactionJournal $journal) use ($account) {
if ($journal->source_account_id === $account->id) {
function (TransactionJournal $journal) use ($account, $destinations) {
if (
$journal->source_account_id === $account->id &&
in_array($journal->destination_account_id, $destinations)
) {
return $journal;
}
}