diff --git a/conservancy_beancount/plugin/meta_approval.py b/conservancy_beancount/plugin/meta_approval.py index 8bc8d97..416e23d 100644 --- a/conservancy_beancount/plugin/meta_approval.py +++ b/conservancy_beancount/plugin/meta_approval.py @@ -47,7 +47,7 @@ class MetaApproval(core._RequireLinksPostingMetadataHook): # In this case, debits_sum keeps a running tally of how much is # moving in each direction, and we'll return True if it ends up over # the payment threshold. - elif post.is_payment(0) or post.account.is_credit_card(): + elif post.account.is_cash_equivalent() or post.account.is_credit_card(): debits_sum -= post.units.number or 0 return debits_sum > self.payment_threshold diff --git a/tests/test_meta_approval.py b/tests/test_meta_approval.py index 2bc883c..da0d7f5 100644 --- a/tests/test_meta_approval.py +++ b/tests/test_meta_approval.py @@ -156,3 +156,21 @@ def test_approval_not_required_to_pay_credit_card(hook): (CREDITCARD_ACCOUNT, 25), ]) assert not list(hook.run(txn)) + +def test_approval_not_required_for_asset_transfers(hook): + txn = testutil.Transaction(postings=[ + ('Assets:Checking', -250, {'tax-implication': 'Bank-Transfer'}), + ('Assets:Savings', 250), + ]) + assert not list(hook.run(txn)) + +def test_approval_required_for_partial_transfer(hook): + # I'm not sure this ever comes up in reality, but just being thorough + # out of an abundance of precaution. + txn = testutil.Transaction(postings=[ + ('Assets:Checking', -250, {'tax-implication': 'Bank-Transfer'}), + ('Assets:Savings', 225), + ('Expenses:BankingFees', 25), + ]) + actual = {error.message for error in hook.run(txn)} + assert actual == {"Assets:Checking missing {}".format(TEST_KEY)}