firefly-iii/resources/views/v1/transactions/convert.twig
2019-11-25 18:41:40 +01:00

299 lines
22 KiB
Twig

{% extends "./layout/default" %}
{% block breadcrumbs %}
{{ Breadcrumbs.render(Route.getCurrentRoute.getName, group, groupTitle) }}
{% endblock %}
{% block content %}
<form method="POST" action="{{ route('transactions.convert.index.post', [destinationType.type|lower, group.id]) }}" accept-charset="UTF-8"
class="form-horizontal"
enctype="multipart/form-data">
<input name="_token" type="hidden" value="{{ csrf_token() }}">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-12 col-sm-12">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">{{ ('convert_options_'~sourceType.type~destinationType.type)|_ }}</h3>
</div>
<div class="box-body">
<p>
{# ONE: WITHDRAWAL TO DEPOSIT #}
{% if sourceType.type == 'Withdrawal' and destinationType.type == 'Deposit' %}
{{ 'convert_expl_w_d'|_ }}
{% endif %}
{# TWO: WITHDRAWAL TO TRANSFER #}
{% if sourceType.type == 'Withdrawal' and destinationType.type == 'Transfer' %}
{{ 'convert_expl_w_t'|_ }}
{% endif %}
{# THREE: DEPOSIT TO WITHDRAWAL #}
{% if sourceType.type == 'Deposit' and destinationType.type == 'Withdrawal' %}
{{ 'convert_expl_d_w'|_ }}
{% endif %}
{# FOUR: DEPOSIT TO TRANSFER#}
{% if sourceType.type == 'Deposit' and destinationType.type == 'Transfer' %}
{{ 'convert_expl_d_t'|_ }}
{% endif %}
{# FIVE: TRANSFER TO WITHDRAWAL #}
{% if sourceType.type == 'Transfer' and destinationType.type == 'Withdrawal' %}
{{ 'convert_expl_t_w'|_ }}
{% endif %}
{# SIX: TRANSFER TO DEPOSIT #}
{% if sourceType.type == 'Transfer' and destinationType.type == 'Deposit' %}
{{ 'convert_expl_t_d'|_ }}
{% endif %}
</p>
<table class="table">
<tr>
<th style="width:10%;">ID</th>
<th style="width:25%;">Description</th>
<th style="width:25%;">Source account</th>
<th style="width:25%;">Destination account</th>
<th style="width:15%;">Amount</th>
</tr>
{% for transaction in groupArray.transactions %}
<tr>
<td>#{{ transaction.transaction_journal_id }}</td>
<td>{{ transaction.description }}</td>
<td>
{# ONE: WITHDRAWAL TO DEPOSIT #}
{% if sourceType.type == 'Withdrawal' and destinationType.type == 'Deposit' %}
{# NEW DESTINATION = Asset, SOURCE MUST BE [Revenue, Cash, Loan, Debt, Mortgage] #}
{% if
transaction.source_type == 'Asset account' %}
{{ Form.select('source_id['~transaction.transaction_journal_id~']', validDepositSources, null, {class: 'form-control'}) }}
{% endif %}
{# NEW DESTINATION = [Loan, Debt, Mortgage], SOURCE MUST BE [Revenue] #}
{% if
transaction.source_type == 'Loan' or
transaction.source_type == 'Debt' or
transaction.source_type == 'Mortgage' %}
<input
autocomplete="off"
placeholder="Source account"
name="source_name[{{ transaction.transaction_journal_id }}]"
type="text"
value="{% if transaction.destination_type != "Cash account" %}{{ preFilled.source_name[transaction.transaction_journal_id]|default(transaction.destination_name) }}{% endif %}"
class="form-control tt-input input-revenue"
spellcheck="false" dir="auto">
{% endif %}
{% endif %}
{# TWO: WITHDRAWAL TO TRANSFER #}
{% if sourceType.type == 'Withdrawal' and destinationType.type == 'Transfer' %}
<a href="{{ route('accounts.show', [transaction.source_id]) }}"
title="{{ transaction.source_iban|default(transaction.source_name) }}">{{ transaction.source_name }}</a>
{# hide source in hidden input #}
<input type="hidden" name="source_id[{{ transaction.transaction_journal_id }}]" value="{{ transaction.source_id }}">
{% endif %}
{# THREE: DEPOSIT TO WITHDRAWAL #}
{% if sourceType.type == 'Deposit' and destinationType.type == 'Withdrawal' %}
<a href="{{ route('accounts.show', [transaction.destination_id]) }}"
title="{{ transaction.destination_iban|default(transaction.destination_name) }}">{{ transaction.destination_name }}</a>
{# hide new source in hidden input #}
<input type="hidden" name="source_id[{{ transaction.transaction_journal_id }}]" value="{{ transaction.destination_id }}">
{% endif %}
{# FOUR: DEPOSIT TO TRANSFER#}
{% if sourceType.type == 'Deposit' and destinationType.type == 'Transfer' %}
{# if new destination is asset, then asset#}
{% if transaction.destination_type == 'Asset account' %}
{{ Form.select('source_id['~transaction.transaction_journal_id~']', assets,null, {class: 'form-control'}) }}
{% endif %}
{% if transaction.destination_type == 'Loan' or
transaction.destination_type == 'Debt' or
transaction.destination_type == 'Mortgage' %}
{{ Form.select('source_id['~transaction.transaction_journal_id~']', liabilities,null, {class: 'form-control'}) }}
{% endif %}
{# if new destination liability, then liability.#}
{% endif %}
{# FIVE: TRANSFER TO WITHDRAWAL #}
{% if sourceType.type == 'Transfer' and destinationType.type == 'Withdrawal' %}
<a href="{{ route('accounts.show', [transaction.source_id]) }}"
title="{{ transaction.source_iban|default(transaction.source_name) }}">{{ transaction.source_name }}</a>
{# hide source in hidden input #}
<input type="hidden" name="source_id[{{ transaction.transaction_journal_id }}]" value="{{ transaction.source_id }}">
{% endif %}
{# SIX: TRANSFER TO DEPOSIT #}
{% if sourceType.type == 'Transfer' and destinationType.type == 'Deposit' %}
{# NEW DESTINATION = Asset, SOURCE MUST BE [Revenue, Cash, Loan, Debt, Mortgage] #}
{% if
transaction.source_type == 'Asset account' %}
{{ Form.select('source_id['~transaction.transaction_journal_id~']', validDepositSources, null, {class: 'form-control'}) }}
{% endif %}
{# NEW DESTINATION = [Debt, Mortgage, Load], SOURCE MUST BE [Revenue] #}
{% if
transaction.source_type == 'Loan' or
transaction.source_type == 'Debt' or
transaction.source_type == 'Mortgage' %}
<input
autocomplete="off"
placeholder="Source account"
name="source_name[{{ transaction.transaction_journal_id }}]"
type="text"
value="{% if transaction.destination_type != "Cash account" %}{{ transaction.source_name }}{% endif %}"
class="form-control tt-input"
spellcheck="false" dir="auto">
{% endif %}
{% endif %}
</td>
<td>
{# ONE: WITHDRAWAL TO DEPOSIT #}
{% if sourceType.type == 'Withdrawal' and destinationType.type == 'Deposit' %}
<a href="{{ route('accounts.show', [transaction.source_id]) }}"
title="{{ transaction.source_iban|default(transaction.source_name) }}">{{ transaction.source_name }}</a>
{# hide destination in hidden input #}
<input type="hidden" name="destination_id[{{ transaction.transaction_journal_id }}]" value="{{ transaction.source_id }}">
{% endif %}
{# TWO: WITHDRAWAL TO TRANSFER #}
{% if sourceType.type == 'Withdrawal' and destinationType.type == 'Transfer' %}
{#if the source is a liability, destination must also be a liability.#}
{% if
transaction.source_type == 'Loan' or
transaction.source_type == 'Debt' or
transaction.source_type == 'Mortgage' %}
{{ Form.select('destination_id['~transaction.transaction_journal_id~']', liabilities, null, {class: 'form-control'}) }}
{% endif %}
{# if the source is an asset, destination can only be an asset. #}
{% if transaction.source_type == 'Asset account' %}
{{ Form.select('destination_id['~transaction.transaction_journal_id~']', assets, null, {class: 'form-control'}) }}
{% endif %}
{% endif %}
{# THREE: DEPOSIT TO WITHDRAWAL #}
{% if sourceType.type == 'Deposit' and destinationType.type == 'Withdrawal' %}
{# if new source is Asset, destination must be [Expense, Loan, Debt or Mortgage] #}
{% if transaction.destination_type == 'Asset account' %}
{{ Form.select('destination_id['~transaction.transaction_journal_id~']', validWithdrawalDests, null, {class: 'form-control'}) }}
{% endif %}
{% if transaction.destination_type == 'Loan' or
transaction.destination_type == 'Debt' or
transaction.destination_type == 'Mortgage' %}
{# if new source is Liability, destination must be expense account. #}
<input
autocomplete="off"
placeholder="Destination account"
name="destination_name[{{ transaction.transaction_journal_id }}]"
type="text"
value="{% if transaction.source_type != "Cash account" %}{{ transaction.source_name }}{% endif %}"
class="form-control tt-input"
spellcheck="false" dir="auto">
{% endif %}
{% endif %}
{# FOUR: DEPOSIT TO TRANSFER#}
{% if sourceType.type == 'Deposit' and destinationType.type == 'Transfer' %}
<a href="{{ route('accounts.show', [transaction.destination_id]) }}"
title="{{ transaction.destination_iban|default(transaction.destination_name) }}">{{ transaction.destination_name }}</a>
{# hide destination in hidden input #}
<input type="hidden" name="destination_id[{{ transaction.transaction_journal_id }}]" value="{{ transaction.destination_id }}">
{% endif %}
{# FIVE: TRANSFER TO WITHDRAWAL #}
{% if sourceType.type == 'Transfer' and destinationType.type == 'Withdrawal' %}
{% if transaction.source_type == 'Asset account' %}
{{ Form.select('destination_id['~transaction.transaction_journal_id~']', validWithdrawalDests, null, {class: 'form-control'}) }}
{% endif %}
{% if transaction.source_type == 'Loan' or
transaction.source_type == 'Debt' or
transaction.source_type == 'Mortgage' %}
<input
autocomplete="off"
placeholder="Destination account"
name="destination_name[{{ transaction.transaction_journal_id }}]"
type="text"
value="{% if transaction.source_type != "Cash account" %}{{ transaction.destination_name }}{% endif %}"
class="form-control tt-input"
spellcheck="false" dir="auto">
{% endif %}
{% endif %}
{# SIX: TRANSFER TO DEPOSIT #}
{% if sourceType.type == 'Transfer' and destinationType.type == 'Deposit' %}
<a href="{{ route('accounts.show', [transaction.destination_id]) }}"
title="{{ transaction.destination_iban|default(transaction.destination_name) }}">{{ transaction.destination_name }}</a>
{# hide destination in hidden input #}
<input type="hidden" name="destination_id[{{ transaction.transaction_journal_id }}]" value="{{ transaction.destination_id }}">
{% endif %}
</td>
<td>
{% if transaction.transaction_type_type == 'Deposit' %}
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}
{% if null != transaction.foreign_amount %}
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
{% endif %}
{% elseif transaction.transaction_type_type == 'Transfer' %}
<span class="text-info">{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}
{% if null != transaction.foreign_amount %}
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})
{% endif %}</span>
{% else %}
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
{% if null != transaction.foreign_amount %}
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
</table>
{# in case of withdrawal #}
{% if sourceType.type == "Withdrawal" %}
{{ ExpandedForm.staticText('source_account_asset', '<a href="'~route('accounts.show',[sourceAccount.id])~'">'~sourceAccount.name|escape~'</a>') }}
{# if destination is cash, show (cash) #}
{% if destinationAccount.accountType.type == "Cash account" %}
{{ ExpandedForm.staticText('destination_account_expense', '<span class="text-success">(cash)</a>') }}
{% else %}
{{ ExpandedForm.staticText('destination_account_expense', '<a href="'~route('accounts.show',[destinationAccount.id])~'">'~destinationAccount.name|escape~'</a>') }}
{% endif %}
{% endif %}
{# in case of transfer #}
{% if sourceType.type == "Transfer" %}
{{ ExpandedForm.staticText('source_account_asset', '<a href="'~route('accounts.show',[sourceAccount.id])~'">'~sourceAccount.name|escape~'</a>') }}
{{ ExpandedForm.staticText('destination_account_asset', '<a href="'~route('accounts.show',[destinationAccount.id])~'">'~destinationAccount.name|escape~'</a>') }}
{% endif %}
</div>
<div class="box-footer">
<a href="{{ route('transactions.show', group.id) }}" class="btn btn-danger">{{ 'cancel'|_ }}</a>
<button type="submit" id="transaction-btn" class="btn btn-success pull-right">
{{ trans('form.convert_'~sourceType.type) }}
</button>
</div>
</div>
</div>
</div>
</form>
{% endblock %}
{% block scripts %}
<script type="text/javascript" src="v1/js/lib/typeahead/typeahead.bundle.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="v1/js/ff/transactions/convert.js?v={{ FF_VERSION }}"></script>
{% endblock %}