Renamed the IsDebitAccount, IsCreditAccount, NotStartPayableFromDebit, and NotStartReceivableFromCredit validators to IsExpenseAccount, IsIncomeAccount, NotStartPayableFromExpense, and NotStartReceivableFromIncome, respectively, in the "accounting.option.forms" module.
This commit is contained in:
parent
a4644ede5f
commit
9728ff30e0
@ -44,8 +44,8 @@ class AccountExists:
|
|||||||
"The account does not exist."))
|
"The account does not exist."))
|
||||||
|
|
||||||
|
|
||||||
class IsDebitAccount:
|
class IsExpenseAccount:
|
||||||
"""The validator to check if the account is for debit line items."""
|
"""The validator to check if the account is for expense."""
|
||||||
|
|
||||||
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
||||||
if field.data is None:
|
if field.data is None:
|
||||||
@ -55,11 +55,11 @@ class IsDebitAccount:
|
|||||||
and not field.data.startswith("3353-"):
|
and not field.data.startswith("3353-"):
|
||||||
return
|
return
|
||||||
raise ValidationError(lazy_gettext(
|
raise ValidationError(lazy_gettext(
|
||||||
"This account is not for debit line items."))
|
"This account is not for expense."))
|
||||||
|
|
||||||
|
|
||||||
class IsCreditAccount:
|
class IsIncomeAccount:
|
||||||
"""The validator to check if the account is for credit line items."""
|
"""The validator to check if the account is for income."""
|
||||||
|
|
||||||
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
||||||
if field.data is None:
|
if field.data is None:
|
||||||
@ -69,12 +69,12 @@ class IsCreditAccount:
|
|||||||
and not field.data.startswith("3353-"):
|
and not field.data.startswith("3353-"):
|
||||||
return
|
return
|
||||||
raise ValidationError(lazy_gettext(
|
raise ValidationError(lazy_gettext(
|
||||||
"This account is not for credit line items."))
|
"This account is not for income."))
|
||||||
|
|
||||||
|
|
||||||
class NotStartPayableFromDebit:
|
class NotStartPayableFromExpense:
|
||||||
"""The validator to check that a payable line item does not start from
|
"""The validator to check that a payable line item does not start from
|
||||||
debit."""
|
expense."""
|
||||||
|
|
||||||
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
||||||
if field.data is None or field.data[0] != "2":
|
if field.data is None or field.data[0] != "2":
|
||||||
@ -82,12 +82,12 @@ class NotStartPayableFromDebit:
|
|||||||
account: Account | None = Account.find_by_code(field.data)
|
account: Account | None = Account.find_by_code(field.data)
|
||||||
if account is not None and account.is_need_offset:
|
if account is not None and account.is_need_offset:
|
||||||
raise ValidationError(lazy_gettext(
|
raise ValidationError(lazy_gettext(
|
||||||
"A payable line item cannot start from debit."))
|
"A payable line item cannot start from expense."))
|
||||||
|
|
||||||
|
|
||||||
class NotStartReceivableFromCredit:
|
class NotStartReceivableFromIncome:
|
||||||
"""The validator to check that a receivable line item does not start
|
"""The validator to check that a receivable line item does not start
|
||||||
from credit."""
|
from income."""
|
||||||
|
|
||||||
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
def __call__(self, form: FlaskForm, field: StringField) -> None:
|
||||||
if field.data is None or field.data[0] != "1":
|
if field.data is None or field.data[0] != "1":
|
||||||
@ -95,7 +95,7 @@ class NotStartReceivableFromCredit:
|
|||||||
account: Account | None = Account.find_by_code(field.data)
|
account: Account | None = Account.find_by_code(field.data)
|
||||||
if account is not None and account.is_need_offset:
|
if account is not None and account.is_need_offset:
|
||||||
raise ValidationError(lazy_gettext(
|
raise ValidationError(lazy_gettext(
|
||||||
"A receivable line item cannot start from credit."))
|
"A receivable line item cannot start from income."))
|
||||||
|
|
||||||
|
|
||||||
class RecurringItemForm(FlaskForm):
|
class RecurringItemForm(FlaskForm):
|
||||||
@ -144,8 +144,8 @@ class RecurringExpenseForm(RecurringItemForm):
|
|||||||
account_code = StringField(
|
account_code = StringField(
|
||||||
filters=[strip_text],
|
filters=[strip_text],
|
||||||
validators=[AccountExists(),
|
validators=[AccountExists(),
|
||||||
IsDebitAccount(),
|
IsExpenseAccount(),
|
||||||
NotStartPayableFromDebit()])
|
NotStartPayableFromExpense()])
|
||||||
"""The account code."""
|
"""The account code."""
|
||||||
description_template = StringField(
|
description_template = StringField(
|
||||||
filters=[strip_text],
|
filters=[strip_text],
|
||||||
@ -166,8 +166,8 @@ class RecurringIncomeForm(RecurringItemForm):
|
|||||||
account_code = StringField(
|
account_code = StringField(
|
||||||
filters=[strip_text],
|
filters=[strip_text],
|
||||||
validators=[AccountExists(),
|
validators=[AccountExists(),
|
||||||
IsCreditAccount(),
|
IsIncomeAccount(),
|
||||||
NotStartReceivableFromCredit()])
|
NotStartReceivableFromIncome()])
|
||||||
"""The account code."""
|
"""The account code."""
|
||||||
description_template = StringField(
|
description_template = StringField(
|
||||||
filters=[strip_text],
|
filters=[strip_text],
|
||||||
|
Loading…
Reference in New Issue
Block a user