How to use the plaid2qif.transaction_writer function in plaid2qif

To help you get started, we’ve selected a few plaid2qif examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ebridges / plaid2qif / plaid2qif / plaid2qif.py View on Github external
response = client.Transactions.get(access_token, 
    fromto['start'], fromto['end'], 
    account_ids=[account_id])

  txn_batch = len(response['transactions'])
  txn_total = response['total_transactions']
  txn_sofar = txn_batch

  output_to_file = True if output['dir'] else False
  output_file = '%s/%s' % (output['dir'], util.output_filename(account_name, fromto, output['format']))

  output_handle = output_to_file and open(output_file, 'w') or sys.stdout
  
  try:
    w = transaction_writer.TransactionWriter.instance(output['format'], output_handle)
    w.begin(account)

    debug("txn cnt: %d, txn total: %d" % (txn_batch, txn_total))
    while  txn_batch > 0 and txn_batch <= txn_total:
      
      for t in response['transactions']:
        if ignore_pending and t['pending']:
          info('skipping pending transaction for [%s: %s]' % (t['date'], t['name']))
          continue
        info('writing record for [%s: %s]' % (t['date'], t['name']))
        debug('%s' % t)
        w.write_record(t)

      response = client.Transactions.get(access_token, 
        start_date=fromto['start'], end_date=fromto['end'], 
        offset=txn_sofar, account_ids=[account_id] )