set type of accounts on professional accounts

This commit is contained in:
Romain Bignon 2015-06-21 18:07:55 +02:00
commit 39e00ab2a1

View file

@ -35,8 +35,16 @@ class HistoryParser(CsvParser):
class ProAccountsList(Page):
ACCOUNT_TYPES = {u'Comptes épargne': Account.TYPE_SAVINGS,
u'Comptes courants': Account.TYPE_CHECKING,
}
def get_accounts_list(self):
for tr in self.document.xpath('//div[@class="comptestabl"]/table/tbody/tr'):
for table in self.document.xpath('//div[@class="comptestabl"]/table'):
try:
account_type = self.ACCOUNT_TYPES[table.xpath('./caption/text()')[0].strip()]
except (IndexError,KeyError):
account_type = Account.TYPE_UNKNOWN
for tr in table.xpath('./tbody/tr'):
cols = tr.findall('td')
link = cols[0].find('a')
@ -44,6 +52,7 @@ class ProAccountsList(Page):
continue
a = Account()
a.type = account_type
a.id, a.label = map(unicode, link.attrib['title'].split(' ', 1))
tmp_balance = self.parser.tocleanstring(cols[1])
a.currency = a.get_currency(tmp_balance)