Skip to content

Firefly III: a personal finances manager

Add sum.

James Cole7a216f95ca8d
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index 8de911f5f1..2a4b16e1d3 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -52,7 +52,7 @@ class General extends Twig_Extension
$this->getCurrencySymbol(),
$this->phpdate(),
$this->env(),
-
+ $this->getAmountFromJournal(),
$this->activeRouteStrict(),
$this->activeRoutePartial(),
$this->activeRoutePartialWhat(),
@@ -306,4 +306,16 @@ class General extends Twig_Extension
);
}
+ /**
+ * @return Twig_SimpleFunction
+ */
+ private function getAmountFromJournal()
+ {
+ return new Twig_SimpleFunction(
+ 'getAmount', function (TransactionJournal $journal) : string {
+ return TransactionJournal::amount($journal);
+ }
+ );
+ }
+
}
diff --git a/resources/views/popup/list/journals.twig b/resources/views/popup/list/journals.twig
index 64d425c32a..f4bf459842 100644
--- a/resources/views/popup/list/journals.twig
+++ b/resources/views/popup/list/journals.twig
@@ -9,7 +9,7 @@
<th class="hidden-xs">{{ trans('list.from') }}</th>
{% endif %}
{% if not hideDestination %}
- <th class="hidden-xs">{{ trans('list.to') }}</th>
+ <th class="hidden-xs">{{ trans('list.to') }}</th>
{% endif %}
<!-- Hide budgets? -->
{% if not hideBudget %}
@@ -23,7 +23,14 @@
</tr>
</thead>
<tbody>
+ <!--
+ Make sum:
+ {% set sum = 0 %}
+ -->
{% for journal in journals %}
+ <!-- add to sum
+ {% set sum = (sum + getAmount(journal) ) %}
+ -->
<tr class="drag" data-date="{{ journal.date.format('Y-m-d') }}" data-id="{{ journal.id }}">
<td class="hidden-xs">
{{ journal|typeIcon }}
@@ -38,22 +45,22 @@
{{ journal.date.formatLocalized(monthAndDayFormat) }}
</td>
{% if not hideSource %}
- <td class="hidden-xs">
- {% if journal.source_account_type == 'Cash account' %}
- <span class="text-success">(cash)</span>
- {% else %}
- <a href="{{ route('accounts.show',journal.source_account_id) }}">{{ journal.source_account_name }}</a>
- {% endif %}
- </td>
+ <td class="hidden-xs">
+ {% if journal.source_account_type == 'Cash account' %}
+ <span class="text-success">(cash)</span>
+ {% else %}
+ <a href="{{ route('accounts.show',journal.source_account_id) }}">{{ journal.source_account_name }}</a>
+ {% endif %}
+ </td>
{% endif %}
{% if not hideDestination %}
- <td class="hidden-xs">
- {% if journal.destination_account_type == 'Cash account' %}
- <span class="text-success">(cash)</span>
- {% else %}
- <a href="{{ route('accounts.show',journal.destination_account_id) }}">{{ journal.destination_account_name }}</a>
- {% endif %}
- </td>
+ <td class="hidden-xs">
+ {% if journal.destination_account_type == 'Cash account' %}
+ <span class="text-success">(cash)</span>
+ {% else %}
+ <a href="{{ route('accounts.show',journal.destination_account_id) }}">{{ journal.destination_account_name }}</a>
+ {% endif %}
+ </td>
{% endif %}
<!-- Do NOT hide the budget? -->
@@ -76,6 +83,12 @@
</tr>
{% endfor %}
</tbody>
+ <tfoot>
+ <tr>
+ <td colspan="2" style="text-align: right;"><em>{{ 'sum'|_ }}:</em></td>
+ <td>{{ sum|formatAmount }}</td>
+ </tr>
+ </tfoot>
</table>
{{ journals.render|raw }}