meta_approval: Not required for chargebacks. RT#10978.

This commit is contained in:
Brett Smith 2020-05-01 16:24:24 -04:00
parent 23e1ed7cee
commit e429a6c6fd
2 changed files with 12 additions and 4 deletions

View file

@ -44,4 +44,8 @@ class MetaApproval(core._RequireLinksPostingMetadataHook):
)
def _run_on_post(self, txn: Transaction, post: data.Posting) -> bool:
return post.account.is_cash_equivalent() and post.units.number < 0
return (
post.account.is_cash_equivalent()
and post.units.number < 0
and post.meta.get('tax-implication', '').title() != 'Chargeback'
)

View file

@ -159,10 +159,14 @@ def test_approval_not_required_to_pay_credit_card(hook):
])
assert not list(hook.run(txn))
def test_approval_not_required_for_asset_transfers(hook):
@pytest.mark.parametrize('tax_implication,other_acct', [
('Bank-Transfer', 'Assets:Savings'),
('Chargeback', 'Income:Donations'),
])
def test_approval_not_required_for_asset_transfers(hook, tax_implication, other_acct):
txn = testutil.Transaction(postings=[
('Assets:Checking', -250, {'tax-implication': 'Bank-Transfer'}),
('Assets:Savings', 250),
('Assets:Checking', -250, {'tax-implication': tax_implication}),
(other_acct, 250),
])
assert not list(hook.run(txn))