Changeset - 2d49f7dfbcf4
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-03-30 19:01:25
brettcsmith@brettcsmith.org
data: Add Account.is_checking() method.
2 files changed with 22 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/data.py
Show inline comments
...
 
@@ -59,12 +59,15 @@ class Account(str):
 
    This is a string that names an account, like Accrued:AccountsPayable
 
    or Income:Donations. This class provides additional methods for common
 
    account name parsing and queries.
 
    """
 
    SEP = bc_account.sep
 

	
 
    def is_checking(self) -> bool:
 
        return self.is_real_asset() and ':Check' in self
 

	
 
    def is_income(self) -> bool:
 
        return self.is_under('Income:', 'UnearnedIncome:') is not None
 

	
 
    def is_real_asset(self) -> bool:
 
        return bool(
 
            self.is_under('Assets:')
tests/test_data_account.py
Show inline comments
...
 
@@ -68,6 +68,25 @@ def test_is_income(acct_name, expected):
 
    ('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
 

	
 
@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
0 comments (0 inline, 0 general)