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:
parent
a732a8a051
commit
e14af3b890
3 changed files with 47 additions and 3 deletions
|
|
@ -58,5 +58,7 @@ class LCLBackend(BaseBackend, ICapBank):
|
|||
return iter([])
|
||||
|
||||
def iter_history(self, account):
|
||||
""" TODO Not supported yet """
|
||||
return iter([])
|
||||
with self.browser:
|
||||
for history in self.browser.get_history(account):
|
||||
yield history
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||
|
||||
from .pages import LoginPage, LoginErrorPage, FramePage, AccountsPage
|
||||
from .pages import LoginPage, LoginErrorPage, FramePage, AccountsPage, AccountHistoryPage
|
||||
|
||||
|
||||
__all__ = ['LCLBrowser']
|
||||
|
|
@ -35,6 +35,7 @@ class LCLBrowser(BaseBrowser):
|
|||
'https://particuliers.secure.lcl.fr/everest/UWBI/UWBIAccueil\?DEST=IDENTIFICATION': LoginErrorPage,
|
||||
'https://particuliers.secure.lcl.fr/outil/UWSP/Synthese/accesSynthese': AccountsPage,
|
||||
'https://particuliers.secure.lcl.fr/outil/UWB2/Accueil\?DEST=INIT': FramePage,
|
||||
'https://particuliers.secure.lcl.fr/outil/UWLM/ListeMouvementsPro/accesListeMouvementsPro.*': AccountHistoryPage,
|
||||
}
|
||||
|
||||
def __init__(self, agency, *args, **kwargs):
|
||||
|
|
@ -73,6 +74,11 @@ class LCLBrowser(BaseBrowser):
|
|||
|
||||
return None
|
||||
|
||||
def get_history(self,account):
|
||||
if not self.is_on_page(AccountHistoryPage) :
|
||||
self.location('%s://%s%s' % (self.PROTOCOL, self.DOMAIN, account.link_id))
|
||||
return self.page.get_operations()
|
||||
|
||||
#def get_coming_operations(self, account):
|
||||
# if not self.is_on_page(AccountComing) or self.page.account.id != account.id:
|
||||
# self.location('/NS_AVEEC?ch4=%s' % account.link_id)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue