Updates for new Sandstorm package.

This commit is contained in:
James Cole
2018-07-24 20:30:52 +02:00
parent 871033501a
commit 086eccaf4a
10 changed files with 83 additions and 93 deletions

View File

@@ -371,10 +371,9 @@ class AccountRepository implements AccountRepositoryInterface
* Returns the date of the very first transaction in this account.
*
* @param Account $account
* @deprecated
* @return TransactionJournal
* @return TransactionJournal|null
*/
public function oldestJournal(Account $account): TransactionJournal
public function oldestJournal(Account $account): ?TransactionJournal
{
$first = $account->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
@@ -387,7 +386,7 @@ class AccountRepository implements AccountRepositoryInterface
return TransactionJournal::find((int)$first->id);
}
return new TransactionJournal();
return null;
}
/**
@@ -402,7 +401,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$result = new Carbon;
$journal = $this->oldestJournal($account);
if (null !== $journal->id) {
if (null !== $journal) {
$result = $journal->date;
}

View File

@@ -164,10 +164,9 @@ interface AccountRepositoryInterface
* Returns the date of the very first transaction in this account.
*
* @param Account $account
* @deprecated
* @return TransactionJournal
* @return TransactionJournal|null
*/
public function oldestJournal(Account $account): TransactionJournal;
public function oldestJournal(Account $account): ?TransactionJournal;
/**
* Returns the date of the very first transaction in this account.

View File

@@ -80,7 +80,7 @@ class AccountTasker implements AccountTaskerInterface
$entry['end_balance'] = $endSet[$account->id] ?? '0';
// first journal exists, and is on start, then this is the actual opening balance:
if (null !== $first->id && $first->date->isSameDay($start)) {
if (null !== $first && $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']));