Commit 6239b02e authored by Christophe Francois's avatar Christophe Francois Committed by Vincent A

[caissedepargne] Get missing accounts from savings page

Some accounts are on the "Epargne" tab but not in the summary page where
we fetched them. We need to get the ones we missed from this page. This
also means we need to get on that tab to get history and investments.

For now we only have the issue with some life insurances so we go on the
new tab only for them, but the connector might need larger changes if we
find out that other accounts are concerned.
parent afbf9adf
......@@ -1010,6 +1010,15 @@ class CaisseEpargne(LoginBrowser, StatesMixin):
self.home.go()
self.accounts = list(self.page.get_list(owner_name))
# Get wealth accounts that are not on the summary page
self.home_tache.go(tache='EPASYNT0')
# If there are no wealth accounts we are redirected to the "garbage page"
if self.home.is_here():
for account in self.page.get_list(owner_name):
if account.id not in [acc.id for acc in self.accounts]:
self.accounts.append(account)
self.add_linebourse_accounts_data()
self.add_card_accounts()
......@@ -1200,6 +1209,8 @@ class CaisseEpargne(LoginBrowser, StatesMixin):
return sorted_transactions(self.page.get_history())
if account.label.startswith('NUANCES ') or account.label in self.insurance_accounts:
# Some life insurances are not on the accounts summary
self.home_tache.go(tache='EPASYNT0')
self.page.go_life_insurance(account)
if 'JSESSIONID' in self.session.cookies:
# To access the life insurance space, we need to delete the JSESSIONID cookie to avoid an expired session
......@@ -1374,6 +1385,8 @@ class CaisseEpargne(LoginBrowser, StatesMixin):
return
try:
# Some life insurances are not on the accounts summary
self.home_tache.go(tache='EPASYNT0')
self.page.go_life_insurance(account)
if self.home.is_here():
# no detail is available for this account
......
......@@ -519,7 +519,11 @@ class IndexPage(LoggedPage, BasePage):
id = re.search(r"([\d]+)", a.attrib.get('title', ''))
if len(parts) > 1:
info['type'] = parts[0]
info['id'] = info['_id'] = parts[1]
if info['type'] == 'REDIR_ASS_VIE':
# The link format for this account type has an additional parameter
info['id'] = info['_id'] = parts[2]
else:
info['id'] = info['_id'] = parts[1]
if id or info['id'] in [acc._info['_id'] for acc in accounts.values()]:
if id:
_id = id.group(1)
......@@ -530,7 +534,7 @@ class IndexPage(LoggedPage, BasePage):
else:
info['type'] = link
info['id'] = info['_id'] = id.group(1)
if info['type'] in ('SYNTHESE_ASSURANCE_CNP', 'SYNTHESE_EPARGNE', 'ASSURANCE_VIE'):
if info['type'] in ('SYNTHESE_ASSURANCE_CNP', 'REDIR_ASS_VIE', 'SYNTHESE_EPARGNE', 'ASSURANCE_VIE'):
info['acc_type'] = Account.TYPE_LIFE_INSURANCE
if info['type'] in ('BOURSE', 'COMPTE_TITRE'):
info['acc_type'] = Account.TYPE_MARKET
......@@ -682,10 +686,10 @@ class IndexPage(LoggedPage, BasePage):
if title is None:
continue
account_type = self.ACCOUNT_TYPES.get(CleanText('.')(title), Account.TYPE_UNKNOWN)
for tr in table.xpath('.//tr'):
for tr in table.xpath('.//tr[@class!="en-tetes" and @class!="Inactive"]'):
tds = tr.findall('td')
for i in range(len(tds)):
a = tds[i].find('a')
a = tds[i].find('.//a')
if a is not None:
break
......@@ -694,10 +698,9 @@ class IndexPage(LoggedPage, BasePage):
# sometimes there's a tooltip span to ignore next to <strong>
# (perhaps only on creditcooperatif)
label = CleanText('./strong')(tds[0])
balance = CleanText('.')(tds[-1])
label = CleanText('.//strong')(tds[0])
balance = CleanText('.//td[has-class("somme")]')(tr)
ownership = self.get_ownership(tds, owner_name)
account = self._add_account(accounts, a, label, account_type, balance, ownership=ownership)
if account:
account.number = CleanText('.')(tds[1])
......
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