Skip to content

Firefly III: a personal finances manager

Display and handle errors.

James Cole0b747076388a
diff --git a/resources/views/split/journals/from-store.twig b/resources/views/split/journals/from-store.twig
index 8de8d22426..6f41cde1be 100644
--- a/resources/views/split/journals/from-store.twig
+++ b/resources/views/split/journals/from-store.twig
@@ -5,7 +5,7 @@
{% endblock %}
{% block content %}
{{ Form.open({'class' : 'form-horizontal','id' : 'store','url' : route('split.journal.from-store.post')}) }}
- <input type="hidden" name="what" value="{{ data.what }}" />
+ <input type="hidden" name="what" value="{{ data.what }}"/>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box">
@@ -30,25 +30,32 @@
{{ trans(('firefly.split_intro_three_'~data.what), {total: 20|formatAmount, split_one: 15|formatAmount, split_two: 5|formatAmount})|raw }}
{% endif %}
</p>
- <!--
- <p>
- Firefly supports the "splitting" of an [expense / withdrawal / transfer].
-
- It means that the amount of money you've spent/earned/transfered is divided between
- several source accounts, destination accounts or budgets.
-
- Example for withdrawals: split your 20,- groceries so you pay 15,- from your "daily groceries" budget
- and 5,- from your "cigarettes" budget.
-
- Example for deposits: split your 500,- salary so that 450,- is categorized "salary" and 50,- is categorized "reimbursed expenses".
-
- Example for transfers: split your 100,- transfer so that 50,- is put in the piggy bank "new couch" and 50,- is not.
- </p>
- -->
+ <p class="text-danger">This feature is experimental.</p>
</div>
</div>
</div>
</div>
+ {% if errors.all()|length > 0 %}
+ <div class="row">
+ <div class="col-lg-12 col-md-12 col-sm-12">
+ <div class="box box-danger">
+ <div class="box-header with-border">
+ <h3 class="box-title">{{ 'errors'|_ }}</h3>
+ <div class="box-tools pull-right">
+ <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
+ </div>
+ </div>
+ <div class="box-body">
+ <ul>
+ {% for key, err in errors.all() %}
+ <li class="text-danger">{{ err }}</li>
+ {% endfor %}
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ {% endif %}
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="box">
@@ -60,23 +67,24 @@
</div>
</div>
<div class="box-body">
- {{ ExpandedForm.text('journal_description', data.description) }}
- {{ ExpandedForm.select('currency', currencies, data.amount_currency_id_amount) }}
- {{ ExpandedForm.staticText('amount', data.amount|formatAmount) }}
+ {{ ExpandedForm.text('journal_description') }}
+ {{ ExpandedForm.select('journal_currency_id', currencies, data.journal_currency_id) }}
+ {{ ExpandedForm.staticText('journal_amount', data.journal_amount|formatAmount) }}
+ <input type="hidden" name="journal_amount" value="{{ data.journal_amount }}"/>
<!-- show static source if withdrawal or transfer -->
{% if data.what == 'withdrawal' or data.what == 'transfer' %}
- {{ ExpandedForm.staticText('asset_source_account', assetAccounts[data.source_account_id]) }}
- <input type="hidden" name="source_account_id" value="{{ data.source_account_id }}"/>
+ {{ ExpandedForm.staticText('asset_source_account', assetAccounts[data.journal_source_account_id]) }}
+ <input type="hidden" name="source_account_id" value="{{ data.journal_source_account_id }}"/>
{% endif %}
<!-- show static source if deposit: -->
{% if data.what == 'deposit' %}
- {{ ExpandedForm.staticText('revenue_account', data.source_account_name) }}
- <input type="hidden" name="source_account_name" value="{{ data.source_account_name }}"/>
+ {{ ExpandedForm.staticText('revenue_account', data.journal_source_account_name) }}
+ <input type="hidden" name="source_account_name" value="{{ data.journal_source_account_name }}"/>
{% endif %}
<!-- show static destination if transfer -->
{% if data.what == 'transfer' %}
- {{ ExpandedForm.staticText('asset_destination_account', assetAccounts[data.destination_account_id]) }}
- <input type="hidden" name="destination_account_id" value="{{ data.destination_account_id }}"/>
+ {{ ExpandedForm.staticText('asset_destination_account', assetAccounts[data.journal_destination_account_id]) }}
+ <input type="hidden" name="destination_account_id" value="{{ data.journal_destination_account_id }}"/>
{% endif %}
</div>
</div>
@@ -143,43 +151,48 @@
</tr>
</thead>
<tbody>
- <tr class="initial-row">
- <td class="count">#1</td>
- <td>{{ Form.input('text', 'description[]', data.description, {class: 'form-control'}) }}</td>
-
- <!-- withdrawal has several destination names. -->
- {% if data.what == 'withdrawal' %}
+ {% for index, descr in data.description %}
+ <tr class="{% if loop.index == 1 %}initial-row{% else %}not-initial-row{% endif %}">
+ <td class="count">#{{ loop.index }}</td>
<td>
- {{ Form.input('text', 'destination_account_name[]', data.destination_account_name, {class: 'form-control'}) }}
+ <input type="text" name="description[]" value="{{ descr }}" class="form-control"/>
</td>
- {% endif %}
- <!-- deposit has several destination id's -->
- {% if data.what == 'deposit' %}
- <td>
- {{ Form.select('destination_account_id[]', assetAccounts, data.destination_account_id, {class: 'form-control'}) }}
+ <!-- withdrawal has several destination names. -->
+ {% if data.what == 'withdrawal' %}
+ <td>
+ <input type="text" name="destination_account_name[]" value="{{ data.destination_account_name[index] }}"
+ class="form-control"/>
+ </td>
+ {% endif %}
+
+ <!-- deposit has several destination id's -->
+ {% if data.what == 'deposit' %}
+ <td>
+ {{ Form.select('destination_account_id[]', assetAccounts, data.destination_account_id[index], {class: 'form-control'}) }}
+ </td>
+ {% endif %}
+
+
+ <td style="width:10%;">
+ <input type="number" name="amount[]" value="{{ data.amount[index] }}"
+ class="form-control" autocomplete="off" step="any" min="0.01">
</td>
- {% endif %}
-
-
-
- <td style="width:10%;">
- {{ Form.input('number', 'amount[]', data.amount, {class: 'form-control', autocomplete: 'off', step: 'any', min:'0.01'}) }}
- </td>
- {% if data.what == 'withdrawal' %}
+ {% if data.what == 'withdrawal' %}
+ <td>
+ {{ Form.select('budget_id[]', budgets, data.budget_id[index], {class: 'form-control'}) }}
+ </td>
+ {% endif %}
<td>
- {{ Form.select('budget[]', budgets, data.budget_id, {class: 'form-control'}) }}
+ <input type="text" name="category[]" value="{{ data.category[index] }}" class="form-control"/>
</td>
- {% endif %}
- <td>
- {{ Form.input('text', 'category[]', data.category, {class: 'form-control'}) }}
- </td>
- {% if data.what == 'transfer' %}
- <td>
- {{ Form.select('piggy_bank_id[]', piggyBanks, data.piggy_bank_id, {class: 'form-control'}) }}
- </td>
- {% endif %}
- </tr>
+ {% if data.what == 'transfer' %}
+ <td>
+ {{ Form.select('piggy_bank_id[]', piggyBanks, data.piggy_bank_id[index], {class: 'form-control'}) }}
+ </td>
+ {% endif %}
+ </tr>
+ {% endfor %}
</tbody>
</table>
<p>
@@ -200,7 +213,7 @@
{% endblock %}
{% block scripts %}
<script type="text/javascript">
- var originalSum = {{ data.amount }};
+ var originalSum = {{ data.journal_amount }};
var what = "{{ data.what }}";
</script>
<script type="text/javascript" src="js/lib/bootstrap3-typeahead.min.js"></script>