Commit 87bf5559 authored by Célande Adrien's avatar Célande Adrien Committed by Romain Bignon

[creditcooperatif] duplicate transactions

Looking at the website, you can see that some transactions are duplicates.
So it is normal to have some, since it is what is send.

But sometimes, some requests send have the same transaction list, even if they had different parameters/data.
So there are some more duplicates.
It happens only for the card type transactions.

They are compared to be sure they does not bring duplicates.
It is pretty easy since their labels always have the same format: 'TOT DIF %MONTH%'.
And the duplicates one have the same amount too.
The rest is checked just to be sure.

Closes: 6257@zendesk
parent 4e213b9d
......@@ -23,6 +23,7 @@ from weboob.browser import LoginBrowser, need_login, StatesMixin
from weboob.browser.url import URL
from weboob.browser.exceptions import ClientError
from weboob.exceptions import BrowserIncorrectPassword, BrowserUnavailable
from weboob.capabilities.base import find_object
from weboob.tools.capabilities.bank.transactions import sorted_transactions, FrenchTransaction
from .pages import (
......@@ -150,12 +151,20 @@ class CenetBrowser(LoginBrowser, StatesMixin):
items = []
self.cenet_account_history.go(data=json.dumps(data), headers=headers)
# there might be some duplicate transactions regarding the card type ones
# because some requests lead to the same transaction list
# even with different parameters/data in the request
card_tr_list = []
while True:
data_out = self.page.doc['DonneesSortie']
for tr in self.page.get_history():
items.append(tr)
if tr.type is FrenchTransaction.TYPE_CARD_SUMMARY:
if find_object(card_tr_list, label=tr.label, amount=tr.amount, raw=tr.raw, date=tr.date, rdate=tr.rdate):
self.logger.warning('Duplicate transaction: %s' % tr)
continue
card_tr_list.append(tr)
tr.deleted = True
tr_dict = [tr_dict for tr_dict in data_out if tr_dict['Libelle'] == tr.label]
donneesEntree = {}
......@@ -178,10 +187,9 @@ class CenetBrowser(LoginBrowser, StatesMixin):
data['filtreEntree'] = json.dumps({
'Offset': offset,
})
self.cenet_account_history.go(data=json.dumps(data), headers=headers)
return items
return sorted_transactions(items)
@need_login
def get_coming(self, account):
......
......@@ -184,11 +184,18 @@ class CenetCardSummaryPage(LoggedPage, CenetJsonPage):
class item(ItemElement):
klass = Transaction
obj_raw = Format('%s %s', Dict('Libelle'), Dict('Libelle2'))
obj_label = CleanText(Dict('Libelle'))
obj_date = Date(Dict('DateGroupImputation'), dayfirst=True)
obj_type = Transaction.TYPE_DEFERRED_CARD
def obj_raw(self):
label = Dict('Libelle')(self)
label2 = Dict('Libelle2')(self)
if label2 and label2 != 'None':
return '%s %s' % (label, label2)
else:
return label
def obj_rdate(self):
rdate = re.search('(FACT\s)(\d{6})', Field('label')(self))
if rdate.group(2):
......
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