Build edit split transactions.

This commit is contained in:
James Cole
2016-05-12 10:38:44 +02:00
parent b7c446f7db
commit ce7eebac5c
5 changed files with 49 additions and 10 deletions

View File

@@ -72,13 +72,10 @@ class TransactionJournalSupport extends Model
return $cache->get();
}
$amount = '0';
/** @var Transaction $t */
foreach ($journal->transactions as $t) {
if ($t->amount > 0) {
$amount = $t->amount;
}
}
// saves on queries:
$amount = $journal->transactions()->where('amount', '>', 0)->get()->sum('amount');
$amount = strval($amount);
$cache->store($amount);
return $amount;