Reordered the validators in the "accounting.transaction.forms.journal_entry" module.

This commit is contained in:
依瑪貓 2023-03-16 20:42:32 +08:00
parent 23a0721d8d
commit 40e329d37f

View File

@ -46,17 +46,6 @@ class AccountExists:
"The account does not exist."))
class PositiveAmount:
"""The validator to check if the amount is positive."""
def __call__(self, form: FlaskForm, field: DecimalField) -> None:
if field.data is None:
return
if field.data <= 0:
raise ValidationError(lazy_gettext(
"Please fill in a positive amount."))
class IsDebitAccount:
"""The validator to check if the account is for debit journal entries."""
@ -85,6 +74,17 @@ class IsCreditAccount:
"This account is not for credit entries."))
class PositiveAmount:
"""The validator to check if the amount is positive."""
def __call__(self, form: FlaskForm, field: DecimalField) -> None:
if field.data is None:
return
if field.data <= 0:
raise ValidationError(lazy_gettext(
"Please fill in a positive amount."))
class JournalEntryForm(FlaskForm):
"""The base form to create or edit a journal entry."""
eid = IntegerField()