Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Add liabilities to home screen #2768
James Cole1058bcd31dbb
diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.phpindex bd146d38e1..9af0e535a7 100644--- a/app/Http/Controllers/PreferencesController.php+++ b/app/Http/Controllers/PreferencesController.php@@ -22,6 +22,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers;+use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;use FireflyIII\Models\Preference;use FireflyIII\Repositories\Account\AccountRepositoryInterface;@@ -59,10 +60,29 @@ class PreferencesController extends Controller*/public function index(AccountRepositoryInterface $repository){- $accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);+ $accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);++ // group accounts+ $groupedAccounts = [];+ /** @var Account $account */+ foreach ($accounts as $account) {+ $type = $account->accountType->type;+ $role = sprintf('opt_group_%s', $repository->getMetaValue($account, 'account_role'));++ if (in_array($type, [AccountType::MORTGAGE, AccountType::DEBT, AccountType::LOAN], true)) {+ $role = sprintf('opt_group_l_%s',$type);+ }++ if ('' === $role || 'opt_group_' === $role) {+ $role = 'opt_group_defaultAsset';+ }+ $groupedAccounts[trans(sprintf('firefly.%s',$role))][$account->id] = $account->name;+ }+ ksort($groupedAccounts);+$accountIds = $accounts->pluck('id')->toArray();$viewRangePref = app('preferences')->get('viewRange', '1M');- /** @noinspection NullPointerExceptionInspection */+$viewRange = $viewRangePref->data;$frontPageAccounts = app('preferences')->get('frontPageAccounts', $accountIds);$language = app('preferences')->get('language', config('firefly.default_language', 'en_US'))->data;@@ -82,7 +102,7 @@ class PreferencesController extends Controller'preferences.index',compact('language',- 'accounts',+ 'groupedAccounts','frontPageAccounts','tjOptionalFields','viewRange',@@ -135,7 +155,7 @@ class PreferencesController extends Controller// language:/** @var Preference $currentLang */$currentLang = app('preferences')->get('language', 'en_US');- $lang = $request->get('language');+ $lang = $request->get('language');if (array_key_exists($lang, config('firefly.languages'))) {app('preferences')->set('language', $lang);}diff --git a/resources/views/v1/preferences/index.twig b/resources/views/v1/preferences/index.twigindex 258306b7d3..efac47f5b2 100644--- a/resources/views/v1/preferences/index.twig+++ b/resources/views/v1/preferences/index.twig@@ -95,23 +95,26 @@<div class="preferences-box"><h3>{{ 'pref_home_screen_accounts'|_ }}</h3><p class="text-info">{{ 'pref_home_screen_accounts_help'|_ }}</p>- {% for account in accounts %}+ {% for type, accounts in groupedAccounts %}+ <strong>{{ type }}</strong>+ {% for id, name in accounts %}<div class="form-group"><div class="col-sm-10"><div class="checkbox"><label>- {% if account.id in frontPageAccounts.data or frontPageAccounts.data|length == 0 %}- <input type="checkbox" name="frontPageAccounts[]" value="{{ account.id }}"- checked> {{ account.name }}+ {% if id in frontPageAccounts.data or frontPageAccounts.data|length == 0 %}+ <input type="checkbox" name="frontPageAccounts[]" value="{{ id }}"+ checked> {{ name }}{% else %}<input type="checkbox" name="frontPageAccounts[]"- value="{{ account.id }}"> {{ account.name }}+ value="{{ id }}"> {{ name }}{% endif %}</label></div></div></div>{% endfor %}+ {% endfor %}</div></div>{# frontpage settings column b #}