mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Merge pull request #3420 from sephrat/fix#3409
Display account names only once when displaying split transactions
This commit is contained in:
commit
6191362fe0
@ -99,8 +99,9 @@ class ShowController extends Controller
|
|||||||
$transformer->setParameters(new ParameterBag);
|
$transformer->setParameters(new ParameterBag);
|
||||||
$groupArray = $transformer->transformObject($transactionGroup);
|
$groupArray = $transformer->transformObject($transactionGroup);
|
||||||
|
|
||||||
// do some amount calculations:
|
// do some calculations:
|
||||||
$amounts = $this->getAmounts($groupArray);
|
$amounts = $this->getAmounts($groupArray);
|
||||||
|
$accounts = $this->getAccounts($groupArray);
|
||||||
|
|
||||||
// make sure notes are escaped but not double escaped.
|
// make sure notes are escaped but not double escaped.
|
||||||
foreach ($groupArray['transactions'] as $index => $transaction) {
|
foreach ($groupArray['transactions'] as $index => $transaction) {
|
||||||
@ -127,7 +128,8 @@ class ShowController extends Controller
|
|||||||
'groupArray',
|
'groupArray',
|
||||||
'events',
|
'events',
|
||||||
'attachments',
|
'attachments',
|
||||||
'links'
|
'links',
|
||||||
|
'accounts',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -166,4 +168,31 @@ class ShowController extends Controller
|
|||||||
|
|
||||||
return $amounts;
|
return $amounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $group
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getAccounts(array $group): array
|
||||||
|
{
|
||||||
|
$accounts = [];
|
||||||
|
|
||||||
|
foreach ($group['transactions'] as $index => $transaction) {
|
||||||
|
$accounts['source'][] = [
|
||||||
|
'type' => $transaction['source_type'],
|
||||||
|
'id' => $transaction['source_id'],
|
||||||
|
'name' => $transaction['source_name'],
|
||||||
|
'iban' => $transaction['source_iban'] ];
|
||||||
|
$accounts['destination'][] = [
|
||||||
|
'type' => $transaction['destination_type'],
|
||||||
|
'id' => $transaction['destination_id'],
|
||||||
|
'name' => $transaction['destination_name'],
|
||||||
|
'iban' => $transaction['destination_iban'] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
$accounts['source'] = array_unique($accounts['source'], SORT_REGULAR);
|
||||||
|
$accounts['destination'] = array_unique($accounts['destination'], SORT_REGULAR);
|
||||||
|
return $accounts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,19 +82,19 @@
|
|||||||
{% if first.transactiontype.type != 'Withdrawal' or splits == 1 %}
|
{% if first.transactiontype.type != 'Withdrawal' or splits == 1 %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{ trans_choice('firefly.source_accounts', groupArray.transactions|length ) }}
|
{{ trans_choice('firefly.source_accounts', accounts['source']|length ) }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% for journal in groupArray.transactions %}
|
{% for account in accounts['source'] %}
|
||||||
{% if 'Cash account' == journal.source_type %}
|
{% if 'Cash account' == account.type %}
|
||||||
<span class="text-success">({{ 'cash'|_ }})</span>
|
<span class="text-success">({{ 'cash'|_ }})</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ route('accounts.show',journal.source_id) }}"
|
<a href="{{ route('accounts.show',account.id) }}"
|
||||||
title="{{ journal.source_iban|default(journal.source_name) }}">
|
title="{{ account.iban|default(account.name) }}">
|
||||||
{{ journal.source_name }}
|
{{ account.name }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if loop.index0 != groupArray.transactions|length -1 %}, {% endif %}
|
{% if loop.index0 != accounts['source']|length -1 %}, {% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -103,20 +103,20 @@
|
|||||||
{% if first.transactiontype.type != 'Deposit' or splits == 1 %}
|
{% if first.transactiontype.type != 'Deposit' or splits == 1 %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{ trans_choice('firefly.destination_accounts', groupArray.transactions|length ) }}
|
{{ trans_choice('firefly.destination_accounts', accounts['destination']|length ) }}
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% for journal in groupArray.transactions %}
|
{% for account in accounts['destination'] %}
|
||||||
{% if 'Cash account' == journal.destination_type %}
|
{% if 'Cash account' == account.type %}
|
||||||
<span class="text-success">({{ 'cash'|_ }})</span>
|
<span class="text-success">({{ 'cash'|_ }})</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ route('accounts.show',journal.destination_id) }}"
|
<a href="{{ route('accounts.show',account.id) }}"
|
||||||
title="{{ journal.destination_iban|default(journal.destination_name) }}">
|
title="{{ account.iban|default(account.name) }}">
|
||||||
{{ journal.destination_name }}
|
{{ account.name }}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if loop.index0 != groupArray.transactions|length -1 %}, {% endif %}
|
{% if loop.index0 != accounts['destination']|length -1 %}, {% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user