Add the history for Livret A account (ing)

Signed-off-by: Florent <weboob@flo.fourcot.fr>
Signed-off-by: Romain Bignon <romain@peerfuse.org>
This commit is contained in:
Florent 2012-01-09 16:23:24 +01:00 committed by Romain Bignon
commit 91cfedb247
3 changed files with 45 additions and 8 deletions

View file

@ -32,7 +32,8 @@ class Ing(BaseBrowser):
PAGES = {'.*displayTRAccountSummary.*': pages.AccountsList,
'.*displayLogin.jsf': pages.LoginPage,
'.*displayLogin.jsf.*': pages.LoginPage2,
'.*accountDetail.jsf.*': pages.AccountHistory
'.*accountDetail.jsf.*': pages.AccountHistoryCC,
'.*displayTRHistoriqueLA.*': pages.AccountHistoryLA
}
def __init__(self, *args, **kwargs):
@ -78,8 +79,15 @@ class Ing(BaseBrowser):
return None
def get_history(self, id):
# TODO: It works only with the Compte Courant, Livret A use an another page...
self.location('https://secure.ingdirect.fr/protected/pages/cc/accountDetail.jsf')
account = self.get_account(id)
# The first and the second letter of the label are the account type
if account.label[0:2] == "CC":
self.location('https://secure.ingdirect.fr/protected/pages/cc/accountDetail.jsf')
elif account.label[0:2] == "LA":
# we want "displayTRHistoriqueLA" but this fucking page is not directly available...
self.location('https://secure.ingdirect.fr/general?command=goToAccount&account=%d&zone=COMPTE' % int(id))
else:
raise NotImplementedError()
return self.page.get_operations()
# TODO

View file

@ -19,10 +19,10 @@
from .accounts_list import AccountsList
from .account_history import AccountHistory
from .account_history import AccountHistoryCC, AccountHistoryLA
from .login import LoginPage, LoginPage2, ConfirmPage, MessagePage
class AccountPrelevement(AccountsList): pass
__all__ = ['AccountsList', 'AccountHistory', 'LoginPage', 'LoginPage2',
__all__ = ['AccountsList', 'AccountHistoryCC', 'AccountHistoryLA', 'LoginPage', 'LoginPage2',
'ConfirmPage', 'MessagePage', 'AccountPrelevement']

View file

@ -22,12 +22,12 @@ from datetime import date
from weboob.tools.browser import BasePage
from weboob.capabilities.bank import Operation
from weboob.capabilities.base import NotAvailable
__all__ = ['AccountHistoryCC', 'AccountHistoryLA']
__all__ = ['AccountHistory']
class AccountHistory(BasePage):
class AccountHistoryCC(BasePage):
def on_loaded(self):
self.operations = []
@ -49,3 +49,32 @@ class AccountHistory(BasePage):
def get_operations(self):
return self.operations
class AccountHistoryLA(BasePage):
def on_loaded(self):
self.operations = []
i = 1
history = self.document.xpath('//tr[@align="center"]')
history.pop(0)
for tr in history:
id = i
texte = tr.text_content().strip().split('\n')
op = Operation(id)
# The size is not the same if there are two dates or only one
length = len(texte)
op.label = unicode(texte[length - 2].strip())
op.date = date(*reversed([int(x) for x in texte[0].split('/')]))
op.category = NotAvailable
amount = texte[length - 1].replace('\t','').strip().replace('.', '').replace(u'', '').replace(',', '.').replace(u'\xa0', u'')
op.amount = float(amount)
self.operations.append(op)
i += 1
def get_operations(self):
return self.operations