Commit cf65c54a authored by Jerome Berthier's avatar Jerome Berthier Committed by ntome

[bnporc] Fix broken history for entreprise website and avoid fetching 3 months if not needed

The patch f25c39d44aa4cc9103d746f38c1b76369c669e40 introduced two
regressions:
  - one by reverting the timeframes without updating max/min, so there were overlaps
  - one by asking for more than 3 months

The patch aiming to fix these regressions (5239c14fe1757ee9ab4ecfbd05683595fe0abfd3)
was actually fixing the duplicated transactions by breaking the history behavior and
fetching only one month of history.
parent 483c2034
......@@ -127,27 +127,29 @@ class BNPEnterprise(LoginBrowser):
def _iter_history_base(self, account):
dformat = "%Y%m%d"
for date in rrule(MONTHLY, dtstart=(datetime.now() - relativedelta(months=12)), until=datetime.now())[::-1]:
history = []
self.account_history_view.go(
identifiant=account.iban, type_solde='C', type_releve='Previsionnel',
type_date='O', date_min=(date + relativedelta(days=1)).strftime(dformat),
date_max=(date + relativedelta(months=1)).strftime(dformat)
)
# We ask for more 12 months by default, but it may not be supported for somme account types.
# To avoid duplicated transactions we exit as soon a transaction is not within the expected timeframe
for date in rrule(MONTHLY, dtstart=(datetime.now() - relativedelta(months=11)), until=datetime.now())[::-1]:
self.account_history.go(
identifiant=account.iban, type_solde='C', type_releve='Previsionnel',
type_date='O', date_min=(date + relativedelta(days=1)).strftime(dformat),
date_max=(date + relativedelta(months=1)).strftime(dformat)
params = dict(identifiant=account.iban, type_solde='C', type_releve='Previsionnel', type_date='O',
date_min=(date + relativedelta(days=1) - relativedelta(months=1)).strftime(dformat),
date_max=date.strftime(dformat)
)
for transaction in self.page.iter_history():
self.account_history_view.go(**params)
self.account_history.go(**params)
for transaction in sorted_transactions(self.page.iter_history()):
if transaction._coming:
self.logger.debug('skipping coming %r', transaction.to_dict())
continue
history.append(transaction)
for transaction in sorted_transactions(history):
yield transaction
if transaction.date > date:
self.logger.debug('transaction not within expected timeframe, stop iterating history: %r',
transaction.to_dict())
return
yield transaction
@need_login
def iter_coming_operations(self, account):
......
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