diff --git a/modules/caissedepargne/browser.py b/modules/caissedepargne/browser.py index 07a0796bcfcafdae7bceff199500a571aa4152c0..5a50c976673298f4a0f34e707c3da8ce84d36df1 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 595734663a14fdaf9e4ac2a5b717944308046bcd..b62afcae8b8fe8c327b2964d777e55eabbb5ba28 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])