From f6946c11653716b6a3a149afc73e7f53d87b92fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 11 Mar 2023 19:08:10 +0800 Subject: [PATCH] Revised the IsBalanced validator so that it no longer need the __future__ annotation. --- src/accounting/transaction/forms/currency.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/accounting/transaction/forms/currency.py b/src/accounting/transaction/forms/currency.py index c53e24b..5f5c15c 100644 --- a/src/accounting/transaction/forms/currency.py +++ b/src/accounting/transaction/forms/currency.py @@ -17,8 +17,6 @@ """The currency sub-forms for the transaction management. """ -from __future__ import annotations - from decimal import Decimal from flask_babel import LazyString @@ -62,8 +60,9 @@ class IsBalanced: """The validator to check that the total amount of the debit and credit entries are equal.""" - def __call__(self, form: TransferCurrencyForm, field: BooleanField)\ - -> None: + def __call__(self, form: FlaskForm, field: BooleanField) -> None: + if not isinstance(form, TransferCurrencyForm): + return if len(form.debit) == 0 or len(form.credit) == 0: return if form.debit_total != form.credit_total: