From 9998492451982d8cef19cb6b0e9f272c2ed5b345 Mon Sep 17 00:00:00 2001 From: Jerome Berthier Date: Tue, 2 Apr 2019 19:39:48 +0200 Subject: [PATCH] [caissedepargne] for netpro, fix duplicated transactions between pro accounts The website is broken, when there are several accounts the direct link to an account displays the history of the last visited account (or the first account in the list). To reach the correct history I use the form sent when selecting an account from the dedicated select box. --- modules/caissedepargne/browser.py | 4 ++++ modules/caissedepargne/pages.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/modules/caissedepargne/browser.py b/modules/caissedepargne/browser.py index ad381d01fd..c9297302e5 100644 --- a/modules/caissedepargne/browser.py +++ b/modules/caissedepargne/browser.py @@ -481,6 +481,10 @@ def _get_history(self, info): self.page.go_history(info) + # ensure we are on the correct history page + if 'netpro' in self.page.url and not self.page.is_history_of(info['id']): + self.page.go_history_netpro(info) + info['link'] = [info['link']] for i in range(self.HISTORY_MAX_PAGE): diff --git a/modules/caissedepargne/pages.py b/modules/caissedepargne/pages.py index 8400c8a50b..b1c11113f8 100644 --- a/modules/caissedepargne/pages.py +++ b/modules/caissedepargne/pages.py @@ -589,6 +589,12 @@ def go_loan_list(self): form.submit() + def is_history_of(self, account_id): + """ + Check whether the displayed history is for the correct account + """ + return bool(self.doc.xpath('//option[@value="%s" and @selected]' % account_id)) + def go_history(self, info, is_cbtab=False): form = self.get_form(id='main') @@ -601,6 +607,20 @@ def go_history(self, info, is_cbtab=False): fix_form(form) return form.submit() + def go_history_netpro(self, info, ): + """ + On the netpro website the go_history() does not work. + Even from a web browser the site does not work, and display the history of the first account + We use a different post to go through and display the history we need + """ + form = self.get_form(id='main') + form['m_ScriptManager'] = 'MM$m_UpdatePanel|MM$HISTORIQUE_COMPTE$m_ExDropDownList' + form['MM$HISTORIQUE_COMPTE$m_ExDropDownList'] = info['id'] + form['__EVENTTARGET'] = 'MM$HISTORIQUE_COMPTE$m_ExDropDownList' + + fix_form(form) + return form.submit() + def get_form_to_detail(self, transaction): m = re.match('.*\("(.*)", "(DETAIL_OP&[\d]+).*\)\)', transaction._link) # go to detailcard page -- GitLab