From 82e593eb4278e4a638d8b1a8ca04ec808f522b72 Mon Sep 17 00:00:00 2001 From: Maxime Gasselin Date: Wed, 27 Feb 2019 15:41:44 +0100 Subject: [PATCH] [bp] prevent the history from being reached for checking account with balance = 0 In this case when we reached these pages, the navigation is broken. We avoid to reach it in the iter account and return no transactions for history and coming. Closes: 36493@sibi --- modules/bp/browser.py | 9 +++++++-- modules/bp/pages/accountlist.py | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/bp/browser.py b/modules/bp/browser.py index 06ec4194f7..98ddee24b1 100644 --- a/modules/bp/browser.py +++ b/modules/bp/browser.py @@ -312,6 +312,10 @@ def iter_cards(self, account): @need_login def get_history(self, account): + if account.type == Account.TYPE_CHECKING and account.balance == 0: + # When the balance is 0, we get a website unavailable on the history page + # and the following navigation is broken + return [] # TODO scrap pdf to get history of mandate accounts if 'gestion-sous-mandat' in account.url: return [] @@ -366,8 +370,9 @@ def _get_coming_transactions(self, account): def get_coming(self, account): if 'gestion-sous-mandat' in account.url: return [] - - if account.type == Account.TYPE_CHECKING: + # When the balance is 0, we get a website unavailable on the history page + # and the following navigation is broken + if account.type == Account.TYPE_CHECKING and account.balance != 0: return self._get_coming_transactions(account) elif account.type == Account.TYPE_CARD: transactions = [] diff --git a/modules/bp/pages/accountlist.py b/modules/bp/pages/accountlist.py index ef2ab119f8..4cf07f8269 100644 --- a/modules/bp/pages/accountlist.py +++ b/modules/bp/pages/accountlist.py @@ -74,7 +74,9 @@ def obj_balance(self): return CleanDecimal('.//span[@class="number"]', replace_dots=True, default=NotAvailable)(self) def obj_coming(self): - if Field('type')(self) == Account.TYPE_CHECKING: + if Field('type')(self) == Account.TYPE_CHECKING and Field('balance')(self) != 0: + # When the balance is 0, we get a website unavailable on the history page + # and the following navigation is broken has_coming = False coming = 0 -- GitLab