Revised the IsBalanced validator so that it no longer need the __future__ annotation.

This commit is contained in:
依瑪貓 2023-03-11 19:08:10 +08:00
parent 8e219d8006
commit f6946c1165

View File

@ -17,8 +17,6 @@
"""The currency sub-forms for the transaction management. """The currency sub-forms for the transaction management.
""" """
from __future__ import annotations
from decimal import Decimal from decimal import Decimal
from flask_babel import LazyString from flask_babel import LazyString
@ -62,8 +60,9 @@ class IsBalanced:
"""The validator to check that the total amount of the debit and credit """The validator to check that the total amount of the debit and credit
entries are equal.""" entries are equal."""
def __call__(self, form: TransferCurrencyForm, field: BooleanField)\ def __call__(self, form: FlaskForm, field: BooleanField) -> None:
-> None: if not isinstance(form, TransferCurrencyForm):
return
if len(form.debit) == 0 or len(form.credit) == 0: if len(form.debit) == 0 or len(form.credit) == 0:
return return
if form.debit_total != form.credit_total: if form.debit_total != form.credit_total: