addProperty($account->id); $cache->addProperty('balance'); $cache->addProperty($date); $cache->addProperty($ignoreVirtualBalance); if ($cache->has()) { return $cache->get(); // @codeCoverageIgnore } bcscale(2); $balance = $account->transactions()->leftJoin( 'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id' )->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount'); if (!$ignoreVirtualBalance) { $balance = bcadd($balance, $account->virtual_balance); } $cache->store(round($balance, 2)); return round($balance, 2); } }