Small bugs in transaction controller [skip ci]

This commit is contained in:
James Cole 2015-06-16 18:26:17 +02:00
parent a44e5da421
commit 683e9b7c2c

View File

@ -125,7 +125,6 @@ class TransactionController extends Controller
$accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account']));
$budgets = ExpandedForm::makeSelectList(Auth::user()->budgets()->get());
$budgets[0] = trans('form.noBudget');
$transactions = $journal->transactions()->orderBy('amount', 'DESC')->get();
$piggies = ExpandedForm::makeSelectList(Auth::user()->piggyBanks()->get());
$piggies[0] = trans('form.noPiggybank');
$subTitle = trans('breadcrumbs.edit_journal', ['description' => $journal->description]);
@ -157,11 +156,25 @@ class TransactionController extends Controller
}
$preFilled['amount'] = $journal->actual_amount;
if ($journal->transactionType->type == 'Withdrawal') {
$preFilled['account_id'] = $journal->source_account->id;
$preFilled['expense_account'] = $journal->destination_account->name;
} else {
$preFilled['account_id'] = $journal->destination_account->id;
$preFilled['expense_account'] = $transactions[0]->account->name;
$preFilled['revenue_account'] = $transactions[1]->account->name;
$preFilled['account_from_id'] = $transactions[1]->account->id;
$preFilled['account_to_id'] = $transactions[0]->account->id;
$preFilled['revenue_account'] = $journal->source_account->name;
}
if ($journal->destination_account->accountType->type == 'Cash account') {
$preFilled['expense_account'] = '';
}
if ($journal->source_account->accountType->type == 'Cash account') {
$preFilled['revenue_account'] = '';
}
$preFilled['account_from_id'] = $journal->source_account->id;
$preFilled['account_to_id'] = $journal->destination_account->id;
Session::flash('preFilled', $preFilled);
Session::flash('gaEventCategory', 'transactions');