From 1a60bc5a9d45ad6e5ab97e0110ee3b93c6b7c69d Mon Sep 17 00:00:00 2001 From: Jerome Berthier Date: Fri, 5 Apr 2019 13:00:18 +0200 Subject: [PATCH] [themisbanque] Fix duplicated transactions --- modules/themisbanque/browser.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/themisbanque/browser.py b/modules/themisbanque/browser.py index cfe71c944f..861990e231 100644 --- a/modules/themisbanque/browser.py +++ b/modules/themisbanque/browser.py @@ -61,8 +61,19 @@ def iter_accounts(self): def get_history(self, account): if account._link: self.location(account._link) - return self.page.get_operations() - return [] + for tr in self._dedup_transactions(self.page.get_operations()): + yield tr + + @staticmethod + def _dedup_transactions(transactions): + # Sometime the website returns the same list of transactions for each history page. + # So we process the transactions list, and stop if any transaction is newer than the previous one. + last_date = None + for i, tr in enumerate(transactions): + if last_date and tr.date > last_date: + break + last_date = tr.date + yield tr @need_login def get_profile(self): -- GitLab