Revised the IsDebitAccount and IsCreditAccount validators to require the error message, and moved their default error messages to the DebitLineItemForm and CreditLineItemForm forms.
This commit is contained in:
parent
7ccc96bda0
commit
35e05b3708
@ -53,14 +53,11 @@ class AccountExists:
|
||||
class IsDebitAccount:
|
||||
"""The validator to check if the account is for debit line items."""
|
||||
|
||||
def __init__(self, message: str | LazyString | None = None):
|
||||
def __init__(self, message: str | LazyString):
|
||||
"""Constructs the validator.
|
||||
|
||||
:param message: The optional custom error message.
|
||||
:param message: The error message.
|
||||
"""
|
||||
if message is None:
|
||||
message = lazy_gettext(
|
||||
"This account is not for debit line items.")
|
||||
self.__message: str | LazyString = message
|
||||
|
||||
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
||||
@ -76,14 +73,11 @@ class IsDebitAccount:
|
||||
class IsCreditAccount:
|
||||
"""The validator to check if the account is for credit line items."""
|
||||
|
||||
def __init__(self, message: str | LazyString | None = None):
|
||||
def __init__(self, message: str | LazyString):
|
||||
"""Constructs the validator.
|
||||
|
||||
:param message: The optional custom error message.
|
||||
:param message: The error message.
|
||||
"""
|
||||
if message is None:
|
||||
message = lazy_gettext(
|
||||
"This account is not for credit line items.")
|
||||
self.__message: str | LazyString = message
|
||||
|
||||
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
||||
|
@ -413,9 +413,11 @@ class DebitLineItemForm(LineItemForm):
|
||||
"""The ID of the original line item."""
|
||||
account_code = StringField(
|
||||
filters=[strip_text],
|
||||
validators=[ACCOUNT_REQUIRED,
|
||||
validators=[
|
||||
ACCOUNT_REQUIRED,
|
||||
AccountExists(),
|
||||
IsDebitAccount(),
|
||||
IsDebitAccount(lazy_gettext(
|
||||
"This account is not for debit line items.")),
|
||||
SameAccountAsOriginalLineItem(),
|
||||
KeepAccountWhenHavingOffset(),
|
||||
NotStartPayableFromDebit()])
|
||||
@ -463,9 +465,11 @@ class CreditLineItemForm(LineItemForm):
|
||||
"""The ID of the original line item."""
|
||||
account_code = StringField(
|
||||
filters=[strip_text],
|
||||
validators=[ACCOUNT_REQUIRED,
|
||||
validators=[
|
||||
ACCOUNT_REQUIRED,
|
||||
AccountExists(),
|
||||
IsCreditAccount(),
|
||||
IsCreditAccount(lazy_gettext(
|
||||
"This account is not for credit line items.")),
|
||||
SameAccountAsOriginalLineItem(),
|
||||
KeepAccountWhenHavingOffset(),
|
||||
NotStartReceivableFromCredit()])
|
||||
|
Loading…
Reference in New Issue
Block a user