diff --git a/accounting/forms.py b/accounting/forms.py
index 81d725c..86e1ffa 100644
--- a/accounting/forms.py
+++ b/accounting/forms.py
@@ -294,7 +294,7 @@ class TransactionForm(forms.Form):
int: The total amount of the credit records.
"""
return sum([int(x.data["amount"]) for x in self.debit_records
- if "amount" not in x.errors])
+ if "amount" in x.data and "amount" not in x.errors])
def credit_total(self):
"""Returns the total amount of the credit records.
@@ -303,7 +303,7 @@ class TransactionForm(forms.Form):
int: The total amount of the credit records.
"""
return sum([int(x.data["amount"]) for x in self.credit_records
- if "amount" not in x.errors])
+ if "amount" in x.data and "amount" not in x.errors])
class AccountForm(forms.Form):
diff --git a/accounting/templates/accounting/include/record_form-non-transfer.html b/accounting/templates/accounting/include/record_form-non-transfer.html
index 27997e7..0c6cec4 100644
--- a/accounting/templates/accounting/include/record_form-non-transfer.html
+++ b/accounting/templates/accounting/include/record_form-non-transfer.html
@@ -20,8 +20,8 @@ Author: imacat@mail.imacat.idv.tw (imacat)
First written: 2020/8/5
{% endcomment %}
-
-
{% if should_validate and record.non_field_errors %}{{ record.non_field_errors.0 }}{% endif %}
+
+
{% if record.non_field_errors %}{{ record.non_field_errors.0 }}{% endif %}