mia-accounting-django/accounting/templates/accounting/transaction_form-transfer.html

145 lines
6.1 KiB
HTML

{% extends "base.html" %}
{% comment %}
The Mia Accounting Application
form.html: The template for the form of a transfer transaction
Copyright (c) 2020 imacat.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: imacat@mail.imacat.idv.tw (imacat)
First written: 2020/7/23
{% endcomment %}
{% load static %}
{% load i18n %}
{% load mia_core %}
{% block settings %}
{% setvar "title" _("Transfer Transaction") %}
{% setvar "use_jqueryui" True %}
{% static "accounting/css/transactions.css" as file %}{% add_css file %}
{% static "accounting/css/summary-helper.css" as file %}{% add_css file %}
{% static "accounting/js/transaction-form.js" as file %}{% add_js file %}
{% static "accounting/js/regular-payments.js" as file %}{% add_js file %}
{% static "accounting/js/summary-helper.js" as file %}{% add_js file %}
{% endblock %}
{% block content %}
{% include "accounting/include/summary-helper.html" %}
{% for message in form.non_field_errors %}
<div class="alert alert-danger alert-dismissible fade show">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>{{ _("Error:")|force_escape }}</strong> {{ message }}
</div>
{% endfor %}
<div class="btn-group btn-actions">
<a class="btn btn-primary" role="button" href="{% if form.transaction %}{% url_keep_return "accounting:transactions.detail" "transfer" form.transaction %}{% elif request.GET.r %}{{ request.GET.r }}{% else %}{% url "accounting:home" %}{% endif %}">
<i class="fas fa-chevron-circle-left"></i>
{{ _("Back")|force_escape }}
</a>
</div>
<input id="account-option-url" type="hidden" value="{% url "accounting:api.accounts.options" %}" />
<input id="summary-categories" type="hidden" value="{{ summary_categories }}" />
<input id="new-record-template" type="hidden" value="{{ new_record_template }}" />
<form id="txn-form" action="{% if form.transaction %}{% url_keep_return "accounting:transactions.update" "transfer" form.transaction %}{% else %}{% url_keep_return "accounting:transactions.store" "transfer" %}{% endif %}" method="post">
{% csrf_token %}
<div class="row form-group">
<div class="col-sm-2">
<label for="txn-date">{{ _("Date:")|force_escape }}</label>
</div>
<div class="col-sm-10">
<input id="txn-date" class="form-control {% if should_validate and form.date.errors %} is-invalid {% endif %}" type="date" name="date" value="{{ form.date.value }}" required="required" />
<div id="txn-date-error" class="invalid-feedback">{% if should_validate %}{{ form.date.errors.0|default:"" }}{% endif %}</div>
</div>
</div>
<div class="row form-group">
<div class="col-sm-6">
<h2>{{ _("Debit")|force_escape }}</h2>
<ul id="debit-records" class="list-group">
{% for record in form.debit_records %}
{% with record_type="debit" no=forloop.counter order=forloop.counter %}
{% include "accounting/include/record_form-transfer.html" %}
{% endwith %}
{% endfor %}
</ul>
<ul class="list-group">
<li class="list-group-item">
<button class="btn btn-primary btn-new" type="button" data-type="debit">
<i class="fas fa-plus"></i>
</button>
</li>
<li class="list-group-item">
<div id="debit-total-row" class="d-flex justify-content-between align-items-center form-control {% if should_validate and form.balance_error %} is-invalid {% endif %} balance-row">
{{ _("Total")|force_escape }}
<span id="debit-total" class="amount">{{ form.debit_total }}</span>
</div>
<div id="debit-total-error" class="invalid-feedback balance-error">{% if should_validate %}{{ form.balance_error|default:"" }}{% endif %}</div>
</li>
</ul>
</div>
<div class="col-sm-6">
<h2>{{ _("Credit")|force_escape }}</h2>
<ul id="credit-records" class="list-group">
{% for record in form.credit_records %}
{% with record_type="credit" no=forloop.counter order=forloop.counter %}
{% include "accounting/include/record_form-transfer.html" %}
{% endwith %}
{% endfor %}
</ul>
<ul class="list-group">
<li class="list-group-item">
<button class="btn btn-primary btn-new" type="button" data-type="credit">
<i class="fas fa-plus"></i>
</button>
</li>
<li class="list-group-item">
<div id="credit-total-row" class="d-flex justify-content-between align-items-center form-control {% if should_validate and form.balance_error %} is-invalid {% endif %} balance-row">
{{ _("Total")|force_escape }}
<span id="credit-total" class="amount">{{ form.credit_total }}</span>
</div>
<div id="credit-total-error" class="invalid-feedback balance-error">{% if should_validate %}{{ form.balance_error|default:"" }}{% endif %}</div>
</li>
</ul>
</div>
</div>
<div class="row form-group">
<div class="col-sm-2">
<label for="txn-note">{{ _("Notes:")|force_escape }}</label>
</div>
<div class="col-sm-10">
<textarea id="txn-note" class="form-control {% if should_validate and form.notes.errors %} is-invalid {% endif %}" name="notes">{{ form.notes.value|default:"" }}</textarea>
<div id="txn-note-error" class="invalid-feedback">{% if should_validate %}{{ form.notes.errors.0|default:"" }}{% endif %}</div>
</div>
</div>
<div class="row form-group">
<div class="col-sm-12">
<button class="btn btn-primary" type="submit">
<i class="fas fa-save"></i>
{{ _("Save")|force_escape }}
</button>
</div>
</div>
</form>
{% endblock %}