From eb80d54a66238992805416bf796b8c10549a706e Mon Sep 17 00:00:00 2001 From: Guillaume Risbourg Date: Tue, 8 Oct 2019 16:05:06 +0200 Subject: [PATCH] [bred] Skip transaction duplicates The website sometimes send us duplicates transactions that erase other transactions. There is nothing we can do to fix that, so we just skip those duplicates instead of raising an error. Closes: 18569@sibi 13059,13204,13337,13751@zendesk --- modules/bred/bred/browser.py | 2 +- modules/bred/bred/pages.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/bred/bred/browser.py b/modules/bred/bred/browser.py index 088e418b92..8e7e4ee062 100644 --- a/modules/bred/bred/browser.py +++ b/modules/bred/bred/browser.py @@ -198,7 +198,7 @@ def get_history(self, account, coming=False): self.logger.debug('stopping coming after %s', t) return - next_page = len(transactions) == 50 + next_page = len(transactions) > 0 offset += 50 # This assert supposedly prevents infinite loops, diff --git a/modules/bred/bred/pages.py b/modules/bred/bred/pages.py index 3ac794fd61..978fffd917 100644 --- a/modules/bred/bred/pages.py +++ b/modules/bred/bred/pages.py @@ -24,7 +24,7 @@ from decimal import Decimal from weboob.tools.date import parse_french_date -from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable, ActionNeeded, ParseError +from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable, ActionNeeded from weboob.capabilities.base import find_object from weboob.browser.pages import JsonPage, LoggedPage, HTMLPage from weboob.capabilities import NotAvailable @@ -264,7 +264,8 @@ def iter_history(self, account, operation_list, seen, today, coming): t = Transaction() t.id = str(op['id']) if op['id'] in seen: - raise ParseError('There are several transactions with the same ID, probably an infinite loop') + self.logger.debug('Skipped transaction : "%s %s"' % (op['id'], op['libelle'])) + continue seen.add(t.id) d = date.fromtimestamp(op.get('dateDebit', op.get('dateOperation')) / 1000) -- GitLab