Fix account controller + coverage.

This commit is contained in:
James Cole
2017-12-31 10:40:27 +01:00
parent 8bcfa729b6
commit b73884160a
7 changed files with 254 additions and 28 deletions

View File

@@ -157,14 +157,14 @@ class AccountController extends Controller
* @throws FireflyException
* @throws FireflyException
*/
public function edit(Request $request, Account $account)
public function edit(Request $request, Account $account, AccountRepositoryInterface $repository)
{
/** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class);
/** @var CurrencyRepositoryInterface $currencyRepos */
$currencyRepos = app(CurrencyRepositoryInterface::class);
$what = config('firefly.shortNamesByFullName')[$account->accountType->type];
$subTitle = trans('firefly.edit_' . $what . '_account', ['name' => $account->name]);
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $what);
$allCurrencies = $repository->get();
$allCurrencies = $currencyRepos->get();
$currencySelectList = ExpandedForm::makeSelectList($allCurrencies);
$roles = [];
foreach (config('firefly.accountRoles') as $role) {
@@ -184,7 +184,7 @@ class AccountController extends Controller
$openingBalanceAmount = '0' === $account->getOpeningBalanceAmount() ? '' : $openingBalanceAmount;
$openingBalanceDate = $account->getOpeningBalanceDate();
$openingBalanceDate = 1900 === $openingBalanceDate->year ? null : $openingBalanceDate->format('Y-m-d');
$currency = $repository->find(intval($account->getMeta('currency_id')));
$currency = $currencyRepos->find(intval($account->getMeta('currency_id')));
$preFilled = [
'accountNumber' => $account->getMeta('accountNumber'),
@@ -196,10 +196,10 @@ class AccountController extends Controller
'openingBalance' => $openingBalanceAmount,
'virtualBalance' => $account->virtual_balance,
'currency_id' => $currency->id,
'notes' => '',
'notes' => '',
];
/** @var Note $note */
$note = $account->notes()->first();
$note = $repository->getNote($account);
if (null !== $note) {
$preFilled['notes'] = $note->text;
}