예제 #1
0
def get_transactions(chart, config, opts):
    transactions = []
    for cache in abo.cache.transaction_caches(chart, config, opts):
        transactions += cache.transactions()
    if not opts['--projection']:
        transactions = [t for t in transactions if not t.is_projection]
    if opts['--effective']:
        datekey = lambda t: (t.edate, t.date)
    else:
        datekey = lambda t: (t.date, t.edate)
    transactions.sort(key=lambda t: datekey(t) + (t.who or '', t.what or '', -t.amount()))
    if opts['--remove']:
        for text in opts['--remove']:
            try:
                pred = chart.parse_predicate(text)
            except ValueError as e:
                raise InvalidOption('--remove', e)
            transactions = abo.account.remove_account(chart, pred, transactions)
    return transactions
예제 #2
0
 def _all_transactions(self):
     transactions = []
     for cache in abo.cache.transaction_caches(self._chart, self.config, self.opts):
         transactions += cache.transactions()
     transactions.sort(key=lambda t: (t.date, t.who or '', t.what or '', -t.amount()))
     return iter(transactions)