summaryrefslogtreecommitdiff
path: root/ofxparse
diff options
context:
space:
mode:
authorAndrew Shadura <andrewsh@debian.org>2016-10-19 18:48:59 +0200
committerAndrew Shadura <andrewsh@debian.org>2016-10-19 18:48:59 +0200
commitd8736ad37771257f5e8090072fccfbac90098633 (patch)
tree3b3381d36a5c836030e4143a9916b21223298065 /ofxparse
parentd8216aeb9c12ea81d9941edc6eff39be32c24aca (diff)
Imported Upstream version 0.15+git20161013
Diffstat (limited to 'ofxparse')
-rw-r--r--ofxparse/__init__.py4
-rw-r--r--ofxparse/ofxparse.py39
2 files changed, 40 insertions, 3 deletions
diff --git a/ofxparse/__init__.py b/ofxparse/__init__.py
index a08ba77..d9d4d5e 100644
--- a/ofxparse/__init__.py
+++ b/ofxparse/__init__.py
@@ -1,6 +1,6 @@
from __future__ import absolute_import
-from .ofxparse import OfxParser, AccountType, Account, Statement, Transaction
+from .ofxparse import OfxParser, OfxParserException, AccountType, Account, Statement, Transaction
from .ofxprinter import OfxPrinter
-__version__ = '0.15'
+__version__ = '0.14'
diff --git a/ofxparse/ofxparse.py b/ofxparse/ofxparse.py
index 5686030..18b9667 100644
--- a/ofxparse/ofxparse.py
+++ b/ofxparse/ofxparse.py
@@ -46,7 +46,7 @@ def soup_maker(fh):
skip_headers(fh)
try:
from bs4 import BeautifulSoup
- soup = BeautifulSoup(fh, "xml")
+ soup = BeautifulSoup(fh, "html.parser")
for tag in soup.findAll():
tag.name = tag.name.lower()
except ImportError:
@@ -239,6 +239,11 @@ class InvestmentAccount(Account):
super(InvestmentAccount, self).__init__()
self.brokerid = ''
+class BrokerageBalance:
+ def __init__(self):
+ self.name = None
+ self.description = None
+ self.value = None # decimal
class Security:
def __init__(self, uniqueid, name, ticker, memo):
@@ -709,6 +714,38 @@ class OfxParser(object):
six.u('content'): investment_ofx}
)
+ invbal_ofx = invstmtrs_ofx.find('invbal')
+ if invbal_ofx is not None:
+ #<AVAILCASH>18073.98<MARGINBALANCE>+00000000000.00<SHORTBALANCE>+00000000000.00<BUYPOWER>+00000000000.00
+ availcash_ofx = invbal_ofx.find('availcash')
+ if availcash_ofx is not None:
+ statement.available_cash = cls_.toDecimal(availcash_ofx)
+ margin_balance_ofx = invbal_ofx.find('marginbalance')
+ if margin_balance_ofx is not None:
+ statement.margin_balance = cls_.toDecimal(margin_balance_ofx)
+ short_balance_ofx = invbal_ofx.find('shortbalance')
+ if short_balance_ofx is not None:
+ statement.short_balance = cls_.toDecimal(short_balance_ofx)
+ buy_power_ofx = invbal_ofx.find('buypower')
+ if buy_power_ofx is not None:
+ statement.buy_power = cls_.toDecimal(buy_power_ofx)
+
+ ballist_ofx = invbal_ofx.find('ballist')
+ if ballist_ofx is not None:
+ statement.balance_list = []
+ for balance_ofx in ballist_ofx.findAll('bal'):
+ brokerage_balance = BrokerageBalance()
+ name_ofx = balance_ofx.find('name')
+ if name_ofx is not None:
+ brokerage_balance.name = name_ofx.contents[0].strip()
+ description_ofx = balance_ofx.find('desc')
+ if description_ofx is not None:
+ brokerage_balance.description = description_ofx.contents[0].strip()
+ value_ofx = balance_ofx.find('value')
+ if value_ofx is not None:
+ brokerage_balance.value = cls_.toDecimal(value_ofx)
+ statement.balance_list.append(brokerage_balance)
+
return statement
@classmethod