From be58da539e1f3cc237f684a1d382a92081df6087 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 14 Mar 2016 20:38:23 +0100 Subject: [PATCH] Fix various small issues. --- app/Http/Controllers/TransactionController.php | 17 +++++------------ app/Http/breadcrumbs.php | 3 ++- app/Repositories/Journal/JournalRepository.php | 1 - app/Repositories/User/UserRepository.php | 2 +- .../User/UserRepositoryInterface.php | 2 +- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index c866352beb..e137f6bf77 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -140,20 +140,14 @@ class TransactionController extends Controller */ public function edit(ARI $repository, TransactionJournal $journal) { - // cannot edit opening balance - if ($journal->isOpeningBalance()) { - throw new FireflyException('Cannot edit this transaction (#' . $journal->id . '). Edit the account instead!'); - } - - $maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize')); $maxPostSize = Steam::phpBytes(ini_get('post_max_size')); $uploadSize = min($maxFileSize, $maxPostSize); $what = strtolower(TransactionJournal::transactionTypeStr($journal)); $accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account'])); - $budgets = ExpandedForm::makeSelectList(Auth::user()->budgets()->get()); // TODO this must be a repository call + $budgets = ExpandedForm::makeSelectList(Auth::user()->budgets()->get()); $budgets[0] = trans('form.noBudget'); - $piggies = ExpandedForm::makeSelectList(Auth::user()->piggyBanks()->get()); // TODO this must be a repository call + $piggies = ExpandedForm::makeSelectList(Auth::user()->piggyBanks()->get()); $piggies[0] = trans('form.noPiggybank'); $subTitle = trans('breadcrumbs.edit_journal', ['description' => $journal->description]); $preFilled = [ @@ -164,11 +158,10 @@ class TransactionController extends Controller 'category' => '', 'budget_id' => 0, 'piggy_bank_id' => 0, + 'tags' => join(',', $journal->tags->pluck('tag')->toArray()), ]; - // get tags: - $preFilled['tags'] = join(',', $journal->tags->pluck('tag')->toArray()); - $category = $journal->categories()->first(); + $category = $journal->categories()->first(); if (!is_null($category)) { $preFilled['category'] = $category->name; } @@ -286,7 +279,7 @@ class TransactionController extends Controller } ); $what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type); - $subTitle = trans('firefly.' . $journal->transaction_type_type ?? $journal->transactionType->type) . ' "' . e($journal->description) . '"'; + $subTitle = trans('firefly.' . $what) . ' "' . e($journal->description) . '"'; return view('transactions.show', compact('journal', 'events', 'subTitle', 'what')); } diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index 6d1ae21e9c..7c05a79ac9 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -573,7 +573,8 @@ Breadcrumbs::register( Breadcrumbs::register( 'transactions.show', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) { - $breadcrumbs->parent('transactions.index', strtolower($journal->getTransactionType())); + $what = strtolower($journal->transaction_type_type ?? $journal->transactionType->type); + $breadcrumbs->parent('transactions.index', $what); $breadcrumbs->push($journal->description, route('transactions.show', [$journal->id])); } diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index b25ef485a4..0eedc0b419 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -217,7 +217,6 @@ class JournalRepository implements JournalRepositoryInterface 'process_date' => $data['process_date'], ] ); - // TODO catch errors here. Match rules with JournalFormRequest $journal->save(); diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php index 8294ace9c4..78a2a80d5f 100644 --- a/app/Repositories/User/UserRepository.php +++ b/app/Repositories/User/UserRepository.php @@ -42,4 +42,4 @@ class UserRepository implements UserRepositoryInterface { return User::count(); } -} \ No newline at end of file +} diff --git a/app/Repositories/User/UserRepositoryInterface.php b/app/Repositories/User/UserRepositoryInterface.php index f2859377c2..3af280c180 100644 --- a/app/Repositories/User/UserRepositoryInterface.php +++ b/app/Repositories/User/UserRepositoryInterface.php @@ -31,4 +31,4 @@ interface UserRepositoryInterface * @return int */ public function count(): int; -} \ No newline at end of file +}