Changeset - 8f81530f6d97
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-04-08 18:20:00
brettcsmith@brettcsmith.org
meta_approval: Use data.balance_of.
1 file changed with 7 insertions and 9 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/plugin/meta_approval.py
Show inline comments
...
 
@@ -29,5 +29,5 @@ class MetaApproval(core._RequireLinksPostingMetadataHook):
 

	
 
    def __init__(self, config: configmod.Config) -> None:
 
        self.payment_threshold = config.payment_threshold()
 
        self.payment_threshold = -config.payment_threshold()
 

	
 
    def _run_on_txn(self, txn: Transaction) -> bool:
...
 
@@ -37,12 +37,10 @@ class MetaApproval(core._RequireLinksPostingMetadataHook):
 
        # UNLESS that transaction is a transfer to another asset,
 
        # or paying off a credit card.
 
        # 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.
 
        debits_sum = decimal.Decimal(0)
 
        for post in data.iter_postings(txn):
 
            if post.account.is_cash_equivalent() or post.account.is_credit_card():
 
                debits_sum -= post.units.number or 0
 
        return debits_sum > self.payment_threshold
 
        balance = data.balance_of(
 
            txn,
 
            data.Account.is_cash_equivalent,
 
            data.Account.is_credit_card,
 
        )
 
        return balance is None or balance < self.payment_threshold
 

	
 
    def _run_on_post(self, txn: Transaction, post: data.Posting) -> bool:
0 comments (0 inline, 0 general)