Code cleanup [skip ci]

This commit is contained in:
James Cole
2015-01-02 05:52:38 +01:00
parent d9bf4d1c0d
commit 550f301ba2
27 changed files with 52 additions and 97 deletions

View File

@@ -16,6 +16,8 @@ class Steam
{
/**
* TODO find a way to reliably remove cache entries for accounts.
*
* @param \Account $account
* @param Carbon $date
*
@@ -23,24 +25,12 @@ class Steam
*/
public function balance(\Account $account, Carbon $date = null)
{
\Log::debug('Now in Steam::balance() for account #' . $account->id . ' (' . $account->name . ')');
if (is_null($date)) {
$key = 'account.' . $account->id . '.latestBalance';
} else {
$key = 'account.' . $account->id . '.balanceOn' . $date->format('dmy');
}
if (\Cache::has($key)) {
// TODO find a way to reliably remove cache entries for accounts.
#return \Cache::get($key);
}
$date = is_null($date) ? Carbon::now() : $date;
\Log::debug('Now reached the moment we fire the query.');
$balance = floatval(
$account->transactions()->leftJoin(
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
)->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
);
\Cache::put($key, $balance, 20160);
return $balance;
}