From 32e00b53f2a1856aa118c7d39b784c7cb8f6ff64 Mon Sep 17 00:00:00 2001 From: Christophe Francois Date: Thu, 7 Jan 2021 11:46:12 +0100 Subject: [PATCH] [bp] Fetch opening date of life insurances --- modules/bp/browser.py | 12 +++++++++++- modules/bp/pages/accounthistory.py | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/bp/browser.py b/modules/bp/browser.py index 9b942aba2a..4d02be39a1 100644 --- a/modules/bp/browser.py +++ b/modules/bp/browser.py @@ -57,7 +57,7 @@ ) from .pages.accounthistory import ( LifeInsuranceInvest, LifeInsuranceHistory, LifeInsuranceHistoryInv, RetirementHistory, - SavingAccountSummary, CachemireCatalogPage, + SavingAccountSummary, CachemireCatalogPage, LifeInsuranceSummary, ) from .pages.accountlist import ( MarketLoginPage, UselessPage, ProfilePage, MarketCheckPage, MarketHomePage, @@ -170,6 +170,10 @@ class BPBrowser(LoginBrowser, StatesMixin): SavingAccountSummary ) + lifeinsurance_summary = URL( + r'/voscomptes/canalXHTML/assurance/vie/syntheseVie-assuranceVie.ea\?numContrat=(?P\w+)', + LifeInsuranceSummary + ) lifeinsurance_invest = URL( r'/voscomptes/canalXHTML/assurance/retraiteUCEuro/afficherSansDevis-assuranceRetraiteUCEuros.ea\?numContrat=(?P\w+)', LifeInsuranceInvest @@ -561,6 +565,12 @@ def get_accounts_list(self): accounts.extend(self.get_loans(account)) page.go() + elif account.type == Account.TYPE_LIFE_INSURANCE: + self.lifeinsurance_summary.go(id=account.id) + account.opening_date = self.page.get_opening_date() + accounts.append(account) + page.go() + elif account.type == Account.TYPE_PERP: # PERP balances must be fetched from the details page, # otherwise we just scrape the "Rente annuelle estimée": diff --git a/modules/bp/pages/accounthistory.py b/modules/bp/pages/accounthistory.py index effc3606aa..44667a068c 100644 --- a/modules/bp/pages/accounthistory.py +++ b/modules/bp/pages/accounthistory.py @@ -335,6 +335,15 @@ def load_product_codes(self): return product_codes +class LifeInsuranceSummary(LoggedPage, MyHTMLPage): + def get_opening_date(self): + return Date( + CleanText('//dt[span/text()="Date d\'effet :"]/following-sibling::dd[1]'), + dayfirst=True, + default=NotAvailable, + )(self.doc) + + class LifeInsuranceInvest(LoggedPage, MyHTMLPage): def has_error(self): return 'erreur' in CleanText('//p[has-class("titlePage")]')(self.doc) or 'ERREUR' in CleanText('//h2')(self.doc) -- GitLab