LCL: implement account history

Signed-off-by: Pierre Mazière <pierre.maziere@gmail.com>
Signed-off-by: Romain Bignon <romain@peerfuse.org>
This commit is contained in:
Pierre Mazière 2011-03-06 23:47:54 +01:00 committed by Romain Bignon
commit e14af3b890
3 changed files with 47 additions and 3 deletions

View file

@ -16,6 +16,8 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from datetime import date
from weboob.capabilities.bank import Operation
from weboob.capabilities.bank import Account
from weboob.tools.browser import BasePage
@ -52,3 +54,37 @@ class AccountsPage(BasePage):
l.append(account)
return l
class AccountHistoryPage(BasePage):
def on_loaded(self):
self.operations = []
done=False
for table in self.document.getiterator('table'):
title_tr=table.find('tr')
if title_tr is None:
continue
for text in title_tr.itertext():
prefix='Opérations effectuées'
if text.startswith(prefix.decode('utf-8')):
for tr in table.iter('tr'):
tr_class=tr.attrib.get('class')
if tr_class == 'tbl1' or tr_class=='tbl2':
tds=tr.findall('td')
d=date(*reversed([int(x) for x in tds[0].text.split('/')]))
label=u''+tds[1].find('a').text.strip()
if tds[3].text.strip() != u"":
amount = - float(tds[3].text.strip().replace('.','').replace(',','.').replace(u"\u00A0",'').replace(' ',''))
else:
amount= float(tds[4].text.strip().replace('.','').replace(',','.').replace(u"\u00A0",'').replace(' ',''))
operation=Operation(len(self.operations))
operation.date=d
operation.label=label
operation.amount=amount
self.operations.append(operation)
done=True
break
if done:
break
def get_operations(self):
return self.operations