From 6239b02e654be59d7cf9590742f33915f0e54c39 Mon Sep 17 00:00:00 2001 From: Christophe Francois Date: Thu, 20 Aug 2020 17:16:36 +0200 Subject: [PATCH] [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. --- modules/caissedepargne/browser.py | 13 +++++++++++++ modules/caissedepargne/pages.py | 17 ++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/modules/caissedepargne/browser.py b/modules/caissedepargne/browser.py index 07a0796bcf..5a50c97667 100644 --- a/modules/caissedepargne/browser.py +++ b/modules/caissedepargne/browser.py @@ -1010,6 +1010,15 @@ def add_owner_accounts(self): 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 @@ def _get_history_invests(self, account): 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 @@ def get_investment(self, account): 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 diff --git a/modules/caissedepargne/pages.py b/modules/caissedepargne/pages.py index 595734663a..b62afcae8b 100644 --- a/modules/caissedepargne/pages.py +++ b/modules/caissedepargne/pages.py @@ -519,7 +519,11 @@ def _get_account_info(self, a, accounts): 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 @@ def _get_account_info(self, a, accounts): 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 @@ def get_list(self, owner_name): 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 @@ def get_list(self, owner_name): # sometimes there's a tooltip span to ignore next to # (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]) -- GitLab