mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Experimental new transfer filter.
This commit is contained in:
@@ -618,7 +618,7 @@ class JournalCollector implements JournalCollectorInterface
|
|||||||
* account, chances are the set include double entries: transfers get selected
|
* account, chances are the set include double entries: transfers get selected
|
||||||
* on both the source, and then again on the destination account.
|
* on both the source, and then again on the destination account.
|
||||||
*
|
*
|
||||||
* This method filters them out.
|
* This method filters them out by removing transfers that have been selected twice.
|
||||||
*
|
*
|
||||||
* @param Collection $set
|
* @param Collection $set
|
||||||
*
|
*
|
||||||
@@ -627,36 +627,18 @@ class JournalCollector implements JournalCollectorInterface
|
|||||||
private function filterTransfers(Collection $set): Collection
|
private function filterTransfers(Collection $set): Collection
|
||||||
{
|
{
|
||||||
if ($this->filterTransfers) {
|
if ($this->filterTransfers) {
|
||||||
$set = $set->filter(
|
$count = [];
|
||||||
function (Transaction $transaction) {
|
$new = new Collection;
|
||||||
if (!($transaction->transaction_type_type === TransactionType::TRANSFER && bccomp($transaction->transaction_amount, '0') === -1)) {
|
/** @var Transaction $transaction */
|
||||||
|
foreach($set as $transaction) {
|
||||||
Log::debug(
|
$journalId =$transaction->transaction_journal_id;
|
||||||
sprintf(
|
if(!isset($count[$journalId]) ) {
|
||||||
'Included journal #%d (transaction #%d) because its a %s with amount %f',
|
// not yet counted? add to new set and count it:
|
||||||
$transaction->transaction_journal_id,
|
$new->push($transaction);
|
||||||
$transaction->id,
|
$count[$journalId] = 1;
|
||||||
$transaction->transaction_type_type,
|
|
||||||
$transaction->transaction_amount
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return $transaction;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::debug(
|
|
||||||
sprintf(
|
|
||||||
'Removed journal #%d (transaction #%d) because its a %s with amount %f',
|
|
||||||
$transaction->transaction_journal_id,
|
|
||||||
$transaction->id,
|
|
||||||
$transaction->transaction_type_type,
|
|
||||||
$transaction->transaction_amount
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
|
return $new;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $set;
|
return $set;
|
||||||
|
Reference in New Issue
Block a user