Make some parts of the budget repository multi-currency

This commit is contained in:
James Cole 2019-09-02 16:52:35 +02:00
parent 8246d901e7
commit 0fd7e4363d
10 changed files with 408 additions and 185 deletions

View File

@ -66,17 +66,13 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
*/
public function generate(): string
{
$accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$budgetIds = implode(',', $this->budgets->pluck('id')->toArray());
$expenses = $this->getExpenses();
$accountSummary = $this->summarizeByAccount($expenses);
$budgetSummary = $this->summarizeByBudget($expenses);
$averageExpenses = $this->getAverages($expenses, SORT_ASC);
$topExpenses = $this->getTopExpenses();
// render!
$accountIds = implode(',', $this->accounts->pluck('id')->toArray());
$budgetIds = implode(',', $this->budgets->pluck('id')->toArray());
try {
$result = view('reports.budget.month', compact('accountIds', 'budgetIds', 'accountSummary', 'budgetSummary', 'averageExpenses', 'topExpenses'))
$result = view(
'reports.budget.month',
compact('accountIds', 'budgetIds')
)
->with('start', $this->start)->with('end', $this->end)
->with('budgets', $this->budgets)
->with('accounts', $this->accounts)
@ -89,57 +85,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
return $result;
}
/**
* Get the expenses.
*
* @return array
*/
protected function getExpenses(): array
{
if (count($this->expenses) > 0) {
Log::debug('Return previous set of expenses.');
return $this->expenses;
}
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)
->setTypes([TransactionType::WITHDRAWAL])
->withAccountInformation()
->withBudgetInformation()
->setBudgets($this->budgets);
$journals = $collector->getExtractedJournals();
$this->expenses = $journals;
return $journals;
}
/**
* Summarize a collection by its budget.
*
* @param array $array
*
* @return array
*/
private function summarizeByBudget(array $array): array
{
$result = [
'sum' => '0',
];
/** @var array $journal */
foreach ($array as $journal) {
$budgetId = (int)$journal['budget_id'];
$result[$budgetId] = $result[$budgetId] ?? '0';
$result[$budgetId] = bcadd($journal['amount'], $result[$budgetId]);
$result['sum'] = bcadd($result['sum'], $journal['amount']);
}
return $result;
}
/**
* Set the involved accounts.
*
@ -231,4 +176,31 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
{
return $this;
}
/**
* Get the expenses.
*
* @return array
*/
protected function getExpenses(): array
{
if (count($this->expenses) > 0) {
Log::debug('Return previous set of expenses.');
return $this->expenses;
}
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector->setAccounts($this->accounts)->setRange($this->start, $this->end)
->setTypes([TransactionType::WITHDRAWAL])
->withAccountInformation()
->withBudgetInformation()
->setBudgets($this->budgets);
$journals = $collector->getExtractedJournals();
$this->expenses = $journals;
return $journals;
}
}

View File

@ -25,8 +25,8 @@ namespace FireflyIII\Http\Controllers\Report;
use Carbon\Carbon;
use FireflyIII\Helpers\Report\BudgetReportHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Budget\NoBudgetRepositoryInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use FireflyIII\Support\Http\Controllers\BasicDataSupport;
@ -41,6 +41,168 @@ class BudgetController extends Controller
{
use BasicDataSupport;
/**
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*/
public function accountPerBudget(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end)
{
// get all journals.
$opsRepository = app(OperationsRepositoryInterface::class);
$spent = $opsRepository->listExpenses($start, $end, $accounts, $budgets);
$report = [];
/** @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'];
foreach ($currency['budgets'] as $budget) {
foreach ($budget['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'],
'budgets' => [],
];
$report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budget['id']]
= $report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budget['id']]
?? '0';
$report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budget['id']] = bcadd(
$report[$sourceAccountId]['currencies'][$currencyId]['budgets'][$budget['id']], $journal['amount']
);
}
}
}
return view('reports.budget.partials.account-per-budget', compact('report', 'budgets'));
}
/**
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*/
public function accounts(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end)
{
// get all journals.
$opsRepository = app(OperationsRepositoryInterface::class);
$spent = $opsRepository->listExpenses($start, $end, $accounts, $budgets);
$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['budgets'] as $budget) {
foreach ($budget['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.budget.partials.accounts', compact('sums', 'report'));
}
/**
* @param Collection $accounts
* @param Collection $budgets
* @param Carbon $start
* @param Carbon $end
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function budgets(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end)
{
// get all journals.
$opsRepository = app(OperationsRepositoryInterface::class);
$spent = $opsRepository->listExpenses($start, $end, $accounts, $budgets);
$sums = [];
$report = [];
/** @var Budget $budget */
foreach ($budgets as $budget) {
$budgetId = $budget->id;
$report[$budgetId] = $report[$budgetId] ?? [
'name' => $budget->name,
'id' => $budget->id,
'currencies' => [],
];
}
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',
];
/** @var array $budget */
foreach ($currency['budgets'] as $budget) {
$budgetId = $budget['id'];
foreach ($budget['transaction_journals'] as $journal) {
// add currency info to report array:
$report[$budgetId]['currencies'][$currencyId] = $report[$budgetId]['currencies'][$currencyId] ?? [
'sum' => '0',
'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'],
'currency_decimal_places' => $currency['currency_decimal_places'],
];
$report[$budgetId]['currencies'][$currencyId]['sum'] = bcadd($report[$budgetId]['currencies'][$currencyId]['sum'], $journal['amount']);
$sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], $journal['amount']);
}
}
}
return view('reports.budget.partials.budgets', compact('sums', 'report'));
}
/**
* Show partial overview of budgets.
*
@ -94,30 +256,19 @@ class BudgetController extends Controller
$cache->addProperty('budget-period-report');
$cache->addProperty($accounts->pluck('id')->toArray());
if ($cache->has()) {
// return $cache->get(); // @codeCoverageIgnore
return $cache->get(); // @codeCoverageIgnore
}
// generate budget report right here.
/** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepositoryInterface::class);
/** @var OperationsRepositoryInterface $opsRepository */
$opsRepository = app(OperationsRepositoryInterface::class);
/** @var NoBudgetRepositoryInterface $nbRepository */
$nbRepository = app(NoBudgetRepositoryInterface::class);
$budgets = $repository->getBudgets();
$periods = app('navigation')->listOfPeriods($start, $end);
$keyFormat = app('navigation')->preferredCarbonFormat($start, $end);
$periods = app('navigation')->listOfPeriods($start, $end);
$keyFormat = app('navigation')->preferredCarbonFormat($start, $end);
// list expenses for budgets in account(s)
$expenses = $opsRepository->listExpenses($start, $end, $accounts);
$report = [];
$report = [];
foreach ($expenses as $currency) {
foreach ($currency['budgets'] as $budget) {
foreach ($budget['transaction_journals'] as $journal) {
@ -136,7 +287,7 @@ class BudgetController extends Controller
];
$report[$key] ['entries'][$dateKey] = $report[$key] ['entries'][$dateKey] ?? '0';
$report[$key] ['entries'][$dateKey] = bcadd($journal['amount'], $report[$key] ['entries'][$dateKey]);
$report[$key] ['sum'] = bcadd($report[$key] ['sum'], $journal['amount']);
$report[$key] ['sum'] = bcadd($report[$key] ['sum'], $journal['amount']);
}
}
}

View File

@ -248,8 +248,9 @@ class OperationsRepository implements OperationsRepositoryInterface
$array[$currencyId]['budgets'][$budgetId]['transaction_journals'][$journalId] = [
'amount' => app('steam')->negative($journal['amount']),
'date' => $journal['date'],
'amount' => app('steam')->negative($journal['amount']),
'source_account_id' => $journal['source_account_id'],
'date' => $journal['date'],
];
}

View File

@ -24,6 +24,11 @@ $(function () {
"use strict";
drawChart();
loadAjaxPartial('accountsHolder', accountsUri);
loadAjaxPartial('budgetsHolder', budgetsUri);
loadAjaxPartial('accountPerbudgetHolder', accountPerBudgetUri);
$('#budgets-out-pie-chart-checked').on('change', function () {
redrawPieChart('budgets-out-pie-chart', budgetExpenseUri);
});

View File

@ -887,6 +887,7 @@ return [
'cannot_edit_other_fields' => 'You cannot mass-edit other fields than the ones here, because there is no room to show them. Please follow the link and edit them by one-by-one, if you need to edit these fields.',
'cannot_change_amount_reconciled' => 'You can\'t change the amount of reconciled transactions.',
'no_budget' => '(no budget)',
'account_per_budget' => 'Account per budget',
'no_budget_squared' => '(no budget)',
'perm-delete-many' => 'Deleting many items in one go can be very disruptive. Please be cautious. You can delete part of a split transaction from this page, so take care.',
'mass_deleted_transactions_success' => 'Deleted :amount transaction(s).',
@ -1434,7 +1435,7 @@ return [
'box_balance_in_currency' => 'Balance (:currency)',
'box_spent_in_currency' => 'Spent (:currency)',
'box_earned_in_currency' => 'Earned (:currency)',
'box_budgeted_in_currency' => 'Budgeted (:currency)',
'box_budgeted_in_currency' => 'Budgeted (:currency)',
'box_sum_in_currency' => 'Sum (:currency)',
'box_bill_paid_in_currency' => 'Bills paid (:currency)',
'box_bill_unpaid_in_currency' => 'Bills unpaid (:currency)',

View File

@ -7,83 +7,50 @@
{% block content %}
<div class="row">
<div class="col-lg-4 col-md-6">
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
{# spent in these budgets per account, per currency.#}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'accounts'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover sortable">
<thead>
<tr>
<th data-defaultsign="az">{{ 'name'|_ }}</th>
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent'|_ }}</th>
</tr>
</thead>
<tbody>
{% set sum = 0 %}
{% for account in accounts %}
<tr>
<td data-value="{{ account.name }}">
<a href="{{ route('accounts.show', account.id) }}" title="{{ account.name }}">{{ account.name }}</a>
</td>
{% if accountSummary[account.id] %}
{% set sum = sum + accountSummary[account.id] %}
<td data-value="{{ accountSummary[account.id] }}"
style="text-align: right;">{{ accountSummary[account.id]|formatAmount }}</td>
{% else %}
<td data-value="0" style="text-align: right;">{{ 0|formatAmount }}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td>{{ 'sum'|_ }}</td>
<td style="text-align: right;">{{ sum|formatAmount }}</td>
</tr>
</tfoot>
</table>
<div class="box-body table-responsive no-padding" id="accountsHolder">
</div>
{# loading indicator #}
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'budgets'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover sortable">
<thead>
<tr>
<th data-defaultsign="az">{{ 'name'|_ }}</th>
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent'|_ }}</th>
</tr>
</thead>
<tbody>
{% for budget in budgets %}
<tr>
<td data-value="{{ budget.name }}">
<a href="{{ route('budgets.show', budget.id) }}" title="{{ budget.name }}">{{ budget.name }}</a>
</td>
{% if budgetSummary[budget.id] %}
<td data-value="{{ budgetSummary[budget.id] }}" style="text-align: right;">{{ budgetSummary[budget.id]|formatAmount }}</td>
{% else %}
<td data-value="0" style="text-align: right;">{{ 0|formatAmount }}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td>{{ 'sum'|_ }}</td>
<td style="text-align: right;">{{ budgetSummary.sum|formatAmount }}</td>
</tr>
</tfoot>
</table>
<div class="box-body table-responsive no-padding" id="budgetsHolder">
</div>
{# loading indicator #}
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'account_per_budget'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding" id="accountPerbudgetHolder">
</div>
{# loading indicator #}
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
</div>
</div>
</div>
</div>
<div class="row">
{% if budgets.count > 1 %}
<div class="col-lg-4 col-md-6">
<div class="box">
@ -145,6 +112,12 @@
<h3 class="box-title">{{ 'average_spending_per_account'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
</div>
{# loading indicator #}
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
</div>
{#
<table class="table table-hover sortable">
<thead>
<tr>
@ -198,6 +171,7 @@
</tfoot>
</table>
</div>
#}
</div>
</div>
{% endif %}
@ -208,7 +182,14 @@
<div class="box-header with-border">
<h3 class="box-title">{{ 'expenses'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})</h3>
</div>
<div class="box-body">
<div class="box-body table-responsive no-padding">
</div>
{# loading indicator #}
<div class="overlay">
<i class="fa fa-refresh fa-spin"></i>
</div>
{#
<table class="table table-hover sortable">
<thead>
<tr>
@ -249,7 +230,7 @@
</td>
<td data-value="{{ row.amount}}" style="text-align: right;">
<td data-value="{{ row.amount }}" style="text-align: right;">
{{ formatAmountBySymbol(row.amount, row.currency_symbol, row.currency_decimal_places) }}
</td>
@ -273,6 +254,7 @@
</tfoot>
</table>
</div>
#}
</div>
</div>
{% endif %}
@ -293,6 +275,11 @@
var accountIds = '{{ accountIds }}';
var budgetIds = '{{ budgetIds }}';
// html block URI's:
var accountsUri = '{{ route('report-data.budget.accounts', [accountIds, budgetIds, start.format('Ymd'), end.format('Ymd')]) }}';
var budgetsUri = '{{ route('report-data.budget.budgets', [accountIds, budgetIds, start.format('Ymd'), end.format('Ymd')]) }}';
var accountPerBudgetUri = '{{ route('report-data.budget.account-per-budget', [accountIds, budgetIds, start.format('Ymd'), end.format('Ymd')]) }}';
// chart uri's
var budgetExpenseUri = '{{ route('chart.budget.budget-expense', [accountIds, budgetIds, start.format('Ymd'), end.format('Ymd'),'OTHERS']) }}';
var accountExpenseUri = '{{ route('chart.budget.account-expense', [accountIds, budgetIds, start.format('Ymd'), end.format('Ymd'),'OTHERS']) }}';

View File

@ -0,0 +1,30 @@
<table class="table table-hover sortable">
<thead>
<tr>
<th data-defaultsign="az">{{ 'name'|_ }}</th>
{% for budget in budgets %}
<th data-defaultsign="_19" style="text-align: right;">{{ budget.name }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for account in report %}
{% for currency in account.currencies %}
<tr>
<td data-value="{{ account.name }} ({{ currency.currency_name }})">
<a href="{{ route('accounts.show', account.id) }}" title="{{ account.iban }}">{{ account.name }} ({{ currency.currency_name }})</a>
</td>
{% for budget in budgets %}
<td style="text-align: right;">
{% if currency.budgets[budget.id] %}
{{ formatAmountBySymbol(currency.budgets[budget.id], currency.currency_symbol, currency.currency_decimal_places) }}
{% else %}
&mdash;
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>

View File

@ -0,0 +1,32 @@
<table class="table table-hover sortable">
<thead>
<tr>
<th data-defaultsign="az">{{ 'name'|_ }}</th>
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent'|_ }}</th>
</tr>
</thead>
<tbody>
{% for account in report %}
{% for currency in account.currencies %}
<tr>
<td data-value="{{ account.name }} ({{ currency.currency_name }})">
<a href="{{ route('accounts.show', account.id) }}" title="{{ account.iban }}">{{ account.name }} ({{ currency.currency_name }})</a>
</td>
<td data-value="{{ currency.sum }}" style="text-align: right;">
{{ formatAmountBySymbol(currency.sum, currency.currency_symbol, currency.currency_decimal_places) }}
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
<tfoot>
{% for sum in sums %}
<tr>
<td>{{ 'sum'|_ }} ({{ sum.currency_name }})</td>
<td style="text-align: right;">
{{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }}
</td>
</tr>
{% endfor %}
</tfoot>
</table>

View File

@ -0,0 +1,40 @@
<table class="table table-hover sortable">
<thead>
<tr>
<th data-defaultsign="az">{{ 'name'|_ }}</th>
<th data-defaultsign="_19" style="text-align: right;">{{ 'spent'|_ }}</th>
</tr>
</thead>
<tbody>
{% for budget in report %}
{% if budget.currencies|length == 0 %}
<tr>
<td data-value="{{ budget.name }}">
<a href="{{ route('budgets.show', budget.id) }}" title="{{ budget.name }}">{{ budget.name }}</a>
</td>
<td style="text-align: right;">&mdash;</td>
</tr>
{% endif %}
{% for currency in budget.currencies %}
<tr>
<td data-value="{{ budget.name }} ({{ currency.currency_name }})">
<a href="{{ route('budgets.show', budget.id) }}" title="{{ budget.name }}">{{ budget.name }} ({{ currency.currency_name }})</a>
</td>
<td data-value="{{ currency.sym }}" style="text-align: right;">
{{ formatAmountBySymbol(currency.sum, currency.currency_symbol, currency.currency_decimal_places) }}
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
<tfoot>
{% for sum in sums %}
<tr>
<td>{{ 'sum'|_ }} ({{ sum.currency_name }})</td>
<td style="text-align: right;">
{{ formatAmountBySymbol(sum.sum, sum.currency_symbol, sum.currency_decimal_places) }}
</td>
</tr>
{% endfor %}
</tfoot>
</table>

View File

@ -23,7 +23,7 @@ declare(strict_types=1);
Route::group(
['namespace' => 'FireflyIII\Http\Controllers\System',
'as' => 'installer.', 'prefix' => 'install'], function () {
'as' => 'installer.', 'prefix' => 'install'], static function () {
Route::get('', ['uses' => 'InstallController@index', 'as' => 'index']);
Route::post('runCommand', ['uses' => 'InstallController@runCommand', 'as' => 'runCommand']);
}
@ -67,7 +67,7 @@ Route::group(
* For some other routes, it is only relevant that the user is authenticated.
*/
Route::group(
['middleware' => 'user-simple-auth', 'namespace' => 'FireflyIII\Http\Controllers'], function () {
['middleware' => 'user-simple-auth', 'namespace' => 'FireflyIII\Http\Controllers'], static function () {
Route::get('error', ['uses' => 'DebugController@displayError', 'as' => 'error']);
Route::any('logout', ['uses' => 'Auth\LoginController@logout', 'as' => 'logout']);
Route::get('flush', ['uses' => 'DebugController@flush', 'as' => 'flush']);
@ -82,7 +82,7 @@ Route::group(
// *
// */
Route::group(
['middleware' => 'user-logged-in-no-2fa', 'prefix' => 'two-factor', 'as' => 'two-factor.', 'namespace' => 'FireflyIII\Http\Controllers\Auth'], function () {
['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']);
@ -98,7 +98,7 @@ Route::group(
* Home Controller
*/
Route::group(
['middleware' => ['user-full-auth'], 'namespace' => 'FireflyIII\Http\Controllers'], function () {
['middleware' => ['user-full-auth'], 'namespace' => 'FireflyIII\Http\Controllers'], static function () {
Route::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);
Route::get('/flash', ['uses' => 'DebugController@testFlash', 'as' => 'test-flash']);
Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']);
@ -111,7 +111,7 @@ Route::group(
* Account Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'accounts', 'as' => 'accounts.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'accounts', 'as' => 'accounts.'], static function () {
// show:
Route::get('{objectType}', ['uses' => 'Account\IndexController@index', 'as' => 'index'])->where('objectType', 'revenue|asset|expense|liabilities');
@ -159,7 +159,7 @@ Route::group(
* Attachment Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'attachments', 'as' => 'attachments.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'attachments', 'as' => 'attachments.'], static function () {
Route::get('', ['uses' => 'AttachmentController@index', 'as' => 'index']);
Route::get('edit/{attachment}', ['uses' => 'AttachmentController@edit', 'as' => 'edit']);
Route::get('delete/{attachment}', ['uses' => 'AttachmentController@delete', 'as' => 'delete']);
@ -176,7 +176,7 @@ Route::group(
* Bills Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'bills', 'as' => 'bills.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'bills', 'as' => 'bills.'], static function () {
Route::get('', ['uses' => 'BillController@index', 'as' => 'index']);
Route::get('rescan/{bill}', ['uses' => 'BillController@rescan', 'as' => 'rescan']);
Route::get('create', ['uses' => 'BillController@create', 'as' => 'create']);
@ -195,7 +195,7 @@ Route::group(
* Budget Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'budgets', 'as' => 'budgets.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'budgets', 'as' => 'budgets.'], static function () {
// delete
Route::get('delete/{budget}', ['uses' => 'Budget\DeleteController@delete', 'as' => 'delete']);
@ -267,7 +267,7 @@ Route::group(
* Category Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'categories', 'as' => 'categories.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'categories', 'as' => 'categories.'], static function () {
// index:
Route::get('', ['uses' => 'Category\IndexController@index', 'as' => 'index']);
@ -300,7 +300,7 @@ Route::group(
* Currency Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'currencies', 'as' => 'currencies.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'currencies', 'as' => 'currencies.'], static function () {
Route::get('', ['uses' => 'CurrencyController@index', 'as' => 'index']);
Route::get('create', ['uses' => 'CurrencyController@create', 'as' => 'create']);
Route::get('edit/{currency}', ['uses' => 'CurrencyController@edit', 'as' => 'edit']);
@ -320,7 +320,7 @@ Route::group(
* Chart\Account Controller (default report)
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/account', 'as' => 'chart.account.'], function () {
['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']);
@ -342,7 +342,7 @@ Route::group(
* Chart\Bill Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/bill', 'as' => 'chart.bill.'], function () {
['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']);
@ -353,7 +353,7 @@ Route::group(
* Chart\Budget Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/budget', 'as' => 'chart.budget.'], 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']);
@ -429,7 +429,7 @@ Route::group(
* Chart\Tag Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/tag', 'as' => 'chart.tag.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/tag', 'as' => 'chart.tag.'], static function () {
// these charts are used in reports (tag reports):
Route::get(
@ -473,7 +473,7 @@ 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.'], function () {
['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']
@ -496,7 +496,7 @@ Route::group(
* Chart\Report Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Chart', 'prefix' => 'chart/report', 'as' => 'chart.report.'], function () {
['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']);
@ -507,7 +507,7 @@ Route::group(
* Import Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'import', 'as' => 'import.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'import', 'as' => 'import.'], static function () {
// index
Route::get('', ['uses' => 'Import\IndexController@index', 'as' => 'index']);
@ -543,7 +543,7 @@ Route::group(
* Help Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'help', 'as' => 'help.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'help', 'as' => 'help.'], static function () {
Route::get('{route}', ['uses' => 'HelpController@show', 'as' => 'show']);
}
@ -553,7 +553,7 @@ Route::group(
* Budget Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'v1/jscript', 'as' => 'javascript.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'v1/jscript', 'as' => 'javascript.'], static function () {
Route::get('variables', ['uses' => 'JavascriptController@variables', 'as' => 'variables']);
Route::get('accounts', ['uses' => 'JavascriptController@accounts', 'as' => 'accounts']);
Route::get('currencies', ['uses' => 'JavascriptController@currencies', 'as' => 'currencies']);
@ -564,7 +564,7 @@ Route::group(
* JSON Controller(s)
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'json', 'as' => 'json.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'json', 'as' => 'json.'], static function () {
// for auto complete
Route::get('accounts', ['uses' => 'Json\AutoCompleteController@accounts', 'as' => 'autocomplete.accounts']);
@ -611,7 +611,7 @@ Route::group(
* NewUser Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'new-user', 'as' => 'new-user.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'new-user', 'as' => 'new-user.'], static function () {
Route::get('', ['uses' => 'NewUserController@index', 'as' => 'index']);
Route::post('submit', ['uses' => 'NewUserController@submit', 'as' => 'submit']);
}
@ -621,7 +621,7 @@ Route::group(
* Piggy Bank Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'piggy-banks', 'as' => 'piggy-banks.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'piggy-banks', 'as' => 'piggy-banks.'], static function () {
Route::get('', ['uses' => 'PiggyBankController@index', 'as' => 'index']);
Route::get('add/{piggyBank}', ['uses' => 'PiggyBankController@add', 'as' => 'add-money']);
Route::get('remove/{piggyBank}', ['uses' => 'PiggyBankController@remove', 'as' => 'remove-money']);
@ -648,7 +648,7 @@ Route::group(
* Preferences Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'preferences', 'as' => 'preferences.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'preferences', 'as' => 'preferences.'], static function () {
Route::get('', ['uses' => 'PreferencesController@index', 'as' => 'index']);
Route::post('', ['uses' => 'PreferencesController@postIndex', 'as' => 'update']);
@ -660,7 +660,7 @@ Route::group(
* Profile Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'profile', 'as' => 'profile.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'profile', 'as' => 'profile.'], static function () {
Route::get('', ['uses' => 'ProfileController@index', 'as' => 'index']);
Route::get('change-email', ['uses' => 'ProfileController@changeEmail', 'as' => 'change-email']);
@ -686,7 +686,7 @@ Route::group(
* Recurring Transactions Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'recurring', 'as' => 'recurring.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'recurring', 'as' => 'recurring.'], static function () {
Route::get('', ['uses' => 'Recurring\IndexController@index', 'as' => 'index']);
@ -709,7 +709,7 @@ Route::group(
* Report Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'reports', 'as' => 'reports.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'reports', 'as' => 'reports.'], static function () {
Route::get('', ['uses' => 'ReportController@index', 'as' => 'index']);
Route::get('options/{reportType}', ['uses' => 'ReportController@options', 'as' => 'options']);
@ -770,7 +770,7 @@ Route::group(
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Report', 'prefix' => 'report-data/operations',
'as' => 'report-data.operations.'], function () {
'as' => 'report-data.operations.'], static function () {
Route::get('operations/{accountList}/{start_date}/{end_date}', ['uses' => 'OperationsController@operations', 'as' => 'operations']);
Route::get('income/{accountList}/{start_date}/{end_date}', ['uses' => 'OperationsController@income', 'as' => 'income']);
Route::get('expenses/{accountList}/{start_date}/{end_date}', ['uses' => 'OperationsController@expenses', 'as' => 'expenses']);
@ -783,7 +783,7 @@ Route::group(
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Report', 'prefix' => 'report-data/category',
'as' => 'report-data.category.'], function () {
'as' => 'report-data.category.'], static function () {
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']);
@ -807,11 +807,15 @@ Route::group(
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Report', 'prefix' => 'report-data/budget', 'as' => 'report-data.budget.'],
function () {
static function () {
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']);
}
);
@ -819,7 +823,7 @@ Route::group(
* Rules Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'rules', 'as' => 'rules.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'rules', 'as' => 'rules.'], static function () {
// create controller
Route::get('create/{ruleGroup?}', ['uses' => 'Rule\CreateController@create', 'as' => 'create']);
@ -855,7 +859,7 @@ Route::group(
* Rule Groups Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'rule-groups', 'as' => 'rule-groups.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'rule-groups', 'as' => 'rule-groups.'], static function () {
Route::get('create', ['uses' => 'RuleGroup\CreateController@create', 'as' => 'create']);
Route::get('edit/{ruleGroup}', ['uses' => 'RuleGroup\EditController@edit', 'as' => 'edit']);
Route::get('delete/{ruleGroup}', ['uses' => 'RuleGroup\DeleteController@delete', 'as' => 'delete']);
@ -874,7 +878,7 @@ Route::group(
* Search Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'search', 'as' => 'search.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'search', 'as' => 'search.'], static function () {
Route::get('', ['uses' => 'SearchController@index', 'as' => 'index']);
Route::any('search', ['uses' => 'SearchController@search', 'as' => 'search']);
}
@ -885,7 +889,7 @@ Route::group(
* Tag Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'tags', 'as' => 'tags.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'tags', 'as' => 'tags.'], static function () {
Route::get('', ['uses' => 'TagController@index', 'as' => 'index']);
Route::get('create', ['uses' => 'TagController@create', 'as' => 'create']);
@ -906,7 +910,7 @@ Route::group(
* Transaction Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'transactions', 'as' => 'transactions.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers', 'prefix' => 'transactions', 'as' => 'transactions.'], static function () {
// show groups:
// TODO improve these routes
@ -993,7 +997,7 @@ Route::group(
*/
//Route::group(
// ['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Transaction', 'prefix' => 'transactions/split',
// 'as' => 'transactions.split.'], function () {
// 'as' => 'transactions.split.'], static function () {
// // TODO improve these routes
// Route::get('edit/{tj}', ['uses' => 'SplitController@edit', 'as' => 'edit']);
// Route::post('update/{tj}', ['uses' => 'SplitController@update', 'as' => 'update']);
@ -1035,7 +1039,7 @@ Route::group(
* Report Popup Controller
*/
Route::group(
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Popup', 'prefix' => 'popup', 'as' => 'popup.'], function () {
['middleware' => 'user-full-auth', 'namespace' => 'FireflyIII\Http\Controllers\Popup', 'prefix' => 'popup', 'as' => 'popup.'], static function () {
Route::get('general', ['uses' => 'ReportController@general', 'as' => 'general']);
}
@ -1045,7 +1049,7 @@ Route::group(
* For the admin routes, the user must be logged in and have the role of 'owner'
*/
Route::group(
['middleware' => 'admin', 'namespace' => 'FireflyIII\Http\Controllers\Admin', 'prefix' => 'admin', 'as' => 'admin.'], function () {
['middleware' => 'admin', 'namespace' => 'FireflyIII\Http\Controllers\Admin', 'prefix' => 'admin', 'as' => 'admin.'], static function () {
// admin home
Route::get('', ['uses' => 'HomeController@index', 'as' => 'index']);