Commit 32e00b53 authored by Christophe Francois's avatar Christophe Francois Committed by Vincent A

[bp] Fetch opening date of life insurances

parent c1a5a4ce
......@@ -57,7 +57,7 @@ from .pages import (
)
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<id>\w+)',
LifeInsuranceSummary
)
lifeinsurance_invest = URL(
r'/voscomptes/canalXHTML/assurance/retraiteUCEuro/afficherSansDevis-assuranceRetraiteUCEuros.ea\?numContrat=(?P<id>\w+)',
LifeInsuranceInvest
......@@ -561,6 +565,12 @@ class BPBrowser(LoginBrowser, StatesMixin):
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":
......
......@@ -335,6 +335,15 @@ class CachemireCatalogPage(LoggedPage, MyHTMLPage):
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment