Moved the ACCOUNT_REQUIRED validator from the "accounting.journal_entry.forms.line_item" module to the "accounting.forms" module, in order to share it.

This commit is contained in:
依瑪貓 2023-03-22 23:23:53 +08:00
parent 35e05b3708
commit 87fa5aa6bc
2 changed files with 9 additions and 6 deletions

View File

@ -22,12 +22,18 @@ import re
from flask_babel import LazyString
from flask_wtf import FlaskForm
from wtforms import StringField, ValidationError
from wtforms.validators import DataRequired
from accounting import db
from accounting.locale import lazy_gettext
from accounting.models import Currency, Account
ACCOUNT_REQUIRED: DataRequired = DataRequired(
lazy_gettext("Please select the account."))
"""The validator to check if the account code is empty."""
class CurrencyExists:
"""The validator to check if the account exists."""

View File

@ -25,10 +25,11 @@ from flask_babel import LazyString
from flask_wtf import FlaskForm
from sqlalchemy.orm import selectinload
from wtforms import StringField, ValidationError, DecimalField, IntegerField
from wtforms.validators import DataRequired, Optional
from wtforms.validators import Optional
from accounting import db
from accounting.forms import AccountExists, IsDebitAccount, IsCreditAccount
from accounting.forms import ACCOUNT_REQUIRED, AccountExists, IsDebitAccount, \
IsCreditAccount
from accounting.locale import lazy_gettext
from accounting.models import Account, JournalEntryLineItem
from accounting.template_filters import format_amount
@ -37,10 +38,6 @@ from accounting.utils.random_id import new_id
from accounting.utils.strip_text import strip_text
from accounting.utils.user import get_current_user_pk
ACCOUNT_REQUIRED: DataRequired = DataRequired(
lazy_gettext("Please select the account."))
"""The validator to check if the account code is empty."""
class OriginalLineItemExists:
"""The validator to check if the original line item exists."""