How to use the ofxparse.OfxParser.parse function in ofxparse

To help you get started, we’ve selected a few ofxparse 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 egh / ledger-autosync / tests / test_ofx_formatter.py View on Github external
def test_investments(self):
        with open(os.path.join('fixtures', 'fidelity.ofx'), 'rb') as ofx_file:
            ofx = OfxParser.parse(ofx_file)
        converter = OfxConverter(
            account=ofx.account,
            name="Foo",
            security_list=SecurityList(ofx))
        self.assertEqualLedgerPosting(
            converter.convert(
                ofx.account.statement.transactions[0]).format(),
            """2012/07/20 YOU BOUGHT
  Foo  100.00000 INTC @ $25.635000000
  ; ofxid: 7776.01234567890.0123456789020201120120720
  Assets:Unknown  -$2563.50
""")
        # test no payee/memo
        self.assertEqualLedgerPosting(
            converter.convert(
                ofx.account.statement.transactions[1]).format(),
github jseutter / ofxparse / tests / test_parse.py View on Github external
def testThatParseWorksWithoutErrors(self):
        with open_file('bank_medium.ofx') as f:
            OfxParser.parse(f)
github egh / ledger-autosync / tests / test_ofx_formatter.py View on Github external
def test_investments_custom_payee(self):
        with open(os.path.join('fixtures', 'investment_401k.ofx'), 'rb') as ofx_file:
            ofx = OfxParser.parse(ofx_file)
        converter = OfxConverter(
            account=ofx.account,
            name="Foo",
            payee_format="{txntype}")
        self.assertEqual(
            converter.format_payee(ofx.account.statement.transactions[1]),
            'transfer')
        converter = OfxConverter(
            account=ofx.account,
            name="Foo",
            payee_format="{tferaction}")
        self.assertEqual(
            converter.format_payee(ofx.account.statement.transactions[1]),
            'in')
github egh / ledger-autosync / tests / test_ofx_formatter.py View on Github external
def test_indent(self):
        with open(os.path.join('fixtures', 'checking.ofx'), 'rb') as ofx_file:
            ofx = OfxParser.parse(ofx_file)
        converter = OfxConverter(account=ofx.account, name="Foo", indent=4)
        # testing indent, so do not use the string collapsing version of assert
        self.assertEqual(
            converter.convert(
                ofx.account.statement.transactions[0]).format(),
            """2011/03/31 DIVIDEND EARNED FOR PERIOD OF 03/01/2011 THROUGH 03/31/2011 ANNUAL PERCENTAGE YIELD EARNED IS 0.05%
    Foo                                                     $0.01
github egh / ledger-autosync / tests / test_sync.py View on Github external
def test_fresh_sync(self):
        ledger = Ledger(os.path.join('fixtures', 'empty.lgr'))
        sync = OfxSynchronizer(ledger)
        with open(os.path.join('fixtures', 'checking.ofx'), 'rb') as ofx_file:
            ofx = OfxParser.parse(ofx_file)
        txns1 = ofx.account.statement.transactions
        txns2 = sync.filter(txns1, ofx.account.account_id)
        self.assertEqual(txns1, txns2)
github egh / ledger-autosync / tests / test_ofx_formatter.py View on Github external
def test_balance_assertion(self):
        with open(os.path.join('fixtures', 'checking.ofx'), 'rb') as ofx_file:
            ofx = OfxParser.parse(ofx_file)
        ledger = Ledger(os.path.join('fixtures', 'checking.lgr'))
        converter = OfxConverter(
            account=ofx.account,
            name="Assets:Foo",
            ledger=ledger)
        self.assertEqualLedgerPosting(
            converter.format_balance(
                ofx.account.statement),
            """2013/05/25 * --Autosync Balance Assertion
  Assets:Foo  $0.00 = $100.99
github egh / ledger-autosync / ledgerautosync / sync.py View on Github external
def parse_file(path):
        with open(path, 'rb') as ofx_file:
            return OfxParser.parse(ofx_file)
github pkkid / pushingkarma / pk / apps / budget / manager.py View on Github external
def import_qfx(self, user, filename, handle):
        """ Import transactions from a qfx file. """
        try:
            self.files += 1
            transactions = []
            log.info('Importing transactions qfx file: %s' % filename)
            qfx = OfxParser.parse(handle)
            fid = int(qfx.account.institution.fid)
            if fid not in self._accounts:
                raise Exception('Not tracking account fid: %s' % fid)
            account = self._accounts[fid]
            # Update transactions
            for trx in qfx.account.statement.transactions:
                trx = trx.__dict__
                trx['trxid'] = trx['id']
                trx['accountfid'] = fid
                if not self._transaction_exists(trx, addit=True):
                    transactions.append(Transaction(
                        user=user,
                        account_id=account.id,
                        trxid=trx['id'],
                        payee=trx[account.payee or 'payee'],
                        amount=trx['amount'],