diff --git a/modules/ing/browser.py b/modules/ing/browser.py index 4e5235f5..17536c69 100644 --- a/modules/ing/browser.py +++ b/modules/ing/browser.py @@ -23,7 +23,8 @@ from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword from weboob.capabilities.bank import Account, TransferError from .pages import AccountsList, LoginPage, \ TransferPage, TransferConfirmPage, \ - BillsPage, StopPage, TitrePage + BillsPage, StopPage, TitrePage, \ + TitreHistory __all__ = ['Ing'] @@ -45,6 +46,7 @@ class Ing(BaseBrowser): '.*displayCoordonneesCommand.*': StopPage, '.*portefeuille-TR.*': (TitrePage, 'raw'), '.*compteTempsReelCK.php.*': (TitrePage, 'raw'), + '.*compte.php\?ong=3': TitreHistory, } CERTHASH = "257100e5f69b3c24b27eaaa82951ca5539e9ca264dee433b7c8d4779e778a0b4" @@ -110,9 +112,14 @@ class Ing(BaseBrowser): def get_history(self, account): if not isinstance(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: raise NotImplementedError() + if self.where != "start": self.location(self.accountspage) data = {"AJAX:EVENTS_COUNT": 1, @@ -190,9 +197,7 @@ class Ing(BaseBrowser): else: raise TransferError('Recipient not found') - def get_investments(self, account): - if account.type != Account.TYPE_MARKET: - raise NotImplementedError() + def go_investments(self, account): if self.where != "start": self.location(self.accountspage) data = {"AJAX:EVENTS_COUNT": 1, @@ -209,9 +214,20 @@ class Ing(BaseBrowser): self.where = "titre" 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') 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): self.location('/protected/pages/common/estatement/eStatement.jsf') return self.page.iter_account() diff --git a/modules/ing/pages/__init__.py b/modules/ing/pages/__init__.py index df54c4cd..e246da20 100644 --- a/modules/ing/pages/__init__.py +++ b/modules/ing/pages/__init__.py @@ -22,7 +22,7 @@ from .accounts_list import AccountsList from .login import LoginPage, StopPage from .transfer import TransferPage, TransferConfirmPage from .bills import BillsPage -from .titre import TitrePage +from .titre import TitrePage, TitreHistory class AccountPrelevement(AccountsList): @@ -30,4 +30,4 @@ class AccountPrelevement(AccountsList): __all__ = ['AccountsList', 'LoginPage', 'AccountPrelevement', 'TransferPage', 'TransferConfirmPage', - 'BillsPage', 'StopPage', 'TitrePage'] + 'BillsPage', 'StopPage', 'TitrePage', 'TitreHistory'] diff --git a/modules/ing/pages/titre.py b/modules/ing/pages/titre.py index b60c55ab..f72ddb44 100644 --- a/modules/ing/pages/titre.py +++ b/modules/ing/pages/titre.py @@ -19,6 +19,7 @@ from decimal import Decimal +from datetime import date from weboob.capabilities.bank import Investment from weboob.tools.browser import BasePage @@ -26,6 +27,8 @@ from weboob.tools.capabilities.bank.transactions import FrenchTransaction __all__ = ['TitrePage'] +class Transaction(FrenchTransaction): + pass class TitrePage(BasePage): def on_loaded(self): @@ -52,3 +55,23 @@ class TitrePage(BasePage): invest.diff = Decimal(FrenchTransaction.clean_amount(columns[5])) 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