Fix various small issues.

This commit is contained in:
James Cole 2016-03-14 20:38:23 +01:00
parent a508ac9dda
commit be58da539e
5 changed files with 9 additions and 16 deletions

View File

@ -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,9 +158,8 @@ 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();
if (!is_null($category)) {
@ -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'));
}

View File

@ -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]));
}

View File

@ -217,7 +217,6 @@ class JournalRepository implements JournalRepositoryInterface
'process_date' => $data['process_date'],
]
);
// TODO catch errors here. Match rules with JournalFormRequest
$journal->save();