Commit 87c2b09e authored by Lucas Ficheux's avatar Lucas Ficheux Committed by ntome

[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
parent 4903a7b5
......@@ -145,14 +145,6 @@ class AccountsPage(MyJsonPage):
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 @@ class AccountsPage(MyJsonPage):
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment