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:
|
class IsDebitAccount:
|
||||||
"""The validator to check if the account is for debit line items."""
|
"""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.
|
"""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
|
self.__message: str | LazyString = message
|
||||||
|
|
||||||
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
||||||
@ -76,14 +73,11 @@ class IsDebitAccount:
|
|||||||
class IsCreditAccount:
|
class IsCreditAccount:
|
||||||
"""The validator to check if the account is for credit line items."""
|
"""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.
|
"""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
|
self.__message: str | LazyString = message
|
||||||
|
|
||||||
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
||||||
|
@ -413,12 +413,14 @@ class DebitLineItemForm(LineItemForm):
|
|||||||
"""The ID of the original line item."""
|
"""The ID of the original line item."""
|
||||||
account_code = StringField(
|
account_code = StringField(
|
||||||
filters=[strip_text],
|
filters=[strip_text],
|
||||||
validators=[ACCOUNT_REQUIRED,
|
validators=[
|
||||||
AccountExists(),
|
ACCOUNT_REQUIRED,
|
||||||
IsDebitAccount(),
|
AccountExists(),
|
||||||
SameAccountAsOriginalLineItem(),
|
IsDebitAccount(lazy_gettext(
|
||||||
KeepAccountWhenHavingOffset(),
|
"This account is not for debit line items.")),
|
||||||
NotStartPayableFromDebit()])
|
SameAccountAsOriginalLineItem(),
|
||||||
|
KeepAccountWhenHavingOffset(),
|
||||||
|
NotStartPayableFromDebit()])
|
||||||
"""The account code."""
|
"""The account code."""
|
||||||
description = StringField(filters=[strip_text])
|
description = StringField(filters=[strip_text])
|
||||||
"""The description."""
|
"""The description."""
|
||||||
@ -463,12 +465,14 @@ class CreditLineItemForm(LineItemForm):
|
|||||||
"""The ID of the original line item."""
|
"""The ID of the original line item."""
|
||||||
account_code = StringField(
|
account_code = StringField(
|
||||||
filters=[strip_text],
|
filters=[strip_text],
|
||||||
validators=[ACCOUNT_REQUIRED,
|
validators=[
|
||||||
AccountExists(),
|
ACCOUNT_REQUIRED,
|
||||||
IsCreditAccount(),
|
AccountExists(),
|
||||||
SameAccountAsOriginalLineItem(),
|
IsCreditAccount(lazy_gettext(
|
||||||
KeepAccountWhenHavingOffset(),
|
"This account is not for credit line items.")),
|
||||||
NotStartReceivableFromCredit()])
|
SameAccountAsOriginalLineItem(),
|
||||||
|
KeepAccountWhenHavingOffset(),
|
||||||
|
NotStartReceivableFromCredit()])
|
||||||
"""The account code."""
|
"""The account code."""
|
||||||
description = StringField(filters=[strip_text])
|
description = StringField(filters=[strip_text])
|
||||||
"""The description."""
|
"""The description."""
|
||||||
|
Loading…
Reference in New Issue
Block a user