Skip to content

Firefly III: a personal finances manager

Some overhauls.

James Colee7285c64999c
diff --git a/app/Helpers/Collection/Budget.php b/app/Helpers/Collection/Budget.php
new file mode 100644
index 0000000000..3347302dcd
--- /dev/null
+++ b/app/Helpers/Collection/Budget.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sander
+ * Date: 16/05/15
+ * Time: 13:09
+ */
+
+namespace FireflyIII\Helpers\Collection;
+
+
+class Budget {
+
+}
\ No newline at end of file
diff --git a/app/Helpers/Collection/Category.php b/app/Helpers/Collection/Category.php
new file mode 100644
index 0000000000..bbce06ace3
--- /dev/null
+++ b/app/Helpers/Collection/Category.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sander
+ * Date: 16/05/15
+ * Time: 13:09
+ */
+
+namespace FireflyIII\Helpers\Collection;
+
+
+class Category {
+
+}
\ No newline at end of file
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php
index c5f046c432..7994ba03f3 100644
--- a/app/Helpers/Report/ReportHelper.php
+++ b/app/Helpers/Report/ReportHelper.php
@@ -4,6 +4,8 @@ namespace FireflyIII\Helpers\Report;
use Carbon\Carbon;
use FireflyIII\Helpers\Collection\Account as AccountCollection;
+use FireflyIII\Helpers\Collection\Budget as BudgetCollection;
+use FireflyIII\Helpers\Collection\Category as CategoryCollection;
use FireflyIII\Helpers\Collection\Expense;
use FireflyIII\Helpers\Collection\Income;
use FireflyIII\Models\Account;
@@ -64,6 +66,30 @@ class ReportHelper implements ReportHelperInterface
return $object;
}
+ /**
+ * @param Carbon $start
+ * @param Carbon $end
+ * @param boolean $shared
+ *
+ * @return BudgetCollection
+ */
+ public function getBudgetReport(Carbon $start, Carbon $end, $shared)
+ {
+ return null;
+ }
+
+ /**
+ * @param Carbon $start
+ * @param Carbon $end
+ * @param boolean $shared
+ *
+ * @return CategoryCollection
+ */
+ public function getCategoryReport(Carbon $start, Carbon $end, $shared)
+ {
+ return null;
+ }
+
/**
* Get a full report on the users expenses during the period.
*
diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.php
index 1a91975479..66af64da7e 100644
--- a/app/Helpers/Report/ReportHelperInterface.php
+++ b/app/Helpers/Report/ReportHelperInterface.php
@@ -6,6 +6,8 @@ use Carbon\Carbon;
use FireflyIII\Helpers\Collection\Account;
use FireflyIII\Helpers\Collection\Expense;
use FireflyIII\Helpers\Collection\Income;
+use FireflyIII\Helpers\Collection\Budget as BudgetCollection;
+use FireflyIII\Helpers\Collection\Category as CategoryCollection;
/**
* Interface ReportHelperInterface
@@ -27,6 +29,24 @@ interface ReportHelperInterface
*/
public function getAccountReport(Carbon $date, Carbon $end, $shared);
+ /**
+ * @param Carbon $start
+ * @param Carbon $end
+ * @param boolean $shared
+ *
+ * @return BudgetCollection
+ */
+ public function getBudgetReport(Carbon $start, Carbon $end, $shared);
+
+ /**
+ * @param Carbon $start
+ * @param Carbon $end
+ * @param boolean $shared
+ *
+ * @return CategoryCollection
+ */
+ public function getCategoryReport(Carbon $start, Carbon $end, $shared);
+
/**
* Get a full report on the users expenses during the period.
*
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index 2ae0518a7c..3b69b1280c 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -1,6 +1,5 @@
<?php namespace FireflyIII\Http\Controllers;
-use App;
use Carbon\Carbon;
use FireflyIII\Helpers\Report\ReportHelperInterface;
use FireflyIII\Helpers\Report\ReportQueryInterface;
@@ -10,7 +9,6 @@ use FireflyIII\Models\LimitRepetition;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
-use Illuminate\Support\Collection;
use Session;
use View;
@@ -148,8 +146,6 @@ class ReportController extends Controller
$subTitle = trans('firefly.reportForMonth', ['date' => $start->formatLocalized($this->monthFormat)]);
$subTitleIcon = 'fa-calendar';
$end = clone $start;
- $totalExpense = 0;
- $totalIncome = 0;
$incomeTopLength = 8;
$expenseTopLength = 8;
if ($shared == 'shared') {
@@ -159,152 +155,87 @@ class ReportController extends Controller
$end->endOfMonth();
- // all accounts:
- $accounts = $this->helper->getAccountReport($start, $end, $shared);
-
- /**
- * ALL INCOMES.
- * Grouped, sorted and summarized.
- */
- $set = $this->query->incomeInPeriod($start, $end, $shared);
- // group, sort and sum:
- $incomes = [];
- foreach ($set as $entry) {
- $id = $entry->account_id;
- $totalIncome += floatval($entry->queryAmount);
- if (isset($incomes[$id])) {
- $incomes[$id]['amount'] += floatval($entry->queryAmount);
- $incomes[$id]['count']++;
- } else {
- $incomes[$id] = [
- 'amount' => floatval($entry->queryAmount),
- 'name' => $entry->name,
- 'count' => 1,
- 'id' => $id,
- ];
- }
- }
- // sort with callback:
- uasort(
- $incomes, function ($a, $b) {
- if ($a['amount'] == $b['amount']) {
- return 0;
- }
-
- return ($a['amount'] < $b['amount']) ? 1 : -1;
- }
- );
- unset($set, $id);
-
- /**
- * GET ALL EXPENSES
- * Summarized.
- */
- $set = $this->query->expenseInPeriod($start, $end, $shared);
- // group, sort and sum:
- $expenses = [];
- foreach ($set as $entry) {
- $id = $entry->account_id;
- $totalExpense += floatval($entry->queryAmount);
- if (isset($expenses[$id])) {
- $expenses[$id]['amount'] += floatval($entry->queryAmount);
- $expenses[$id]['count']++;
- } else {
- $expenses[$id] = [
- 'amount' => floatval($entry->queryAmount),
- 'name' => $entry->name,
- 'count' => 1,
- 'id' => $id,
- ];
- }
- }
- // sort with callback:
- uasort(
- $expenses, function ($a, $b) {
- if ($a['amount'] == $b['amount']) {
- return 0;
- }
-
- return ($a['amount'] < $b['amount']) ? -1 : 1;
- }
- );
- unset($set, $id);
-
- /**
- * DO BUDGETS.
- */
- /** @var \FireflyIII\Repositories\Budget\BudgetRepositoryInterface $repository */
- $repository = App::make('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
- $set = $repository->getBudgets();
- $budgets = new Collection;
- $budgetSums = ['budgeted' => 0, 'spent' => 0, 'left' => 0, 'overspent' => 0];
- /** @var Budget $budget */
- foreach ($set as $budget) {
- $repetitions = $repository->getBudgetLimitRepetitions($budget, $start, $end);
- if ($repetitions->count() == 0) {
- $exp = $repository->spentInPeriod($budget, $start, $end, $shared);
- $budgets->push([$budget, null, 0, 0, $exp]);
- $budgetSums['overspent'] += $exp;
- continue;
- }
- /** @var LimitRepetition $repetition */
- foreach ($repetitions as $repetition) {
- $exp = $repository->spentInPeriod($budget, $repetition->startdate, $repetition->enddate, $shared);
- $left = $exp < floatval($repetition->amount) ? floatval($repetition->amount) - $exp : 0;
- $spent = $exp > floatval($repetition->amount) ? 0 : $exp;
- $overspent = $exp > floatval($repetition->amount) ? $exp - floatval($repetition->amount) : 0;
-
- $budgetSums['budgeted'] += floatval($repetition->amount);
- $budgetSums['spent'] += $spent;
- $budgetSums['left'] += $left;
- $budgetSums['overspent'] += $overspent;
-
- $budgets->push([$budget, $repetition, $left, $spent, $overspent]);
- }
- }
-
- $noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end);
- $budgets->push([null, null, 0, 0, $noBudgetExpenses]);
- $budgetSums['overspent'] += $noBudgetExpenses;
- unset($noBudgetExpenses, $repository, $set, $repetition, $repetitions, $exp);
-
- /**
- * GET CATEGORIES:
- */
- /** @var \FireflyIII\Repositories\Category\CategoryRepositoryInterface $repository */
- $repository = App::make('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
- $set = $repository->getCategories();
- $categories = [];
- $categorySum = 0;
- foreach ($set as $category) {
- $spent = $repository->spentInPeriod($category, $start, $end, $shared);
- $categories[] = [$category, $spent];
- $categorySum += $spent;
- }
- // no category:
+ $accounts = $this->helper->getAccountReport($start, $end, $shared);
+ $incomes = $this->helper->getIncomeReport($start, $end, $shared);
+ $expenses = $this->helper->getExpenseReport($start, $end, $shared);
+ $budgets = $this->helper->getBudgetReport($start, $end, $shared);
+ $categories = $this->helper->getCategoryReport($start, $end, $shared);
- // sort with callback:
- uasort(
- $categories, function ($a, $b) {
- if ($a[1] == $b[1]) {
- return 0;
- }
+ // /**
+ // * DO BUDGETS.
+ // */
+ // /** @var \FireflyIII\Repositories\Budget\BudgetRepositoryInterface $repository */
+ // $repository = App::make('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
+ // $set = $repository->getBudgets();
+ // $budgets = new Collection;
+ // $budgetSums = ['budgeted' => 0, 'spent' => 0, 'left' => 0, 'overspent' => 0];
+ // /** @var Budget $budget */
+ // foreach ($set as $budget) {
+ // $repetitions = $repository->getBudgetLimitRepetitions($budget, $start, $end);
+ // if ($repetitions->count() == 0) {
+ // $exp = $repository->spentInPeriod($budget, $start, $end, $shared);
+ // $budgets->push([$budget, null, 0, 0, $exp]);
+ // $budgetSums['overspent'] += $exp;
+ // continue;
+ // }
+ // /** @var LimitRepetition $repetition */
+ // foreach ($repetitions as $repetition) {
+ // $exp = $repository->spentInPeriod($budget, $repetition->startdate, $repetition->enddate, $shared);
+ // $left = $exp < floatval($repetition->amount) ? floatval($repetition->amount) - $exp : 0;
+ // $spent = $exp > floatval($repetition->amount) ? 0 : $exp;
+ // $overspent = $exp > floatval($repetition->amount) ? $exp - floatval($repetition->amount) : 0;
+ //
+ // $budgetSums['budgeted'] += floatval($repetition->amount);
+ // $budgetSums['spent'] += $spent;
+ // $budgetSums['left'] += $left;
+ // $budgetSums['overspent'] += $overspent;
+ //
+ // $budgets->push([$budget, $repetition, $left, $spent, $overspent]);
+ // }
+ // }
+ //
+ // $noBudgetExpenses = $repository->getWithoutBudgetSum($start, $end);
+ // $budgets->push([null, null, 0, 0, $noBudgetExpenses]);
+ // $budgetSums['overspent'] += $noBudgetExpenses;
+ // unset($noBudgetExpenses, $repository, $set, $repetition, $repetitions, $exp);
- return ($a[1] < $b[1]) ? 1 : -1;
- }
- );
- unset($set, $repository, $spent);
+ // /**
+ // * GET CATEGORIES:
+ // */
+ // /** @var \FireflyIII\Repositories\Category\CategoryRepositoryInterface $repository */
+ // $repository = App::make('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
+ // $set = $repository->getCategories();
+ // $categories = [];
+ // $categorySum = 0;
+ // foreach ($set as $category) {
+ // $spent = $repository->spentInPeriod($category, $start, $end, $shared);
+ // $categories[] = [$category, $spent];
+ // $categorySum += $spent;
+ // }
+ // // no category:
+ //
+ // // sort with callback:
+ // uasort(
+ // $categories, function ($a, $b) {
+ // if ($a[1] == $b[1]) {
+ // return 0;
+ // }
+ //
+ // return ($a[1] < $b[1]) ? 1 : -1;
+ // }
+ // );
+ // unset($set, $repository, $spent);
return view(
'reports.month',
compact(
'start', 'shared',
'subTitle', 'subTitleIcon',
- 'accounts', 'accountsSums',
- 'incomes', 'totalIncome', 'incomeTopLength',
- 'expenses', 'totalExpense', 'expenseTopLength',
- 'budgets', 'budgetSums',
- 'categories', 'categorySum'
+ 'accounts',
+ 'incomes', 'incomeTopLength',
+ 'expenses', 'expenseTopLength',
+ 'budgets',
+ 'categories'
)
);
diff --git a/resources/twig/partials/reports/accounts.twig b/resources/twig/partials/reports/accounts.twig
new file mode 100644
index 0000000000..eb810fe051
--- /dev/null
+++ b/resources/twig/partials/reports/accounts.twig
@@ -0,0 +1,30 @@
+<div class="panel panel-default">
+ <div class="panel-heading">
+ <i class="fa fa-credit-card fa-fw"></i>
+ {{ 'accountBalances'|_ }}
+ </div>
+ <table class="table table-bordered table-striped">
+ <tr>
+ <th>{{ 'name'|_ }}</th>
+ <th>{{ 'balanceStartOfYear'|_ }}</th>
+ <th>{{ 'balanceStartOfYear'|_ }}</th>
+ <th>{{ 'difference'|_ }}</th>
+ </tr>
+ {% for account in accounts.getAccounts %}
+ <tr>
+ <td>
+ <a href="{{ route('accounts.show',account.id) }}" title="{{ account.name }}">{{ account.name }}</a>
+ </td>
+ <td>{{ account.startBalance|formatAmount }}</td>
+ <td>{{ account.endBalance|formatAmount }}</td>
+ <td>{{ (account.endBalance - account.startBalance)|formatAmount }}</td>
+ </tr>
+ {% endfor %}
+ <tr>
+ <td><em>Sum of sums</em></td>
+ <td>{{ accounts.getStart|formatAmount }}</td>
+ <td>{{ accounts.getEnd|formatAmount }}</td>
+ <td>{{ accounts.getDifference|formatAmount }}</td>
+ </tr>
+ </table>
+</div>
\ No newline at end of file
diff --git a/resources/twig/partials/reports/expenses.twig b/resources/twig/partials/reports/expenses.twig
new file mode 100644
index 0000000000..c4e588e731
--- /dev/null
+++ b/resources/twig/partials/reports/expenses.twig
@@ -0,0 +1,34 @@
+<div class="panel panel-default">
+ <div class="panel-heading">
+ <i class="fa fa-long-arrow-left fa-fw"></i>
+ {{ 'expenses'|_ }} ({{ trans('firefly.topX',{number: expenseTopLength}) }})
+ </div>
+ <table class="table">
+ {% for expense in expenses.getExpenses %}
+ {% if loop.index > expenseTopLength %}
+ <tr class="collapse out expenseCollapsed">
+ {% else %}
+ <tr>
+ {% endif %}
+ <td>
+ <a href="{{ route('accounts.show',expense.id) }}">{{ expense.name }}</a>
+ {% if expense.count > 1 %}
+ <br /><small>{{ expense.count }} {{ 'transactions'|_|lower }}</small>
+ {% endif %}
+ </td>
+ <td><span class="text-danger">{{ (expense.amount*-1)|formatAmountPlain }}</span></td>
+ </tr>
+ {% endfor %}
+ {% if expenses.getExpenses|length > expenseTopLength %}
+ <tr>
+ <td colspan="2" class="active">
+ <a href="#" id="showExpenses">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a>
+ </td>
+ </tr>
+ {% endif %}
+ <tr>
+ <td><em>{{ 'sum'|_ }}</em></td>
+ <td><span class="text-danger">{{ (expenses.getTotal * -1)|formatAmountPlain }}</span></td>
+ </tr>
+ </table>
+</div>
\ No newline at end of file
diff --git a/resources/twig/partials/reports/income-vs-expenses.twig b/resources/twig/partials/reports/income-vs-expenses.twig
new file mode 100644
index 0000000000..5ef1e880a0
--- /dev/null
+++ b/resources/twig/partials/reports/income-vs-expenses.twig
@@ -0,0 +1,20 @@
+<div class="panel panel-default">
+ <div class="panel-heading">
+ <i class="fa fa-fw fa-exchange"></i>
+ {{ 'incomeVsExpenses'|_ }}
+ </div>
+ <table class="table table-bordered table-striped">
+ <tr>
+ <td>{{ 'in'|_ }}</td>
+ <td>{{ incomes.getTotal|formatAmount }}</td>
+ </tr>
+ <tr>
+ <td>{{ 'out'|_ }}</td>
+ <td><span class="text-danger">{{ expenses.getTotal|formatAmountPlain }}</span></td>
+ </tr>
+ <tr>
+ <td>{{ 'difference'|_ }}</td>
+ <td>{{ (incomes.getTotal - expenses.getTotal)|formatAmount }}</td>
+ </tr>
+ </table>
+</div>
\ No newline at end of file
diff --git a/resources/twig/partials/reports/income.twig b/resources/twig/partials/reports/income.twig
new file mode 100644
index 0000000000..145d487a05
--- /dev/null
+++ b/resources/twig/partials/reports/income.twig
@@ -0,0 +1,34 @@
+<div class="panel panel-default">
+ <div class="panel-heading">
+ <i class="fa fa-long-arrow-right fa-fw"></i>
+ {{ 'income'|_ }} ({{ trans('firefly.topX',{number: incomeTopLength}) }})
+ </div>
+ <table class="table">
+ {% for income in incomes.getIncomes %}
+ {% if loop.index > incomeTopLength %}
+ <tr class="collapse out incomesCollapsed">
+ {% else %}
+ <tr>
+ {% endif %}
+ <td>
+ <a href="{{ route('accounts.show',income.id) }}" title="{{ income.name }}">{{ income.name }}</a>
+ {% if income.count > 1 %}
+ <br /><small>{{ income.count }} {{ 'transactions'|_|lower }}</small>
+ {% endif %}
+ </td>
+ <td>{{ income.amount|formatAmount }}</td>
+ </tr>
+ {% endfor %}
+ {% if incomes.getIncomes|length > incomeTopLength %}
+ <tr>
+ <td colspan="2" class="active">
+ <a href="#" id="showIncomes">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a>
+ </td>
+ </tr>
+ {% endif %}
+ <tr>
+ <td><em>{{ 'sum'|_ }}</em></td>
+ <td>{{ incomes.getTotal|formatAmount }}</td>
+ </tr>
+ </table>
+</div>
\ No newline at end of file
diff --git a/resources/twig/reports/month.twig b/resources/twig/reports/month.twig
index 16594a5a8b..6f39a41189 100644
--- a/resources/twig/reports/month.twig
+++ b/resources/twig/reports/month.twig
@@ -18,129 +18,16 @@
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
- <div class="panel panel-default">
- <div class="panel-heading">
- <i class="fa fa-fw fa-credit-card"></i>
- {{ 'accountBalances'|_ }}
- </div>
- <table class="table table-bordered table-striped">
- <tr>
- <th>{{ 'account'|_ }}</th>
- <th>{{ 'balanceStartOfMonth'|_ }}</th>
- <th>{{ 'balanceEndOfMonth'|_ }}</th>
- <th>{{ 'difference'|_ }}</th>
- </tr>
-
- {% for account in accounts %}
- <tr>
- <td><a href="{{route('accounts.show',account.id)}}">{{ account.name }}</a></td>
- <td>{{ account.startBalance|formatAmount }}</td>
- <td>{{ account.endBalance|formatAmount }}</td>
- <td>
- {{ (account.startBalance - account.endBalance)|formatAmount }}
- </td>
- </tr>
- {% endfor %}
- </table>
- </div>
-
- <!-- income vs expenses -->
- <div class="panel panel-default">
- <div class="panel-heading">
- <i class="fa fa-fw fa-exchange"></i>
- {{ 'incomeVsExpenses'|_ }}
- </div>
- <table class="table table-bordered table-striped">
- <tr>
- <td>{{ 'in'|_ }}</td>
- <td>{{ totalIncome|formatAmount }}</td>
- </tr>
- <tr>
- <td>{{ 'out'|_ }}</td>
- <td><span class="text-danger">{{ (totalExpense * -1)|formatAmountPlain }}</span></td>
- </tr>
- <tr>
- <td>{{ 'difference'|_ }}</td>
- <td>{{ (totalIncome + totalExpense)|formatAmount }}</td>
- </tr>
- </table>
- </div>
+ {% 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 -->
- <div class="panel panel-default">
- <div class="panel-heading">
- <i class="fa fa-long-arrow-right fa-fw"></i>
- {{ 'income'|_ }} ({{ trans('firefly.topX',{number: incomeTopLength}) }})
- </div>
- <table class="table">
- {% for id,row in incomes %}
- {% if loop.index > incomeTopLength %}
- <tr class="collapse out incomesCollapsed">
- {% else %}
- <tr>
- {% endif %}
- <td>
- <a href="{{ route('accounts.show',id) }}" title="{{ row.name }}">{{ row.name }}</a>
- {% if row.count > 1 %}
- <br /><small>{{ row.count }} {{ 'transactions'|_|lower }}</small>
- {% endif %}
- </td>
- <td>{{ row.amount|formatAmount }}</td>
- </tr>
- {% endfor %}
- {% if incomes|length > incomeTopLength %}
- <tr>
- <td colspan="2" class="active">
- <a href="#" id="showIncomes">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a>
- </td>
- </tr>
- {% endif %}
- <tr>
- <td><em>{{ 'sum'|_ }}</em></td>
- <td>{{ totalIncome|formatAmount }}</td>
- </tr>
- </table>
- </div>
+ {% include 'partials/reports/income.twig' %}
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<!-- expenses -->
- <div class="panel panel-default">
- <div class="panel-heading">
- <i class="fa fa-long-arrow-left fa-fw"></i>
- {{ 'expenses'|_ }} ({{ trans('firefly.topX',{number: expenseTopLength}) }})
- </div>
- <table class="table">
- {% set sum =0 %}
- {% for row in expenses %}
- {% if loop.index > expenseTopLength %}
- <tr class="collapse out expenseCollapsed">
- {% else %}
- <tr>
- {% endif %}
- <td>
- <a href="{{ route('accounts.show',row.id) }}">{{ row.name }}</a>
- {% if row.count > 1 %}
- <br /><small>{{ row.count }} {{ 'transactions'|_|lower }}</small>
- {% endif %}
- </td>
- <td><span class="text-danger">{{ (row.amount*-1)|formatAmountPlain }}</span></td>
- </tr>
- {% set sum = sum + row.amount %}
- {% endfor %}
- {% if expenses|length > expenseTopLength %}
- <tr>
- <td colspan="2" class="active">
- <a href="#" id="showExpenses">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a>
- </td>
- </tr>
- {% endif %}
- <tr>
- <td><em>{{ 'sum'|_ }}</em></td>
- <td><span class="text-danger">{{ (sum * -1)|formatAmountPlain }}</span></td>
- </tr>
- </table>
- </div>
+ {% include 'partials/reports/expenses.twig' %}
</div>
</div>
<div class="row">
diff --git a/resources/twig/reports/year.twig b/resources/twig/reports/year.twig
index faaabd1ae4..ed9bd1c78b 100644
--- a/resources/twig/reports/year.twig
+++ b/resources/twig/reports/year.twig
@@ -29,129 +29,15 @@
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
- <div class="panel panel-default">
- <div class="panel-heading">
- <i class="fa fa-credit-card fa-fw"></i>
- {{ 'accountBalances'|_ }}
- </div>
- <table class="table table-bordered table-striped">
- <tr>
- <th>{{ 'name'|_ }}</th>
- <th>{{ 'balanceStartOfYear'|_ }}</th>
- <th>{{ 'balanceStartOfYear'|_ }}</th>
- <th>{{ 'difference'|_ }}</th>
- </tr>
- {% for account in accounts.getAccounts %}
- <tr>
- <td>
- <a href="{{ route('accounts.show',account.id) }}" title="{{ account.name }}">{{ account.name }}</a>
- </td>
- <td>{{ account.startBalance|formatAmount }}</td>
- <td>{{ account.endBalance|formatAmount }}</td>
- <td>{{ (account.endBalance - account.startBalance)|formatAmount }}</td>
- </tr>
- {% endfor %}
- <tr>
- <td><em>Sum of sums</em></td>
- <td>{{ accounts.getStart|formatAmount }}</td>
- <td>{{ accounts.getEnd|formatAmount }}</td>
- <td>{{ accounts.getDifference|formatAmount }}</td>
- </tr>
- </table>
- </div>
+ {% include 'partials/reports/accounts.twig' %}
+ {% include 'partials/reports/income-vs-expenses.twig' %}
- <div class="panel panel-default">
- <div class="panel-heading">
- <i class="fa fa-fw fa-exchange"></i>
- {{ 'incomeVsExpenses'|_ }}
- </div>
- <table class="table table-bordered table-striped">
- <tr>
- <td>{{ 'in'|_ }}</td>
- <td>{{ totalIncome|formatAmount }}</td>
- </tr>
- <tr>
- <td>{{ 'out'|_ }}</td>
- <td><span class="text-danger">{{ totalExpense|formatAmountPlain }}</span></td>
- </tr>
- <tr>
- <td>{{ 'difference'|_ }}</td>
- <td>{{ (totalIncome - totalExpense)|formatAmount }}</td>
- </tr>
- </table>
- </div>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
- <div class="panel panel-default">
- <div class="panel-heading">
- <i class="fa fa-long-arrow-right fa-fw"></i>
- {{ 'income'|_ }} ({{ trans('firefly.topX',{number: incomeTopLength}) }})
- </div>
- <table class="table">
- {% for income in incomes.getIncomes %}
- {% if loop.index > incomeTopLength %}
- <tr class="collapse out incomesCollapsed">
- {% else %}
- <tr>
- {% endif %}
- <td>
- <a href="{{ route('accounts.show',income.id) }}" title="{{ income.name }}">{{ income.name }}</a>
- {% if income.count > 1 %}
- <br /><small>{{ income.count }} {{ 'transactions'|_|lower }}</small>
- {% endif %}
- </td>
- <td>{{ income.amount|formatAmount }}</td>
- </tr>
- {% endfor %}
- {% if incomes.getIncomes|length > incomeTopLength %}
- <tr>
- <td colspan="2" class="active">
- <a href="#" id="showIncomes">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a>
- </td>
- </tr>
- {% endif %}
- <tr>
- <td><em>{{ 'sum'|_ }}</em></td>
- <td>{{ incomes.getTotal|formatAmount }}</td>
- </tr>
- </table>
- </div>
+ {% include 'partials/reports/income.twig' %}
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
- <div class="panel panel-default">
- <div class="panel-heading">
- <i class="fa fa-long-arrow-left fa-fw"></i>
- {{ 'expenses'|_ }} ({{ trans('firefly.topX',{number: expenseTopLength}) }})
- </div>
- <table class="table">
- {% for expense in expenses.getExpenses %}
- {% if loop.index > expenseTopLength %}
- <tr class="collapse out expenseCollapsed">
- {% else %}
- <tr>
- {% endif %}
- <td>
- <a href="{{ route('accounts.show',expense.id) }}">{{ expense.name }}</a>
- {% if expense.count > 1 %}
- <br /><small>{{ expense.count }} {{ 'transactions'|_|lower }}</small>
- {% endif %}
- </td>
- <td><span class="text-danger">{{ (expense.amount*-1)|formatAmountPlain }}</span></td>
- </tr>
- {% endfor %}
- {% if expenses.getExpenses|length > expenseTopLength %}
- <tr>
- <td colspan="2" class="active">
- <a href="#" id="showExpenses">{{ trans('firefly.showTheRest',{number:incomeTopLength}) }}</a>
- </td>
- </tr>
- {% endif %}
- <tr>
- <td><em>{{ 'sum'|_ }}</em></td>
- <td><span class="text-danger">{{ (expenses.getTotal * -1)|formatAmountPlain }}</span></td>
- </tr>
- </table>
- </div>
+ {% include 'partials/reports/expenses.twig' %}
</div>
</div>
<div class="row">