First attempt at #142. Needs a lot of work still.

This commit is contained in:
James Cole
2016-04-29 20:59:28 +02:00
parent 4af8272faa
commit 0e3ccebd0b
19 changed files with 714 additions and 155 deletions

View File

@@ -4,163 +4,184 @@
{{ Breadcrumbs.renderIfExists }}
{% endblock %}
{% block content %}
<form method="POST" action="bla" accept-charset="UTF-8" class="form-horizontal" id="store" enctype="multipart/form-data">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Split your new [type]</h3>
{{ Form.open({'class' : 'form-horizontal','id' : 'store','url' : route('split.journal.from-store.post')}) }}
<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">
<div class="box-header with-border">
<h3 class="box-title">{{ ('split_title_'~data.what)|_ }}</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 class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
<div class="box-body">
<p>
Firefly supports the "splitting" of an [expense / withdrawal / transfer].
</div>
<div class="box-body">
<p>
{{ ('split_intro_one_'~data.what)|_ }}
</p>
<p>
{{ ('split_intro_two_'~data.what)|_ }}
</p>
<p>
{{ trans(('firefly.split_intro_three_'~data.what), {total: 20|formatAmount, split_one: 15|formatAmount, split_two: 5|formatAmount})|raw }}
</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.
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 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 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>
</div>
Example for transfers: split your 100,- transfer so that 50,- is put in the piggy bank "new couch" and 50,- is not.
</p>
-->
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Transaction meta-data</h3>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'transaction_meta_data'|_ }}</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">
{{ ExpandedForm.text('journal_description', data.description) }}
{{ ExpandedForm.staticText('amount', data.amount|formatAmount) }}
<!-- 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]) }}
{% endif %}
<!-- show static destination if deposit or transfer -->
{% if data.what == 'deposit' or data.what == 'transfer' %}
{{ ExpandedForm.staticText('asset_destination_account', assetAccounts[data.destination_account_id]) }}
{% endif %}
<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>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Transaction dates</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">
{{ ExpandedForm.date('date', data.date) }}
{{ ExpandedForm.date('interest_date', data.interest_date) }}
{{ ExpandedForm.date('book_date', data.book_date) }}
{{ ExpandedForm.date('process_date', data.process_date) }}
</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) }}
<!-- 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 }}"/>
{% endif %}
<!-- show static destination if deposit or transfer -->
{% if data.what == 'deposit' or 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 }}"/>
{% endif %}
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Splits</h3>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'transaction_dates'|_ }}</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 class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div>
<div class="box-body">
<p>
Split your [x] in as many things as you want. By default the transaction will not split, there is just one entry.
Add as many splits as you want to, below. Remember that you should not deviate from your total amount. If you
do, Firefly will warn you but not correct you.
</p>
<table class="table">
<thead>
<tr>
<th>Split #</th>
<th>Description</th>
<!-- split the source of a deposit -->
{% if data.what == 'deposit' %}
<th>Source</th>
{% endif %}
<!-- split where a withdrawal is going -->
{% if data.what == 'withdrawal' %}
<th>Destination</th>
{% endif %}
<th>Amount</th>
{% if data.what == 'withdrawal' %}
<th>Budget</th>
{% endif %}
<th>Category</th>
{% if data.what == 'transfer' %}
<th>Piggy bank</th>
{% endif %}
</tr>
</thead>
<tbody>
<tr class="initial-row">
<td>#1</td>
<td>{{ Form.input('text', 'description[]', data.description, {class: 'form-control'}) }}</td>
{% if data.what == 'deposit' %}
<td>
{{ Form.input('text', 'source_account_name[]', data.source_account_name, {class: 'form-control'}) }}
</td>
{% endif %}
{% if data.what == 'withdrawal' %}
<td>
{{ Form.input('text', 'destination_account_name[]', data.destination_account_name, {class: 'form-control'}) }}
</td>
{% endif %}
<td style="width:10%;">
{{ ExpandedForm.amountSmall('amount[]', data.amount) }}
</td>
{% if data.what == 'withdrawal' %}
<td>
{{ Form.select('budget[]', budgets, data.budget_id, {class: 'form-control'}) }}
</td>
{% endif %}
</div>
<div class="box-body">
{{ ExpandedForm.date('date', data.date) }}
{{ ExpandedForm.date('interest_date', data.interest_date) }}
{{ ExpandedForm.date('book_date', data.book_date) }}
{{ ExpandedForm.date('process_date', data.process_date) }}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ 'splits'|_ }}</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">
<p>
{{ ('split_table_intro_'~data.what)|_ }}
</p>
<table class="table table-bordered table-condensed table-striped split-table">
<thead>
<tr>
<th>{{ trans('list.split_number') }}</th>
<th>{{ trans('list.description') }}</th>
<!-- split the source of a deposit -->
{% if data.what == 'deposit' %}
<th>{{ trans('list.source') }}</th>
{% endif %}
<!-- split where a withdrawal is going -->
{% if data.what == 'withdrawal' %}
<th>{{ trans('list.destination') }}</th>
{% endif %}
<th>{{ trans('list.amount') }}</th>
{% if data.what == 'withdrawal' %}
<th>{{ trans('list.budget') }}</th>
{% endif %}
<th>{{ trans('list.category') }}</th>
{% if data.what == 'transfer' %}
<th>{{ trans('list.piggy_bank') }}</th>
{% endif %}
</tr>
</thead>
<tbody>
<tr class="initial-row">
<td class="count">#1</td>
<td>{{ Form.input('text', 'description[]', data.description, {class: 'form-control'}) }}</td>
{% if data.what == 'deposit' %}
<td>
{{ Form.input('text', 'category[]', data.category, {class: 'form-control'}) }}
{{ Form.input('text', 'source_account_name[]', data.source_account_name, {class: 'form-control'}) }}
</td>
</tr>
</tbody>
</table>
<p>
<a href="#" class="btn btn-success btn-do-split"><i class="fa fa-plus-circle"></i> Add another split</a>
</p>
</div>
{% endif %}
{% if data.what == 'withdrawal' %}
<td>
{{ Form.input('text', 'destination_account_name[]', data.destination_account_name, {class: 'form-control'}) }}
</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' %}
<td>
{{ Form.select('budget[]', budgets, data.budget_id, {class: 'form-control'}) }}
</td>
{% endif %}
<td>
{{ Form.input('text', 'category[]', data.category, {class: 'form-control'}) }}
</td>
</tr>
</tbody>
</table>
<p>
<br/>
<a href="#" class="btn btn-default btn-do-split"><i class="fa fa-plus-circle"></i> {{ 'add_another_split'|_ }}</a>
</p>
<p class="pull-right">
<button type="submit" id="transaction-btn" class="btn btn-success pull-right">
{{ ('store_splitted_'~data.what)|_ }}
</button>
</p>
</div>
</div>
</div>
</div>
</form>
{% endblock %}
{% block scripts %}
<script type="text/javascript">
var originalSum = {{ data.amount }};
var what = "{{ data.what }}";
</script>
<script type="text/javascript" src="js/lib/bootstrap3-typeahead.min.js"></script>
<script type="text/javascript" src="js/ff/transactions/create-edit.js"></script>
<script type="text/javascript" src="js/ff/split/journal/from-store.js"></script>
{% endblock %}
{% block styles %}
{% endblock %}