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 HasMany $query;
|
||||||
private ?int $startRow;
|
private ?int $startRow;
|
||||||
private array $stringFields;
|
private array $stringFields;
|
||||||
|
private array $booleanFields;
|
||||||
/*
|
/*
|
||||||
* This array is used to collect ALL tags the user may search for (using 'setTags').
|
* 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.
|
* 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->hasJoinedAttTables = false;
|
||||||
$this->expandGroupSearch = false;
|
$this->expandGroupSearch = false;
|
||||||
$this->hasJoinedMetaTables = false;
|
$this->hasJoinedMetaTables = false;
|
||||||
|
$this->booleanFields = ['balance_dirty'];
|
||||||
$this->integerFields = [
|
$this->integerFields = [
|
||||||
'transaction_group_id',
|
'transaction_group_id',
|
||||||
'user_id',
|
'user_id',
|
||||||
@@ -100,7 +101,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
'category_id',
|
'category_id',
|
||||||
'budget_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->total = 0;
|
||||||
$this->fields = [
|
$this->fields = [
|
||||||
// group
|
// group
|
||||||
@@ -131,6 +132,8 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
|
|
||||||
// currency info:
|
// currency info:
|
||||||
'source.amount as amount',
|
'source.amount as amount',
|
||||||
|
'source.balance_after as balance_after',
|
||||||
|
'source.balance_dirty as balance_dirty',
|
||||||
'source.native_amount as native_amount',
|
'source.native_amount as native_amount',
|
||||||
'source.transaction_currency_id as currency_id',
|
'source.transaction_currency_id as currency_id',
|
||||||
'currency.code as currency_code',
|
'currency.code as currency_code',
|
||||||
@@ -596,6 +599,9 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
// convert values to integers:
|
// convert values to integers:
|
||||||
$result = $this->convertToInteger($result);
|
$result = $this->convertToInteger($result);
|
||||||
|
|
||||||
|
// convert to boolean
|
||||||
|
$result = $this->convertToBoolean($result);
|
||||||
|
|
||||||
// convert back to strings because SQLite is dumb like that.
|
// convert back to strings because SQLite is dumb like that.
|
||||||
$result = $this->convertToStrings($result);
|
$result = $this->convertToStrings($result);
|
||||||
|
|
||||||
@@ -653,6 +659,15 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
return $array;
|
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
|
private function convertToStrings(array $array): array
|
||||||
{
|
{
|
||||||
foreach ($this->stringFields as $field) {
|
foreach ($this->stringFields as $field) {
|
||||||
|
@@ -145,6 +145,7 @@ class ShowController extends Controller
|
|||||||
$collector->setExpandGroupSearch(true);
|
$collector->setExpandGroupSearch(true);
|
||||||
$groups = $collector->getPaginatedGroups();
|
$groups = $collector->getPaginatedGroups();
|
||||||
|
|
||||||
|
|
||||||
Log::debug('End collect transactions');
|
Log::debug('End collect transactions');
|
||||||
Timer::stop('collection');
|
Timer::stop('collection');
|
||||||
|
|
||||||
|
@@ -43,6 +43,7 @@ return [
|
|||||||
'recurring_transaction' => 'Recurring transaction',
|
'recurring_transaction' => 'Recurring transaction',
|
||||||
'next_due' => 'Next due',
|
'next_due' => 'Next due',
|
||||||
'transaction_type' => 'Type',
|
'transaction_type' => 'Type',
|
||||||
|
'running_balance' => 'Running balance',
|
||||||
'lastActivity' => 'Last activity',
|
'lastActivity' => 'Last activity',
|
||||||
'balanceDiff' => 'Balance difference',
|
'balanceDiff' => 'Balance difference',
|
||||||
'other_meta_data' => 'Other meta data',
|
'other_meta_data' => 'Other meta data',
|
||||||
|
@@ -33,6 +33,9 @@
|
|||||||
<th class="hidden-xs"> </th>
|
<th class="hidden-xs"> </th>
|
||||||
<th>{{ trans('list.description') }}</th>
|
<th>{{ trans('list.description') }}</th>
|
||||||
<th>{{ trans('list.amount') }}</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.date') }}</th>
|
||||||
<th>{{ trans('list.source_account') }}</th>
|
<th>{{ trans('list.source_account') }}</th>
|
||||||
<th>{{ trans('list.destination_account') }}</th>
|
<th>{{ trans('list.destination_account') }}</th>
|
||||||
@@ -250,6 +253,13 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</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 }}">
|
<td style=" {{ style|raw }}">
|
||||||
{{ transaction.date.isoFormat(monthAndDayFormat) }}
|
{{ transaction.date.isoFormat(monthAndDayFormat) }}
|
||||||
</td>
|
</td>
|
||||||
|
Reference in New Issue
Block a user