Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Code for #384
James Cole4998eaeaf19a
diff --git a/app/Generator/Report/Account/MonthReportGenerator.php b/app/Generator/Report/Account/MonthReportGenerator.phpnew file mode 100644index 0000000000..9e0e54a504--- /dev/null+++ b/app/Generator/Report/Account/MonthReportGenerator.php@@ -0,0 +1,137 @@+<?php+/**+ * MonthReportGenerator.php+ * Copyright (c) 2017 [email protected]+ *+ * This file is part of Firefly III.+ *+ * Firefly III is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * Firefly III is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.+ */+declare(strict_types=1);++namespace FireflyIII\Generator\Report\Account;++use Carbon\Carbon;+use FireflyIII\Generator\Report\ReportGeneratorInterface;+use Illuminate\Support\Collection;++/**+ * Class MonthReportGenerator.+ */+class MonthReportGenerator implements ReportGeneratorInterface+{++ /** @var Collection */+ private $accounts;+ /** @var Carbon */+ private $end;+ /** @var Collection */+ private $expense;+ /** @var Carbon */+ private $start;++ /**+ * @return string+ * @throws \Throwable+ */+ public function generate(): string+ {+ $accountIds = join(',', $this->accounts->pluck('id')->toArray());+ $expenseIds = join(',', $this->expense->pluck('id')->toArray());+ $reportType = 'account';++ return view(+ 'reports.account.report',+ compact('accountIds', 'reportType','expenseIds')+ )->with('start', $this->start)->with('end', $this->end)->render();+ }++ /**+ * @param Collection $accounts+ *+ * @return ReportGeneratorInterface+ */+ public function setAccounts(Collection $accounts): ReportGeneratorInterface+ {+ $this->accounts = $accounts;++ return $this;+ }++ /**+ * @param Collection $budgets+ *+ * @return ReportGeneratorInterface+ */+ public function setBudgets(Collection $budgets): ReportGeneratorInterface+ {+ return $this;+ }++ /**+ * @param Collection $categories+ *+ * @return ReportGeneratorInterface+ */+ public function setCategories(Collection $categories): ReportGeneratorInterface+ {+ return $this;+ }++ /**+ * @param Carbon $date+ *+ * @return ReportGeneratorInterface+ */+ public function setEndDate(Carbon $date): ReportGeneratorInterface+ {+ $this->end = $date;++ return $this;+ }++ /**+ * @param Collection $expense+ *+ * @return ReportGeneratorInterface+ */+ public function setExpense(Collection $expense): ReportGeneratorInterface+ {+ $this->expense = $expense;++ return $this;+ }++ /**+ * @param Carbon $date+ *+ * @return ReportGeneratorInterface+ */+ public function setStartDate(Carbon $date): ReportGeneratorInterface+ {+ $this->start = $date;++ return $this;+ }++ /**+ * @param Collection $tags+ *+ * @return ReportGeneratorInterface+ */+ public function setTags(Collection $tags): ReportGeneratorInterface+ {+ return $this;+ }+}diff --git a/app/Generator/Report/Account/MultiYearReportGenerator.php b/app/Generator/Report/Account/MultiYearReportGenerator.phpnew file mode 100644index 0000000000..cd88b4ea75--- /dev/null+++ b/app/Generator/Report/Account/MultiYearReportGenerator.php@@ -0,0 +1,31 @@+<?php+/**+ * MultiYearReportGenerator.php+ * Copyright (c) 2017 [email protected]+ *+ * This file is part of Firefly III.+ *+ * Firefly III is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * Firefly III is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.+ */+declare(strict_types=1);++namespace FireflyIII\Generator\Report\Account;++/**+ * Class MultiYearReportGenerator.+ */+class MultiYearReportGenerator extends MonthReportGenerator+{+ // Doesn't do anything different.+}diff --git a/app/Generator/Report/Account/YearReportGenerator.php b/app/Generator/Report/Account/YearReportGenerator.phpnew file mode 100644index 0000000000..3debf38d0c--- /dev/null+++ b/app/Generator/Report/Account/YearReportGenerator.php@@ -0,0 +1,31 @@+<?php+/**+ * YearReportGenerator.php+ * Copyright (c) 2017 [email protected]+ *+ * This file is part of Firefly III.+ *+ * Firefly III is free software: you can redistribute it and/or modify+ * it under the terms of the GNU General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * Firefly III is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU General Public License for more details.+ *+ * You should have received a copy of the GNU General Public License+ * along with Firefly III. If not, see <http://www.gnu.org/licenses/>.+ */+declare(strict_types=1);++namespace FireflyIII\Generator\Report\Account;++/**+ * Class YearReportGenerator.+ */+class YearReportGenerator extends MonthReportGenerator+{+ // Doesn't do anything different.+}diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.phpindex f944874ea4..8d44f252b7 100644--- a/app/Generator/Report/Audit/MonthReportGenerator.php+++ b/app/Generator/Report/Audit/MonthReportGenerator.php@@ -119,6 +119,16 @@ class MonthReportGenerator implements ReportGeneratorInterfacereturn $this;}+ /**+ * @param Collection $expense+ *+ * @return ReportGeneratorInterface+ */+ public function setExpense(Collection $expense): ReportGeneratorInterface+ {+ return $this;+ }+/*** @param Carbon $date*diff --git a/app/Generator/Report/Budget/MonthReportGenerator.php b/app/Generator/Report/Budget/MonthReportGenerator.phpindex 1295061e6b..0c9bfa7c51 100644--- a/app/Generator/Report/Budget/MonthReportGenerator.php+++ b/app/Generator/Report/Budget/MonthReportGenerator.php@@ -128,6 +128,16 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterfacereturn $this;}+ /**+ * @param Collection $expense+ *+ * @return ReportGeneratorInterface+ */+ public function setExpense(Collection $expense): ReportGeneratorInterface+ {+ return $this;+ }+/*** @param Carbon $date*diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.phpindex 24370c6be0..ee9f045f51 100644--- a/app/Generator/Report/Category/MonthReportGenerator.php+++ b/app/Generator/Report/Category/MonthReportGenerator.php@@ -146,6 +146,16 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterfacereturn $this;}+ /**+ * @param Collection $expense+ *+ * @return ReportGeneratorInterface+ */+ public function setExpense(Collection $expense): ReportGeneratorInterface+ {+ return $this;+ }+/*** @param Carbon $date*diff --git a/app/Generator/Report/ReportGeneratorInterface.php b/app/Generator/Report/ReportGeneratorInterface.phpindex c3752b2739..15ed0d9d81 100644--- a/app/Generator/Report/ReportGeneratorInterface.php+++ b/app/Generator/Report/ReportGeneratorInterface.php@@ -63,6 +63,13 @@ interface ReportGeneratorInterface*/public function setEndDate(Carbon $date): ReportGeneratorInterface;+ /**+ * @param Collection $expense+ *+ * @return ReportGeneratorInterface+ */+ public function setExpense(Collection $expense): ReportGeneratorInterface;+/*** @param Carbon $date*diff --git a/app/Generator/Report/Standard/MonthReportGenerator.php b/app/Generator/Report/Standard/MonthReportGenerator.phpindex 74c005b0ab..6e41f462e8 100644--- a/app/Generator/Report/Standard/MonthReportGenerator.php+++ b/app/Generator/Report/Standard/MonthReportGenerator.php@@ -101,6 +101,16 @@ class MonthReportGenerator implements ReportGeneratorInterfacereturn $this;}+ /**+ * @param Collection $expense+ *+ * @return ReportGeneratorInterface+ */+ public function setExpense(Collection $expense): ReportGeneratorInterface+ {+ return $this;+ }+/*** @param Carbon $date*diff --git a/app/Generator/Report/Tag/MonthReportGenerator.php b/app/Generator/Report/Tag/MonthReportGenerator.phpindex 418b05dd16..4873e1b5fe 100644--- a/app/Generator/Report/Tag/MonthReportGenerator.php+++ b/app/Generator/Report/Tag/MonthReportGenerator.php@@ -141,6 +141,16 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterfacereturn $this;}+ /**+ * @param Collection $expense+ *+ * @return ReportGeneratorInterface+ */+ public function setExpense(Collection $expense): ReportGeneratorInterface+ {+ return $this;+ }+/*** @param Carbon $date*diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.phpindex 9a6d131f8b..c1d7be7e41 100644--- a/app/Http/Controllers/ReportController.php+++ b/app/Http/Controllers/ReportController.php@@ -74,6 +74,39 @@ class ReportController extends Controller* @param Carbon $end** @return string+ * @throws \FireflyIII\Exceptions\FireflyException+ */+ public function accountReport(Collection $accounts, Collection $expense, Carbon $start, Carbon $end)+ {+ if ($end < $start) {+ return view('error')->with('message', trans('firefly.end_after_start_date'));+ }++ if ($start < session('first')) {+ $start = session('first');+ }++ View::share(+ 'subTitle', trans(+ 'firefly.report_default', ['start' => $start->formatLocalized($this->monthFormat), 'end' => $end->formatLocalized($this->monthFormat),]+ )+ );++ $generator = ReportGeneratorFactory::reportGenerator('Account', $start, $end);+ $generator->setAccounts($accounts);+ $generator->setExpense($expense);+ $result = $generator->generate();++ return $result;+ }++ /**+ * @param Collection $accounts+ * @param Carbon $start+ * @param Carbon $end+ *+ * @return string+ * @throws \FireflyIII\Exceptions\FireflyException*/public function auditReport(Collection $accounts, Carbon $start, Carbon $end){@@ -109,6 +142,7 @@ class ReportController extends Controller* @param Carbon $end** @return string+ * @throws \FireflyIII\Exceptions\FireflyException*/public function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end){@@ -145,6 +179,7 @@ class ReportController extends Controller* @param Carbon $end** @return string+ * @throws \FireflyIII\Exceptions\FireflyException*/public function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end){@@ -180,6 +215,7 @@ class ReportController extends Controller* @param Carbon $end** @return string+ * @throws \FireflyIII\Exceptions\FireflyException*/public function defaultReport(Collection $accounts, Carbon $start, Carbon $end){@@ -230,6 +266,7 @@ class ReportController extends Controller* @param string $reportType** @return mixed+ * @throws \Throwable*/public function options(string $reportType){@@ -246,6 +283,9 @@ class ReportController extends Controllercase 'tag':$result = $this->tagReportOptions();break;+ case 'account':+ $result = $this->accountReportOptions();+ break;}return Response::json(['html' => $result]);@@ -255,6 +295,7 @@ class ReportController extends Controller* @param ReportFormRequest $request** @return RedirectResponse|\Illuminate\Routing\Redirector+ * @throws \FireflyIII\Exceptions\FireflyException* @SuppressWarnings(PHPMD.CyclomaticComplexity)*/public function postIndex(ReportFormRequest $request)@@ -267,6 +308,7 @@ class ReportController extends Controller$categories = join(',', $request->getCategoryList()->pluck('id')->toArray());$budgets = join(',', $request->getBudgetList()->pluck('id')->toArray());$tags = join(',', $request->getTagList()->pluck('tag')->toArray());+ $expense = join(',', $request->getExpenseList()->pluck('id')->toArray());$uri = route('reports.index');if (0 === $request->getAccountList()->count()) {@@ -314,6 +356,9 @@ class ReportController extends Controllercase 'tag':$uri = route('reports.report.tag', [$accounts, $tags, $start, $end]);break;+ case 'account':+ $uri = route('reports.report.account', [$accounts, $expense, $start, $end]);+ break;}return redirect($uri);@@ -326,6 +371,7 @@ class ReportController extends Controller* @param Carbon $end** @return string+ * @throws \FireflyIII\Exceptions\FireflyException*/public function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end){@@ -357,6 +403,30 @@ class ReportController extends Controller/*** @return string+ * @throws \Throwable+ */+ private function accountReportOptions(): string+ {+ /** @var AccountRepositoryInterface $repository */+ $repository = app(AccountRepositoryInterface::class);+ $expense = $repository->getActiveAccountsByType([AccountType::EXPENSE]);+ $revenue = $repository->getActiveAccountsByType([AccountType::REVENUE]);+ $set = new Collection;+ $names = $revenue->pluck('name')->toArray();+ foreach ($expense as $exp) {+ if (in_array($exp->name, $names)) {+ $set->push($exp);+ }+ }++ $result = view('reports.options.account', compact('set'))->render();++ return $result;+ }++ /**+ * @return string+ * @throws \Throwable*/private function budgetReportOptions(): string{@@ -370,6 +440,7 @@ class ReportController extends Controller/*** @return string+ * @throws \Throwable*/private function categoryReportOptions(): string{@@ -383,6 +454,7 @@ class ReportController extends Controller/*** @return string+ * @throws \Throwable*/private function noReportOptions(): string{@@ -391,6 +463,7 @@ class ReportController extends Controller/*** @return string+ * @throws \Throwable*/private function tagReportOptions(): string{diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.phpindex 40eee6037b..187cf09f6d 100644--- a/app/Http/Requests/ReportFormRequest.php+++ b/app/Http/Requests/ReportFormRequest.php@@ -45,6 +45,28 @@ class ReportFormRequest extends Requestreturn auth()->check();}+ /**+ * @return Collection+ */+ public function getExpenseList(): Collection+ {+ // fixed+ /** @var AccountRepositoryInterface $repository */+ $repository = app(AccountRepositoryInterface::class);+ $set = $this->get('exp_rev');+ $collection = new Collection;+ if (is_array($set)) {+ foreach ($set as $accountId) {+ $account = $repository->find(intval($accountId));+ if (null !== $account->id) {+ $collection->push($account);+ }+ }+ }++ return $collection;+ }+/*** @return Collection*/@@ -178,7 +200,7 @@ class ReportFormRequest extends Requestpublic function rules(): array{return [- 'report_type' => 'in:audit,default,category,budget,tag',+ 'report_type' => 'in:audit,default,category,budget,tag,account',];}}diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.phpindex 424c2857cf..af7c54da60 100644--- a/app/Http/breadcrumbs.php+++ b/app/Http/breadcrumbs.php@@ -676,6 +676,20 @@ Breadcrumbs::register(});+Breadcrumbs::register(+ 'reports.report.account',+ function (BreadCrumbGenerator $breadcrumbs, string $accountIds, string $expenseIds, Carbon $start, Carbon $end) {+ $breadcrumbs->parent('reports.index');++ $monthFormat = (string)trans('config.month_and_day');+ $startString = $start->formatLocalized($monthFormat);+ $endString = $end->formatLocalized($monthFormat);+ $title = (string)trans('firefly.report_account', ['start' => $startString, 'end' => $endString]);++ $breadcrumbs->push($title, route('reports.report.account', [$accountIds, $expenseIds, $start->format('Ymd'), $end->format('Ymd')]));+ }+);+Breadcrumbs::register('reports.report.default',function (BreadCrumbGenerator $breadcrumbs, string $accountIds, Carbon $start, Carbon $end) {diff --git a/config/firefly.php b/config/firefly.phpindex 744d82cfc3..025619c595 100644--- a/config/firefly.php+++ b/config/firefly.php@@ -180,6 +180,7 @@ return ['jobKey' => 'FireflyIII\Models\ExportJob','importJob' => 'FireflyIII\Models\ImportJob','accountList' => 'FireflyIII\Support\Binder\AccountList',+ 'expenseList' => 'FireflyIII\Support\Binder\AccountList','budgetList' => 'FireflyIII\Support\Binder\BudgetList','journalList' => 'FireflyIII\Support\Binder\JournalList','categoryList' => 'FireflyIII\Support\Binder\CategoryList',diff --git a/public/js/ff/reports/index.js b/public/js/ff/reports/index.jsindex b95531e0df..d15de74232 100644--- a/public/js/ff/reports/index.js+++ b/public/js/ff/reports/index.js@@ -124,10 +124,22 @@ function setOptionalFromCookies() {if ((readCookie('report-tags') !== null)) {arr = readCookie('report-tags').split(',');arr.forEach(function (val) {- $('#inputBudgets').find('option[value="' + val + '"]').prop('selected', true);+ $('#inputTags').find('option[value="' + val + '"]').prop('selected', true);});}$('#inputTags').multiselect(defaultMultiSelect);++ // and expense/revenue thing+ if ((readCookie('report-exp-rev') !== null)) {+ arr = readCookie('report-exp-rev').split(',');+ arr.forEach(function (val) {+ $('#inputExpRevAccounts').find('option[value="' + val + '"]').prop('selected', true);+ });+ }+ $('#inputExpRevAccounts').multiselect(defaultMultiSelect);+++}function catchSubmit() {@@ -140,6 +152,7 @@ function catchSubmit() {var categories = $('#inputCategories').val();var budgets = $('#inputBudgets').val();var tags = $('#inputTags').val();+ var expRev = $('#inputExpRevAccounts').val();// remember all// set cookie to remember choices.@@ -148,6 +161,7 @@ function catchSubmit() {createCookie('report-categories', categories, 365);createCookie('report-budgets', budgets, 365);createCookie('report-tags', tags, 365);+ createCookie('report-exp-rev', expRev , 365);createCookie('report-start', moment(picker.startDate).format("YYYYMMDD"), 365);createCookie('report-end', moment(picker.endDate).format("YYYYMMDD"), 365);diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.phpindex 6ac6cdf35c..78058c3f35 100644--- a/resources/lang/en_US/firefly.php+++ b/resources/lang/en_US/firefly.php@@ -786,6 +786,7 @@ return ['report_default' => 'Default financial report between :start and :end','report_audit' => 'Transaction history overview between :start and :end','report_category' => 'Category report between :start and :end',+ 'report_account' => 'Expense/revenue account report between :start and :end','report_budget' => 'Budget report between :start and :end','report_tag' => 'Tag report between :start and :end','quick_link_reports' => 'Quick links',@@ -821,6 +822,7 @@ return ['report_type_category' => 'Category report','report_type_budget' => 'Budget report','report_type_tag' => 'Tag report',+ 'report_type_account' => 'Combined account report','more_info_help' => 'More information about these types of reports can be found in the help pages. Press the (?) icon in the top right corner.','report_included_accounts' => 'Included accounts','report_date_range' => 'Date range',@@ -873,49 +875,52 @@ return ['budget_chart_click' => 'Please click on a budget name in the table above to see a chart.','category_chart_click' => 'Please click on a category name in the table above to see a chart.',+ 'in_out_accounts' => 'Earned and spent per combined account',+ 'in_out_accounts_period' => 'Earned and spent, grouped by :period',+ 'in_out_per_category' => 'Earned and spent per category',+ 'out_per_budget' => 'Spent per budget',// charts:- 'chart' => 'Chart',- 'month' => 'Month',- 'budget' => 'Budget',- 'spent' => 'Spent',- 'spent_in_budget' => 'Spent in budget',- 'left_to_spend' => 'Left to spend',- 'earned' => 'Earned',- 'overspent' => 'Overspent',- 'left' => 'Left',- 'no_budget' => '(no budget)',- 'max-amount' => 'Maximum amount',- 'min-amount' => 'Minumum amount',- 'journal-amount' => 'Current bill entry',- 'name' => 'Name',- 'date' => 'Date',- 'paid' => 'Paid',- 'unpaid' => 'Unpaid',- 'day' => 'Day',- 'budgeted' => 'Budgeted',- 'period' => 'Period',- 'balance' => 'Balance',- 'sum' => 'Sum',- 'average' => 'Average',- 'balanceFor' => 'Balance for :name',+ 'chart' => 'Chart',+ 'month' => 'Month',+ 'budget' => 'Budget',+ 'spent' => 'Spent',+ 'spent_in_budget' => 'Spent in budget',+ 'left_to_spend' => 'Left to spend',+ 'earned' => 'Earned',+ 'overspent' => 'Overspent',+ 'left' => 'Left',+ 'max-amount' => 'Maximum amount',+ 'min-amount' => 'Minumum amount',+ 'journal-amount' => 'Current bill entry',+ 'name' => 'Name',+ 'date' => 'Date',+ 'paid' => 'Paid',+ 'unpaid' => 'Unpaid',+ 'day' => 'Day',+ 'budgeted' => 'Budgeted',+ 'period' => 'Period',+ 'balance' => 'Balance',+ 'sum' => 'Sum',+ 'average' => 'Average',+ 'balanceFor' => 'Balance for :name',// piggy banks:- 'add_money_to_piggy' => 'Add money to piggy bank ":name"',- 'piggy_bank' => 'Piggy bank',- 'new_piggy_bank' => 'New piggy bank',- 'store_piggy_bank' => 'Store new piggy bank',- 'stored_piggy_bank' => 'Store new piggy bank ":name"',- 'account_status' => 'Account status',- 'left_for_piggy_banks' => 'Left for piggy banks',- 'sum_of_piggy_banks' => 'Sum of piggy banks',- 'saved_so_far' => 'Saved so far',- 'left_to_save' => 'Left to save',- 'suggested_amount' => 'Suggested monthly amount to save',- 'add_money_to_piggy_title' => 'Add money to piggy bank ":name"',- 'remove_money_from_piggy_title' => 'Remove money from piggy bank ":name"',- 'add' => 'Add',- 'no_money_for_piggy' => 'You have no money to put in this piggy bank.',+ 'add_money_to_piggy' => 'Add money to piggy bank ":name"',+ 'piggy_bank' => 'Piggy bank',+ 'new_piggy_bank' => 'New piggy bank',+ 'store_piggy_bank' => 'Store new piggy bank',+ 'stored_piggy_bank' => 'Store new piggy bank ":name"',+ 'account_status' => 'Account status',+ 'left_for_piggy_banks' => 'Left for piggy banks',+ 'sum_of_piggy_banks' => 'Sum of piggy banks',+ 'saved_so_far' => 'Saved so far',+ 'left_to_save' => 'Left to save',+ 'suggested_amount' => 'Suggested monthly amount to save',+ 'add_money_to_piggy_title' => 'Add money to piggy bank ":name"',+ 'remove_money_from_piggy_title' => 'Remove money from piggy bank ":name"',+ 'add' => 'Add',+ 'no_money_for_piggy' => 'You have no money to put in this piggy bank.','remove' => 'Remove','max_amount_add' => 'The maximum amount you can add is',diff --git a/resources/views/reports/account/report.twig b/resources/views/reports/account/report.twignew file mode 100644index 0000000000..8aaea0a1bc--- /dev/null+++ b/resources/views/reports/account/report.twig@@ -0,0 +1,438 @@+{% extends "./layout/default" %}++{% block breadcrumbs %}+ {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, accountIds, expenseIds, start, end) }}+{% endblock %}++{% block content %}++ {# in/out + In/out per per periode #}+ <div class="row">+ <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">{{ 'in_out_accounts'|_ }}</h3>+ </div>+ <div class="box-body table-responsive no-padding" id="inOutAccounts">+ {# loading indicator #}+ <div class="overlay">+ <i class="fa fa-refresh fa-spin"></i>+ </div>+ </div>+ </div>+ </div>++ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12" id="inOutPeriod">+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'in_out_accounts_period'|_ }}</h3>+ </div>+ <div class="box-body table-responsive no-padding">+ {# loading indicator #}+ <div class="overlay">+ <i class="fa fa-refresh fa-spin"></i>+ </div>+ </div>+ </div>+ </div>+ </div>++ {# chart #}+ <div class="row">+ <div class="col-lg-12">+ <div class="box" id="incomeAndExpensesChart">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'income_and_expenses'|_ }}</h3>+ </div>+ <div class="box-body">+ <canvas id="in-out-chart" style="width:100%;height:400px;" height="400" width="100%"></canvas>+ </div>+ </div>+ </div>+ </div>++ {# in/out category + out per budget #}+ <div class="row">+ <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">{{ 'in_out_per_category'|_ }}</h3>+ </div>+ <div class="box-body table-responsive no-padding" id="inOutCategory">+ {# loading indicator #}+ <div class="overlay">+ <i class="fa fa-refresh fa-spin"></i>+ </div>+ </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">{{ 'out_per_budget'|_ }}</h3>+ </div>+ <div class="box-body table-responsive no-padding" id="inOutBudget">+ {# loading indicator #}+ <div class="overlay">+ <i class="fa fa-refresh fa-spin"></i>+ </div>+ </div>+ </div>+ </div>+ </div>++ {# expenses top 10 + income top 10 #}+ <div class="row">+ <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">{{ 'expenses'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})</h3>+ </div>+ <div class="box-body table-responsive no-padding" id="topXExpense">+ {# loading indicator #}+ <div class="overlay">+ <i class="fa fa-refresh fa-spin"></i>+ </div>+ </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">{{ 'income'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})</h3>+ </div>+ <div class="box-body table-responsive no-padding" id="topXincome">+ {# loading indicator #}+ <div class="overlay">+ <i class="fa fa-refresh fa-spin"></i>+ </div>+ </div>+ </div>+ </div>+ </div>+ {#+ <div class="row">+ {% if categories.count > 1 %}+ <div class="col-lg-2 col-md-3">+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'income_per_category'|_ }}</h3>+ </div>+ <div class="box-body">+ <canvas id="categories-in-pie-chart" style="margin:0 auto;" height="150" width="150"></canvas>+ <label style="font-weight:normal;">+ <input type="checkbox" id="categories-in-pie-chart-checked">+ <small>{{ 'include_income_not_in_category'|_ }}</small>+ </label>+ </div>+ </div>+ </div>+ <div class="col-lg-2 col-md-3">+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'expense_per_category'|_ }}</h3>+ </div>+ <div class="box-body">+ <canvas id="categories-out-pie-chart" style="margin:0 auto;" height="150" width="150"></canvas>+ <label style="font-weight:normal;">+ <input type="checkbox" id="categories-out-pie-chart-checked">+ <small>{{ 'include_expense_not_in_category'|_ }}</small>+ </label>+ </div>+ </div>+ </div>+ {% endif %}+ <div class="col-lg-2 col-md-3" id="pieCharts">+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'income_per_account'|_ }}</h3>+ </div>+ <div class="box-body">+ <canvas id="accounts-in-pie-chart" style="margin:0 auto;" height="150" width="150"></canvas>+ <label style="font-weight:normal;">+ <input type="checkbox" id="accounts-in-pie-chart-checked">+ <small>{{ 'include_income_not_in_account'|_ }}</small>+ </label>+ </div>+ </div>+ </div>+ <div class="col-lg-2 col-md-3">+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'expense_per_account'|_ }}</h3>+ </div>+ <div class="box-body">+ <canvas id="accounts-out-pie-chart" style="margin:0 auto;" height="150" width="150"></canvas>+ <label style="font-weight:normal;">+ <input type="checkbox" id="accounts-out-pie-chart-checked">+ <small>{{ 'include_expense_not_in_account'|_ }}</small>+ </label>+ </div>+ </div>+ </div>+ </div>++ <div class="row">+ <div class="col-lg-12">+ <div class="box" id="incomeAndExpensesChart">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'income_and_expenses'|_ }}</h3>+ </div>+ <div class="box-body">+ <canvas id="in-out-chart" style="width:100%;height:400px;" height="400" width="100%"></canvas>+ </div>+ </div>+ </div>+ </div>+ <div class="row">+ {% if averageExpenses|length > 0 %}+ <div class="col-lg-6">+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'average_spending_per_account'|_ }}</h3>+ </div>+ <div class="box-body table-responsive no-padding">+ <table class="table table-hover sortable">+ <thead>+ <tr>+ <th data-defaultsign="az">{{ 'account'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'spent_average'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'total'|_ }}</th>+ <th data-defaultsign="_19">{{ 'transaction_count'|_ }}</th>+ </tr>+ </thead>+ <tbody>+ {% for row in averageExpenses %}+ {% if loop.index > listLength %}+ <tr class="overListLength">+ {% else %}+ <tr>+ {% endif %}+ <td data-value="{{ row.name }}">+ <a href="{{ route('accounts.show', row.id) }}">{{ row.name }}</a>+ </td>+ <td data-value="{{ row.average }}" style="text-align: right;">+ {{ row.average|formatAmount }}+ </td>+ <td data-value="{{ row.sum }}" style="text-align: right;">+ {{ row.sum|formatAmount }}+ </td>+ <td data-value="{{ row.count }}">+ {{ row.count }}+ </td>+ </tr>+ {% endfor %}+ </tbody>+ <tfoot>+ {% if averageExpenses|length > listLength %}+ <tr>+ <td colspan="4" class="active">+ <a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>+ </td>+ </tr>+ {% endif %}+ </tfoot>+ </table>+ </div>+ </div>+ </div>+ {% endif %}+ {% if topExpenses.count > 0 %}+ <div class="col-lg-6">++ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'expenses'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})</h3>+ </div>+ <div class="box-body">+ <table class="table table-hover sortable">+ <thead>+ <tr>+ <th data-defaultsort="disabled">{{ 'description'|_ }}</th>+ <th data-defaultsign="month">{{ 'date'|_ }}</th>+ <th data-defaultsign="az">{{ 'account'|_ }}</th>+ <th data-defaultsign="_19" style="text-align: right;">{{ 'amount'|_ }}</th>+ </tr>+ </thead>+ <tbody>+ {% for row in topExpenses %}+ {% if loop.index > listLength %}+ <tr class="overListLength">+ {% else %}+ <tr>+ {% endif %}+ <td data-sortable="false">+ <a href="{{ route('transactions.show', row.journal_id) }}">+ {% if row.transaction_description|length > 0 %}+ {{ row.transaction_description }} ({{ row.description }})+ {% else %}+ {{ row.description }}+ {% endif %}+ </a>+ </td>+ <td data-value="{{ row.date.format('Y-m-d') }}">+ {{ row.date.formatLocalized(monthAndDayFormat) }}+ </td>+ <td data-value="{{ row.opposing_account_name }}">+ <a href="{{ route('accounts.show', row.opposing_account_id) }}">+ {{ row.opposing_account_name }}+ </a>+ </td>+ <td data-value="{{ row.transaction_amount }}" style="text-align: right;">+ {{ row.transaction_amount|formatAmount }}+ </td>+ </tr>+ {% endfor %}+ </tbody>+ <tfoot>+ {% if topExpenses|length > listLength %}+ <tr>+ <td colspan="3" class="active">+ <a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>+ </td>+ </tr>+ {% endif %}+ </tfoot>+ </table>+ </div>+ </div>+ </div>+ {% endif %}+ </div>+ <div class="row">+ {% if averageIncome|length > 0 %}+ <div class="col-lg-6">+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'average_income_per_account'|_ }}</h3>+ </div>+ <div class="box-body">+ <table class="table table-hover sortable">+ <thead>+ <tr>+ <th data-defaultsign="az">{{ 'account'|_ }}</th>+ <th data-defaultsign="_19">{{ 'income_average'|_ }}</th>+ <th data-defaultsign="_19">{{ 'total'|_ }}</th>+ <th data-defaultsign="_19">{{ 'transaction_count'|_ }}</th>+ </tr>+ </thead>+ <tbody>+ {% for row in averageIncome %}+ <tr>+ <td data-value="{{ row.name }}">+ <a href="{{ route('accounts.show', row.id) }}">{{ row.name }}</a>+ </td>+ <td data-value="{{ row.average }}">+ {{ row.average|formatAmount }}+ </td>+ <td data-value="{{ row.sum }}">+ {{ row.sum|formatAmount }}+ </td>+ <td data-value="{{ row.count }}">+ {{ row.count }}+ </td>+ </tr>+ {% endfor %}+ </tbody>+ </table>+ </div>+ </div>+ </div>+ {% endif %}+ <div class="col-lg-6">+ {% if topIncome.count > 0 %}+ <div class="box">+ <div class="box-header with-border">+ <h3 class="box-title">{{ 'income'|_ }} ({{ trans('firefly.topX', {number: listLength}) }})</h3>+ </div>+ <div class="box-body">+ <table class="table table-hover sortable">+ <thead>+ <tr>+ <th data-defaultsort="disabled">{{ 'description'|_ }}</th>+ <th data-defaultsign="month">{{ 'date'|_ }}</th>+ <th data-defaultsign="az">{{ 'account'|_ }}</th>+ <th data-defaultsign="_19">{{ 'amount'|_ }}</th>+ </tr>+ </thead>+ <tbody>+ {% for row in topIncome %}+ {% if loop.index > listLength %}+ <tr class="overListLength">+ {% else %}+ <tr>+ {% endif %}+ <td>+ <a href="{{ route('transactions.show', row.journal_id) }}">+ {% if row.transaction_description|length > 0 %}+ {{ row.transaction_description }} ({{ row.description }})+ {% else %}+ {{ row.description }}+ {% endif %}+ </a>+ </td>+ <td data-value="{{ row.date.format('Y-m-d H-i-s') }}">+ {{ row.date.formatLocalized(monthAndDayFormat) }}+ </td>+ <td data-value="{{ row.opposing_account_name }}">+ <a href="{{ route('accounts.show', row.opposing_account_id) }}">+ {{ row.opposing_account_name }}+ </a>+ </td>+ <td data-value="{{ row.transaction_amount }}">+ {{ row.transaction_amount|formatAmount }}+ </td>+ </tr>+ {% endfor %}+ </tbody>+ <tfoot>+ {% if topIncome.count > listLength %}+ <tr>+ <td colspan="3" class="active">+ <a href="#" class="listLengthTrigger">{{ trans('firefly.show_full_list',{number:incomeTopLength}) }}</a>+ </td>+ </tr>+ {% endif %}+ </tfoot>+ </table>+ </div>+ </div>+ {% endif %}+ </div>+ </div>+ #}++{% endblock %}++{% block scripts %}+ <script type="text/javascript" src="js/lib/Chart.bundle.min.js?v={{ FF_VERSION }}"></script>+ <script type="text/javascript" src="js/ff/charts.defaults.js?v={{ FF_VERSION }}"></script>+ <script type="text/javascript" src="js/ff/charts.js?v={{ FF_VERSION }}"></script>+ <script type="text/javascript" src="js/lib/bootstrap-sortable.js?v={{ FF_VERSION }}"></script>++ <script type="text/javascript">+ // to report another URL:+ var startDate = '{{ start.format('Ymd') }}';+ var endDate = '{{ end.format('Ymd') }}';+ var accountIds = '{{ accountIds }}';+ var categoryIds = '{{ categoryIds }}';++ // 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')]) }}';+ </script>+++ <script type="text/javascript" src="js/ff/reports/category/all.js?v={{ FF_VERSION }}"></script>+ <script type="text/javascript" src="js/ff/reports/category/month.js?v={{ FF_VERSION }}"></script>++{% endblock %}++{% block styles %}+ <link rel="stylesheet" href="css/bootstrap-sortable.css?v={{ FF_VERSION }}" type="text/css" media="all"/>+{% endblock %}diff --git a/resources/views/reports/index.twig b/resources/views/reports/index.twigindex d6247a2324..fd1bcd0b0c 100644--- a/resources/views/reports/index.twig+++ b/resources/views/reports/index.twig@@ -29,6 +29,7 @@<option label="{{ 'report_type_budget'|_ }}" value="budget">{{ 'report_type_budget'|_ }}</option><option label="{{ 'report_type_category'|_ }}" value="category">{{ 'report_type_category'|_ }}</option><option label="{{ 'report_type_tag'|_ }}" value="tag">{{ 'report_type_tag'|_ }}</option>+ <option label="{{ 'report_type_account'|_ }}" value="account">{{ 'report_type_account'|_ }}</option></select></div></div>diff --git a/resources/views/reports/options/account.twig b/resources/views/reports/options/account.twignew file mode 100644index 0000000000..34792dc3cf--- /dev/null+++ b/resources/views/reports/options/account.twig@@ -0,0 +1,10 @@+<div class="form-group">+ <label for="inputExpRevAccounts" class="col-sm-3 control-label">{{ 'select_expense_revenue'|_ }}</label>+ <div class="col-sm-9">+ <select id="inputExpRevAccounts" name="exp_rev[]" multiple="multiple" class="form-control">+ {% for account in set %}+ <option value="{{ account.id }}" label="{{ account.name }}">{{ account.name }}</option>+ {% endfor %}+ </select>+ </div>+</div>diff --git a/routes/web.php b/routes/web.phpindex 86b29cb942..099baa9b65 100755--- a/routes/web.php+++ b/routes/web.php@@ -567,6 +567,7 @@ Route::group(Route::get('category/{accountList}/{categoryList}/{start_date}/{end_date}', ['uses' => 'ReportController@categoryReport', 'as' => 'report.category']);Route::get('budget/{accountList}/{budgetList}/{start_date}/{end_date}', ['uses' => 'ReportController@budgetReport', 'as' => 'report.budget']);Route::get('tag/{accountList}/{tagList}/{start_date}/{end_date}', ['uses' => 'ReportController@tagReport', 'as' => 'report.tag']);+ Route::get('account/{accountList}/{expenseList}/{start_date}/{end_date}', ['uses' => 'ReportController@accountReport', 'as' => 'report.account']);Route::post('', ['uses' => 'ReportController@postIndex', 'as' => 'index.post']);}