diff --git a/modules/bp/browser.py b/modules/bp/browser.py index 3033866d3f67349fd18b67251e5b47377b19c3cf..73361b9fdf94ea1887d66db990d95b025ecf0dc2 100644 --- a/modules/bp/browser.py +++ b/modules/bp/browser.py @@ -398,7 +398,9 @@ def iter_investment(self, account): 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([]) diff --git a/modules/linebourse/browser.py b/modules/linebourse/browser.py index 3f44b30ae041c788fce31fcaacd66f16cce315e4..44d5edca0c9a70ec40daaf8b81840798de6d96a0 100644 --- a/modules/linebourse/browser.py +++ b/modules/linebourse/browser.py @@ -72,7 +72,24 @@ def iter_investment(self, account_id): 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() diff --git a/modules/linebourse/pages.py b/modules/linebourse/pages.py index 058788514049f23f0ea91f65f6f1ebaee4e6caed..b58c2017fcf4e5d7f8ab3d3240399c9a38d0a73e 100644 --- a/modules/linebourse/pages.py +++ b/modules/linebourse/pages.py @@ -30,6 +30,7 @@ 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 @@ def obj_investments(self): 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 @@ def condition(self): 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):