Renamed all the is_XXX_needed properties to is_need_XXX. For example, especially the is_offset_needed property to is_need_offset, to be clear and understandable.

This commit is contained in:
2023-03-18 22:52:29 +08:00
parent 98e1bad413
commit 5571c0d01f
21 changed files with 55 additions and 55 deletions

View File

@ -81,7 +81,7 @@ class OriginalEntryNeedOffset:
= db.session.get(JournalEntry, field.data)
if original_entry is None:
return
if not original_entry.account.is_offset_needed:
if not original_entry.account.is_need_offset:
raise ValidationError(lazy_gettext(
"The original entry does not need offset."))
@ -186,7 +186,7 @@ class NotStartPayableFromDebit:
or form.original_entry_id.data is not None:
return
account: Account | None = Account.find_by_code(field.data)
if account is not None and account.is_offset_needed:
if account is not None and account.is_need_offset:
raise ValidationError(lazy_gettext(
"A payable entry cannot start from the debit side."))
@ -202,7 +202,7 @@ class NotStartReceivableFromCredit:
or form.original_entry_id.data is not None:
return
account: Account | None = Account.find_by_code(field.data)
if account is not None and account.is_offset_needed:
if account is not None and account.is_need_offset:
raise ValidationError(lazy_gettext(
"A receivable entry cannot start from the credit side."))
@ -361,7 +361,7 @@ class JournalEntryForm(FlaskForm):
else:
return False
account: Account | None = Account.find_by_code(self.account_code.data)
return account is not None and account.is_offset_needed
return account is not None and account.is_need_offset
@property
def offsets(self) -> list[JournalEntry]:

View File

@ -219,7 +219,7 @@ class TransactionForm(FlaskForm):
"""
accounts: list[AccountOption] \
= [AccountOption(x) for x in Account.debit()
if not (x.code[0] == "2" and x.is_offset_needed)]
if not (x.code[0] == "2" and x.is_need_offset)]
in_use: set[int] = set(db.session.scalars(
sa.select(JournalEntry.account_id)
.filter(JournalEntry.is_debit)
@ -236,7 +236,7 @@ class TransactionForm(FlaskForm):
"""
accounts: list[AccountOption] \
= [AccountOption(x) for x in Account.credit()
if not (x.code[0] == "1" and x.is_offset_needed)]
if not (x.code[0] == "1" and x.is_need_offset)]
in_use: set[int] = set(db.session.scalars(
sa.select(JournalEntry.account_id)
.filter(sa.not_(JournalEntry.is_debit))

View File

@ -38,7 +38,7 @@ class AccountOption:
"""The string representation of the account option."""
self.is_in_use: bool = False
"""True if this account is in use, or False otherwise."""
self.is_offset_needed: bool = account.is_offset_needed
self.is_need_offset: bool = account.is_need_offset
"""True if this account needs offset, or False otherwise."""
def __str__(self) -> str:

View File

@ -50,7 +50,7 @@ def get_selectable_original_entries(
(offset.c.id.in_(entry_id_on_form), 0),
(be(offset.c.is_debit == JournalEntry.is_debit), offset.c.amount),
else_=-offset.c.amount))).label("net_balance")
conditions: list[sa.BinaryExpression] = [Account.is_offset_needed]
conditions: list[sa.BinaryExpression] = [Account.is_need_offset]
sub_conditions: list[sa.BinaryExpression] = []
if is_payable:
sub_conditions.append(sa.and_(Account.base_code.startswith("2"),