Added the ACCOUNT_REQUIRED validator to the account_code field of the RecurringExpenseForm and RecurringIncomeForm forms.

This commit is contained in:
依瑪貓 2023-03-22 23:25:20 +08:00
parent 87fa5aa6bc
commit 6f773dd837

View File

@ -23,8 +23,8 @@ from flask_wtf import FlaskForm
from wtforms import StringField, FieldList, FormField, IntegerField
from wtforms.validators import DataRequired, ValidationError
from accounting.forms import CurrencyExists, AccountExists, IsDebitAccount, \
IsCreditAccount
from accounting.forms import ACCOUNT_REQUIRED, CurrencyExists, AccountExists, \
IsDebitAccount, IsCreditAccount
from accounting.locale import lazy_gettext
from accounting.models import Account
from accounting.utils.current_account import CurrentAccount
@ -126,6 +126,7 @@ class RecurringExpenseForm(RecurringItemForm):
account_code = StringField(
filters=[strip_text],
validators=[
ACCOUNT_REQUIRED,
AccountExists(),
IsDebitAccount(lazy_gettext("This account is not for expense.")),
NotStartPayableFromExpense()])
@ -149,6 +150,7 @@ class RecurringIncomeForm(RecurringItemForm):
account_code = StringField(
filters=[strip_text],
validators=[
ACCOUNT_REQUIRED,
AccountExists(),
IsCreditAccount(lazy_gettext("This account is not for income.")),
NotStartReceivableFromIncome()])