Skip to content

Firefly III: a personal finances manager

Some refactoring.

James Colec4c3d0f07fc3
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index 19e5bcbe36..2113cf7329 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -68,7 +68,7 @@ class ReportController extends Controller
*
* @return View
*/
- public function year($report_type, Carbon $start, Carbon $end, Collection $accounts)
+ public function defaultYear($report_type, Carbon $start, Carbon $end, Collection $accounts)
{
$subTitle = trans('firefly.reportForYear', ['year' => $start->year]);
$subTitleIcon = 'fa-bar-chart';
@@ -92,7 +92,7 @@ class ReportController extends Controller
$accountIds = join(';', $accountIds);
return view(
- 'reports.year',
+ 'reports.default.year',
compact(
'start', 'accountReport', 'incomes', 'report_type', 'accountIds', 'end',
'expenses', 'subTitle', 'subTitleIcon', 'incomeTopLength', 'expenseTopLength'
@@ -109,7 +109,7 @@ class ReportController extends Controller
*
* @return View
*/
- public function month($report_type, Carbon $start, Carbon $end, Collection $accounts)
+ public function defaultMonth($report_type, Carbon $start, Carbon $end, Collection $accounts)
{
// some fields for translation:
$subTitle = trans('firefly.reportForMonth', ['month' => $start->formatLocalized($this->monthFormat)]);
@@ -136,7 +136,7 @@ class ReportController extends Controller
// continue!
return view(
- 'reports.default',
+ 'reports.default.month',
compact(
'start', 'end', 'report_type',
'subTitle', 'subTitleIcon',
@@ -168,10 +168,10 @@ class ReportController extends Controller
// more than two months date difference means year report.
if ($start->diffInMonths($end) > 1) {
- return $this->year($report_type, $start, $end, $accounts);
+ return $this->defaultYear($report_type, $start, $end, $accounts);
}
- return $this->month($report_type, $start, $end, $accounts);
+ return $this->defaultMonth($report_type, $start, $end, $accounts);
}
diff --git a/resources/twig/reports/default.twig b/resources/twig/reports/default.twig
deleted file mode 100644
index d2347b4391..0000000000
--- a/resources/twig/reports/default.twig
+++ /dev/null
@@ -1,105 +0,0 @@
-{% extends "./layout/default.twig" %}
-
-{% block breadcrumbs %}
- {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, start, shared) }}
-{% endblock %}
-
-{% block content %}
-
- <div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
- <div class="box">
- <div class="box-header with-border">
- <h3 class="box-title">{{ 'accountBalances'|_ }}</h3>
- </div>
- <div class="box-body">
- {% if Config.get('firefly.chart') == 'google' %}
- <div id="account-balances-chart"></div>
- {% endif %}
- {% if Config.get('firefly.chart') == 'chartjs' %}
- <canvas id="account-balances-chart" style="width:100%;height:400px;"></canvas>
- {% endif %}
- </div>
- </div>
- </div>
- </div>
-
- <div class="row">
- <div class="col-lg-6 col-md-6 col-sm-6">
- {% include 'partials/reports/accounts.twig' %}
- {% include 'partials/reports/income-vs-expenses.twig' %}
- </div>
- <div class="col-lg-3 col-md-3 col-sm-3">
- <!-- income -->
- {% include 'partials/reports/income.twig' %}
- </div>
- <div class="col-lg-3 col-md-3 col-sm-3">
- <!-- expenses -->
- {% include 'partials/reports/expenses.twig' %}
- </div>
- </div>
- <div class="row">
- <div class="col-lg-8 col-md-8 col-sm-12">
- <!-- budgets -->
- {% include 'partials/reports/budgets.twig' %}
- </div>
- <div class="col-lg-4 col-md-4 col-sm-12">
- <!-- categories -->
- {% include 'partials/reports/categories.twig' %}
- </div>
- </div>
- <div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
-
- </div>
- </div>
- <div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
- {% include 'partials/reports/balance.twig' %}
- </div>
- </div>
- <div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
- {% include 'partials/reports/bills.twig' %}
-
- </div>
- </div>
-{% endblock %}
-{% block styles %}
- <link rel="stylesheet" href="css/bootstrap-sortable.css" type="text/css" media="all"/>
-{% endblock %}
-{% block scripts %}
-
- <script type="text/javascript" src="js/bootstrap-sortable.js"></script>
-
- <!-- load the libraries and scripts necessary for Google Charts: -->
- {% if Config.get('firefly.chart') == 'google' %}
- <script type="text/javascript" src="https://www.google.com/jsapi"></script>
- <script type="text/javascript" src="js/gcharts.js"></script>
- {% endif %}
- {% if Config.get('firefly.chart') == 'chartjs' %}
- <script type="text/javascript" src="js/Chart.min.js"></script>
- <script type="text/javascript" src="js/charts.js"></script>
- {% endif %}
-
- <script type="text/javascript">
- var year = {{ start.year }};
- var month = {{ start.month }};
-
- // to report another URL:
- var startDate = '{{ start.format('Ymd') }}';
- var endDate = '{{ end.format('Ymd') }}';
- var reportType = '{{ report_type }}';
- var accountIds = '{{ accountIds }}';
-
- var incomeTopLength = {{ incomeTopLength }};
- var expenseTopLength = {{ expenseTopLength }};
- var incomeRestShow = false; // starts hidden.
- var expenseRestShow = false; // starts hidden.
- var showTheRest = '{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}';
- var hideTheRest = '{{ trans('firefly.hideTheRest',{number:incomeTopLength}) }}';
- var showTheRestExpense = '{{ trans('firefly.showTheRest',{number:expenseTopLength}) }}';
- var hideTheRestExpense = '{{ trans('firefly.hideTheRest',{number:expenseTopLength}) }}';
- </script>
- <script type="text/javascript" src="js/reports.js"></script>
-{% endblock %}
diff --git a/resources/twig/reports/month.twig b/resources/twig/reports/default/month.twig
similarity index 82%
rename from resources/twig/reports/month.twig
rename to resources/twig/reports/default/month.twig
index 0b9111669b..6330b99266 100644
--- a/resources/twig/reports/month.twig
+++ b/resources/twig/reports/default/month.twig
@@ -26,26 +26,26 @@
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
- {% include 'partials/reports/accounts.twig' %}
- {% include 'partials/reports/income-vs-expenses.twig' %}
+ {% include 'reports/partials/accounts.twig' %}
+ {% include 'reports/partials/income-vs-expenses.twig' %}
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<!-- income -->
- {% include 'partials/reports/income.twig' %}
+ {% include 'reports/partials/income.twig' %}
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<!-- expenses -->
- {% include 'partials/reports/expenses.twig' %}
+ {% include 'reports/partials/expenses.twig' %}
</div>
</div>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12">
<!-- budgets -->
- {% include 'partials/reports/budgets.twig' %}
+ {% include 'reports/partials/budgets.twig' %}
</div>
<div class="col-lg-4 col-md-4 col-sm-12">
<!-- categories -->
- {% include 'partials/reports/categories.twig' %}
+ {% include 'reports/partials/categories.twig' %}
</div>
</div>
<div class="row">
@@ -55,12 +55,12 @@
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
- {% include 'partials/reports/balance.twig' %}
+ {% include 'reports/partials/balance.twig' %}
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
- {% include 'partials/reports/bills.twig' %}
+ {% include 'reports/partials/bills.twig' %}
</div>
</div>
@@ -85,8 +85,13 @@
<script type="text/javascript">
var year = {{ start.year }};
var month = {{ start.month }};
- var shared = {% if shared %}'/shared'
- {% else %}''{% endif %};
+
+ // to report another URL:
+ var startDate = '{{ start.format('Ymd') }}';
+ var endDate = '{{ end.format('Ymd') }}';
+ var reportType = '{{ report_type }}';
+ var accountIds = '{{ accountIds }}';
+
var incomeTopLength = {{ incomeTopLength }};
var expenseTopLength = {{ expenseTopLength }};
var incomeRestShow = false; // starts hidden.
diff --git a/resources/twig/reports/year.twig b/resources/twig/reports/default/year.twig
similarity index 95%
rename from resources/twig/reports/year.twig
rename to resources/twig/reports/default/year.twig
index 02e236b75b..af52b11b2f 100644
--- a/resources/twig/reports/year.twig
+++ b/resources/twig/reports/default/year.twig
@@ -41,15 +41,15 @@
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
- {% include 'partials/reports/accounts.twig' %}
- {% include 'partials/reports/income-vs-expenses.twig' %}
+ {% include 'reports/partials/accounts.twig' %}
+ {% include 'reports/partials/income-vs-expenses.twig' %}
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
- {% include 'partials/reports/income.twig' %}
+ {% include 'reports/partials/income.twig' %}
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
- {% include 'partials/reports/expenses.twig' %}
+ {% include 'reports/partials/expenses.twig' %}
</div>
</div>
<div class="row">
diff --git a/resources/twig/partials/reports/accounts.twig b/resources/twig/reports/partials/accounts.twig
similarity index 100%
rename from resources/twig/partials/reports/accounts.twig
rename to resources/twig/reports/partials/accounts.twig
diff --git a/resources/twig/partials/reports/balance.twig b/resources/twig/reports/partials/balance.twig
similarity index 100%
rename from resources/twig/partials/reports/balance.twig
rename to resources/twig/reports/partials/balance.twig
diff --git a/resources/twig/partials/reports/bills.twig b/resources/twig/reports/partials/bills.twig
similarity index 100%
rename from resources/twig/partials/reports/bills.twig
rename to resources/twig/reports/partials/bills.twig
diff --git a/resources/twig/partials/reports/budgets.twig b/resources/twig/reports/partials/budgets.twig
similarity index 100%
rename from resources/twig/partials/reports/budgets.twig
rename to resources/twig/reports/partials/budgets.twig
diff --git a/resources/twig/partials/reports/categories.twig b/resources/twig/reports/partials/categories.twig
similarity index 100%
rename from resources/twig/partials/reports/categories.twig
rename to resources/twig/reports/partials/categories.twig
diff --git a/resources/twig/partials/reports/expenses.twig b/resources/twig/reports/partials/expenses.twig
similarity index 100%
rename from resources/twig/partials/reports/expenses.twig
rename to resources/twig/reports/partials/expenses.twig
diff --git a/resources/twig/partials/reports/income-vs-expenses.twig b/resources/twig/reports/partials/income-vs-expenses.twig
similarity index 100%
rename from resources/twig/partials/reports/income-vs-expenses.twig
rename to resources/twig/reports/partials/income-vs-expenses.twig
diff --git a/resources/twig/partials/reports/income.twig b/resources/twig/reports/partials/income.twig
similarity index 100%
rename from resources/twig/partials/reports/income.twig
rename to resources/twig/reports/partials/income.twig