Improve view for transactions.

This commit is contained in:
James Cole
2018-03-11 14:09:44 +01:00
parent a9870b35be
commit c2dfbcba10
4 changed files with 103 additions and 158 deletions

View File

@@ -88,10 +88,13 @@
{{ journal|journalTotalAmount }}
{# if more transactions, list each one: #}
{% if transactions|length > 1 %}
({% for transaction in transactions %}{{ transaction|transactionArrayAmount }}{% if loop.index != loop.length %}, {% endif %}{% endfor %})
{% endif %}
{% if transactions|length > 2 %}
({% for transaction in transactions %}
{{ transaction|transactionArrayAmount }}
{% if loop.index != loop.length %}, {% endif %}
{% endfor %})
{% endif %}
</td>
</tr>
<tr>
@@ -366,64 +369,73 @@
<div class="box-header with-border">
<h3 class="box-title">{{ 'transactions'|_ }}</h3>
</div>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="hidden-md hidden-sm hidden-xs">{{ trans('list.description') }}</th>
<th>{{ trans('list.source_account') }}</th>
<th class="hidden-sm hidden-xs">&#916;</th>
<th>{{ trans('list.destination_account') }}</th>
<th class="hidden-sm hidden-xs">&#916;</th>
<th>{{ trans('list.amount') }}</th>
<th class="hidden-md hidden-xs">{{ trans('list.budget') }}</th>
<th class="hidden-md hidden-xs">{{ trans('list.category') }}</th>
</tr>
</thead>
<tbody>
{% for transaction in transactions %}
<div class="box-body no-padding">
<table class="table table-bordered table-striped">
<thead>
<tr>
<td class="hidden-md hidden-sm hidden-xs">
{% if transaction.description == "" %}
{{ journal.description }}
{% else %}
{{ transaction.description }}
{% endif %}
</td>
<td>
{% if transaction.source_account_type == 'Cash account' %}
<span class="text-success">({{ 'cash'|_ }})</span>
{% else %}
<a href="{{ route('accounts.show', transaction.source_account_id) }}">{{ transaction.source_account_name }}</a>
{% endif %}
</td>
<td class="hidden-sm hidden-xs">
{{ formatSourceBefore(transaction) }} &rarr; {{ formatSourceAfter(transaction) }}
</td>
<td>
{% if transaction.destination_account_type == 'Cash account' %}
<span class="text-success">({{ 'cash'|_ }})</span>
{% else %}
<a href="{{ route('accounts.show', transaction.destination_account_id) }}">{{ transaction.destination_account_name }}</a>
{% endif %}
</td>
<td class="hidden-sm hidden-xs">
{{ formatDestinationBefore(transaction) }} &rarr; {{ formatDestinationAfter(transaction) }}
</td>
<td>
{{ transaction|transactionArrayAmount }}
</td>
<td class="hidden-md hidden-xs">
{{ transaction.source|transactionBudgets }}
</td>
<td class="hidden-md hidden-xs">
{{ transaction.source|transactionCategories }}
</td>
<th class="hidden-md hidden-sm hidden-xs">{{ trans('list.description') }}</th>
<th>{{ trans('list.source_account') }}</th>
<th>{{ trans('list.destination_account') }}</th>
<th>{{ trans('list.amount') }}</th>
<th class="hidden-md hidden-xs">{{ trans('list.budget') }}</th>
<th class="hidden-md hidden-xs">{{ trans('list.category') }}</th>
</tr>
{% endfor %}
</tbody>
</table>
</thead>
<tbody>
{% set maxIdentifier = ((transactions|length) / 2) -1 %}
{% for x in 0..maxIdentifier %}
<tr>
{# loop each transaction in the array.#}
{% for transaction in transactions %}
{% if
((transaction.type == 'Withdrawal') and transaction.identifier == x and transaction.amount < 0)
or
((transaction.type == 'Deposit' or transaction.type == 'Transfer') and transaction.identifier == x and transaction.amount > 0)
%}
<td class="hidden-md hidden-sm hidden-xs">
{% if transaction.description == "" %}
{{ journal.description }}
{% else %}
{{ transaction.description }}
{% endif %}
</td>
<td>
{% if transaction.source_type == 'Cash account' %}
<span class="text-success">({{ 'cash'|_ }})</span>
{% else %}
<a href="{{ route('accounts.show', transaction.source_id) }}">{{ transaction.source_name }}</a>
{% endif %}
</td>
<td>
{% if transaction.destination_type == 'Cash account' %}
<span class="text-success">({{ 'cash'|_ }})</span>
{% else %}
<a href="{{ route('accounts.show', transaction.destination_id) }}">{{ transaction.destination_name }}</a>
{% endif %}
</td>
<td>
{{ transaction|transactionArrayAmount }}
</td>
<td class="hidden-md hidden-xs">
{% if transaction.budget_id %}
<a href="{{ route('budgets.show', transaction.budget_id) }}" title="{{ transaction.budget_name }}">{{ transaction.budget_name }}</a>
{% endif %}
</td>
<td class="hidden-md hidden-xs">
{% if transaction.category_id %}
<a href="{{ route('categories.show', transaction.category_id) }}" title="{{ transaction.category_name }}">{{ transaction.category_name }}</a>
{% endif %}
</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>