How to use ofxparse - 10 common examples

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 / tests / test_sync.py View on Github external
def test_sync_order(self):
        ledger = Ledger(os.path.join('fixtures', 'empty.lgr'))
        sync = OfxSynchronizer(ledger)
        with open(os.path.join('fixtures', 'checking_order.ofx'), 'rb') as ofx_file:
            ofx = OfxParser.parse(ofx_file)
        txns = sync.filter(
            ofx.account.statement.transactions,
            ofx.account.account_id)
        self.assertTrue(txns[0].date < txns[1].date and
                        txns[1].date < txns[2].date)
github jseutter / ofxparse / tests / test_write.py View on Github external
def test_write(self):
        with open_file('fidelity.ofx') as f:
            ofx = OfxParser.parse(f)
        self.assertEqual(str(ofx), "")
github jseutter / ofxparse / tests / test_parse.py View on Github external
<MEMO>POS MERCHANDISE;MCDONALD'S #112
   </STMTTRN>
  </BANKTRANLIST>
  <LEDGERBAL>
   <BALAMT>382.34
   <DTASOF>20090523122017
  </LEDGERBAL>
  <AVAILBAL>
   <BALAMT>682.34
   <DTASOF>20090523122017
  </AVAILBAL>
 </STMTRS>
</STMTTRNRS>
        '''
        txn = soup_maker(input)
        statement = OfxParser.parseStatement(txn.find('stmttrnrs'))
        self.assertEqual(datetime(2009, 4, 1), statement.start_date)
        self.assertEqual(
            datetime(2009, 5, 23, 12, 20, 17), statement.end_date)
        self.assertEqual(1, len(statement.transactions))
        self.assertEqual(Decimal('382.34'), statement.balance)
        self.assertEqual(datetime(2009, 5, 23, 12, 20, 17), statement.balance_date)
        self.assertEqual(Decimal('682.34'), statement.available_balance)
        self.assertEqual(datetime(2009, 5, 23, 12, 20, 17), statement.available_balance_date)
github jseutter / ofxparse / tests / test_parse.py View on Github external
def testThatParseTransactionWithCommaAsDecimalPoint(self):
        input = '''
<STMTTRN>
 <TRNTYPE>POS
 <DTPOSTED>20090401122017.000[-5:EST]
 <TRNAMT>-1006,60
 <FITID>0000123456782009040100001
 <NAME>MCDONALD'S #112
 <MEMO>POS MERCHANDISE;MCDONALD'S #112
</STMTTRN>
'''
        txn = soup_maker(input)
        transaction = OfxParser.parseTransaction(txn.find('stmttrn'))
        self.assertEqual(Decimal('-1006.60'), transaction.amount)