Commit 26e5b5a0 authored by Damien Mat's avatar Damien Mat Committed by Vincent A

[cmso] Fix: fetch missing transactions at the start of a month

For now, transactions were fetch on a month by month basis.
Each month would display transactions with at least one type of id
among 2 possible, and those are collected.
Finally, a global history page is parsed, without month param.
A special condition would avoid duplicates based on the ids.

But at the turn of the month there are transactions that
don't have any id, and so would not be selected.

First page fetched is the 'SIX_DERNIERES_SEMAINES'. All transactions from
current month are selected here (they don't bear any id).
Then the month by month selection is done.
No final page without month param is fetched at the end since we
already got all transactions.

Tested also on CMB and BPE child modules.
parent bdf4dc8a
Pipeline #3415 passed with stages
in 16 minutes and 52 seconds
......@@ -432,16 +432,25 @@ class CmsoParBrowser(TwoFactorBrowser):
# Getting a year of history
# We have to finish by "SIX_DERNIERES_SEMAINES" to get in priority the transactions with ids.
# In "SIX_DERNIERES_SEMAINES" you can have duplicates transactions without ids of the previous two months.
trs = []
self.history.go(json={"index": account._index}, page="pendingListOperations")
has_deferred_cards =
# 1.fetch the last 6 weeks transactions but keep only the current month ones
# those don't have any id and include 'hier' and 'Plus tôt dans la semaine'
trs = []
'index': account._index,
'filtreOperationsComptabilisees': "SIX_DERNIERES_SEMAINES",
for tr in, last_trs=True):
# 2. get the month by month transactions
# and avoid duplicates based on ids
nbs = ["DEUX", "TROIS", "QUATRE", "CINQ", "SIX", "SEPT", "HUIT", "NEUF", "DIX", "ONZE", "DOUZE"]
'index': account._index,
......@@ -450,7 +459,6 @@ class CmsoParBrowser(TwoFactorBrowser):
self.trs = set()
for tr in, nbs=nbs):
# Check for duplicates
if tr._operationid in self.trs or ( and in self.trs):
......@@ -409,9 +409,8 @@ class HistoryPage(LoggedPage, JsonPage):
def next_page(self):
if len(Env('nbs', default=[])(self)):
data = {'index': Env('index')(self)}
if Env('nbs')(self)[0] != "SIX_DERNIERES_SEMAINES":
data.update({'filtreOperationsComptabilisees': "MOIS_MOINS_%s" % Env('nbs')(self)[0]})
next_month = Env('nbs')(self).pop(0)
data.update({'filtreOperationsComptabilisees': "MOIS_MOINS_%s" % next_month})
return requests.Request('POST', data=json.dumps(data))
def parse(self, el):
......@@ -462,6 +461,12 @@ class HistoryPage(LoggedPage, JsonPage):
self.obj._deferred_date = self.FromTimestamp().filter(deferred_date)
def validate(self, obj):
if Env('last_trs', default=None)(self):
# keep only current month transactions
return >=
return True
class RedirectInsurancePage(LoggedPage, JsonPage):
def get_url(self):
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