Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Code for #2389
James Coled107e78641cf
diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.phpindex d349f6a818..ff2c715d86 100644--- a/app/Http/Controllers/Account/ShowController.php+++ b/app/Http/Controllers/Account/ShowController.php@@ -57,6 +57,8 @@ class ShowController extends Controller{parent::__construct();+ app('view')->share('showCategory', true);+// translations:$this->middleware(function ($request, $next) {@@ -116,7 +118,7 @@ class ShowController extends Controller$collector->setAccounts(new Collection([$account]))->setLimit($pageSize)- ->setPage($page)->withAccountInformation()+ ->setPage($page)->withAccountInformation()->withCategoryInformation()->setRange($start, $end);$groups = $collector->getPaginatedGroups();$groups->setPath(route('accounts.show', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]));@@ -158,7 +160,7 @@ class ShowController extends Controller$periods = new Collection;/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);- $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page)->withAccountInformation();+ $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation();$groups = $collector->getPaginatedGroups();$groups->setPath(route('accounts.show.all', [$account->id]));$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.phpindex ea42c54ff2..006163607b 100644--- a/app/Http/Controllers/BillController.php+++ b/app/Http/Controllers/BillController.php@@ -65,6 +65,7 @@ class BillController extends Controller$maxPostSize = app('steam')->phpBytes(ini_get('post_max_size'));$uploadSize = min($maxFileSize, $maxPostSize);app('view')->share('uploadSize', $uploadSize);+ app('view')->share('showBudget', true);$this->middleware(function ($request, $next) {diff --git a/app/Http/Controllers/Budget/AvailableBudgetController.php b/app/Http/Controllers/Budget/AvailableBudgetController.phpindex bdfb94c125..3ca5f7d7c4 100644--- a/app/Http/Controllers/Budget/AvailableBudgetController.php+++ b/app/Http/Controllers/Budget/AvailableBudgetController.php@@ -53,8 +53,6 @@ class AvailableBudgetController extends Controller{parent::__construct();- app('view')->share('hideBudgets', true);-$this->middleware(function ($request, $next) {app('view')->share('title', (string)trans('firefly.budgets'));diff --git a/app/Http/Controllers/Budget/CreateController.php b/app/Http/Controllers/Budget/CreateController.phpindex eb930fba73..61db789ee0 100644--- a/app/Http/Controllers/Budget/CreateController.php+++ b/app/Http/Controllers/Budget/CreateController.php@@ -46,7 +46,6 @@ class CreateController extends Controller{parent::__construct();- app('view')->share('hideBudgets', true);$this->middleware(function ($request, $next) {diff --git a/app/Http/Controllers/Budget/DeleteController.php b/app/Http/Controllers/Budget/DeleteController.phpindex 0b913ed23d..4b40d92b2b 100644--- a/app/Http/Controllers/Budget/DeleteController.php+++ b/app/Http/Controllers/Budget/DeleteController.php@@ -46,8 +46,6 @@ class DeleteController extends Controller{parent::__construct();- app('view')->share('hideBudgets', true);-$this->middleware(function ($request, $next) {app('view')->share('title', (string)trans('firefly.budgets'));diff --git a/app/Http/Controllers/Budget/EditController.php b/app/Http/Controllers/Budget/EditController.phpindex d74c8b7479..1d02d1bc42 100644--- a/app/Http/Controllers/Budget/EditController.php+++ b/app/Http/Controllers/Budget/EditController.php@@ -48,8 +48,6 @@ class EditController extends Controller{parent::__construct();- app('view')->share('hideBudgets', true);-$this->middleware(function ($request, $next) {app('view')->share('title', (string)trans('firefly.budgets'));diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.phpindex e2cae5f065..d8292f71ef 100644--- a/app/Http/Controllers/Budget/IndexController.php+++ b/app/Http/Controllers/Budget/IndexController.php@@ -69,8 +69,6 @@ class IndexController extends Controller{parent::__construct();- app('view')->share('hideBudgets', true);-$this->middleware(function ($request, $next) {app('view')->share('title', (string)trans('firefly.budgets'));diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.phpindex 1fb7370ac7..7c09722e6f 100644--- a/app/Http/Controllers/Budget/ShowController.php+++ b/app/Http/Controllers/Budget/ShowController.php@@ -53,6 +53,7 @@ class ShowController extends Controller*/public function __construct(){+ app('view')->share('showCategory', true);parent::__construct();$this->middleware(function ($request, $next) {@@ -76,6 +77,8 @@ class ShowController extends Controller*/public function noBudget(Request $request, Carbon $start = null, Carbon $end = null){++/** @var Carbon $start */$start = $start ?? session('start');/** @var Carbon $end */@@ -95,7 +98,7 @@ class ShowController extends Controller/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)- ->withoutBudget()->withAccountInformation();+ ->withoutBudget()->withAccountInformation()->withCategoryInformation();$groups = $collector->getPaginatedGroups();$groups->setPath(route('budgets.no-budget'));@@ -111,6 +114,7 @@ class ShowController extends Controller*/public function noBudgetAll(Request $request){+$subTitle = (string)trans('firefly.all_journals_without_budget');$first = $this->journalRepos->firstNull();$start = null === $first ? new Carbon : $first->date;@@ -121,7 +125,7 @@ class ShowController extends Controller/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setLimit($pageSize)->setPage($page)- ->withoutBudget()->withAccountInformation();+ ->withoutBudget()->withAccountInformation()->withCategoryInformation();$groups = $collector->getPaginatedGroups();$groups->setPath(route('budgets.no-budget'));@@ -150,7 +154,7 @@ class ShowController extends Controller// collector:/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);- $collector->setRange($start, $end)->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();+ $collector->setRange($start, $end)->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation()->withCategoryInformation();$groups = $collector->getPaginatedGroups();$groups->setPath(route('budgets.show', [$budget->id]));@@ -191,7 +195,7 @@ class ShowController extends Controller$collector = app(GroupCollectorInterface::class);$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date)- ->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation();+ ->setBudget($budget)->setLimit($pageSize)->setPage($page)->withBudgetInformation()->withCategoryInformation();$groups = $collector->getPaginatedGroups();$groups->setPath(route('budgets.show', [$budget->id, $budgetLimit->id]));/** @var Carbon $start */diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.phpindex aa8df71950..c63bd85d0c 100644--- a/app/Http/Controllers/Category/NoCategoryController.php+++ b/app/Http/Controllers/Category/NoCategoryController.php@@ -51,6 +51,7 @@ class NoCategoryController extends Controllerpublic function __construct(){parent::__construct();+ app('view')->share('showBudget', true);$this->middleware(function ($request, $next) {diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.phpindex 2c48b9d429..bf6b8e327e 100644--- a/app/Http/Controllers/Category/ShowController.php+++ b/app/Http/Controllers/Category/ShowController.php@@ -50,6 +50,7 @@ class ShowController extends Controllerpublic function __construct(){parent::__construct();+ app('view')->share('showBudget', true);$this->middleware(function ($request, $next) {diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.phpindex 269b21e90b..1a8c733fc1 100644--- a/app/Http/Controllers/Controller.php+++ b/app/Http/Controllers/Controller.php@@ -54,15 +54,9 @@ class Controller extends BaseController*/public function __construct(){- // for transaction lists:- app('view')->share('hideBudgets', false,); // Firefly III will break here if you don't have PHP 7.3up- app('view')->share('hideCategories', false,);- app('view')->share('hideBills', false,);- app('view')->share('hideTags', false,);-// is site a demo site?- $isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;- app('view')->share('IS_DEMO_SITE', $isDemoSite);+ $isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site', ), )->data;+ app('view')->share('IS_DEMO_SITE', $isDemoSite, );app('view')->share('DEMO_USERNAME', config('firefly.demo_username'));app('view')->share('DEMO_PASSWORD', config('firefly.demo_password'));app('view')->share('FF_VERSION', config('firefly.version'));diff --git a/app/Http/Controllers/Recurring/ShowController.php b/app/Http/Controllers/Recurring/ShowController.phpindex bccf857f46..c0892aafe5 100644--- a/app/Http/Controllers/Recurring/ShowController.php+++ b/app/Http/Controllers/Recurring/ShowController.php@@ -50,6 +50,7 @@ class ShowController extends Controllerpublic function __construct(){parent::__construct();+ app('view')->share('showCategory', true);// translations:$this->middleware(diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.phpindex e93eb9833f..13d8f325ba 100644--- a/app/Http/Controllers/SearchController.php+++ b/app/Http/Controllers/SearchController.php@@ -39,9 +39,9 @@ class SearchController extends Controllerpublic function __construct(){parent::__construct();-+ app('view')->share('showCategory', true);$this->middleware(- function ($request, $next) {+ static function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-search');app('view')->share('title', (string)trans('firefly.search'));diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.phpindex 798a6b2c45..30224198b3 100644--- a/app/Http/Controllers/TagController.php+++ b/app/Http/Controllers/TagController.php@@ -49,7 +49,6 @@ class TagController extends Controllerpublic function __construct(){parent::__construct();- app('view')->share('hideTags', true);$this->redirectUri = route('tags.index');$this->middleware(diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.phpindex 251d01d124..59bcafcebb 100644--- a/app/Http/Controllers/Transaction/IndexController.php+++ b/app/Http/Controllers/Transaction/IndexController.php@@ -48,7 +48,7 @@ class IndexController extends Controllerpublic function __construct(){parent::__construct();-+ app('view')->share('showCategory', true);// translations:$this->middleware(function ($request, $next) {diff --git a/resources/views/v1/list/groups.twig b/resources/views/v1/list/groups.twigindex dc56e482c4..692378fb7d 100644--- a/resources/views/v1/list/groups.twig+++ b/resources/views/v1/list/groups.twig@@ -5,13 +5,31 @@ TODO: hide and show columns<table class="table table-condensed table-hover"><thead><tr>- <td colspan="7" class="no-margin-pagination">{{ groups.render|raw }}</td>+ {% if showCategory or showBudget %}+ <td colspan="8" class="no-margin-pagination">{{ groups.render|raw }}</td>+ {% else %}+ <td colspan="7" class="no-margin-pagination">{{ groups.render|raw }}</td>+ {% endif %}<td colspan="1"><div class="pull-right"><input id="list_ALL" value="1" name="select-all" type="checkbox" class="select-all form-check-inline"/></div></td></tr>+ <tr>+ <th> </th>+ <th>{{ trans('list.description') }}</th>+ <th>{{ trans('list.amount') }}</th>+ <th>{{ trans('list.date') }}</th>+ <th>{{ trans('list.source_account') }}</th>+ <th>{{ trans('list.destination_account') }}</th>+ {% if showCategory %}+ <th>{{ trans('list.category') }}</th>+ {% endif %}+ {% if showBudget %}+ <th>{{ trans('list.budget') }}</th>+ {% endif %}+ </tr></thead><tbody>{% for group in groups %}@@ -35,9 +53,14 @@ TODO: hide and show columns{% endif %}{% endfor %}</td>- <td colspan="2" style="border-top:1px #aaa solid;"> </td>- <td style="border-top:1px #aaa solid;" colspan="2">- <div class="btn-group btn-group-xs">+ <!-- column to span accounts + extra fields -->+ {% if showCategory or showBudget %}+ <td style="border-top:1px #aaa solid;" colspan="3"> </td>+ {% else %}+ <td style="border-top:1px #aaa solid;" colspan="2"> </td>+ {% endif %}+ <td style="border-top:1px #aaa solid;">+ <div class="btn-group btn-group-xs pull-right"><button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{ 'actions'|_ }} <span class="caret"></span></button><ul class="dropdown-menu dropdown-menu-right" role="menu">@@ -47,6 +70,7 @@ TODO: hide and show columns</ul></div></td>+ <td style="border-top:1px #aaa solid;"> </td></tr>{% endif %}{% for index, transaction in group.transactions %}@@ -81,11 +105,11 @@ TODO: hide and show columns<i class="fa fa-check"></i>{% endif %}{% if group.count == 1 %}- <a href="{{ route('transactions.show', [group.id]) }}" title="{{ transaction.description }}">- {% endif %}- {{ transaction.description }}- {% if group.count == 1 %}- </a>+ <a href="{{ route('transactions.show', [group.id]) }}" title="{{ transaction.description }}">+ {% endif %}+ {{ transaction.description }}+ {% if group.count == 1 %}+ </a>{% endif %}</td><td style=" {{ style|raw }}">@@ -97,15 +121,15 @@ TODO: hide and show columns{% elseif transaction.transaction_type_type == 'Transfer' %}<span class="text-info">{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}- {% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})- {% endif %}- </span>- {% else %}- {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}{% if null != transaction.foreign_amount %}- ({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})+ ({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }}){% endif %}+ </span>+ {% else %}+ {{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}+ {% if null != transaction.foreign_amount %}+ ({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})+ {% endif %}{% endif %}</td><td style=" {{ style|raw }}">@@ -119,7 +143,23 @@ TODO: hide and show columns<a href="{{ route('accounts.show', [transaction.destination_account_id]) }}"title="{{ transaction.destination_account_iban|default(transaction.destination_account_name) }}">{{ transaction.destination_account_name }}</a></td>- <td style=" {{ style|raw }}">+ {% if showCategory %}+ <td style=" {{ style|raw }}">+ {% if transaction.category_id %}+ <a href="{{ route('categories.show', [transaction.category_id]) }}"+ title="{{ transaction.category_name }}">{{ transaction.category_name }}</a>+ {% endif %}+ </td>+ {% endif %}+ {% if showBudget %}+ <td style=" {{ style|raw }}">+ {% if transaction.budget_id %}+ <a href="{{ route('budgets.show', [transaction.budget_id]) }}"+ title="{{ transaction.budget_name }}">{{ transaction.budget_name }}</a>+ {% endif %}+ </td>+ {% endif %}+ <td style=" {{ style|raw }};" class="pull-right">{% if group.count == 1 %}<div class="btn-group btn-group-xs"><button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">@@ -134,7 +174,8 @@ TODO: hide and show columns</td><td style="{{ style|raw }}"><div class="pull-right">- <input id="list_{{ transaction.transaction_journal_id }}" value="{{ transaction.transaction_journal_id }}" name="journals[{{ transaction.transaction_journal_id }}]"+ <input id="list_{{ transaction.transaction_journal_id }}" value="{{ transaction.transaction_journal_id }}"+ name="journals[{{ transaction.transaction_journal_id }}]"type="checkbox" class="mass-select form-check-inline" data-value="{{ transaction.transaction_journal_id }}"/></div></td>diff --git a/resources/views/v1/recurring/show.twig b/resources/views/v1/recurring/show.twigindex b60f10377d..c60c054988 100644--- a/resources/views/v1/recurring/show.twig+++ b/resources/views/v1/recurring/show.twig@@ -159,7 +159,7 @@<div class="box"><div class="box-header with-border"><h3 class="box-title">- {{ ('created_'~array.transaction_type~'s')|_ }}+ {{ ('created_'~array.type~'s')|_ }}</h3></div><div class="box-body">