data: Add Account.is_checking() method.

This commit is contained in:
Brett Smith 2020-03-30 15:01:25 -04:00
parent 8a2721ec0f
commit 2d49f7dfbc
2 changed files with 22 additions and 0 deletions

View file

@ -62,6 +62,9 @@ class Account(str):
""" """
SEP = bc_account.sep SEP = bc_account.sep
def is_checking(self) -> bool:
return self.is_real_asset() and ':Check' in self
def is_income(self) -> bool: def is_income(self) -> bool:
return self.is_under('Income:', 'UnearnedIncome:') is not None return self.is_under('Income:', 'UnearnedIncome:') is not None

View file

@ -71,3 +71,22 @@ def test_is_income(acct_name, expected):
]) ])
def test_is_real_asset(acct_name, expected): def test_is_real_asset(acct_name, expected):
assert data.Account(acct_name).is_real_asset() == expected assert data.Account(acct_name).is_real_asset() == expected
@pytest.mark.parametrize('acct_name,expected', [
('Accrued:AccountsPayable', False),
('Accrued:AccountsReceivable', False),
('Assets:Bank:Check9999', True),
('Assets:Bank:CheckCard', True),
('Assets:Bank:Checking', True),
('Assets:Bank:Savings', False),
('Assets:Cash', False),
('Assets:Check9999', True),
('Assets:CheckCard', True),
('Assets:Checking', True),
('Assets:PrepaidExpenses', False),
('Assets:Savings', False),
('Expenses:CheckingFees', False),
('Income:Interest:Checking', False),
])
def test_is_checking(acct_name, expected):
assert data.Account(acct_name).is_checking() == expected