def queue_copy_to_account(ts, account): utils.log_debug('queue_copy_to_account', ts, account) assert afy.Assistant.accounts.get(account.id) to_copy = utils.copy(ts) for t in to_copy: modify_transaction_for_moving(t, account) utils.log_debug('to_copy', to_copy) queue_create(to_copy)
def enqueue(xs, queue): utils.log_debug('enqueue', xs, queue) xs = utils.copy(xs) has_id = list(filter(lambda x: x.id is not None, xs)) assert len(set(map(lambda x: x.id, has_id))) == len(has_id) queue.update(utils.by(xs, lambda x: x.id)) null_id = list(filter(lambda x: x.id is None, xs)) if null_id: if None not in queue: queue[None] = [] queue[None].extend(null_id)
def add_adjustment_subtransaction(t): ''' Ensures that the sum of subtransaction prices equals the transaction amount ''' utils.log_debug('add_adjustment_subtransaction', t) if not t.subtransactions: return amount = calculate_adjustment(t) if not amount: return adjustment = utils.copy(t.subtransactions[0]) adjustment.memo = 'Split transaction adjustment' adjustment.amount = amount adjustment.category_name = afy.settings.default_category # TODO utils.log_info('Warning, adjusting: subtransactions do not add up, by $%s' % -get_amount(adjustment)) t.subtransactions.append(adjustment) assert utils.equalish(t.amount, sum(s.amount for s in t.subtransactions))