Account: Add is_opening_balance method.
This commit is contained in:
parent
8f81530f6d
commit
e00ec95d93
2 changed files with 20 additions and 0 deletions
|
@ -78,6 +78,9 @@ class Account(str):
|
||||||
def is_credit_card(self) -> bool:
|
def is_credit_card(self) -> bool:
|
||||||
return self.is_under('Liabilities:CreditCard') is not None
|
return self.is_under('Liabilities:CreditCard') is not None
|
||||||
|
|
||||||
|
def is_opening_equity(self) -> bool:
|
||||||
|
return self.is_under('Equity:Funds', 'Equity:OpeningBalance') is not None
|
||||||
|
|
||||||
def is_under(self, *acct_seq: str) -> Optional[str]:
|
def is_under(self, *acct_seq: str) -> Optional[str]:
|
||||||
"""Return a match if this account is "under" a part of the hierarchy
|
"""Return a match if this account is "under" a part of the hierarchy
|
||||||
|
|
||||||
|
|
|
@ -98,3 +98,20 @@ def test_is_checking(acct_name, expected):
|
||||||
])
|
])
|
||||||
def test_is_credit_card(acct_name, expected):
|
def test_is_credit_card(acct_name, expected):
|
||||||
assert data.Account(acct_name).is_credit_card() == expected
|
assert data.Account(acct_name).is_credit_card() == expected
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('acct_name,expected', [
|
||||||
|
('Assets:Cash', False),
|
||||||
|
('Assets:Prepaid:Expenses', False),
|
||||||
|
('Assets:Receivable:Accounts', False),
|
||||||
|
('Expenses:Other', False),
|
||||||
|
('Equity:Funds:Restricted', True),
|
||||||
|
('Equity:Funds:Unrestricted', True),
|
||||||
|
('Equity:OpeningBalance', True),
|
||||||
|
('Equity:Retained:Costs', False),
|
||||||
|
('Income:Other', False),
|
||||||
|
('Liabilities:CreditCard', False),
|
||||||
|
('Liabilities:Payable:Accounts', False),
|
||||||
|
('Liabilities:UnearnedIncome:Donations', False),
|
||||||
|
])
|
||||||
|
def test_is_opening_equity(acct_name, expected):
|
||||||
|
assert data.Account(acct_name).is_opening_equity() == expected
|
||||||
|
|
Loading…
Reference in a new issue