This commit is contained in:
James Cole
2017-09-03 10:51:02 +02:00
parent 816b291ed3
commit 6b09466819
3 changed files with 30 additions and 2 deletions

View File

@@ -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
*