diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.php index faf5a15d1d..ca08e03c59 100644 --- a/app/Generator/Report/Category/MonthReportGenerator.php +++ b/app/Generator/Report/Category/MonthReportGenerator.php @@ -95,7 +95,7 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface ->render(); } catch (Throwable $e) { Log::error(sprintf('Cannot render reports.category.month: %s', $e->getMessage())); - $result = 'Could not render report view.'; + $result = sprintf('Could not render report view: %s', $e->getMessage()); } return $result; diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.php index 559038008a..ac82971151 100644 --- a/app/Http/Controllers/Report/BudgetController.php +++ b/app/Http/Controllers/Report/BudgetController.php @@ -116,6 +116,8 @@ class BudgetController extends Controller * @param Collection $budgets * @param Carbon $start * @param Carbon $end + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function accounts(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end) { @@ -392,6 +394,8 @@ class BudgetController extends Controller 'currency_name' => $currency['currency_name'], 'currency_symbol' => $currency['currency_symbol'], 'currency_decimal_places' => $currency['currency_decimal_places'], + 'budget_id' => $budget['id'], + 'budget_name' => $budget['name'], ]; } } diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.php index 0822e0b768..045726a30c 100644 --- a/app/Http/Controllers/Report/CategoryController.php +++ b/app/Http/Controllers/Report/CategoryController.php @@ -24,6 +24,7 @@ namespace FireflyIII\Http\Controllers\Report; use Carbon\Carbon; use FireflyIII\Http\Controllers\Controller; +use FireflyIII\Models\Account; use FireflyIII\Models\Category; use FireflyIII\Repositories\Category\CategoryRepositoryInterface; use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface; @@ -41,6 +42,27 @@ class CategoryController extends Controller { use BasicDataSupport; + + /** @var OperationsRepositoryInterface */ + private $opsRepository; + + /** + * ExpenseReportController constructor. + * + * @codeCoverageIgnore + */ + public function __construct() + { + parent::__construct(); + $this->middleware( + function ($request, $next) { + $this->opsRepository = app(OperationsRepositoryInterface::class); + + return $next($request); + } + ); + } + /** * Show overview of expenses in category. * @@ -146,6 +168,61 @@ class CategoryController extends Controller return $result; } + /** + * @param Collection $accounts + * @param Collection $categories + * @param Carbon $start + * @param Carbon $end + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function accounts(Collection $accounts, Collection $categories, Carbon $start, Carbon $end) + { + $spent = $this->opsRepository->listExpenses($start, $end, $accounts, $categories); + $report = []; + $sums = []; + /** @var Account $account */ + foreach ($accounts as $account) { + $accountId = $account->id; + $report[$accountId] = $report[$accountId] ?? [ + 'name' => $account->name, + 'id' => $account->id, + 'iban' => $account->iban, + 'currencies' => [], + ]; + } + + // loop expenses. + foreach ($spent as $currency) { + $currencyId = $currency['currency_id']; + $sums[$currencyId] = $sums[$currencyId] ?? [ + 'currency_id' => $currency['currency_id'], + 'currency_symbol' => $currency['currency_symbol'], + 'currency_name' => $currency['currency_name'], + 'currency_decimal_places' => $currency['currency_decimal_places'], + 'sum' => '0', + ]; + foreach ($currency['categories'] as $category) { + foreach ($category['transaction_journals'] as $journal) { + $sourceAccountId = $journal['source_account_id']; + $report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [ + 'currency_id' => $currency['currency_id'], + 'currency_symbol' => $currency['currency_symbol'], + 'currency_name' => $currency['currency_name'], + 'currency_decimal_places' => $currency['currency_decimal_places'], + 'sum' => '0', + ]; + $report[$sourceAccountId]['currencies'][$currencyId]['sum'] = bcadd( + $report[$sourceAccountId]['currencies'][$currencyId]['sum'], $journal['amount'] + ); + $sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], $journal['amount']); + } + } + } + + return view('reports.category.partials.accounts', compact('sums', 'report')); + } + /** * Show overview of income in category. diff --git a/app/Repositories/Category/OperationsRepository.php b/app/Repositories/Category/OperationsRepository.php index 7ddd3805e3..d6113215cf 100644 --- a/app/Repositories/Category/OperationsRepository.php +++ b/app/Repositories/Category/OperationsRepository.php @@ -78,7 +78,7 @@ class OperationsRepository implements OperationsRepositoryInterface if (null === $categories || (null !== $categories && 0 === $categories->count())) { $collector->setCategories($this->getCategories()); } - $collector->withCategoryInformation(); + $collector->withCategoryInformation()->withAccountInformation(); $journals = $collector->getExtractedJournals(); $array = []; @@ -115,8 +115,9 @@ class OperationsRepository implements OperationsRepositoryInterface $array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = [ - 'amount' => app('steam')->negative($journal['amount']), - 'date' => $journal['date'], + 'amount' => app('steam')->negative($journal['amount']), + 'date' => $journal['date'], + 'source_account_id' => $journal['source_account_id'], ]; } @@ -155,8 +156,8 @@ class OperationsRepository implements OperationsRepositoryInterface $array = []; foreach ($journals as $journal) { - $currencyId = (int)$journal['currency_id']; - $categoryId = (int)$journal['category_id']; + $currencyId = (int)$journal['currency_id']; + $categoryId = (int)$journal['category_id']; $categoryName = (string)$journal['category_name']; // catch "no category" entries. diff --git a/public/v1/js/ff/reports/category/month.js b/public/v1/js/ff/reports/category/month.js index 35df4b25b3..7b12946e1e 100644 --- a/public/v1/js/ff/reports/category/month.js +++ b/public/v1/js/ff/reports/category/month.js @@ -17,28 +17,26 @@ * You should have received a copy of the GNU General Public License * along with Firefly III. If not, see . */ - -/** global: categoryIncomeUri, categoryExpenseUri, accountIncomeUri, accountExpenseUri, mainUri */ - $(function () { "use strict"; drawChart(); - $('#categories-in-pie-chart-checked').on('change', function () { - redrawPieChart(categoryIncomeUri, 'categories-in-pie-chart'); - }); - $('#categories-out-pie-chart-checked').on('change', function () { - redrawPieChart(categoryExpenseUri, 'categories-out-pie-chart'); - }); - - $('#accounts-in-pie-chart-checked').on('change', function () { - redrawPieChart(accountIncomeUri, 'accounts-in-pie-chart'); - }); - - $('#accounts-out-pie-chart-checked').on('change', function () { - redrawPieChart(accountExpenseUri, 'accounts-out-pie-chart'); - }); + // $('#categories-in-pie-chart-checked').on('change', function () { + // redrawPieChart(categoryIncomeUri, 'categories-in-pie-chart'); + // }); + // + // $('#categories-out-pie-chart-checked').on('change', function () { + // redrawPieChart(categoryExpenseUri, 'categories-out-pie-chart'); + // }); + // + // $('#accounts-in-pie-chart-checked').on('change', function () { + // redrawPieChart(accountIncomeUri, 'accounts-in-pie-chart'); + // }); + // + // $('#accounts-out-pie-chart-checked').on('change', function () { + // redrawPieChart(accountExpenseUri, 'accounts-out-pie-chart'); + // }); }); @@ -46,28 +44,21 @@ $(function () { function drawChart() { "use strict"; + loadAjaxPartial('accountsHolder', accountsUri); + + // month view: - doubleYChart(mainUri, 'in-out-chart'); + //doubleYChart(mainUri, 'in-out-chart'); // draw pie chart of income, depending on "show other transactions too": - redrawPieChart(categoryIncomeUri, 'categories-in-pie-chart'); - redrawPieChart(categoryExpenseUri, 'categories-out-pie-chart'); - redrawPieChart(accountIncomeUri, 'accounts-in-pie-chart'); - redrawPieChart(accountExpenseUri, 'accounts-out-pie-chart'); + // redrawPieChart(categoryIncomeUri, 'categories-in-pie-chart'); + // redrawPieChart(categoryExpenseUri, 'categories-out-pie-chart'); + // redrawPieChart(accountIncomeUri, 'accounts-in-pie-chart'); + // redrawPieChart(accountExpenseUri, 'accounts-out-pie-chart'); } function redrawPieChart(uri, container) { "use strict"; - var checkbox = $('#' + container + '-checked'); - - var others = '0'; - // check if box is checked: - if (checkbox.prop('checked')) { - others = '1'; - } - uri = uri.replace('OTHERS', others); - - pieChart(uri, container); - + multiCurrencyPieChart(uri, container); } diff --git a/resources/views/v1/reports/budget/partials/top-expenses.twig b/resources/views/v1/reports/budget/partials/top-expenses.twig index f0c9c0e031..96e825a8ad 100644 --- a/resources/views/v1/reports/budget/partials/top-expenses.twig +++ b/resources/views/v1/reports/budget/partials/top-expenses.twig @@ -4,6 +4,7 @@ {{ 'description'|_ }} {{ 'date'|_ }} {{ 'account'|_ }} + {{ 'budget'|_ }} {{ 'amount'|_ }} @@ -28,6 +29,11 @@ {{ row.destination_account_name }} + + + {{ row.budget_name }} + + {{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_decimal_places) }} diff --git a/resources/views/v1/reports/category/month.twig b/resources/views/v1/reports/category/month.twig index e5376a2b77..9f4d2d3b90 100644 --- a/resources/views/v1/reports/category/month.twig +++ b/resources/views/v1/reports/category/month.twig @@ -1,434 +1,213 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.render(Route.getCurrentRoute.getName, accountIds, categoryIds, start, end) }} + {#{{ Breadcrumbs.render(Route.getCurrentRoute.getName, accountIds, budgetIds, start, end) }}#} {% endblock %} {% block content %}
-
+

{{ 'accounts'|_ }}

-
- - - - - - - - - - {% for account in accounts %} - - - {% if accountSummary[account.id] %} - - {% else %} - - {% endif %} - {% if accountSummary[account.id] %} - - {% else %} - - {% endif %} - - {% endfor %} - - - - - - - - -
{{ 'name'|_ }}{{ 'earned'|_ }}{{ 'spent'|_ }}
- {{ account.name }} - {{ accountSummary[account.id].earned|formatAmount }}{{ 0|formatAmount }}{{ accountSummary[account.id].spent|formatAmount }}{{ 0|formatAmount }}
{{ 'sum'|_ }}{{ accountSummary.sum.earned|formatAmount }}{{ accountSummary.sum.spent|formatAmount }}
+
+
+ {# loading indicator #} +
+
- +
+

{{ 'categories'|_ }}

-
- - - - - - - - - - {% for category in categories %} - - - {% if categorySummary[category.id] %} - - {% else %} - - {% endif %} - {% if categorySummary[category.id] %} - - {% else %} - - {% endif %} - - {% endfor %} - - - - - - - - -
{{ 'name'|_ }}{{ 'earned'|_ }}{{ 'spent'|_ }}
- {{ category.name }} - {{ categorySummary[category.id].earned|formatAmount }}{{ 0|formatAmount }}{{ categorySummary[category.id].spent|formatAmount }}{{ 0|formatAmount }}
{{ 'sum'|_ }}{{ categorySummary.sum.earned|formatAmount }}{{ categorySummary.sum.spent|formatAmount }}
+
+
+ {# loading indicator #} +
+
- {% if categories.count > 1 %} -
-
-
-

{{ 'income_per_category'|_ }}

-
-
- - -
-
-
-
-
-
-

{{ 'expense_per_category'|_ }}

-
-
- - -
-
-
- {% endif %} -
+
+
+
-

{{ 'income_per_account'|_ }}

+

{{ 'account_per_category'|_ }}

-
- - +
+
+ {# loading indicator #} +
+
-
+
+
+
-

{{ 'expense_per_account'|_ }}

+

{{ 'expense_per_category'|_ }}

- - +
+ +
-
- -
-
-
+
+
-

{{ 'income_and_expenses'|_ }}

+

{{ 'income_per_category'|_ }}

- +
+ +
+
+
+
+
+
+
+

{{ 'expense_per_budget'|_ }}

+
+
+
+ +
- - {% if averageExpenses|length > 0 %} -
-
-
-

{{ 'average_spending_per_account'|_ }}

-
-
- - - - - - - - - - - {% set totalCount = 0 %} - {% set totalSum = 0 %} - {% for row in averageExpenses %} - {% if loop.index > listLength %} - - {% else %} - - {% endif %} - - - - - - {% set totalCount = totalCount+ row.count %} - {% set totalSum = totalSum + row.sum %} - {% endfor %} - - - {% if averageExpenses|length > listLength %} - - - - {% endif %} - - - - - - -
{{ 'account'|_ }}{{ 'spent_average'|_ }}{{ 'total'|_ }}{{ 'transaction_count'|_ }}
- {{ row.name }} - - {{ row.average|formatAmount }} - - {{ row.sum|formatAmount }} - - {{ row.count }} -
- {{ trans('firefly.show_full_list',{number:incomeTopLength}) }} -
- {{ 'sum'|_ }} - {{ totalSum|formatAmount }}{{ totalCount }}
+
+
+
+

{{ 'expense_per_source_account'|_ }}

+
+
+
+
- {% endif %} - {% if topExpenses|length > 0 %} -
- -
-
-

{{ 'expenses'|_ }} ({{ trans('firefly.topX', {number: listLength}) }} - )

-
-
- - - - - - - - - - - {% set totalSum = 0 %} - {% for row in topExpenses %} - {% set totalSum = totalSum + row.amount %} - {% if loop.index > listLength %} - - {% else %} - - {% endif %} - - - - - - {% endfor %} - - - {% if topExpenses|length > listLength %} - - - - {% endif %} - - - - - -
{{ 'description'|_ }}{{ 'date'|_ }}{{ 'account'|_ }}{{ 'amount'|_ }}
- - {% if row.group_title|length > 0 %} - {{ row.group_title }} ({{ row.description }}) - {% else %} - {{ row.description }} - {% endif %} - - - {{ row.date.formatLocalized(monthAndDayFormat) }} - - - {{ row.destination_account_name }} - - - {{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_decimal_places) }} -
- {{ trans('firefly.show_full_list',{number:incomeTopLength}) }} -
- {{ 'sum'|_ }} - {{ totalSum|formatAmount }}
+
+
+
+
+

{{ 'income_per_source_account'|_ }}

+
+
+
+
- {% endif %} +
- {% if averageIncome|length > 0 %} -
-
-
-

{{ 'average_income_per_account'|_ }}

-
-
- - - - - - - - - - - {% set totalCount = 0 %} - {% set totalSum = 0 %} - {% for row in averageIncome %} - {% set totalCount = totalCount+ row.count %} - {% set totalSum = totalSum + row.sum %} - - - - - - - {% endfor %} - - - - - - -
{{ 'account'|_ }}{{ 'income_average'|_ }}{{ 'total'|_ }}{{ 'transaction_count'|_ }}
- {{ row.name }} - - {{ (row.average*-1)|formatAmount }} - - {{ (row.sum*-1)|formatAmount }} - - {{ row.count }} -
- {{ 'sum'|_ }} - {{ (totalSum*-1)|formatAmount }}{{ totalCount }}
+
+
+
+

{{ 'expense_per_destination_account'|_ }}

+
+
+
+
- {% endif %} +
+
+
+
+

{{ 'income_per_destination_account'|_ }}

+
+
+
+ +
+
+
+
+
+ + {% for category in categories %} +
+
+
+
+

{{ 'income_and_expenses'|_ }} ({{ category.name }})

+
+
+ {##} +
+
+
+
+ {% endfor %} +
- {% if topIncome|length > 0 %} -
-
-

{{ 'income'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})

-
-
- - - - - - - - - - - {% set totalSum = 0 %} - {% for row in topIncome %} - {% set totalSum = totalSum + row.amount %} - {% if loop.index > listLength %} - - {% else %} - - {% endif %} - - - - - - {% endfor %} - - - {% if topIncome|length > listLength %} - - - - {% endif %} - - - - - -
{{ 'description'|_ }}{{ 'date'|_ }}{{ 'account'|_ }}{{ 'amount'|_ }}
- - {% if row.group_title|length > 0 %} - {{ row.group_title }} ({{ row.description }}) - {% else %} - {{ row.description }} - {% endif %} - - - {{ row.date.formatLocalized(monthAndDayFormat) }} - - - {{ row.destination_account_name }} - - - {{ formatAmountBySymbol(row.amount*-1, row.currency_symbol, row.currency_decimal_places) }} -
- {{ trans('firefly.show_full_list',{number:incomeTopLength}) }} -
- {{ 'sum'|_ }} - {{ (totalSum*-1)|formatAmount }}
-
+
+
+

{{ 'average_spending_per_destination'|_ }}

- {% endif %} +
+
+ {# loading indicator #} +
+ +
+
+
+
+
+
+

{{ 'average_earning_per_source'|_ }}

+
+
+
+ {# loading indicator #} +
+ +
+
+
+
+
+
+
+
+

{{ 'expenses'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})

+
+
+
+ {# loading indicator #} +
+ +
+
+
+
+
+
+

{{ 'income'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})

+
+
+
+ {# loading indicator #} +
+ +
+
@@ -447,15 +226,24 @@ var accountIds = '{{ accountIds }}'; var categoryIds = '{{ categoryIds }}'; + // html block URI's: + + var accountsUri = '{{ route('report-data.category.accounts', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}'; + + {#var categoriesUri = '{{ route('report-data.category.categories', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#} + {#var accountPerCategoryUri = '{{ route('report-data.category.account-per-category', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#} + {#var avgExpensesUri = '{{ route('report-data.category.avg-expenses', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#} + {#var topExpensesUri = '{{ route('report-data.category.top-expenses', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#} + + {#var avgIncomeUri = '{{ route('report-data.category.avg-income', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#} + {#var topIncomesUri = '{{ route('report-data.category.top-income', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#} + // chart uri's - var categoryIncomeUri = '{{ route('chart.category.category-income', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd'),'OTHERS']) }}'; - var categoryExpenseUri = '{{ route('chart.category.category-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd'),'OTHERS']) }}'; - var accountIncomeUri = '{{ route('chart.category.account-income', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd'),'OTHERS']) }}'; - var accountExpenseUri = '{{ route('chart.category.account-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd'),'OTHERS']) }}'; - var mainUri = '{{ route('chart.category.main', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}'; + {#var budgetExpenseUri = '{{ route('chart.category.category-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#} + {#var categoryExpenseUri = '{{ route('chart.category.category-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#} + {#var sourceExpenseUri = '{{ route('chart.budget.source-account-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#} + {#var destinationExpenseUri = '{{ route('chart.budget.destination-account-expense', [accountIds, categoryIds, start.format('Ymd'), end.format('Ymd')]) }}';#} - - diff --git a/resources/views/v1/reports/category/partials/accounts.twig b/resources/views/v1/reports/category/partials/accounts.twig new file mode 100644 index 0000000000..b85fe8cf11 --- /dev/null +++ b/resources/views/v1/reports/category/partials/accounts.twig @@ -0,0 +1,32 @@ + + + + + + + + + {% for account in report %} + {% for currency in account.currencies %} + + + + + {% endfor %} + {% endfor %} + + + {% for sum in sums %} + + + + + {% endfor %} + +
{{ 'name'|_ }}{{ 'spent'|_ }}
+ {{ account.name }} ({{ currency.currency_name }}) + + {{ formatAmountBySymbol(currency.sum, currency.currency_symbol, currency.currency_decimal_places) }} +
{{ 'sum'|_ }} ({{ sum.currency_name }}) + {{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }} +
\ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 8caf467ca3..b5725d08e1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -82,12 +82,13 @@ Route::group( // * // */ Route::group( - ['middleware' => 'user-logged-in-no-2fa', 'prefix' => 'two-factor', 'as' => 'two-factor.', 'namespace' => 'FireflyIII\Http\Controllers\Auth'], static function () { - Route::post('submit', ['uses' => 'TwoFactorController@submitMFA', 'as' => 'submit']); - Route::get('lost', ['uses' => 'TwoFactorController@lostTwoFactor', 'as' => 'lost']); - // Route::post('', ['uses' => 'TwoFactorController@postIndex', 'as' => 'post']); - // -} + ['middleware' => 'user-logged-in-no-2fa', 'prefix' => 'two-factor', 'as' => 'two-factor.', 'namespace' => 'FireflyIII\Http\Controllers\Auth'], + static function () { + Route::post('submit', ['uses' => 'TwoFactorController@submitMFA', 'as' => 'submit']); + Route::get('lost', ['uses' => 'TwoFactorController@lostTwoFactor', 'as' => 'lost']); + // Route::post('', ['uses' => 'TwoFactorController@postIndex', 'as' => 'post']); + // + } ); /** @@ -320,21 +321,22 @@ Route::group( * Chart\Account Controller (default report) */ Route::group( - ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/account', 'as' => 'chart.account.'], static function () { - Route::get('frontpage', ['uses' => 'AccountController@frontpage', 'as' => 'frontpage']); - Route::get('expense', ['uses' => 'AccountController@expenseAccounts', 'as' => 'expense']); - Route::get('revenue', ['uses' => 'AccountController@revenueAccounts', 'as' => 'revenue']); - Route::get('report/{accountList}/{start_date}/{end_date}', ['uses' => 'AccountController@report', 'as' => 'report']); - Route::get('period/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@period', 'as' => 'period']); + ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/account', 'as' => 'chart.account.'], + static function () { + Route::get('frontpage', ['uses' => 'AccountController@frontpage', 'as' => 'frontpage']); + Route::get('expense', ['uses' => 'AccountController@expenseAccounts', 'as' => 'expense']); + Route::get('revenue', ['uses' => 'AccountController@revenueAccounts', 'as' => 'revenue']); + Route::get('report/{accountList}/{start_date}/{end_date}', ['uses' => 'AccountController@report', 'as' => 'report']); + Route::get('period/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@period', 'as' => 'period']); - Route::get('income-category/{account}/all/all', ['uses' => 'AccountController@incomeCategoryAll', 'as' => 'income-category-all']); - Route::get('expense-category/{account}/all/all', ['uses' => 'AccountController@expenseCategoryAll', 'as' => 'expense-category-all']); - Route::get('expense-budget/{account}/all/all', ['uses' => 'AccountController@expenseBudgetAll', 'as' => 'expense-budget-all']); + Route::get('income-category/{account}/all/all', ['uses' => 'AccountController@incomeCategoryAll', 'as' => 'income-category-all']); + Route::get('expense-category/{account}/all/all', ['uses' => 'AccountController@expenseCategoryAll', 'as' => 'expense-category-all']); + Route::get('expense-budget/{account}/all/all', ['uses' => 'AccountController@expenseBudgetAll', 'as' => 'expense-budget-all']); - Route::get('income-category/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@incomeCategory', 'as' => 'income-category']); - Route::get('expense-category/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@expenseCategory', 'as' => 'expense-category']); - Route::get('expense-budget/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@expenseBudget', 'as' => 'expense-budget']); -} + Route::get('income-category/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@incomeCategory', 'as' => 'income-category']); + Route::get('expense-category/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@expenseCategory', 'as' => 'expense-category']); + Route::get('expense-budget/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@expenseBudget', 'as' => 'expense-budget']); + } ); @@ -342,37 +344,50 @@ Route::group( * Chart\Bill Controller */ Route::group( - ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/bill', 'as' => 'chart.bill.'], static function () { - Route::get('frontpage', ['uses' => 'BillController@frontpage', 'as' => 'frontpage']); - Route::get('single/{bill}', ['uses' => 'BillController@single', 'as' => 'single']); + ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/bill', 'as' => 'chart.bill.'], + static function () { + Route::get('frontpage', ['uses' => 'BillController@frontpage', 'as' => 'frontpage']); + Route::get('single/{bill}', ['uses' => 'BillController@single', 'as' => 'single']); -} + } ); /** * Chart\Budget Controller */ Route::group( - ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/budget', 'as' => 'chart.budget.'], static function () { + ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/budget', 'as' => 'chart.budget.'], + static function () { - Route::get('frontpage', ['uses' => 'BudgetController@frontpage', 'as' => 'frontpage']); - Route::get('period/0/{currency}/{accountList}/{start_date}/{end_date}', ['uses' => 'BudgetController@periodNoBudget', 'as' => 'period.no-budget']); - Route::get('period/{budget}/{currency}/{accountList}/{start_date}/{end_date}', ['uses' => 'BudgetController@period', 'as' => 'period']); - Route::get('budget/{budget}/{budgetLimit}', ['uses' => 'BudgetController@budgetLimit', 'as' => 'budget-limit']); - Route::get('budget/{budget}', ['uses' => 'BudgetController@budget', 'as' => 'budget']); + Route::get('frontpage', ['uses' => 'BudgetController@frontpage', 'as' => 'frontpage']); + Route::get('period/0/{currency}/{accountList}/{start_date}/{end_date}', ['uses' => 'BudgetController@periodNoBudget', 'as' => 'period.no-budget']); + Route::get('period/{budget}/{currency}/{accountList}/{start_date}/{end_date}', ['uses' => 'BudgetController@period', 'as' => 'period']); + Route::get('budget/{budget}/{budgetLimit}', ['uses' => 'BudgetController@budgetLimit', 'as' => 'budget-limit']); + Route::get('budget/{budget}', ['uses' => 'BudgetController@budget', 'as' => 'budget']); - // these charts are used in budget/show: - Route::get('expense-category/{budget}/{budgetLimit?}', ['uses' => 'BudgetController@expenseCategory', 'as' => 'expense-category']); - Route::get('expense-asset/{budget}/{budgetLimit?}', ['uses' => 'BudgetController@expenseAsset', 'as' => 'expense-asset']); - Route::get('expense-expense/{budget}/{budgetLimit?}', ['uses' => 'BudgetController@expenseExpense', 'as' => 'expense-expense']); + // these charts are used in budget/show: + Route::get('expense-category/{budget}/{budgetLimit?}', ['uses' => 'BudgetController@expenseCategory', 'as' => 'expense-category']); + Route::get('expense-asset/{budget}/{budgetLimit?}', ['uses' => 'BudgetController@expenseAsset', 'as' => 'expense-asset']); + Route::get('expense-expense/{budget}/{budgetLimit?}', ['uses' => 'BudgetController@expenseExpense', 'as' => 'expense-expense']); - // these charts are used in reports (category reports): - Route::get('category/expense/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetReportController@categoryExpense', 'as' => 'category-expense']); - Route::get('budget/expense/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetReportController@budgetExpense', 'as' => 'budget-expense']); - Route::get('source-account/expense/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetReportController@sourceAccountExpense', 'as' => 'source-account-expense']); - Route::get('destination-account/expense/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetReportController@destinationAccountExpense', 'as' => 'destination-account-expense']); - Route::get('operations/{accountList}/{budget}/{start_date}/{end_date}', ['uses' => 'BudgetReportController@mainChart', 'as' => 'main']); -} + // these charts are used in reports (category reports): + Route::get( + 'category/expense/{accountList}/{budgetList}/{start_date}/{end_date}', + ['uses' => 'BudgetReportController@categoryExpense', 'as' => 'category-expense'] + ); + Route::get( + 'budget/expense/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetReportController@budgetExpense', 'as' => 'budget-expense'] + ); + Route::get( + 'source-account/expense/{accountList}/{budgetList}/{start_date}/{end_date}', + ['uses' => 'BudgetReportController@sourceAccountExpense', 'as' => 'source-account-expense'] + ); + Route::get( + 'destination-account/expense/{accountList}/{budgetList}/{start_date}/{end_date}', + ['uses' => 'BudgetReportController@destinationAccountExpense', 'as' => 'destination-account-expense'] + ); + Route::get('operations/{accountList}/{budget}/{start_date}/{end_date}', ['uses' => 'BudgetReportController@mainChart', 'as' => 'main']); + } ); /** @@ -465,12 +480,13 @@ Route::group( * Chart\Expense Controller (for expense/revenue report). */ Route::group( - ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/expense', 'as' => 'chart.expense.'], static function () { - Route::get( - 'operations/{accountList}/{expenseList}/{start_date}/{end_date}', - ['uses' => 'ExpenseReportController@mainChart', 'as' => 'main'] - ); -} + ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/expense', 'as' => 'chart.expense.'], + static function () { + Route::get( + 'operations/{accountList}/{expenseList}/{start_date}/{end_date}', + ['uses' => 'ExpenseReportController@mainChart', 'as' => 'main'] + ); + } ); @@ -488,11 +504,12 @@ Route::group( * Chart\Report Controller */ Route::group( - ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/report', 'as' => 'chart.report.'], static function () { - Route::get('operations/{accountList}/{start_date}/{end_date}', ['uses' => 'ReportController@operations', 'as' => 'operations']); - Route::get('net-worth/{accountList}/{start_date}/{end_date}/', ['uses' => 'ReportController@netWorth', 'as' => 'net-worth']); + ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/report', 'as' => 'chart.report.'], + static function () { + Route::get('operations/{accountList}/{start_date}/{end_date}', ['uses' => 'ReportController@operations', 'as' => 'operations']); + Route::get('net-worth/{accountList}/{start_date}/{end_date}/', ['uses' => 'ReportController@netWorth', 'as' => 'net-worth']); -} + } ); /** @@ -776,10 +793,15 @@ Route::group( Route::group( ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Report', 'prefix' => 'report-data/category', 'as' => 'report-data.category.'], static function () { + + // TODO still in use? Route::get('operations/{accountList}/{start_date}/{end_date}', ['uses' => 'CategoryController@operations', 'as' => 'operations']); Route::get('income/{accountList}/{start_date}/{end_date}', ['uses' => 'CategoryController@income', 'as' => 'income']); Route::get('expenses/{accountList}/{start_date}/{end_date}', ['uses' => 'CategoryController@expenses', 'as' => 'expenses']); + Route::get('accounts/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'CategoryController@accounts', 'as' => 'accounts']); + + } ); @@ -788,7 +810,7 @@ Route::group( */ Route::group( ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Report', 'prefix' => 'report-data/balance', 'as' => 'report-data.balance.'], - function () { + static function () { Route::get('general/{accountList}/{start_date}/{end_date}', ['uses' => 'BalanceController@general', 'as' => 'general']); } @@ -801,12 +823,16 @@ Route::group( ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Report', 'prefix' => 'report-data/budget', 'as' => 'report-data.budget.'], static function () { + // todo are these two routes still used? Route::get('general/{accountList}/{start_date}/{end_date}/', ['uses' => 'BudgetController@general', 'as' => 'general']); Route::get('period/{accountList}/{start_date}/{end_date}', ['uses' => 'BudgetController@period', 'as' => 'period']); Route::get('accounts/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@accounts', 'as' => 'accounts']); Route::get('budgets/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@budgets', 'as' => 'budgets']); - Route::get('account-per-budget/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@accountPerBudget', 'as' => 'account-per-budget']); + Route::get( + 'account-per-budget/{accountList}/{budgetList}/{start_date}/{end_date}', + ['uses' => 'BudgetController@accountPerBudget', 'as' => 'account-per-budget'] + ); Route::get('top-expenses/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@topExpenses', 'as' => 'top-expenses']); Route::get('avg-expenses/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'BudgetController@avgExpenses', 'as' => 'avg-expenses']);