Martin Sicot
Committed by Romain Bignon

[bp] french_liquidity added for invesments account

French liquidity wasn't retrieved.
......@@ -398,7 +398,9 @@ class BPBrowser(LoginBrowser, StatesMixin):
if account.type in (account.TYPE_PEA, account.TYPE_MARKET):
self.go_linebourse(account)
return self.linebourse.iter_investment(account.id)
investments = list(self.linebourse.iter_investment(account.id))
investments.append(self.linebourse.get_liquidity(account.id))
return investments
if account.type != Account.TYPE_LIFE_INSURANCE:
return iter([])
......
......@@ -72,7 +72,24 @@ class LinebourseBrowser(LoginBrowser):
assert self.invest.is_here()
if not self.page.is_on_right_portfolio(account_id):
self.invest.go(id=self.page.get_compte(account_id))
return self.page.iter_investment()
return self.page.iter_investments()
# Method used only by bp module
def get_liquidity(self, account_id):
self.main.go()
self.invest.go()
if self.message.is_here():
self.page.submit()
self.invest.go()
if self.broken.is_here():
return iter([])
assert self.invest.is_here()
if not self.page.is_on_right_portfolio(account_id):
self.invest.go(id=self.page.get_compte(account_id))
return self.page.get_liquidity()
def iter_history(self, account_id):
self.main.go()
......
......@@ -30,6 +30,7 @@ from weboob.browser.filters.html import TableCell
from weboob.capabilities.base import NotAvailable
from weboob.capabilities.bank import Investment
from weboob.tools.capabilities.bank.transactions import FrenchTransaction as Transaction
from weboob.tools.capabilities.bank.investments import create_french_liquidity
from weboob.tools.compat import quote_plus
from weboob.exceptions import ActionNeeded
......@@ -110,7 +111,7 @@ class HistoryPage(AccountPage):
class InvestmentPage(AccountPage):
@method
class get_investment(TableElement):
class iter_investments(TableElement):
col_label = 'Valeur'
col_quantity = u'Quantité'
col_valuation = u'Valorisation EUR'
......@@ -139,9 +140,11 @@ class InvestmentPage(AccountPage):
obj_label = CleanText(Regexp(CleanText('./preceding-sibling::tr/td[1]'), '(.*)- .*'))
obj_code = Regexp(CleanText('./preceding-sibling::tr/td[1]'), '- (.*)')
def iter_investment(self):
for inv in self.get_investment():
yield inv
# Only used by bp modules since others quality websites provide another account with the liquidities
def get_liquidity(self):
liquidity = CleanDecimal('//table//tr[@class="titreAvant"]/td[contains(text(), "Liquidit")]/following-sibling::td', replace_dots=True)(self.doc)
if liquidity:
return create_french_liquidity(liquidity)
class MessagePage(LoggedPage, HTMLPage):
......