Added the common form-debit-credit.html template to reduce the duplicated code for the currency sub-forms in the transaction form.
This commit is contained in:
parent
cb7a0d377f
commit
592910187b
@ -22,33 +22,12 @@ First written: 2023/2/25
|
||||
{% extends "accounting/journal-entry/include/form-currency.html" %}
|
||||
|
||||
{% block line_items %}
|
||||
<div class="mb-3">
|
||||
<div id="accounting-currency-{{ currency_index }}-debit" class="form-control accounting-material-text-field accounting-not-empty {% if debit_errors %} is-invalid {% endif %}">
|
||||
<label class="form-label" for="accounting-currency-{{ currency_index }}-debit">{{ A_("Content") }}</label>
|
||||
<ul id="accounting-currency-{{ currency_index }}-debit-list" class="list-group accounting-line-item-list">
|
||||
{% for line_item_form in debit_forms %}
|
||||
{% with currency_index = currency_index,
|
||||
debit_credit = "debit",
|
||||
line_item_index = loop.index,
|
||||
only_one_line_item_form = debit_forms|length == 1,
|
||||
form = line_item_form.form %}
|
||||
{% include "accounting/journal-entry/include/form-line-item.html" %}
|
||||
line_item_forms = debit_forms,
|
||||
header = A_("Content"),
|
||||
debit_credit_total = debit_total,
|
||||
debit_credit_errors = debit_errors %}
|
||||
{% include "accounting/journal-entry/include/form-debit-credit.html" %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<div>{{ A_("Total") }}</div>
|
||||
<div><span id="accounting-currency-{{ currency_index }}-debit-total" class="badge rounded-pill bg-primary">{{ debit_total }}</span></div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button id="accounting-currency-{{ currency_index }}-debit-add-line-item" class="btn btn-primary" type="button" data-currency-index="{{ currency_index }}" data-debit-credit="debit" data-bs-toggle="modal" data-bs-target="#accounting-line-item-editor-modal">
|
||||
<i class="fas fa-plus"></i>
|
||||
{{ A_("New") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="accounting-currency-{{ currency_index }}-debit-error" class="invalid-feedback">{% if debit_errors %}{{ debit_errors[0] }}{% endif %}</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -0,0 +1,49 @@
|
||||
{#
|
||||
The Mia! Accounting Flask Project
|
||||
form-debit-credit.html: The debit or credit line items in the journal entry form
|
||||
|
||||
Copyright (c) 2023 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: 2023/3/21
|
||||
#}
|
||||
<div class="mb-2">
|
||||
<div id="accounting-currency-{{ currency_index }}-{{ debit_credit }}" class="form-control accounting-material-text-field accounting-not-empty {% if debit_errors %} is-invalid {% endif %}">
|
||||
<label class="form-label" for="accounting-currency-{{ currency_index }}-{{ debit_credit }}">{{ header }}</label>
|
||||
<ul id="accounting-currency-{{ currency_index }}-{{ debit_credit }}-list" class="list-group accounting-line-item-list">
|
||||
{% for line_item_form in line_item_forms %}
|
||||
{% with currency_index = currency_index,
|
||||
line_item_index = loop.index,
|
||||
only_one_line_item_form = line_item_forms|length == 1,
|
||||
form = line_item_form.form %}
|
||||
{% include "accounting/journal-entry/include/form-line-item.html" %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<div>{{ A_("Total") }}</div>
|
||||
<div><span id="accounting-currency-{{ currency_index }}-{{ debit_credit }}-total" class="badge rounded-pill bg-primary">{{ debit_credit_total }}</span></div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button id="accounting-currency-{{ currency_index }}-{{ debit_credit }}-add-line-item" class="btn btn-primary" type="button" data-currency-index="{{ currency_index }}" data-debit-credit="{{ debit_credit }}" data-bs-toggle="modal" data-bs-target="#accounting-line-item-editor-modal">
|
||||
<i class="fas fa-plus"></i>
|
||||
{{ A_("New") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="accounting-currency-{{ currency_index }}-{{ debit_credit }}-error" class="invalid-feedback">{% if debit_credit_errors %}{{ debit_credit_errors[0] }}{% endif %}</div>
|
||||
</div>
|
@ -22,33 +22,12 @@ First written: 2023/2/25
|
||||
{% extends "accounting/journal-entry/include/form-currency.html" %}
|
||||
|
||||
{% block line_items %}
|
||||
<div class="mb-3">
|
||||
<div id="accounting-currency-{{ currency_index }}-credit" class="form-control accounting-material-text-field accounting-not-empty {% if credit_errors %} is-invalid {% endif %}">
|
||||
<label class="form-label" for="accounting-currency-{{ currency_index }}-credit">{{ A_("Content") }}</label>
|
||||
<ul id="accounting-currency-{{ currency_index }}-credit-list" class="list-group accounting-line-item-list">
|
||||
{% for line_item_form in credit_forms %}
|
||||
{% with currency_index = currency_index,
|
||||
debit_credit = "credit",
|
||||
line_item_index = loop.index,
|
||||
only_one_line_item_form = credit_forms|length == 1,
|
||||
form = line_item_form.form %}
|
||||
{% include "accounting/journal-entry/include/form-line-item.html" %}
|
||||
line_item_forms = credit_forms,
|
||||
header = A_("Content"),
|
||||
debit_credit_total = credit_total,
|
||||
debit_credit_errors = credit_errors %}
|
||||
{% include "accounting/journal-entry/include/form-debit-credit.html" %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<div>{{ A_("Total") }}</div>
|
||||
<div><span id="accounting-currency-{{ currency_index }}-credit-total" class="badge rounded-pill bg-primary">{{ credit_total }}</span></div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button id="accounting-currency-{{ currency_index }}-credit-add-line-item" class="btn btn-primary" type="button" data-currency-index="{{ currency_index }}" data-debit-credit="credit" data-bs-toggle="modal" data-bs-target="#accounting-line-item-editor-modal">
|
||||
<i class="fas fa-plus"></i>
|
||||
{{ A_("New") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="accounting-currency-{{ currency_index }}-credit-error" class="invalid-feedback">{% if credit_errors %}{{ credit_errors[0] }}{% endif %}</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -23,66 +23,26 @@ First written: 2023/2/25
|
||||
|
||||
{% block line_items %}
|
||||
<div class="row">
|
||||
{# The debit line items #}
|
||||
<div class="col-sm-6 mb-3">
|
||||
<div id="accounting-currency-{{ currency_index }}-debit" class="form-control accounting-material-text-field accounting-not-empty {% if debit_errors %} is-invalid {% endif %}">
|
||||
<label class="form-label" for="accounting-currency-{{ currency_index }}-debit">{{ A_("Debit") }}</label>
|
||||
<ul id="accounting-currency-{{ currency_index }}-debit-list" class="list-group accounting-line-item-list">
|
||||
{% for line_item_form in debit_forms %}
|
||||
<div class="col-sm-6">
|
||||
{% with currency_index = currency_index,
|
||||
debit_credit = "debit",
|
||||
line_item_index = loop.index,
|
||||
only_one_line_item_form = debit_forms|length == 1,
|
||||
form = line_item_form.form %}
|
||||
{% include "accounting/journal-entry/include/form-line-item.html" %}
|
||||
line_item_forms = debit_forms,
|
||||
header = A_("Debit"),
|
||||
debit_credit_total = debit_total,
|
||||
debit_credit_errors = debit_errors %}
|
||||
{% include "accounting/journal-entry/include/form-debit-credit.html" %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<div>{{ A_("Total") }}</div>
|
||||
<div><span id="accounting-currency-{{ currency_index }}-debit-total" class="badge rounded-pill bg-primary">{{ debit_total }}</span></div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button id="accounting-currency-{{ currency_index }}-debit-add-line-item" class="btn btn-primary" type="button" data-currency-index="{{ currency_index }}" data-debit-credit="debit" data-bs-toggle="modal" data-bs-target="#accounting-line-item-editor-modal">
|
||||
<i class="fas fa-plus"></i>
|
||||
{{ A_("New") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="accounting-currency-{{ currency_index }}-debit-error" class="invalid-feedback">{% if debit_errors %}{{ debit_errors[0] }}{% endif %}</div>
|
||||
</div>
|
||||
|
||||
{# The credit line items #}
|
||||
<div class="col-sm-6 mb-3">
|
||||
<div id="accounting-currency-{{ currency_index }}-credit" class="form-control accounting-material-text-field accounting-not-empty {% if credit_errors %} is-invalid {% endif %}">
|
||||
<label class="form-label" for="accounting-currency-{{ currency_index }}-credit">{{ A_("Credit") }}</label>
|
||||
<ul id="accounting-currency-{{ currency_index }}-credit-list" class="list-group accounting-line-item-list">
|
||||
{% for line_item_form in credit_forms %}
|
||||
<div class="col-sm-6">
|
||||
{% with currency_index = currency_index,
|
||||
debit_credit = "credit",
|
||||
line_item_index = loop.index,
|
||||
only_one_line_item_form = credit_forms|length == 1,
|
||||
form = line_item_form.form %}
|
||||
{% include "accounting/journal-entry/include/form-line-item.html" %}
|
||||
line_item_forms = credit_forms,
|
||||
header = A_("Credit"),
|
||||
debit_credit_total = credit_total,
|
||||
debit_credit_errors = credit_errors %}
|
||||
{% include "accounting/journal-entry/include/form-debit-credit.html" %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<div class="d-flex justify-content-between mb-2">
|
||||
<div>{{ A_("Total") }}</div>
|
||||
<div><span id="accounting-currency-{{ currency_index }}-credit-total" class="badge rounded-pill bg-primary">{{ credit_total }}</span></div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button id="accounting-currency-{{ currency_index }}-credit-add-line-item" class="btn btn-primary" type="button" data-currency-index="{{ currency_index }}" data-debit-credit="credit" data-bs-toggle="modal" data-bs-target="#accounting-line-item-editor-modal">
|
||||
<i class="fas fa-plus"></i>
|
||||
{{ A_("New") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="accounting-currency-{{ currency_index }}-credit-error" class="invalid-feedback">{% if credit_errors %}{{ credit_errors[0] }}{% endif %}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user