mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Code cleanup [skip ci]
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user