Get history of titre account

Beta version. Probably need some new parameters
This commit is contained in:
Florent 2013-09-11 20:19:25 +02:00
commit b6c61210b1
3 changed files with 46 additions and 7 deletions

View file

@ -23,7 +23,8 @@ from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
from weboob.capabilities.bank import Account, TransferError from weboob.capabilities.bank import Account, TransferError
from .pages import AccountsList, LoginPage, \ from .pages import AccountsList, LoginPage, \
TransferPage, TransferConfirmPage, \ TransferPage, TransferConfirmPage, \
BillsPage, StopPage, TitrePage BillsPage, StopPage, TitrePage, \
TitreHistory
__all__ = ['Ing'] __all__ = ['Ing']
@ -45,6 +46,7 @@ class Ing(BaseBrowser):
'.*displayCoordonneesCommand.*': StopPage, '.*displayCoordonneesCommand.*': StopPage,
'.*portefeuille-TR.*': (TitrePage, 'raw'), '.*portefeuille-TR.*': (TitrePage, 'raw'),
'.*compteTempsReelCK.php.*': (TitrePage, 'raw'), '.*compteTempsReelCK.php.*': (TitrePage, 'raw'),
'.*compte.php\?ong=3': TitreHistory,
} }
CERTHASH = "257100e5f69b3c24b27eaaa82951ca5539e9ca264dee433b7c8d4779e778a0b4" CERTHASH = "257100e5f69b3c24b27eaaa82951ca5539e9ca264dee433b7c8d4779e778a0b4"
@ -110,9 +112,14 @@ class Ing(BaseBrowser):
def get_history(self, account): def get_history(self, account):
if not isinstance(account, Account): if not isinstance(account, Account):
account = self.get_account(account) account = self.get_account(account)
if account.type != Account.TYPE_CHECKING and\ if account.type == Account.TYPE_MARKET:
for tr in self.get_history_titre(account):
yield tr
return
elif account.type != Account.TYPE_CHECKING and\
account.type != Account.TYPE_SAVINGS: account.type != Account.TYPE_SAVINGS:
raise NotImplementedError() raise NotImplementedError()
if self.where != "start": if self.where != "start":
self.location(self.accountspage) self.location(self.accountspage)
data = {"AJAX:EVENTS_COUNT": 1, data = {"AJAX:EVENTS_COUNT": 1,
@ -190,9 +197,7 @@ class Ing(BaseBrowser):
else: else:
raise TransferError('Recipient not found') raise TransferError('Recipient not found')
def get_investments(self, account): def go_investments(self, account):
if account.type != Account.TYPE_MARKET:
raise NotImplementedError()
if self.where != "start": if self.where != "start":
self.location(self.accountspage) self.location(self.accountspage)
data = {"AJAX:EVENTS_COUNT": 1, data = {"AJAX:EVENTS_COUNT": 1,
@ -209,9 +214,20 @@ class Ing(BaseBrowser):
self.where = "titre" self.where = "titre"
self.location(self.titrepage) self.location(self.titrepage)
def get_investments(self, account):
if account.type != Account.TYPE_MARKET:
raise NotImplementedError()
self.go_investments(account)
self.location('https://bourse.ingdirect.fr/streaming/compteTempsReelCK.php') self.location('https://bourse.ingdirect.fr/streaming/compteTempsReelCK.php')
return self.page.iter_investments() return self.page.iter_investments()
def get_history_titre(self, account):
self.go_investments(account)
self.location('https://bourse.ingdirect.fr/priv/compte.php?ong=3')
return self.page.iter_history()
def get_subscriptions(self): def get_subscriptions(self):
self.location('/protected/pages/common/estatement/eStatement.jsf') self.location('/protected/pages/common/estatement/eStatement.jsf')
return self.page.iter_account() return self.page.iter_account()

View file

@ -22,7 +22,7 @@ from .accounts_list import AccountsList
from .login import LoginPage, StopPage from .login import LoginPage, StopPage
from .transfer import TransferPage, TransferConfirmPage from .transfer import TransferPage, TransferConfirmPage
from .bills import BillsPage from .bills import BillsPage
from .titre import TitrePage from .titre import TitrePage, TitreHistory
class AccountPrelevement(AccountsList): class AccountPrelevement(AccountsList):
@ -30,4 +30,4 @@ class AccountPrelevement(AccountsList):
__all__ = ['AccountsList', 'LoginPage', __all__ = ['AccountsList', 'LoginPage',
'AccountPrelevement', 'TransferPage', 'TransferConfirmPage', 'AccountPrelevement', 'TransferPage', 'TransferConfirmPage',
'BillsPage', 'StopPage', 'TitrePage'] 'BillsPage', 'StopPage', 'TitrePage', 'TitreHistory']

View file

@ -19,6 +19,7 @@
from decimal import Decimal from decimal import Decimal
from datetime import date
from weboob.capabilities.bank import Investment from weboob.capabilities.bank import Investment
from weboob.tools.browser import BasePage from weboob.tools.browser import BasePage
@ -26,6 +27,8 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction
__all__ = ['TitrePage'] __all__ = ['TitrePage']
class Transaction(FrenchTransaction):
pass
class TitrePage(BasePage): class TitrePage(BasePage):
def on_loaded(self): def on_loaded(self):
@ -52,3 +55,23 @@ class TitrePage(BasePage):
invest.diff = Decimal(FrenchTransaction.clean_amount(columns[5])) invest.diff = Decimal(FrenchTransaction.clean_amount(columns[5]))
yield invest yield invest
class TitreHistory(BasePage):
def on_loaded(self):
pass
def iter_history(self):
table = self.document.xpath('//table[@class="datas retour"]')[0]
trs = table.xpath('tr')
trs.pop(0)
trs.pop(-1)
for tr in trs:
td = tr.xpath('td')
op = Transaction(1)
textraw = td[3].text_content()
if len(td[2].xpath('a')) > 0:
textraw += u" " + td[2].xpath('a')[0].text_content()
amount = op.clean_amount(td[6].text_content())
op.parse(date(*reversed([int(x) for x in td[1].text_content().split('/')])), raw = textraw)
op.amount = Decimal(amount)
yield op