From cb7a0d377fc7202c2eedb79d396dc145501f8168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Tue, 21 Mar 2023 11:26:28 +0800 Subject: [PATCH] Added the common form-currency.html template to reduce the duplicated code for the currency sub-forms in the transaction form. --- .../disbursement/include/form-currency.html | 75 ++++------- .../journal-entry/include/form-currency.html | 47 +++++++ .../receipt/include/form-currency.html | 75 ++++------- .../transfer/include/form-currency.html | 127 ++++++++---------- 4 files changed, 154 insertions(+), 170 deletions(-) create mode 100644 src/accounting/templates/accounting/journal-entry/include/form-currency.html diff --git a/src/accounting/templates/accounting/journal-entry/disbursement/include/form-currency.html b/src/accounting/templates/accounting/journal-entry/disbursement/include/form-currency.html index d2339ae..3e97656 100644 --- a/src/accounting/templates/accounting/journal-entry/disbursement/include/form-currency.html +++ b/src/accounting/templates/accounting/journal-entry/disbursement/include/form-currency.html @@ -19,57 +19,36 @@ form-currency.html: The currency sub-form in the cash disbursement journal entry Author: imacat@mail.imacat.idv.tw (imacat) First written: 2023/2/25 #} -
- - -
-
-
- - -
{% if currency_code_errors %}{{ currency_code_errors[0] }}{% endif %}
-
+{% extends "accounting/journal-entry/include/form-currency.html" %} -
- -
+{% block line_items %} +
+
+ +
    + {% 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" %} + {% endwith %} + {% endfor %} +
+ +
+
{{ A_("Total") }}
+
{{ debit_total }}
-
-
- -
    - {% 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" %} - {% endwith %} - {% endfor %} -
- -
-
{{ A_("Total") }}
-
{{ debit_total }}
-
- -
- -
-
-
{% if debit_errors %}{{ debit_errors[0] }}{% endif %}
+
+
-
{% if currency_errors %}{{ currency_errors[0] }}{% endif %}
+
{% if debit_errors %}{{ debit_errors[0] }}{% endif %}
+{% endblock %} diff --git a/src/accounting/templates/accounting/journal-entry/include/form-currency.html b/src/accounting/templates/accounting/journal-entry/include/form-currency.html new file mode 100644 index 0000000..79b80f5 --- /dev/null +++ b/src/accounting/templates/accounting/journal-entry/include/form-currency.html @@ -0,0 +1,47 @@ +{# +The Mia! Accounting Flask Project +form-currency.html: The currency sub-form 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 +#} +
+ + +
+
+
+ + +
{% if currency_code_errors %}{{ currency_code_errors[0] }}{% endif %}
+
+ +
+ +
+
+ + {% block line_items %}{% endblock %} +
+
{% if currency_errors %}{{ currency_errors[0] }}{% endif %}
+
diff --git a/src/accounting/templates/accounting/journal-entry/receipt/include/form-currency.html b/src/accounting/templates/accounting/journal-entry/receipt/include/form-currency.html index c07a541..bd756a1 100644 --- a/src/accounting/templates/accounting/journal-entry/receipt/include/form-currency.html +++ b/src/accounting/templates/accounting/journal-entry/receipt/include/form-currency.html @@ -19,57 +19,36 @@ form-currency.html: The currency sub-form in the cash receipt journal entry form Author: imacat@mail.imacat.idv.tw (imacat) First written: 2023/2/25 #} -
- - -
-
-
- - -
{% if currency_code_errors %}{{ currency_code_errors[0] }}{% endif %}
-
+{% extends "accounting/journal-entry/include/form-currency.html" %} -
- -
+{% block line_items %} +
+
+ +
    + {% 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" %} + {% endwith %} + {% endfor %} +
+ +
+
{{ A_("Total") }}
+
{{ credit_total }}
-
-
- -
    - {% 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" %} - {% endwith %} - {% endfor %} -
- -
-
{{ A_("Total") }}
-
{{ credit_total }}
-
- -
- -
-
-
{% if credit_errors %}{{ credit_errors[0] }}{% endif %}
+
+
-
{% if currency_errors %}{{ currency_errors[0] }}{% endif %}
+
{% if credit_errors %}{{ credit_errors[0] }}{% endif %}
+{% endblock %} diff --git a/src/accounting/templates/accounting/journal-entry/transfer/include/form-currency.html b/src/accounting/templates/accounting/journal-entry/transfer/include/form-currency.html index 9c7445f..607f6a7 100644 --- a/src/accounting/templates/accounting/journal-entry/transfer/include/form-currency.html +++ b/src/accounting/templates/accounting/journal-entry/transfer/include/form-currency.html @@ -19,91 +19,70 @@ form-currency.html: The currency sub-form in the transfer journal entry form Author: imacat@mail.imacat.idv.tw (imacat) First written: 2023/2/25 #} -
- - -
-
-
- - -
{% if currency_code_errors %}{{ currency_code_errors[0] }}{% endif %}
+{% extends "accounting/journal-entry/include/form-currency.html" %} + +{% block line_items %} +
+ {# The debit line items #} +
+
+ +
    + {% 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" %} + {% endwith %} + {% endfor %} +
+ +
+
{{ A_("Total") }}
+
{{ debit_total }}
-
+
{% if debit_errors %}{{ debit_errors[0] }}{% endif %}
+
-
- {# The debit line items #} -
-
- -
    - {% 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" %} - {% endwith %} - {% endfor %} -
+ {# The credit line items #} +
+
+ +
    + {% 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" %} + {% endwith %} + {% endfor %} +
-
-
{{ A_("Total") }}
-
{{ debit_total }}
-
- -
- -
-
-
{% if debit_errors %}{{ debit_errors[0] }}{% endif %}
+
+
{{ A_("Total") }}
+
{{ credit_total }}
- {# The credit line items #} -
-
- -
    - {% 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" %} - {% endwith %} - {% endfor %} -
- -
-
{{ A_("Total") }}
-
{{ credit_total }}
-
- -
- -
-
-
{% if credit_errors %}{{ credit_errors[0] }}{% endif %}
+
+
+
{% if credit_errors %}{{ credit_errors[0] }}{% endif %}
-
{% if currency_errors %}{{ currency_errors[0] }}{% endif %}
+{% endblock %}