From 87c2b09e2d77b1e8c5c6386f79677363627f4289 Mon Sep 17 00:00:00 2001 From: Lucas Ficheux Date: Fri, 12 Jul 2019 16:36:34 +0200 Subject: [PATCH] [bred] Fix accounts not scrapped Accounts were filtered using their ID before it was fully formed resulting in bad filtering. I moved the filtering after the ID is fully formed and the module now scrapes all accounts. I also added the number of the account to account where it's present to better reflect what is displayed on the website. closes : 11436@zendesk --- modules/bred/bred/pages.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/bred/bred/pages.py b/modules/bred/bred/pages.py index 5906781604..93d1d31076 100644 --- a/modules/bred/bred/pages.py +++ b/modules/bred/bred/pages.py @@ -145,14 +145,6 @@ def iter_accounts(self, accnum, current_univers): a._univers = current_univers a.id = '%s.%s' % (a._number, a._nature) - if a.id in seen: - # some accounts like "compte à terme fidélis" have the same _number and _nature - # but in fact are kind of closed, so worthless... - self.logger.warning('ignored account id %r (%r) because it is already used', a.id, poste.get('numeroDossier')) - continue - - seen.add(a.id) - a.type = self.ACCOUNT_TYPES.get(poste['codeNature'], Account.TYPE_UNKNOWN) if a.type == Account.TYPE_UNKNOWN: self.logger.warning("unknown type %s" % poste['codeNature']) @@ -176,11 +168,22 @@ def iter_accounts(self, accnum, current_univers): continue a.label = ' '.join([content['intitule'].strip(), poste['libelle'].strip()]) + if poste['numeroDossier']: + a.label = '{} {}{}'.format(a.label, 'n°', poste['numeroDossier']) + a.balance = Decimal(str(poste['solde']['valeur'])) a.currency = poste['solde']['monnaie']['code'].strip() # Some accounts may have balance currency if 'Solde en devises' in a.label and a.currency != u'EUR': a.id += str(poste['monnaie']['codeSwift']) + + if a.id in seen: + # some accounts like "compte à terme fidélis" have the same _number and _nature + # but in fact are kind of closed, so worthless... + self.logger.warning('ignored account id %r (%r) because it is already used', a.id, poste.get('numeroDossier')) + continue + + seen.add(a.id) accounts_list.append(a) return accounts_list -- GitLab