diff --git a/src/accounting/account/forms.py b/src/accounting/account/forms.py index 24904b4..291aaee 100644 --- a/src/accounting/account/forms.py +++ b/src/accounting/account/forms.py @@ -57,10 +57,9 @@ class NoOffsetNominalAccount: """The validator to check nominal account is not to be offset.""" def __call__(self, form: FlaskForm, field: BooleanField) -> None: + assert isinstance(form, AccountForm) if not field.data: return - if not isinstance(form, AccountForm): - return if form.base_code.data is None: return if form.base_code.data[0] not in {"1", "2"}: diff --git a/src/accounting/currency/forms.py b/src/accounting/currency/forms.py index b3dff4d..ae59cb9 100644 --- a/src/accounting/currency/forms.py +++ b/src/accounting/currency/forms.py @@ -32,10 +32,9 @@ class CodeUnique: """The validator to check if the code is unique.""" def __call__(self, form: FlaskForm, field: StringField) -> None: + assert isinstance(form, CurrencyForm) if field.data == "": return - if not isinstance(form, CurrencyForm): - return if form.obj_code is not None and form.obj_code == field.data: return if db.session.get(Currency, field.data) is not None: diff --git a/src/accounting/transaction/forms/currency.py b/src/accounting/transaction/forms/currency.py index 5f5c15c..36162db 100644 --- a/src/accounting/transaction/forms/currency.py +++ b/src/accounting/transaction/forms/currency.py @@ -61,8 +61,7 @@ class IsBalanced: entries are equal.""" def __call__(self, form: FlaskForm, field: BooleanField) -> None: - if not isinstance(form, TransferCurrencyForm): - return + assert isinstance(form, TransferCurrencyForm) if len(form.debit) == 0 or len(form.credit) == 0: return if form.debit_total != form.credit_total: