diff --git a/app/Helpers/Collector/Extensions/CollectorProperties.php b/app/Helpers/Collector/Extensions/CollectorProperties.php index 81aa7fca10..cfa3a5f78d 100644 --- a/app/Helpers/Collector/Extensions/CollectorProperties.php +++ b/app/Helpers/Collector/Extensions/CollectorProperties.php @@ -55,6 +55,7 @@ trait CollectorProperties private HasMany $query; private ?int $startRow; private array $stringFields; + private array $booleanFields; /* * This array is used to collect ALL tags the user may search for (using 'setTags'). * This way the user can call 'setTags' multiple times and get a joined result. diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php index 7d090996a7..a9e9b31984 100644 --- a/app/Helpers/Collector/GroupCollector.php +++ b/app/Helpers/Collector/GroupCollector.php @@ -82,6 +82,7 @@ class GroupCollector implements GroupCollectorInterface $this->hasJoinedAttTables = false; $this->expandGroupSearch = false; $this->hasJoinedMetaTables = false; + $this->booleanFields = ['balance_dirty']; $this->integerFields = [ 'transaction_group_id', 'user_id', @@ -100,7 +101,7 @@ class GroupCollector implements GroupCollectorInterface 'category_id', 'budget_id', ]; - $this->stringFields = ['amount', 'foreign_amount', 'native_amount', 'native_foreign_amount']; + $this->stringFields = ['amount', 'foreign_amount', 'native_amount', 'native_foreign_amount','balance_after']; $this->total = 0; $this->fields = [ // group @@ -131,6 +132,8 @@ class GroupCollector implements GroupCollectorInterface // currency info: 'source.amount as amount', + 'source.balance_after as balance_after', + 'source.balance_dirty as balance_dirty', 'source.native_amount as native_amount', 'source.transaction_currency_id as currency_id', 'currency.code as currency_code', @@ -596,6 +599,9 @@ class GroupCollector implements GroupCollectorInterface // convert values to integers: $result = $this->convertToInteger($result); + // convert to boolean + $result = $this->convertToBoolean($result); + // convert back to strings because SQLite is dumb like that. $result = $this->convertToStrings($result); @@ -653,6 +659,15 @@ class GroupCollector implements GroupCollectorInterface return $array; } + private function convertToBoolean(array $array): array + { + foreach ($this->booleanFields as $field) { + $array[$field] = array_key_exists($field, $array) ? (bool) $array[$field] : null; + } + + return $array; + } + private function convertToStrings(array $array): array { foreach ($this->stringFields as $field) { diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php index 8a602f59e4..7aec7bc667 100644 --- a/app/Http/Controllers/Account/ShowController.php +++ b/app/Http/Controllers/Account/ShowController.php @@ -145,6 +145,7 @@ class ShowController extends Controller $collector->setExpandGroupSearch(true); $groups = $collector->getPaginatedGroups(); + Log::debug('End collect transactions'); Timer::stop('collection'); diff --git a/resources/lang/en_US/list.php b/resources/lang/en_US/list.php index e367b63a4d..87462ea466 100644 --- a/resources/lang/en_US/list.php +++ b/resources/lang/en_US/list.php @@ -43,6 +43,7 @@ return [ 'recurring_transaction' => 'Recurring transaction', 'next_due' => 'Next due', 'transaction_type' => 'Type', + 'running_balance' => 'Running balance', 'lastActivity' => 'Last activity', 'balanceDiff' => 'Balance difference', 'other_meta_data' => 'Other meta data', diff --git a/resources/views/list/groups.twig b/resources/views/list/groups.twig index c3e4606881..bb228c71a9 100644 --- a/resources/views/list/groups.twig +++ b/resources/views/list/groups.twig @@ -33,6 +33,9 @@   {{ trans('list.description') }} {{ trans('list.amount') }} + {% if config('firefly.feature_flags.running_balance_column') %} + {{ trans('list.running_balance') }} + {% endif %} {{ trans('list.date') }} {{ trans('list.source_account') }} {{ trans('list.destination_account') }} @@ -250,6 +253,13 @@ {% endif %} {% endif %} + {% if config('firefly.feature_flags.running_balance_column') %} + + {% if null == transaction.balance_dirty or false == transaction.balance_dirty %} + {{ formatAmountBySymbol(transaction.balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }} + {% endif %} + + {% endif %} {{ transaction.date.isoFormat(monthAndDayFormat) }}