data.Account: Add is_real_asset method.
This commit is contained in:
parent
661fe676e1
commit
28238643a3
2 changed files with 19 additions and 0 deletions
|
@ -35,6 +35,12 @@ from .beancount_types import (
|
|||
class Account(str):
|
||||
SEP = bc_account.sep
|
||||
|
||||
def is_real_asset(self) -> bool:
|
||||
return (
|
||||
self.is_under('Assets:')
|
||||
and not self.is_under('Assets:PrepaidExpenses')
|
||||
)
|
||||
|
||||
def is_under(self, acct_s: str) -> bool:
|
||||
return self.startswith(acct_s) and (
|
||||
acct_s.endswith(self.SEP)
|
||||
|
|
|
@ -30,3 +30,16 @@ from conservancy_beancount import data
|
|||
])
|
||||
def test_is_under(acct_name, under_arg, expected):
|
||||
assert data.Account(acct_name).is_under(under_arg) == expected
|
||||
|
||||
@pytest.mark.parametrize('acct_name,expected', [
|
||||
('Accrued:AccountsPayable', False),
|
||||
('Accrued:AccountsReceivable', False),
|
||||
('Assets:Cash', True),
|
||||
('Assets:Cash:EUR', True),
|
||||
('Assets:PrepaidExpenses', False),
|
||||
('Assets:Bank:Checking', True),
|
||||
('Expenses:General', False),
|
||||
('Income:Donations', False),
|
||||
])
|
||||
def test_is_real_asset(acct_name, expected):
|
||||
assert data.Account(acct_name).is_real_asset() == expected
|
||||
|
|
Loading…
Reference in a new issue