Big update to properly support multi currencies.

This commit is contained in:
James Cole
2017-06-04 13:39:16 +02:00
parent 771ebde295
commit 82e74a2afd
34 changed files with 470 additions and 498 deletions

View File

@@ -14,10 +14,8 @@
{{ transaction.description }}
{% endif %}
<span class="pull-right small">
<!-- format amount of transaction -->
{{ formatByCode(transaction.transaction_currency_code, transaction.transaction_amount) }}
<!-- and then amount of journal itself. -->
{{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount, transaction.transaction_currency_code, transaction.transaction_type_type) }}
{# TODO replace with new format code #}
XX.XX
</span>
</a>
{% endfor %}

View File

@@ -64,14 +64,11 @@
<span style="margin-right:5px;">
{% if transaction.transaction_type_type == 'Transfer' %}
<!-- format amount of transaction -->
{{ formatByCode(transaction.transaction_currency_code, steam_positive(transaction.transaction_amount)) }}
<!-- and then amount of journal itself. -->
{{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount, transaction.transaction_currency_code, transaction.transaction_type_type) }}
{# TODO format amount of transaction. #}
{# TODO format: Amount of transaction (amount in foreign) / total (total foreign) #}
XX.XX
{% else %}
<!-- format amount of transaction -->
{{ formatByCode(transaction.transaction_currency_code, transaction.transaction_amount) }}
<!-- and then amount of journal itself. -->
{{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount, transaction.transaction_currency_code, transaction.transaction_type_type) }}
XX.XX
{% endif %}
</span>

View File

@@ -45,10 +45,8 @@
</a>
</td>
<td>
<!-- format amount of transaction -->
{{ formatByCode(transaction.transaction_currency_code, transaction.transaction_amount) }}
<!-- and then amount of journal itself. -->
{{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount, transaction.transaction_currency_code, transaction.transaction_type_type) }}
{# TODO replace with new format code #}
XX.XX
</td>
<td class="hidden-sm hidden-xs">
{{ transaction.date.formatLocalized(monthAndDayFormat) }}

View File

@@ -59,10 +59,8 @@
</td>
<td class="hide-balance_before" style="text-align: right;">{{ transaction.before|formatAmount }}</td>
<td class="hide-amount" style="text-align: right;">
<!-- format amount of transaction -->
{{ formatByCode(transaction.transaction_currency_code, transaction.transaction_amount) }}
<!-- and then amount of journal itself. -->
{{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount, transaction.transaction_currency_code, transaction.transaction_type_type) }}
{# TODO replace with new format code #}
XX.XX
</td>
<td class="hide-balance_after" style="text-align: right;">{{ transaction.after|formatAmount }}</td>

View File

@@ -62,17 +62,8 @@
</td>
<td style="text-align: right;">
<span style="margin-right:5px;">
{% if transaction.transaction_type_type == 'Transfer' %}
<!-- format amount of transaction -->
{{ formatByCode(transaction.transaction_currency_code, steam_positive(transaction.transaction_amount)) }}
<!-- and then amount of journal itself. -->
{{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount, transaction.transaction_currency_code, transaction.transaction_type_type) }}
{% else %}
<!-- format amount of transaction -->
{{ formatByCode(transaction.transaction_currency_code, transaction.transaction_amount) }}
<!-- and then amount of journal itself. -->
{{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount, transaction.transaction_currency_code, transaction.transaction_type_type) }}
{% endif %}
{# TODO replace with new format code #}
XX.XX
</span>
</td>

View File

@@ -39,10 +39,8 @@
</td>
<td data-value="{{ transaction.transaction_amount }}">
<!-- format amount of transaction -->
{{ formatByCode(transaction.transaction_currency_code, transaction.transaction_amount) }}
<!-- and then amount of journal itself. -->
{{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount, transaction.transaction_currency_code, transaction.transaction_type_type) }}
{# TODO replace with new format code #}
XX.XX
</td>

View File

@@ -43,7 +43,8 @@
<a href="{{ route('transactions.show',journal.id) }}" title="{{ journal.description }}">{{ journal.description }}</a>
</td>
<td>
{{ journal|formatJournal }}
{# TODO fix amount display #}
XX.XX
</td>
<td>
{{ journal.date.formatLocalized(monthAndDayFormat) }}

View File

@@ -47,11 +47,20 @@
</td>
<td>
<div class="input-group input-group-sm">
<span class="input-group-addon">{{ journal.transactionCurrency.symbol }}</span>
<span class="input-group-addon">{{ journal.currency_symbol }}</span>
<input name="amount[{{ journal.id }}]" class="form-control" autocomplete="off"
step="any" type="number" value="{{ journal.amount }}">
<input type="hidden" name="transaction_currency_id[{{ journal.id }}]" value="{{ journal.transaction_currency_id }}">
</div>
{% if journal.foreign_amount %}
{# insert foreign data #}
<div class="input-group input-group-sm">
<span class="input-group-addon">{{ journal.foreign_currency.symbol }}</span>
<input name="foreign_amount[{{ journal.id }}]" class="form-control" autocomplete="off"
step="any" type="number" value="{{ journal.foreign_amount }}">
<input type="hidden" name="foreign_currency_id[{{ journal.id }}]" value="{{ journal.foreign_currency.id }}">
</div>
{% endif %}
</td>
<td>
{# DATE #}

View File

@@ -36,14 +36,9 @@
<!-- total amount -->
<tr>
<td>{{ 'total_amount'|_ }}</td>
<td>{{ journal|formatJournal }}
{% if journal.hasMeta('foreign_amount') %}
{% if journal.transactiontype.type == 'Withdrawal' %}
({{ formatAnything(foreignCurrency, journal.getMeta('foreign_amount')*-1) }})
{% else %}
({{ formatAnything(foreignCurrency, journal.getMeta('foreign_amount')) }})
{% endif %}
{% endif %}
<td>
{# TODO fix amount display #}
XX.XX
</td>
</tr>
<tr>
@@ -304,9 +299,8 @@
</td>
<td>
{{ formatAnything(journal.transactionCurrency, transaction.source_account_before) }}
&longrightarrow; {{ formatAnything(journal.transactionCurrency, transaction.source_account_after) }}
{# TODO replace with new display: #}
XX.XX
</td>
<td>
{% if transaction.destination_account_type == 'Cash account' %}
@@ -317,25 +311,27 @@
</td>
<td>
{{ formatAnything(journal.transactionCurrency, transaction.destination_account_before) }}
&longrightarrow; {{ formatAnything(journal.transactionCurrency, transaction.destination_account_after) }}
{# TODO replace with new format code #}
XX.XX
</td>
<td>
{% if journal.transactiontype.type == 'Deposit' %}
<!-- deposit, positive amount with correct currency -->
{{ formatAnything(journal.transactionCurrency, transaction.destination_amount) }}
{# TODO replace with new format code #}
XX.XX
{% endif %}
{% if journal.transactiontype.type == 'Withdrawal' %}
<!-- withdrawal, negative amount with correct currency -->
{{ formatAnything(journal.transactionCurrency, transaction.source_amount) }}
{# TODO replace with new format code #}
XX.XX
{% endif %}
{% if journal.transactiontype.type == 'Transfer' %}
<!-- transfer, positive amount in blue -->
<span class="text-info">
{{ formatAnythingPlain(journal.transactionCurrency, transaction.destination_amount) }}
{# TODO replace with new format code #}
XX.XX
</span>
{% endif %}
</td>

View File

@@ -64,9 +64,9 @@
{{ ExpandedForm.nonSelectableAmount('native_amount', data.native_amount, {currency: data.native_currency}) }}
{{ ExpandedForm.nonSelectableAmount('source_amount', data.native_amount, {currency: data.native_currency }) }}
{{ ExpandedForm.nonSelectableAmount('source_amount', data.source_amount, {currency: data.source_currency }) }}
{{ ExpandedForm.nonSelectableAmount('destination_amount', data.amount, {currency: data.currency }) }}
{{ ExpandedForm.nonSelectableAmount('destination_amount', data.destination_amount, {currency: data.destination_currency }) }}
{# ALWAYS SHOW DATE #}
{{ ExpandedForm.date('date',data['date']) }}

View File

@@ -40,9 +40,6 @@
{# DESCRIPTION IS ALWAYS AVAILABLE #}
{{ ExpandedForm.text('journal_description', journal.description) }}
{# CURRENCY IS NEW FOR SPLIT JOURNALS #}
{{ ExpandedForm.select('currency_id', currencies, preFilled.currency_id) }}
{# show source if withdrawal or transfer #}
{% if preFilled.what == 'withdrawal' or preFilled.what == 'transfer' %}
{{ ExpandedForm.select('journal_source_account_id', assetAccounts, preFilled.journal_source_account_id) }}
@@ -59,6 +56,7 @@
{% endif %}
{# TOTAL AMOUNT IS STATIC TEXT #}
{# TODO this does not reflect the actual currency (currencies) #}
{{ ExpandedForm.staticText('journal_amount', preFilled.journal_amount|formatAmount ) }}
<input type="hidden" name="journal_amount" value="{{ preFilled.journal_amount }}"/>
@@ -204,7 +202,7 @@
<th>{{ trans('list.source') }}</th>
{% endif %}
<th>{{ trans('list.amount') }}</th>
<th colspan="2">{{ trans('list.amount') }}</th>
{# only withdrawal has budget #}
{% if preFilled.what == 'withdrawal' %}
@@ -234,7 +232,7 @@
</td>
{% endif %}
<!-- deposit has several source names -->
{# deposit has several source names #}
{% if preFilled.what == 'deposit' %}
<td>
<input type="text" name="transactions[{{ loop.index0 }}][source_account_name]"
@@ -243,10 +241,26 @@
</td>
{% endif %}
{# two fields for amount #}
<td style="width:10%;">
<input type="number" name="transactions[{{ loop.index0 }}][amount]" value="{{ transaction.amount }}"
class="form-control" autocomplete="off" step="any" min="0.01">
<div class="input-group">
<div class="input-group-addon">{{ transaction.transaction_currency_symbol }}</div>
<input type="number" name="transactions[{{ loop.index0 }}][amount]" value="{{ transaction.amount }}"
class="form-control" autocomplete="off" step="any" min="0.01">
</div>
<input type="hidden" name="transactions[{{ loop.index0 }}][transaction_currency_id]" value="{{ transaction.transaction_currency_id }}">
</td>
{# foreign amount #}
<td style="width:10%;">
{% if transaction.foreign_amount != null %}
<div class="input-group">
<div class="input-group-addon">{{ transaction.foreign_currency_symbol }}</div>
<input type="number" name="transactions[{{ loop.index0 }}][foreign_amount]"
value="{{ transaction.foreign_amount }}"
class="form-control" autocomplete="off" step="any" min="0.01">
</div>
<input type="hidden" name="transactions[{{ loop.index0 }}][foreign_currency_id]" value="{{ transaction.foreign_currency_id }}">
{% endif %}
</td>
{% if preFilled.what == 'withdrawal' %}