Fix for income entry.

This commit is contained in:
James Cole
2016-09-20 08:57:08 +02:00
parent ae328de469
commit 11385494eb

View File

@@ -223,11 +223,14 @@ class ReportController extends Controller
$journals = $repository->journalsInPeriod(new Collection([$account]), $types, $attributes['startDate'], $attributes['endDate']); $journals = $repository->journalsInPeriod(new Collection([$account]), $types, $attributes['startDate'], $attributes['endDate']);
$destinations = $attributes['accounts']->pluck('id')->toArray(); $destinations = $attributes['accounts']->pluck('id')->toArray();
// filter for transfers and withdrawals FROM the given $account // filter for transfers and withdrawals FROM the given $account
$journals = $journals->filter( $journals = $journals->filter(
function (TransactionJournal $journal) use ($account, $destinations) { function (TransactionJournal $journal) use ($account, $destinations) {
$currentSources = TransactionJournal::sourceAccountList($journal)->pluck('id')->toArray();
$currentDest = TransactionJournal::destinationAccountList($journal)->pluck('id')->toArray();
if ( if (
$journal->source_account_id === $account->id !empty(array_intersect([$account->id], $currentSources))
&& in_array($journal->destination_account_id, $destinations) && !empty(array_intersect($destinations, $currentDest))
) { ) {
return true; return true;
} }