Fixed null pointer in debug message [skip ci]

This commit is contained in:
James Cole 2017-03-02 16:42:33 +01:00
parent ed9e5b31fa
commit 3bf5040324
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -127,12 +127,12 @@ class AccountTasker implements AccountTaskerInterface
// get first journal date:
$first = $repository->oldestJournal($account);
Log::debug(sprintf('Date of first journal for %s is %s', $account->name, $first->date->format('Y-m-d')));
$entry['start_balance'] = $startSet[$account->id] ?? '0';
$entry['end_balance'] = $endSet[$account->id] ?? '0';
// first journal exists, and is on start, then this is the actual opening balance:
if (!is_null($first->id) && $first->date->isSameDay($start)) {
Log::debug(sprintf('Date of first journal for %s is %s', $account->name, $first->date->format('Y-m-d')));
$entry['start_balance'] = $first->transactions()->where('account_id', $account->id)->first()->amount;
Log::debug(sprintf('Account %s was opened on %s, so opening balance is %f', $account->name, $start->format('Y-m-d'), $entry['start_balance']));
}