meta_approval: Not required for bank transfers. RT#10635.
This commit is contained in:
		
							parent
							
								
									bce438167c
								
							
						
					
					
						commit
						f24f941cfb
					
				
					 2 changed files with 19 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue