diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php index 1265b2c8c3..b02ca753fd 100644 --- a/app/Http/Controllers/Transaction/SingleController.php +++ b/app/Http/Controllers/Transaction/SingleController.php @@ -21,6 +21,7 @@ use FireflyIII\Events\UpdatedTransactionJournal; use FireflyIII\Helpers\Attachments\AttachmentHelperInterface; use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Requests\JournalFormRequest; +use FireflyIII\Models\Account; use FireflyIII\Models\AccountType; use FireflyIII\Models\Transaction; use FireflyIII\Models\TransactionJournal; @@ -143,7 +144,7 @@ class SingleController extends Controller { $what = strtolower($what); $uploadSize = min(Steam::phpBytes(ini_get('upload_max_filesize')), Steam::phpBytes(ini_get('post_max_size'))); - $assetAccounts = ExpandedForm::makeSelectList($this->accounts->getActiveAccountsByType([AccountType::DEFAULT, AccountType::ASSET])); + $assetAccounts = $this->groupedAccountList(); $budgets = ExpandedForm::makeSelectListWithEmpty($this->budgets->getActiveBudgets()); $piggyBanks = $this->piggyBanks->getPiggyBanksWithAmount(); $piggies = ExpandedForm::makeSelectListWithEmpty($piggyBanks); @@ -239,7 +240,7 @@ class SingleController extends Controller } $what = strtolower($journal->transactionTypeStr()); - $assetAccounts = ExpandedForm::makeSelectList($this->accounts->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])); + $assetAccounts = $this->groupedAccountList(); $budgetList = ExpandedForm::makeSelectListWithEmpty($this->budgets->getBudgets()); // view related code @@ -409,6 +410,26 @@ class SingleController extends Controller return redirect($this->getPreviousUri('transactions.edit.uri')); } + /** + * @return array + */ + private function groupedAccountList(): array + { + $accounts = $this->accounts->getActiveAccountsByType([AccountType::DEFAULT, AccountType::ASSET]); + $return = []; + /** @var Account $account */ + foreach ($accounts as $account) { + $type = $account->getMeta('accountRole'); + if (strlen($type) === 0) { + $type = 'no_account_type'; + } + $key = strval(trans('firefly.opt_group_' . $type)); + $return[$key][$account->id] = $account->name; + } + + return $return; + } + /** * @param TransactionJournal $journal * diff --git a/public/js/ff/transactions/single/create.js b/public/js/ff/transactions/single/create.js index f1b375bb92..e1a0c04c9f 100644 --- a/public/js/ff/transactions/single/create.js +++ b/public/js/ff/transactions/single/create.js @@ -37,6 +37,7 @@ $(document).ready(function () { // when user selects different currency, $('.currency-option').on('click', selectsForeignCurrency); + $('#ffInput_description').focus(); }); /** @@ -84,6 +85,7 @@ function updateDescription() { $.getJSON('json/transaction-journals/' + what).done(function (data) { $('input[name="description"]').typeahead('destroy').typeahead({source: data}); }); + $('#ffInput_description').focus(); } /** diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 133d3bb168..1976a06949 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -624,6 +624,11 @@ return [ 'perm-delete-many' => 'Deleting many items in one go can be very disruptive. Please be cautious.', 'mass_deleted_transactions_success' => 'Deleted :amount transaction(s).', 'mass_edited_transactions_success' => 'Updated :amount transaction(s)', + 'opt_group_no_account_type' => '(no account type)', + 'opt_group_defaultAsset' => 'Default asset accounts', + 'opt_group_savingAsset' => 'Savings accounts', + 'opt_group_sharedAsset' => 'Shared asset accounts', + 'opt_group_ccAsset' => 'Credit cards', // new user: