How to use plaid2qif - 9 common examples

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 / transaction_writer.py View on Github external
def begin(self, account_info):
    print( dumps(account_info, sort_keys=True), file=self.output)

  def write_record(self, transaction):
    print( dumps(transaction, sort_keys=True), file=self.output)


class CsvTransactionWriter(TransactionWriter):
  def begin(self, account_info):
    print('Date,Amount,Description', file=self.output)

  def write_record(self, transaction):
    print(transaction['date'],transaction['amount'],transaction['name'], file=self.output)


class QifTransactionWriter(TransactionWriter):
  def begin(self, account):
    print('!Account', file=self.output)
    print('N%s' % account['name'], file=self.output)
    print('T%s' % account['type'], file=self.output)
    if 'description' in account:
      print('D%s' % account['description'], file=self.output)
    print('^', file=self.output)
    print('!Type:%s' % account['type'], file=self.output)


  def write_record(self, transaction):
    print('C', file=self.output) # cleared status: Values are blank (not cleared), "*" or "c" (cleared) and "X" or "R" (reconciled).
    print('D%s' % self.format_date(transaction['date']), file=self.output)
    print('N%s' % self.format_chknum(transaction), file=self.output)
    print('P%s' % transaction['name'], file=self.output)
    print('T%s' % self.format_amount(transaction['amount']), file=self.output)
github ebridges / plaid2qif / plaid2qif / transaction_writer.py View on Github external
def write_record(self, transaction):
    pass

  def end(self):
    pass


class JsonTransactionWriter(TransactionWriter):
  def begin(self, account_info):
    print( dumps(account_info, sort_keys=True), file=self.output)

  def write_record(self, transaction):
    print( dumps(transaction, sort_keys=True), file=self.output)


class CsvTransactionWriter(TransactionWriter):
  def begin(self, account_info):
    print('Date,Amount,Description', file=self.output)

  def write_record(self, transaction):
    print(transaction['date'],transaction['amount'],transaction['name'], file=self.output)


class QifTransactionWriter(TransactionWriter):
  def begin(self, account):
    print('!Account', file=self.output)
    print('N%s' % account['name'], file=self.output)
    print('T%s' % account['type'], file=self.output)
    if 'description' in account:
      print('D%s' % account['description'], file=self.output)
    print('^', file=self.output)
    print('!Type:%s' % account['type'], file=self.output)
github ebridges / plaid2qif / plaid2qif / transaction_writer.py View on Github external
if t == 'raw':
      return JsonTransactionWriter(output)

  instance = staticmethod(instance)

  def begin(self, account_info):
    pass

  def write_record(self, transaction):
    pass

  def end(self):
    pass


class JsonTransactionWriter(TransactionWriter):
  def begin(self, account_info):
    print( dumps(account_info, sort_keys=True), file=self.output)

  def write_record(self, transaction):
    print( dumps(transaction, sort_keys=True), file=self.output)


class CsvTransactionWriter(TransactionWriter):
  def begin(self, account_info):
    print('Date,Amount,Description', file=self.output)

  def write_record(self, transaction):
    print(transaction['date'],transaction['amount'],transaction['name'], file=self.output)


class QifTransactionWriter(TransactionWriter):
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] )
github ebridges / plaid2qif / plaid2qif / plaid2qif.py View on Github external
def download(account, fromto, output, ignore_pending, suppress_warnings, plaid_credentials):
  client = open_client(plaid_credentials, suppress_warnings)
  access_token = read_access_token(account['institution'])
  account_name = account['name']
  account_id = account['id']

  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)
github ebridges / plaid2qif / plaid2qif / plaid2qif.py View on Github external
def main():
  version = require("plaid2qif")[0].version
  args = docopt(__doc__, version=version)
  util.configure_logging(args['--verbose'])
  debug(args)

  if args['save-access-token']:
    save_access_token(args['--institution'], args['--public-token'], args['--credentials'])

  if args['list-accounts']:
    list_accounts(args['--institution'], args['--credentials'])

  if args['download']:
    account = {
      'institution': args['--institution'],
      'id' : args['--account-id'],
      'name': args['--account'],
      'type': args['--account-type'],
    }
    fromto = {
github ebridges / plaid2qif / plaid2qif / transaction_writer.py View on Github external
def instance(t, output):
    if t == 'csv':
      return CsvTransactionWriter(output)
    if t == 'qif':
      return QifTransactionWriter(output)
    if t == 'raw':
      return JsonTransactionWriter(output)
github ebridges / plaid2qif / plaid2qif / transaction_writer.py View on Github external
def instance(t, output):
    if t == 'csv':
      return CsvTransactionWriter(output)
    if t == 'qif':
      return QifTransactionWriter(output)
    if t == 'raw':
      return JsonTransactionWriter(output)
github ebridges / plaid2qif / plaid2qif / transaction_writer.py View on Github external
def instance(t, output):
    if t == 'csv':
      return CsvTransactionWriter(output)
    if t == 'qif':
      return QifTransactionWriter(output)
    if t == 'raw':
      return JsonTransactionWriter(output)