From 1b76666861417c3fa6ca9fdad24e65523195e15f Mon Sep 17 00:00:00 2001 From: Quentin Defenouillere Date: Wed, 13 Feb 2019 14:42:02 +0100 Subject: [PATCH] [milleis] Ignore history for twin accounts that are not in Euros Milleis offers the possibility to have twin accounts, which are actually one same account with two different currencies (Euros and another currency). The iter_accounts works well but on the website, twin accounts transactions are completely mixed up, and for now we scrape the exact same history for both accounts so all twin account transactions are duplicated. Since the currency of each transaciton is not precised, we cannot pair transactions to one of the twin accounts. This patch skips iter_history for twin accounts that are not in euros in order to avoid transaction duplicates, the transactions will now only be associated with the Euro twin account. Closes: 9425@zendesk --- modules/barclays/browser.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/barclays/browser.py b/modules/barclays/browser.py index ae252b919a..eaf08e8954 100644 --- a/modules/barclays/browser.py +++ b/modules/barclays/browser.py @@ -158,10 +158,23 @@ def iter_accounts(self): self.cache['accounts'] = traccounts + # Twin accounts are double accounts with different currencies. + # Transactions for twin accounts are all mixed and the currency + # is not specified, therefore to avoid transaction duplicates, + # we only return transactions from the 'EUR' twin account. + for account in self.cache['accounts']: + if (account.id.replace(account.currency, '') in + [acc.id.replace(acc.currency, '') for acc in self.cache['accounts'] if acc.id != account.id]): + account._twin = True + else: + account._twin = False + return self.cache['accounts'] @need_login def iter_history(self, account): + if account._twin and account.currency != 'EUR': + return [] if account._multiple_type and not self._multiple_account_choice(account): return [] elif account.type in (Account.TYPE_LOAN, Account.TYPE_REVOLVING_CREDIT): -- GitLab