mia-accounting-django/accounting/templates/accounting/transaction_transfer_form.html

155 lines
6.4 KiB
HTML

{% extends "base.html" %}
{% comment %}
The Mia Accounting Application
transaction_form-transfer.html: The template for the form of the
transfer transactions
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 %}
{% load accounting %}
{% block settings %}
{% setvar "title" _("Transfer Transaction") %}
{% add_lib "jquery-ui" "decimal-js" %}
{% 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/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 "accounting:transactions.detail" "transfer" form.transaction as url %}{% url_keep_return url %}{% 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="regular-accounts" type="hidden" value="{{ regular_accounts }}" />
<input id="new-record-template" type="hidden" value="{{ new_record_template }}" />
<form id="txn-form" action="{% if form.transaction %}{% url "accounting:transactions.update" "transfer" form.transaction as url %}{% url_keep_return url %}{% else %}{% url "accounting:transactions.create" "transfer" as url %}{% url_keep_return url %}{% 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 form.date.errors %} is-invalid {% endif %}" type="date" name="date" value="{% if form.is_bound %}{{ form.date.value }}{% else %}{% now "Y-m-d" %}{% endif %}" required="required" />
<div id="txn-date-error" class="invalid-feedback">{{ form.date.errors.0|default:"" }}</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 %}
{% empty %}
{% with record_type="debit" no=1 order=1 %}
{% 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 form.balance_error %} is-invalid {% endif %} balance-row">
{{ _("Total")|force_escape }}
<span id="debit-total" class="amount">{{ form.debit_total|short_amount }}</span>
</div>
<div id="debit-total-error" class="invalid-feedback balance-error">{{ form.balance_error|default:"" }}</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 %}
{% empty %}
{% with record_type="credit" no=1 order=1 %}
{% 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 form.balance_error %} is-invalid {% endif %} balance-row">
{{ _("Total")|force_escape }}
<span id="credit-total" class="amount">{{ form.credit_total|short_amount }}</span>
</div>
<div id="credit-total-error" class="invalid-feedback balance-error">{{ form.balance_error|default:"" }}</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 form.notes.errors %} is-invalid {% endif %}" name="notes">{{ form.notes.value|default:"" }}</textarea>
<div id="txn-note-error" class="invalid-feedback">{{ form.notes.errors.0|default:"" }}</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 %}