mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 07:34:43 +00:00
Add running balance column.
This commit is contained in:
@@ -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.
|
||||
|
@@ -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) {
|
||||
|
@@ -145,6 +145,7 @@ class ShowController extends Controller
|
||||
$collector->setExpandGroupSearch(true);
|
||||
$groups = $collector->getPaginatedGroups();
|
||||
|
||||
|
||||
Log::debug('End collect transactions');
|
||||
Timer::stop('collection');
|
||||
|
||||
|
@@ -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',
|
||||
|
@@ -33,6 +33,9 @@
|
||||
<th class="hidden-xs"> </th>
|
||||
<th>{{ trans('list.description') }}</th>
|
||||
<th>{{ trans('list.amount') }}</th>
|
||||
{% if config('firefly.feature_flags.running_balance_column') %}
|
||||
<th>{{ trans('list.running_balance') }}</th>
|
||||
{% endif %}
|
||||
<th>{{ trans('list.date') }}</th>
|
||||
<th>{{ trans('list.source_account') }}</th>
|
||||
<th>{{ trans('list.destination_account') }}</th>
|
||||
@@ -250,6 +253,13 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% 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) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
<td style=" {{ style|raw }}">
|
||||
{{ transaction.date.isoFormat(monthAndDayFormat) }}
|
||||
</td>
|
||||
|
Reference in New Issue
Block a user