support investments detail

This commit is contained in:
Romain Bignon 2014-11-26 14:55:23 +01:00
commit c4f658341c
3 changed files with 44 additions and 8 deletions

View file

@ -83,6 +83,11 @@ class Fortuneo(Browser):
if self.is_on_page(AccountsList) and self.page.need_reload(): if self.is_on_page(AccountsList) and self.page.need_reload():
self.location('/ReloadContext?action=1&') self.location('/ReloadContext?action=1&')
def get_investments(self, account):
self.location(account._link_id)
return self.page.get_investments()
def get_history(self, account): def get_history(self, account):
self.location(account._link_id) self.location(account._link_id)

View file

@ -58,9 +58,7 @@ class FortuneoModule(Module, CapBank):
def iter_accounts(self): def iter_accounts(self):
"""Iter accounts""" """Iter accounts"""
return self.browser.get_accounts_list()
for account in self.browser.get_accounts_list():
yield account
def get_account(self, _id): def get_account(self, _id):
with self.browser: with self.browser:
@ -72,9 +70,9 @@ class FortuneoModule(Module, CapBank):
def iter_history(self, account): def iter_history(self, account):
"""Iter history of transactions on a specific account""" """Iter history of transactions on a specific account"""
return self.browser.get_history(account)
with self.browser: def iter_investment(self, account):
for history in self.browser.get_history(account): return self.browser.get_investments(account)
yield history
# vim:ts=4:sw=4 # vim:ts=4:sw=4

View file

@ -23,7 +23,7 @@ from decimal import Decimal
import re import re
from time import sleep from time import sleep
from weboob.capabilities.bank import Account from weboob.capabilities.bank import Account, Investment
from weboob.deprecated.browser import Page, BrowserIncorrectPassword from weboob.deprecated.browser import Page, BrowserIncorrectPassword
from weboob.capabilities import NotAvailable from weboob.capabilities import NotAvailable
from weboob.tools.capabilities.bank.transactions import FrenchTransaction from weboob.tools.capabilities.bank.transactions import FrenchTransaction
@ -50,10 +50,43 @@ class Transaction(FrenchTransaction):
] ]
class InvestmentHistoryPage(Page): class InvestmentHistoryPage(Page):
COL_LABEL = 0
COL_QUANTITY = 1
COL_UNITVALUE = 2
COL_DATE = 3
COL_VALUATION = 4
COL_WEIGHT = 5
COL_UNITPRICE = 6
COL_PERF = 7
COL_PERF_PERCENT = 8
def get_investments(self):
for line in self.document.xpath('//table[@id="tableau_support"]/tbody/tr'):
cols = line.findall('td')
inv = Investment()
inv.id = unicode(re.search('cdReferentiel=(.*)', cols[self.COL_LABEL].find('a').attrib['href']).group(1))
inv.code = re.match('^[A-Z]+[0-9]+(.*)$', inv.id).group(1)
inv.quantity = self.parse_decimal(cols[self.COL_QUANTITY])
inv.unitprice = self.parse_decimal(cols[self.COL_UNITPRICE])
inv.unitvalue = self.parse_decimal(cols[self.COL_UNITVALUE])
inv.valuation = self.parse_decimal(cols[self.COL_VALUATION])
inv.diff = self.parse_decimal(cols[self.COL_PERF])
yield inv
def parse_decimal(self, string):
value = self.parser.tocleanstring(string)
if value == '-':
return NotAvailable
return Decimal(Transaction.clean_amount(value))
def get_operations(self, _id): def get_operations(self, _id):
raise NotImplementedError() return iter([])
class AccountHistoryPage(Page): class AccountHistoryPage(Page):
def get_investments(self):
return iter([])
def get_operations(self, _id): def get_operations(self, _id):
"""history, see http://docs.weboob.org/api/capabilities/bank.html?highlight=transaction#weboob.capabilities.bank.Transaction""" """history, see http://docs.weboob.org/api/capabilities/bank.html?highlight=transaction#weboob.capabilities.bank.Transaction"""