Code optimisations.

This commit is contained in:
James Cole
2018-07-22 18:50:27 +02:00
parent ea2c48bca5
commit ca096852a5
56 changed files with 221 additions and 427 deletions

View File

@@ -82,18 +82,6 @@ class AccountRepository implements AccountRepositoryInterface
return $this->user->accounts()->find($accountId);
}
/**
* Return account type by string.
*
* @param string $type
*
* @return AccountType|null
*/
public function getAccountType(string $type): ?AccountType
{
return AccountType::whereType($type)->first();
}
/**
* Return meta value for account. Null if not found.
*
@@ -113,16 +101,6 @@ class AccountRepository implements AccountRepositoryInterface
return null;
}
/**
* @param Account $account
*
* @return Note|null
*/
public function getNote(Account $account): ?Note
{
return $account->notes()->first();
}
/**
* Get note text or null.
*
@@ -185,29 +163,6 @@ class AccountRepository implements AccountRepositoryInterface
return $journal->date->format('Y-m-d');
}
/**
* Returns the date of the very last transaction in this account.
*
* @param Account $account
*
* @return Carbon
*/
public function newestJournalDate(Account $account): Carbon
{
$last = new Carbon;
$date = $account->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->orderBy('transaction_journals.date', 'DESC')
->orderBy('transaction_journals.order', 'ASC')
->orderBy('transaction_journals.id', 'DESC')
->first(['transaction_journals.date']);
if (null !== $date) {
$last = new Carbon($date->date);
}
return $last;
}
/**
* Returns the date of the very first transaction in this account.
*
@@ -253,7 +208,7 @@ class AccountRepository implements AccountRepositoryInterface
/**
* @param User $user
*/
public function setUser(User $user)
public function setUser(User $user): void
{
$this->user = $user;
}
@@ -262,6 +217,7 @@ class AccountRepository implements AccountRepositoryInterface
* @param array $data
*
* @return Account
* @throws \FireflyIII\Exceptions\FireflyException
*/
public function store(array $data): Account
{
@@ -286,20 +242,4 @@ class AccountRepository implements AccountRepositoryInterface
return $account;
}
/**
* @param TransactionJournal $journal
* @param array $data
*
* @return TransactionJournal
*/
public function updateReconciliation(TransactionJournal $journal, array $data): TransactionJournal
{
/** @var JournalUpdateService $service */
$service = app(JournalUpdateService::class);
$journal = $service->update($journal, $data);
return $journal;
}
}