Commit 54d19c58 authored by sinopsysHK's avatar sinopsysHK Committed by Vincent A

[hsbc] fix history issue when multiple credit cards

when two (or more) credit cards are linked to a same parent account, as card numbers are close to each others it can mess'up the fetch of history providing the transactions from the other card.

fixing in a row a side effect of the same issue preventing to revert CB payment record from parent account to card account to perform monthly reset.

fixing also an issue in the history which was missing some transactions:
if history is being called when no new transaction has been recorded
since last credit card payement then history tab will have only last
period and before last period shown. But currently hsbc module assume
that first tab always contains "coming" entries (which are due in the
future) so it is always skipped for fetching history. So past entries of
the last period are not fetched from history and neither form coming as
they are filtered out due to past date.

Add new mapping for transaction types related to Global Transferts (with own foreign accounts).
parent 9cdbb55a
......@@ -475,10 +475,13 @@ class HSBC(LoginBrowser):
history_tabs_urls =
guesser = LinearDateGuesser(date_max_bump=timedelta(45))
history = []
if coming:
self.location(history_tabs_urls[0]) # fetch only first tab coming transactions
history += list(
# gather coming anyway
# in case no new transaction has been recorded since last (past) payement
self.location(history_tabs_urls[0]) # fetch only first tab coming transactions
if not coming:
# get further history
self.logger.debug("get history")
for tab in history_tabs_urls[1:]:
self.location(tab) # fetch all tab but first of past transactions
history += list(
......@@ -41,6 +41,7 @@ from .landing_pages import GenericLandingPage
class Transaction(FrenchTransaction):
(re.compile(r'^VIR(EMENT)? (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER),
(re.compile(r'^TRANSFERT? (?P<text>.*)'), FrenchTransaction.TYPE_TRANSFER),
(re.compile(r'^(PRLV|OPERATION|(TVA )?FACT ABONNEMENTS) (?P<text>.*)'), FrenchTransaction.TYPE_ORDER),
(re.compile(r'^CB (?P<text>.*?)\s+(?P<dd>\d+)/(?P<mm>[01]\d)'), FrenchTransaction.TYPE_CARD),
(re.compile(r'^DAB (?P<dd>\d{2})/(?P<mm>\d{2}) ((?P<HH>\d{2})H(?P<MM>\d{2}) )?(?P<text>.*?)( CB N°.*)?$'), FrenchTransaction.TYPE_WITHDRAWAL),
......@@ -50,6 +51,7 @@ class Transaction(FrenchTransaction):
(re.compile(r'^ARRETE DE COMPTE.*'), FrenchTransaction.TYPE_BANK),
(re.compile(r'^REMISE (?P<text>.*)'), FrenchTransaction.TYPE_DEPOSIT),
(re.compile(r'^FACTURES CB (?P<text>.*)'), FrenchTransaction.TYPE_CARD_SUMMARY),
(re.compile(r'^REJET VIR (?P<text>.*)'), FrenchTransaction.TYPE_BANK),
......@@ -163,8 +165,8 @@ class AccountsPage(GenericLandingPage):
for form in self.doc.xpath('//form[@id]'):
value = Attr('.//input[@name="CPT_IdPrestation" or @name="CB_IdPrestation"]', 'value')(form)
# * if needed, all the card numbers could be fetched at that point to replace 'XXXX' as they appear in 'value'
match = (re.match(r'^(.*)?(\d{11}(\w{3}))$', or re.match(r'^(.*)?(\d{6})(X{6})(\d{4})(.*)?$',
if ( or ( and in value:
pattern = ".*{}.*".format('XXXXXX', '\\d{6}'))
if re.match(pattern, value):
# certain forms have the same id atribute, we must submit the one with the same input 'value' attribute
self.get_form(xpath='//form[@id][input[@value="%s"]]' % value).submit()
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