firefly-iii/resources/views/transactions/show.twig
2022-03-27 20:33:25 +02:00

456 lines
27 KiB
Twig

{% extends './layout/default' %}
{% block breadcrumbs %}
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, transactionGroup) }}
{% endblock %}
{% block content %}
<div class="row">
<div class="col-lg-6">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ 'transaction_journal_information'|_ }}</h3>
<div class="btn-group btn-group-xs pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ 'actions'|_}} <span class="caret"></span>
</button>
<ul class="dropdown-menu">
{# edit + delete #}
<li><a href="{{ route('transactions.edit', [transactionGroup.id]) }}"><span class="fa fa-pencil"></span> {{ 'edit'|_ }}</a></li>
<li><a href="{{ route('transactions.delete', [transactionGroup.id]) }}"><span class="fa fa-trash"></span> {{ 'delete'|_ }}</a></li>
<li role="separator" class="divider"></li>
{# convert to different type #}
{% if groupArray.transactions[0].type != 'withdrawal' %}
<li><a href="{{ route('transactions.convert.index', ['withdrawal', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_withdrawal'|_ }}</a></li>
{% endif %}
{% if groupArray.transactions[0].type != 'deposit' %}
<li><a href="{{ route('transactions.convert.index', ['deposit', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_deposit'|_ }}</a></li>
{% endif %}
{% if groupArray.transactions[0].type != 'transfer' %}
<li><a href="{{ route('transactions.convert.index', ['transfer', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_transfer'|_ }}</a></li>
{% endif %}
{# clone #}
{% if groupArray.transactions[0].type != 'opening balance' and groupArray.transactions[0].type != 'reconciliation' %}
<li role="separator" class="divider"></li>
<li><a href="#" class="clone-transaction" data-id="{{ transactionGroup.id }}"><span class="fa fa-copy"></span> {{ 'clone'|_ }}</a></li>
{% endif %}
</ul>
</div>
</div>
<div class="box-body no-padding">
<table class="table table-hover">
<tbody>
<tr>
<td>{{ trans('list.type') }}</td>
<td>{{ first.transactiontype.type|_ }}</td>
</tr>
<tr>
<td>{{ trans('list.description') }}</td>
<td>
{% if splits == 1 %}
{{ first.description }}
{% else %}
{{ transactionGroup.title }}
{% endif %}
</td>
</tr>
<tr>
<td style="width:30%;">{{ trans('list.date') }}</td>
<td>
{{ first.date.isoFormat(dateTimeFormat) }}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ 'transaction_journal_meta'|_ }}</h3>
</div>
<div class="box-body no-padding">
<table class="table table-hover">
<tbody>
{% if first.transactiontype.type != 'Withdrawal' or splits == 1 %}
<tr>
<td>
{{ trans_choice('firefly.source_accounts', accounts['source']|length ) }}
</td>
<td>
{% for account in accounts['source'] %}
{% if 'Cash account' == account.type %}
<span class="text-success">({{ 'cash'|_ }})</span>
{% else %}
<a href="{{ route('accounts.show',account.id) }}"
title="{{ account.iban|default(account.name) }}">
{{ account.name }}
</a>
{% endif %}
{% if loop.index0 != accounts['source']|length -1 %}, {% endif %}
{% endfor %}
</td>
</tr>
{% endif %}
{% if first.transactiontype.type != 'Deposit' or splits == 1 %}
<tr>
<td>
{{ trans_choice('firefly.destination_accounts', accounts['destination']|length ) }}
</td>
<td>
{% for account in accounts['destination'] %}
{% if 'Cash account' == account.type %}
<span class="text-success">({{ 'cash'|_ }})</span>
{% else %}
<a href="{{ route('accounts.show',account.id) }}"
title="{{ account.iban|default(account.name) }}">
{{ account.name }}
</a>
{% endif %}
{% if loop.index0 != accounts['destination']|length -1 %}, {% endif %}
{% endfor %}
</td>
</tr>
{% endif %}
<tr>
<td style="width:30%;">{{ 'total_amount'|_ }}</td>
<td>
{% for amount in amounts %}
{% if first.transactiontype.type == 'Withdrawal' or first.transactiontype.type == 'Deposit' %}
{{ formatAmountBySymbol(amount.amount*-1,amount.symbol, amount.decimal_places) }}{% if loop.index0 != amounts|length -1 %}, {% endif %}
{% elseif first.transactiontype.type == 'Transfer' %}
<span class="text-info">
{{ formatAmountBySymbol(amount.amount, amount.symbol, amount.decimal_places, false) }}{% if loop.index0 != amounts|length -1 %}, {% endif %}
</span>
{% elseif first.transactiontype.type == 'Opening balance' %}
{# Opening balance stored amount is always negative: find out which way the money goes #}
{% if groupArray.transactions[0].source_type == 'Initial balance account' %}
{{ formatAmountBySymbol(amount.amount*-1,amount.symbol, amount.decimal_places) }}
{% else %}
{{ formatAmountBySymbol(amount.amount,amount.symbol, amount.decimal_places) }}
{% endif %}
{% endif %}
{% endfor %}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row">
</div>
{% if splits > 1 %}
<div class="row">
<div class="col-lg-12">
<h3>{{ 'splits'|_ }}</h3>
</div>
</div>
{% endif %}
{% set boxSize=6 %}
{% if(splits == 2) %}
{% set boxSize=6 %}
{% endif %}
{% if (splits > 2) %}
{% set boxSize = 4 %}
{% endif %}
<div class="row">
{% for index,journal in groupArray.transactions %}
<div class="col-lg-{{ boxSize }}">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
{{ journal.description }}
{% if journal.reconciled %}
<span class="fa fa-check"></span>
{% endif %}
{% if splits > 1 %}
<small>
{{ index+1 }} / {{ splits }}
</small>
{% endif %}
</h3>
<div class="btn-group btn-group-xs pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ 'actions'|_}} <span class="caret"></span>
</button>
<ul class="dropdown-menu">
{# edit + delete #}
<li><a href="{{ route('transactions.edit', [transactionGroup.id]) }}"><span class="fa fa-pencil"></span> {{ 'edit'|_ }}</a></li>
<li><a href="{{ route('transactions.delete', [transactionGroup.id]) }}"><span class="fa fa-trash"></span> {{ 'delete'|_ }}</a></li>
<li role="separator" class="divider"></li>
{# convert to different type #}
{% if groupArray.transactions[0].type != 'withdrawal' %}
<li><a href="{{ route('transactions.convert.index', ['withdrawal', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_withdrawal'|_ }}</a></li>
{% endif %}
{% if groupArray.transactions[0].type != 'deposit' %}
<li><a href="{{ route('transactions.convert.index', ['deposit', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_deposit'|_ }}</a></li>
{% endif %}
{% if groupArray.transactions[0].type != 'transfer' %}
<li><a href="{{ route('transactions.convert.index', ['transfer', transactionGroup.id]) }}"><span class="fa fa-exchange"></span> {{ 'convert_to_transfer'|_ }}</a></li>
{% endif %}
{# clone #}
{% if groupArray.transactions[0].type != 'opening balance' and groupArray.transactions[0].type != 'reconciliation' %}
<li role="separator" class="divider"></li>
<li><a href="#" data-id="{{ transactionGroup.id }}" class="clone-transaction"><span class="fa fa-copy"></span> {{ 'clone'|_ }}</a></li>
{% endif %}
<li><a href="#" class="link-modal" data-journal="{{ journal.transaction_journal_id }}"><span class="fa fa-fw fa-link"></span>{{ 'link_transaction'|_ }}</a></li>
<li role="separator" class="divider"></li>
<li><a href="{{ route('rules.create-from-journal', [journal.transaction_journal_id]) }}"><span class="fa fa-fw fa-random"></span>{{ 'create_rule_from_transaction'|_ }}</a></li>
<li><a href="{{ route('recurring.create-from-journal', [journal.transaction_journal_id]) }}"><span class="fa fa-fw fa-paint-brush"></span>{{ 'create_recurring_from_transaction'|_ }}</a></li>
</ul>
</div>
</div>
<div class="box-body no-padding">
<table class="table">
<tr>
<td colspan="2">
<!-- type is: "{{ first.transactiontype.type }}" -->
{% if 'Cash account' == journal.source_type %}
<span class="text-success">({{ 'cash'|_ }})</span>
{% else %}
<a href="{{ route('accounts.show', journal.source_id) }}"
title="{{ journal.source_iban|default(journal.source_name) }}">{{ journal.source_name }}</a> &rarr;
{% endif %}
{% if first.transactiontype.type == 'Withdrawal' or first.transactiontype.type == 'Deposit' %}
{{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places) }}
{% elseif first.transactiontype.type == 'Transfer' or first.transactiontype.type == 'Opening balance' %}
<span class="text-info">
{{ formatAmountBySymbol(journal.amount, journal.currency_symbol, journal.currency_decimal_places, false) }}
</span>
{% elseif first.transactiontype.type == 'Liability credit' %}
<span class="text-info">
{{ formatAmountBySymbol(journal.amount*-1, journal.currency_symbol, journal.currency_decimal_places, false) }}
</span>
{% endif %}
<!-- do foreign amount -->
{% if null != journal.foreign_amount %}
{% if first.transactiontype.type == 'Withdrawal' or first.transactiontype.type == 'Deposit' %}
({{ formatAmountBySymbol(journal.foreign_amount*-1, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }})
{% elseif first.transactiontype.type == 'Transfer' %}
<span class="text-info">
({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places, false) }})
</span>
{% endif %}
{% endif %}
&rarr;
{% if 'Cash account' == journal.destination_type %}
<span class="text-success">({{ 'cash'|_ }})</span>
{% else %}
<a href="{{ route('accounts.show', journal.destination_id) }}"
title="{{ journal.destination_iban|default(journal.destination_name) }}">{{ journal.destination_name }}</a>
{% endif %}
</td>
</tr>
{% if null != journal.category_id %}
<tr>
<td style="width:30%;">{{ 'category'|_ }}</td>
<td><a href="{{ route('categories.show', [journal.category_id]) }}">{{ journal.category_name }}</a></td>
</tr>
{% endif %}
{% if null != journal.budget_id and first.transactiontype.type == 'Withdrawal' %}
<tr>
<td>{{ 'budget'|_ }}</td>
<td><a href="{{ route('budgets.show', [journal.budget_id]) }}">{{ journal.budget_name }}</a></td>
</tr>
{% endif %}
{% if null != journal.bill_id and first.transactiontype.type == 'Withdrawal' %}
<tr>
<td>{{ 'bill'|_ }}</td>
<td><a href="{{ route('bills.show', [journal.bill_id]) }}">{{ journal.bill_name }}</a></td>
</tr>
{% endif %}
<!-- other fields -->
{% for dateField in ['interest_date','book_date','process_date','due_date','payment_date','invoice_date'] %}
{% if journalHasMeta(journal.transaction_journal_id, dateField) %}
<tr>
<td>{{ trans('list.'~dateField) }}</td>
<td>{{ journalGetMetaDate(journal.transaction_journal_id, dateField).isoFormat(monthAndDayFormat) }}</td>
</tr>
{% endif %}
{% endfor %}
{% for metaField in ['external_id','bunq_payment_id','internal_reference','sepa_batch_id','sepa_ct_id','sepa_ct_op','sepa_db','sepa_country','sepa_cc','sepa_ep','sepa_ci','external_url'] %}
{% if journalHasMeta(journal.transaction_journal_id, metaField) %}
<tr>
<td>{{ trans('list.'~metaField) }}</td>
<td>
{% if 'external_url' == metaField %}
{% set uri = journalGetMetaField(journal.transaction_journal_id, metaField) %}
<a href="{{ uri }}" rel="noopener noreferrer nofollow" target="_blank">
{% if uri|length > 60 %}
{{ uri|slice(0, 60) ~ '...' }}
{% else %}
{{ uri }}
{% endif %}
</a>
{% endif %}
{% if 'external_url' != metaField %}
{{ journalGetMetaField(journal.transaction_journal_id, metaField) }}
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
{% if null != journal.notes and '' != journal.notes %}
<tr>
<td>{{ trans('list.notes') }}</td>
<td class="markdown">{{ journal.notes|default('')|markdown }}</td>
</tr>
{% endif %}
{% if journalHasMeta(journal.transaction_journal_id, 'recurring_total') and journalHasMeta(journal.transaction_journal_id, 'recurring_count') %}
{% set recurringTotal = journalGetMetaField(journal.transaction_journal_id, 'recurring_total') %}
{% if 0 == recurringTotal %}
{% set recurringTotal = '∞' %}
{% endif %}
<tr>
<td>{{ trans('list.recurring_transaction') }}</td>
<td>{{ trans('firefly.recurring_info', {total: recurringTotal, count: journalGetMetaField(journal.transaction_journal_id, 'recurring_count') }) }}</td>
</tr>
{% endif %}
{% if journal.tags|length > 0 %}
<tr>
<td>{{ 'tags'|_ }}</td>
<td>
{% for tag in journal.tags %}
<h4 style="display: inline;"><a class="label label-success" href="{{ route('tags.show', tag.id) }}">
<span class="fa fa-fw fa-tag"></span>{{ tag.tag }}</a>
</h4>
{% endfor %}
</td>
</tr>
{% endif %}
</table>
</div>
</div>
<!-- Transaction links -->
{% if links[journal.transaction_journal_id]|length > 0 %}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
{{ 'journal_links'|_ }}
</h3>
</div>
<div class="box-body no-padding">
<table class="table">
{% for link in links[journal.transaction_journal_id] %}
<tr>
<td style="width:120px;">
<div class="btn-group btn-group-xs">
<a href="#" class="btn btn-default switch-link" data-id="{{ link.id }}"><span
class="fa fa-fw fa-arrows-h"></span></a>
<a href="{{ route('transactions.link.delete', [link.id]) }}" class="btn btn-danger"><span class="fa fa-trash"></span></a>
</div>
</td>
<td>
{% if link.editable %}
{{ link.link }}
{% else %}
{{ trans('firefly.'~link.link) }}
{% endif %}
"<a href="{{ route('transactions.show', link.group) }}"
title="{{ link.description }}">{{ link.description }}</a>"
({{ link.amount|raw }})
{% if '' != link.foreign_amount %}
({{ link.foreign_amount|raw }})
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endif %}
<!-- Attachments -->
{% if attachments[journal.transaction_journal_id]|length > 0 %}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'attachments'|_ }}</h3>
</div>
<div class="box-body no-padding">
{% include 'list.attachments' with {attachments: attachments[journal.transaction_journal_id]} %}
</div>
</div>
{% endif %}
<!-- Piggy bank events -->
{% if events[journal.transaction_journal_id]|length > 0 %}
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'piggy_events'|_ }}</h3>
</div>
<div class="box-body no-padding">
<table class="table table-hover">
{% for event in events[journal.transaction_journal_id] %}
<tr>
<td style="width:30%;">{{ event.amount|raw }}</td>
<td>
<a href="{{ route('piggy-banks.show', [event.piggy_id]) }}">{{ event.piggy }}</a></td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endif %}
</div>
{% endfor %}
</div>
{# modal for linking journals. Will be filled by AJAX #}
<div class="modal fade" tabindex="-1" role="dialog" id="linkJournalModal">
</div>
{% endblock %}
{% block scripts %}
<script type="text/javascript" nonce="{{ JS_NONCE }}">
var modalDialogURI = '{{ route('transactions.link.modal', ['%JOURNAL%']) }}';
var acURI = '{{ route('api.v1.autocomplete.transactions-with-id') }}';
var groupURI = '{{ route('transactions.show',['%GROUP%']) }}';
var cloneGroupUrl = '{{ route('transactions.clone') }}';
$('.switch-link').on('click', switchLink);
var switchLinkUrl = '{{ route('transactions.link.switch') }}';
function switchLink(e) {
e.preventDefault();
var obj = $(e.currentTarget);
$.post(switchLinkUrl, {
_token: token,
id: obj.data('id')
}).done(function () {
location.reload();
}).fail(function () {
console.error('I failed :(');
});
//alert(obj.data('id'));
return false
}
</script>
<script type="text/javascript" src="v1/js/lib/typeahead/typeahead.bundle.min.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/ff/transactions/show.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
{% endblock %}