mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-23 04:18:50 +00:00
Remove some often used long calls with shorter ones.
This commit is contained in:
34
app/lib/FireflyIII/Shared/Toolkit/Steam.php
Normal file
34
app/lib/FireflyIII/Shared/Toolkit/Steam.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Shared\Toolkit;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
*
|
||||
* Steam is a special class used for those small often occurring things you need your application to do.
|
||||
*
|
||||
* Class Steam
|
||||
*
|
||||
* @package FireflyIII\Shared\Toolkit
|
||||
*/
|
||||
class Steam
|
||||
{
|
||||
|
||||
/**
|
||||
* @param \Account $account
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function balance(\Account $account, Carbon $date = null)
|
||||
{
|
||||
$date = is_null($date) ? Carbon::now() : $date;
|
||||
|
||||
return 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')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user