Some refactoring.

This commit is contained in:
James Cole
2016-05-14 13:51:33 +02:00
parent 5a6967cefd
commit 863227c55c
12 changed files with 240 additions and 260 deletions

View File

@@ -279,7 +279,6 @@ class TransactionJournalSupport extends Model
return $account;
}
/**
* @param TransactionJournal $journal
*
@@ -327,6 +326,46 @@ class TransactionJournalSupport extends Model
return $type;
}
/**
* @param TransactionJournal $journal
*
* @return Collection
*/
public static function sourceTransactionList(TransactionJournal $journal): Collection
{
$cache = new CacheProperties;
$cache->addProperty($journal->id);
$cache->addProperty('transaction-journal');
$cache->addProperty('source-transaction-list');
if ($cache->has()) {
return $cache->get();
}
$list = $journal->transactions()->where('amount', '<', 0)->with('account')->get();
$cache->store($list);
return $list;
}
/**
* @param TransactionJournal $journal
*
* @return Collection
*/
public static function destinationTransactionList(TransactionJournal $journal): Collection
{
$cache = new CacheProperties;
$cache->addProperty($journal->id);
$cache->addProperty('transaction-journal');
$cache->addProperty('destination-transaction-list');
if ($cache->has()) {
return $cache->get();
}
$list = $journal->transactions()->where('amount', '>', 0)->with('account')->get();
$cache->store($list);
return $list;
}
/**
* @param TransactionJournal $journal
*