Expand filter

This commit is contained in:
James Cole
2017-02-11 09:34:04 +01:00
parent 3914796e4e
commit aa2d78f36a
2 changed files with 34 additions and 9 deletions

View File

@@ -32,6 +32,7 @@ use Illuminate\Database\Query\JoinClause;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Log;
use Steam;
/**
* Maybe this is a good idea after all...
@@ -631,13 +632,24 @@ class JournalCollector implements JournalCollectorInterface
$new = new Collection;
/** @var Transaction $transaction */
foreach ($set as $transaction) {
if ($transaction->transaction_type_type !== TransactionType::TRANSFER) {
$new->push($transaction);
continue;
}
// make property string:
$journalId = $transaction->transaction_journal_id;
if(!isset($count[$journalId]) ) {
$amount = Steam::positive($transaction->transaction_amount);
$source = $transaction->account_id;
$dest = $transaction->opposing_account_id;
$key = $journalId . $source . $dest . $amount;
if (!isset($count[$key])) {
// not yet counted? add to new set and count it:
$new->push($transaction);
$count[$journalId] = 1;
$count[$key] = 1;
}
}
return $new;
}

View File

@@ -26,7 +26,6 @@ use FireflyIII\Models\Transaction;
class Steam
{
/**
*
* @param \FireflyIII\Models\Account $account
@@ -202,8 +201,6 @@ class Steam
return $list;
}
// parse PHP size:
/**
* @param $string
*
@@ -239,4 +236,20 @@ class Steam
}
// parse PHP size:
/**
* @param string $amount
*
* @return string
*/
public function positive(string $amount): string
{
if (bccomp($amount, '0') === 1) {
$amount = bcmul($amount, '-1');
}
return $amount;
}
}