From ba59c4d294ff6fd8063860dcc3534a4fddafd442 Mon Sep 17 00:00:00 2001 From: Vincent Ardisson Date: Mon, 9 Apr 2018 18:48:16 +0200 Subject: [PATCH] [barclays] return credit card history They were completely skipped. There's a link to access previous month history. However, the debit dates all seem wrong, same for coming. --- modules/barclays/browser.py | 8 ++++++-- modules/barclays/pages.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/barclays/browser.py b/modules/barclays/browser.py index cc83abb122..ee3e9f03d1 100644 --- a/modules/barclays/browser.py +++ b/modules/barclays/browser.py @@ -150,8 +150,7 @@ def iter_accounts(self): @need_login def iter_history(self, account): - if account.type == Account.TYPE_CARD or (account._multiple_type and not self._multiple_account_choice(account)): - # warning: this shit code is not idempotent ^ + if account._multiple_type and not self._multiple_account_choice(account): return [] elif account.type == Account.TYPE_LOAN: return [] @@ -163,6 +162,11 @@ def iter_history(self, account): self.logger.warning('cannot go to history page for %r', account) return [] + if account.type == Account.TYPE_CARD: + if not self._go_to_account_space('Échéance précédente', account): + self.logger.warning('Could not go to history page for %r', account) + return [] + history_page = self.page if account.type != Account.TYPE_LIFE_INSURANCE: diff --git a/modules/barclays/pages.py b/modules/barclays/pages.py index c37c52f4bd..e868f827c3 100644 --- a/modules/barclays/pages.py +++ b/modules/barclays/pages.py @@ -427,6 +427,17 @@ def condition(self): def obj_amount(self): return MyDecimal('./td[5]//div/span')(self) + def get_space_attrs(self, space): + a = self.doc.xpath('//a[contains(span, $space)]', space=space) + if not a: + self.logger.debug('there is no %r link on this page', space) + return None + + a = Regexp(Attr('.', 'onclick'), r'\((.*?)\)')(a[0]).replace('\'', '').split(', ') + form = self.get_form(id='form1') + + return (a[1], 'C4__WORKING[1].LISTCONTRATS', form['C4__WORKING[1].LISTCONTRATS'], a[2]) + class IbanPDFPage(LoggedPage, PDFPage): def get_iban(self): -- GitLab