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