Skip to content

Firefly III: a personal finances manager

Fix running balance

James Cole76e893f86ee9
diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php
index 97387b0588..250face3da 100644
--- a/app/Helpers/Collector/GroupCollector.php
+++ b/app/Helpers/Collector/GroupCollector.php
@@ -101,7 +101,7 @@ class GroupCollector implements GroupCollectorInterface
'category_id',
'budget_id',
];
- $this->stringFields = ['amount', 'foreign_amount', 'native_amount', 'native_foreign_amount', 'balance_after'];
+ $this->stringFields = ['amount', 'foreign_amount', 'native_amount', 'native_foreign_amount','source_balance_after','destination_balance_after'];
$this->total = 0;
$this->fields = [
// group
@@ -132,7 +132,7 @@ class GroupCollector implements GroupCollectorInterface
// currency info:
'source.amount as amount',
- 'source.balance_after as balance_after',
+ 'source.balance_after as source_balance_after',
'source.balance_dirty as balance_dirty',
'source.native_amount as native_amount',
'source.transaction_currency_id as currency_id',
@@ -152,6 +152,7 @@ class GroupCollector implements GroupCollectorInterface
// destination account info (always present)
'destination.account_id as destination_account_id',
+ 'destination.balance_after as destination_balance_after',
];
}
diff --git a/resources/views/list/groups.twig b/resources/views/list/groups.twig
index bb228c71a9..0bd2df088e 100644
--- a/resources/views/list/groups.twig
+++ b/resources/views/list/groups.twig
@@ -256,7 +256,19 @@
{% if config('firefly.feature_flags.running_balance_column') %}
<td>
{% if null == transaction.balance_dirty or false == transaction.balance_dirty %}
- {{ formatAmountBySymbol(transaction.balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
+ {% if transaction.transaction_type_type == 'Deposit' %}
+ {{ formatAmountBySymbol(transaction.destination_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
+ {% elseif transaction.transaction_type_type == 'Withdrawal' %}
+ {{ formatAmountBySymbol(transaction.source_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
+ {% elseif transaction.transaction_type_type == 'Opening balance' %}
+ {% if transaction.source_account_type == 'Initial balance account' %}
+ {{ formatAmountBySymbol(transaction.destination_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
+ {% else %}
+ {{ formatAmountBySymbol(transaction.source_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
+ {% endif %}
+ {% else %}
+ &nbsp;
+ {% endif %}
{% endif %}
</td>
{% endif %}