@@ -60,13 +60,12 @@ ACCOUNTS = [
'Liabilities:Payable:Accounts',
'Liabilities:Payable:Vacation',
]
CONSISTENT_METADATA = [
'contract',
'entity',
'purchase-order',
class AgingRow(NamedTuple):
date: datetime.date
entity: Sequence[str]
@@ -351,12 +350,45 @@ def test_accrual_postings_consistent_metadata(meta_key, acct_name):
])
related = accrual.AccrualPostings(data.Posting.from_txn(txn))
attr_name = meta_key.replace('-', '_')
assert getattr(related, attr_name) == meta_value
assert getattr(related, f'{attr_name}s') == {meta_value}
def test_accrual_postings_entity():
txn = testutil.Transaction(postings=[
(ACCOUNTS[0], 25, {'entity': 'Accruee'}),
(ACCOUNTS[0], -15, {'entity': 'Payee15'}),
(ACCOUNTS[0], -10, {'entity': 'Payee10'}),
assert related.accrued_entities == {'Accruee'}
assert related.paid_entities == {'Payee10', 'Payee15'}
def test_accrual_postings_entities():
actual = related.entities()
assert next(actual, None) == 'Accruee'
assert set(actual) == {'Payee10', 'Payee15'}
def test_accrual_postings_entities_no_duplicates():
(ACCOUNTS[0], -15, {'entity': 'Accruee'}),
(ACCOUNTS[0], -10, {'entity': 'Other'}),
assert next(actual, None) == 'Other'
assert next(actual, None) is None
def test_accrual_postings_inconsistent_account():
meta = {'invoice': 'invoice.pdf'}
(acct_name, index, meta)
for index, acct_name in enumerate(ACCOUNTS)
@@ -396,13 +428,13 @@ def test_consistency_check_when_consistent(meta_key, account):
(account, -100, meta),
assert not list(related.report_inconsistencies())
@pytest.mark.parametrize('meta_key,account', testutil.combine_values(
['approval', 'fx-rate', 'statement'],
['approval', 'entity', 'fx-rate', 'statement'],
ACCOUNTS,
))
def test_consistency_check_ignored_metadata(meta_key, account):
invoice = f'test-{meta_key}-invoice'
(account, 100, {'invoice': invoice, meta_key: 'credit'}),