-
{{ account_text }}
-
{{ description_data }}
-
- {% if original_line_item_text %}{{ A_("Offset %(item)s", item=original_line_item_text) }}{% endif %}
+
{{ form.account_text }}
+
{{ form.description.data|accounting_default }}
+
+ {% if form.original_line_item_id.data %}{{ A_("Offset %(item)s", item=form.original_line_item_text|accounting_default) }}{% endif %}
-
- {% if offset_items %}
-
-
{{ amount_text }}
+
{{ form.amount.data|accounting_format_amount }}
-
{% if line_item_errors %}{{ line_item_errors[0] }}{% endif %}
+
{% if form.all_errors %}{{ form.all_errors[0] }}{% endif %}
-
diff --git a/src/accounting/templates/accounting/voucher/receipt/include/form-currency-item.html b/src/accounting/templates/accounting/voucher/receipt/include/form-currency-item.html
index 4978755..a529a82 100644
--- a/src/accounting/templates/accounting/voucher/receipt/include/form-currency-item.html
+++ b/src/accounting/templates/accounting/voucher/receipt/include/form-currency-item.html
@@ -50,24 +50,7 @@ First written: 2023/2/25
side = "credit",
line_item_index = loop.index,
only_one_line_item_form = credit_forms|length == 1,
- line_item_id = line_item_form.form.eid.data,
- account_code_data = line_item_form.form.account_code.data|accounting_default,
- account_code_error = line_item_form.form.account_code.errors,
- account_text = line_item_form.form.account_text,
- description_data = line_item_form.form.description.data|accounting_default,
- description_errors = line_item_form.form.description.errors,
- original_line_item_id_data = line_item_form.form.original_line_item_id.data|accounting_default,
- original_line_item_date = line_item_form.form.original_line_item_date|accounting_default,
- original_line_item_text = line_item_form.form.original_line_item_text|accounting_default,
- is_need_offset = line_item_form.form.is_need_offset,
- offset_items = line_item_form.form.offsets,
- offset_total = line_item_form.form.offset_total|accounting_default("0"),
- net_balance_data = line_item_form.form.net_balance,
- net_balance_text = line_item_form.form.net_balance|accounting_format_amount,
- amount_data = line_item_form.form.amount.data|accounting_voucher_format_amount_input,
- amount_errors = line_item_form.form.amount.errors,
- amount_text = line_item_form.form.amount.data|accounting_format_amount,
- line_item_errors = line_item_form.form.all_errors %}
+ form = line_item_form.form %}
{% include "accounting/voucher/include/form-line-item.html" %}
{% endwith %}
{% endfor %}
diff --git a/src/accounting/templates/accounting/voucher/transfer/include/form-currency-item.html b/src/accounting/templates/accounting/voucher/transfer/include/form-currency-item.html
index 1af2edf..7259f33 100644
--- a/src/accounting/templates/accounting/voucher/transfer/include/form-currency-item.html
+++ b/src/accounting/templates/accounting/voucher/transfer/include/form-currency-item.html
@@ -52,24 +52,7 @@ First written: 2023/2/25
side = "debit",
line_item_index = loop.index,
only_one_line_item_form = debit_forms|length == 1,
- line_item_id = line_item_form.form.eid.data,
- account_code_data = line_item_form.form.account_code.data|accounting_default,
- account_code_error = line_item_form.form.account_code.errors,
- account_text = line_item_form.form.account_text,
- description_data = line_item_form.form.description.data|accounting_default,
- description_errors = line_item_form.form.description.errors,
- original_line_item_id_data = line_item_form.form.original_line_item_id.data|accounting_default,
- original_line_item_date = line_item_form.form.original_line_item_date|accounting_default,
- original_line_item_text = line_item_form.form.original_line_item_text|accounting_default,
- is_need_offset = line_item_form.form.is_need_offset,
- offset_items = line_item_form.form.offsets,
- offset_total = line_item_form.form.offset_total|accounting_default,
- net_balance_data = line_item_form.form.net_balance,
- net_balance_text = line_item_form.form.net_balance|accounting_format_amount,
- amount_data = line_item_form.form.amount.data|accounting_voucher_format_amount_input,
- amount_errors = line_item_form.form.amount.errors,
- amount_text = line_item_form.form.amount.data|accounting_format_amount,
- line_item_errors = line_item_form.form.all_errors %}
+ form = line_item_form.form %}
{% include "accounting/voucher/include/form-line-item.html" %}
{% endwith %}
{% endfor %}
@@ -100,24 +83,7 @@ First written: 2023/2/25
side = "credit",
line_item_index = loop.index,
only_one_line_item_form = debit_forms|length == 1,
- line_item_id = line_item_form.form.eid.data,
- account_code_data = line_item_form.form.account_code.data|accounting_default,
- account_code_error = line_item_form.form.account_code.errors,
- account_text = line_item_form.form.account_text,
- description_data = line_item_form.form.description.data|accounting_default,
- description_errors = line_item_form.form.description.errors,
- original_line_item_id_data = line_item_form.form.original_line_item_id.data|accounting_default,
- original_line_item_date = line_item_form.form.original_line_item_date|accounting_default,
- original_line_item_text = line_item_form.form.original_line_item_text|accounting_default,
- is_need_offset = line_item_form.form.is_need_offset,
- offset_items = line_item_form.form.offsets,
- offset_total = line_item_form.form.offset_total|accounting_default("0"),
- net_balance_data = line_item_form.form.net_balance,
- net_balance_text = line_item_form.form.net_balance|accounting_format_amount,
- amount_data = line_item_form.form.amount.data|accounting_voucher_format_amount_input,
- amount_errors = line_item_form.form.amount.errors,
- amount_text = line_item_form.form.amount.data|accounting_format_amount,
- line_item_errors = line_item_form.form.all_errors %}
+ form = line_item_form.form %}
{% include "accounting/voucher/include/form-line-item.html" %}
{% endwith %}
{% endfor %}
diff --git a/src/accounting/voucher/forms/line_item.py b/src/accounting/voucher/forms/line_item.py
index 214af30..46dd82d 100644
--- a/src/accounting/voucher/forms/line_item.py
+++ b/src/accounting/voucher/forms/line_item.py
@@ -289,6 +289,8 @@ class LineItemForm(FlaskForm):
"""The Id of the original line item."""
account_code = StringField()
"""The account code."""
+ description = StringField()
+ """The description."""
amount = DecimalField()
"""The amount."""
diff --git a/src/accounting/voucher/utils/operators.py b/src/accounting/voucher/utils/operators.py
index e6a64a8..96319e5 100644
--- a/src/accounting/voucher/utils/operators.py
+++ b/src/accounting/voucher/utils/operators.py
@@ -28,6 +28,7 @@ from accounting.template_globals import default_currency_code
from accounting.utils.voucher_types import VoucherType
from accounting.voucher.forms import VoucherForm, CashReceiptVoucherForm, \
CashDisbursementVoucherForm, TransferVoucherForm
+from accounting.voucher.forms.line_item import LineItemForm
class VoucherOperator(ABC):
@@ -87,7 +88,8 @@ class VoucherOperator(ABC):
"accounting/voucher/include/form-line-item.html",
currency_index="CURRENCY_INDEX",
side="SIDE",
- line_item_index="LINE_ITEM_INDEX")
+ line_item_index="LINE_ITEM_INDEX",
+ form=LineItemForm())
class CashReceiptVoucher(VoucherOperator):