@@ -58,7 +58,7 @@ LINK_METADATA = frozenset([
class Account(str):
"""Account name string
This is a string that names an account, like Accrued:AccountsPayable
This is a string that names an account, like Assets:Bank:Checking
or Income:Donations. This class provides additional methods for common
account name parsing and queries.
"""
@@ -66,17 +66,17 @@ class Account(str):
SEP = bc_account.sep
def is_checking(self) -> bool:
return self.is_real_asset() and ':Check' in self
def is_cash_equivalent(self) -> bool:
return (
self.is_under('Assets:') is not None
and self.is_under('Assets:Prepaid', 'Assets:Receivable') is None
)
def is_income(self) -> bool:
return self.is_under('Income:', 'UnearnedIncome:') is not None
return self.is_cash_equivalent() and ':Check' in self
def is_real_asset(self) -> bool:
return bool(
self.is_under('Assets:')
and not self.is_under('Assets:PrepaidExpenses', 'Assets:PrepaidVacation')
def is_credit_card(self) -> bool:
return self.is_under('Liabilities:CreditCard') is not None
def is_under(self, *acct_seq: str) -> Optional[str]:
"""Return a match if this account is "under" a part of the hierarchy
@@ -248,7 +248,7 @@ class Posting(BasePosting):
threshold: DecimalCompat=0,
default: Optional[bool]=None,
) -> Optional[bool]:
return self.account.is_real_asset() and self.is_debit(threshold, default)
return self.account.is_cash_equivalent() and self.is_debit(threshold, default)
def iter_postings(txn: Transaction) -> Iterator[Posting]: