fetch history of life insurances

This commit is contained in:
Romain Bignon 2015-05-17 16:28:19 +02:00
commit 49da7aaf07
2 changed files with 32 additions and 11 deletions

View file

@ -19,9 +19,6 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from datetime import date
from dateutil.relativedelta import relativedelta
from weboob.deprecated.browser import Browser, BrowserIncorrectPassword
from .pages.login import LoginPage
@ -45,7 +42,7 @@ class Fortuneo(Browser):
'.*/prive/mes-comptes/livret/consulter-situation/consulter-solde\.jsp.*' : AccountHistoryPage,
'.*/prive/mes-comptes/compte-courant/consulter-situation/consulter-solde\.jsp.*' : AccountHistoryPage,
'.*/prive/mes-comptes/compte-titres-.*': InvestmentHistoryPage,
'.*/prive/mes-comptes/compte-titres-.*': PeaHistoryPage,
'.*/prive/mes-comptes/assurance-vie.*': InvestmentHistoryPage,
'.*/prive/mes-comptes/pea.*': PeaHistoryPage,
'.*/prive/mes-comptes/compte-especes.*': InvestmentHistoryPage,
@ -93,12 +90,7 @@ class Fortuneo(Browser):
def get_history(self, account):
self.location(account._link_id)
if self.is_on_page(AccountHistoryPage):
self.select_form(name='ConsultationHistoriqueOperationsForm')
self.set_all_readonly(False)
self['dateRechercheDebut'] = (date.today() - relativedelta(years=1)).strftime('%d/%m/%Y')
self['nbrEltsParPage'] = '100'
self.submit()
self.page.select_period()
return self.page.get_operations(account)

View file

@ -22,6 +22,8 @@ from lxml.html import etree
from decimal import Decimal
import re
from time import sleep
from datetime import date
from dateutil.relativedelta import relativedelta
from weboob.capabilities.bank import Account, Investment
from weboob.deprecated.browser import Page, BrowserIncorrectPassword
@ -88,6 +90,9 @@ class PeaHistoryPage(Page):
return NotAvailable
return Decimal(value)
def select_period(self):
pass
def get_operations(self, _id):
return iter([])
@ -124,14 +129,38 @@ class InvestmentHistoryPage(Page):
return NotAvailable
return Decimal(Transaction.clean_amount(value))
def select_period(self):
self.browser.location(self.url.replace('portefeuille-assurance-vie.jsp', 'operations/assurance-vie-operations.jsp'))
self.browser.select_form(name='OperationsForm')
self.browser.set_all_readonly(False)
self.browser['dateDebut'] = (date.today() - relativedelta(years=1)).strftime('%d/%m/%Y')
self.browser['nbrEltsParPage'] = '100'
self.browser.submit()
def get_operations(self, _id):
return iter([])
for tr in self.document.xpath('//table[@id="tableau_histo_opes"]/tbody/tr'):
tds = tr.findall('td')
t = Transaction()
t.parse(date=self.parser.tocleanstring(tds[1]),
raw=self.parser.tocleanstring(tds[2]))
t.set_amount(self.parser.tocleanstring(tds[-1]))
yield t
class AccountHistoryPage(Page):
def get_investments(self):
return iter([])
def select_period(self):
self.browser.select_form(name='ConsultationHistoriqueOperationsForm')
self.browser.set_all_readonly(False)
self.browser['dateRechercheDebut'] = (date.today() - relativedelta(years=1)).strftime('%d/%m/%Y')
self.browser['nbrEltsParPage'] = '100'
self.browser.submit()
def get_operations(self, _id):
"""history, see http://docs.weboob.org/api/capabilities/bank.html?highlight=transaction#weboob.capabilities.bank.Transaction"""