From 6aadb740e619d19352370a992b46e54268f48033 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Fri, 1 May 2020 16:18:46 -0400 Subject: [PATCH] meta_receipt: Don't check chargebacks. RT#10978. --- conservancy_beancount/plugin/meta_receipt.py | 1 + tests/test_meta_receipt.py | 22 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/conservancy_beancount/plugin/meta_receipt.py b/conservancy_beancount/plugin/meta_receipt.py index c620579..01036fd 100644 --- a/conservancy_beancount/plugin/meta_receipt.py +++ b/conservancy_beancount/plugin/meta_receipt.py @@ -40,6 +40,7 @@ class MetaReceipt(core._RequireLinksPostingMetadataHook): (post.account.is_cash_equivalent() or post.account.is_credit_card()) and not post.account.is_under('Assets:PayPal') and abs(post.units.number) >= self.payment_threshold + and post.meta.get('tax-implication', '').title() != 'Chargeback' ) def _run_checking_debit(self, txn: Transaction, post: data.Posting) -> errormod.Iter: diff --git a/tests/test_meta_receipt.py b/tests/test_meta_receipt.py index af7a370..a4c59bd 100644 --- a/tests/test_meta_receipt.py +++ b/tests/test_meta_receipt.py @@ -343,6 +343,28 @@ def test_fallback_on_zero_amount_postings(hook, test_acct, other_acct, value): ]) assert not list(hook.run(txn)) +@pytest.mark.parametrize('test_acct,other_acct', testutil.combine_values( + ACCOUNTS, + NOT_REQUIRED_ACCOUNTS, +)) +def test_not_required_on_chargeback_txns(hook, test_acct, other_acct): + if test_acct.required_types & PostType.DEBIT: + check(hook, test_acct, other_acct, None, + txn_meta={'tax-implication': 'Chargeback'}, + check_type=PostType.DEBIT, + ) + +@pytest.mark.parametrize('test_acct,other_acct', testutil.combine_values( + ACCOUNTS, + NOT_REQUIRED_ACCOUNTS, +)) +def test_not_required_on_chargeback_posts(hook, test_acct, other_acct): + if test_acct.required_types & PostType.DEBIT: + check(hook, test_acct, other_acct, None, + post_meta={'tax-implication': 'Chargeback'}, + check_type=PostType.DEBIT, + ) + @pytest.mark.parametrize('test_acct,equity_acct', testutil.combine_values( ACCOUNTS, testutil.OPENING_EQUITY_ACCOUNTS,