diff --git a/modules/hsbc/browser.py b/modules/hsbc/browser.py index cae5eecabffa458126665c21c9db226bc6121586..f8eafdb8b5b8b761b9c090950dece1b98d3d307e 100644 --- a/modules/hsbc/browser.py +++ b/modules/hsbc/browser.py @@ -475,10 +475,13 @@ def get_history(self, account, coming=False, retry_li=True): history_tabs_urls = self.page.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(self.page.get_history(date_guesser=guesser)) - else: + # 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 + history.extend(list(self.page.get_history(date_guesser=guesser))) + 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(self.page.get_history(date_guesser=guesser)) diff --git a/modules/hsbc/pages/account_pages.py b/modules/hsbc/pages/account_pages.py index 13fc97a4bd2019d3ab9d369e989174549a085c57..5a6de6d55418c65c9eb39a334f3faa1509d4f3f6 100644 --- a/modules/hsbc/pages/account_pages.py +++ b/modules/hsbc/pages/account_pages.py @@ -41,6 +41,7 @@ class Transaction(FrenchTransaction): PATTERNS = [ (re.compile(r'^VIR(EMENT)? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), + (re.compile(r'^TRANSFERT? (?P.*)'), FrenchTransaction.TYPE_TRANSFER), (re.compile(r'^(PRLV|OPERATION|(TVA )?FACT ABONNEMENTS) (?P.*)'), FrenchTransaction.TYPE_ORDER), (re.compile(r'^CB (?P.*?)\s+(?P
\d+)/(?P[01]\d)'), FrenchTransaction.TYPE_CARD), (re.compile(r'^DAB (?P
\d{2})/(?P\d{2}) ((?P\d{2})H(?P\d{2}) )?(?P.*?)( 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.*)'), FrenchTransaction.TYPE_DEPOSIT), (re.compile(r'^FACTURES CB (?P.*)'), FrenchTransaction.TYPE_CARD_SUMMARY), + (re.compile(r'^REJET VIR (?P.*)'), FrenchTransaction.TYPE_BANK), ] @@ -163,8 +165,8 @@ def go_history_page(self, account): 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}))$', account.id) or re.match(r'^(.*)?(\d{6})(X{6})(\d{4})(.*)?$', account.id)) - if (match.group(2) or (match.group(4) and match.group(2))) in value: + pattern = ".*{}.*".format(account.id.replace('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() return