diff --git a/modules/banquepopulaire/browser.py b/modules/banquepopulaire/browser.py index 814e6c8f11c55b5e58046c769253d923ecbaa25b..df8c1b1397dc9cb83577119fdb303a0b0ecc77af 100644 --- a/modules/banquepopulaire/browser.py +++ b/modules/banquepopulaire/browser.py @@ -312,57 +312,68 @@ def set_gocardless_transaction_details(self, transaction): @retry(LoggedOut) @need_login def get_history(self, account, coming=False): - account = self.get_account(account.id) + def get_history_by_receipt(account, coming, sel_tbl1=None): + account = self.get_account(account.id) - if account is None: - raise BrowserUnavailable() + if account is None: + raise BrowserUnavailable() - if account._invest_params or (account.id.startswith('TIT') and account._params): - if not coming: - for tr in self.get_invest_history(account): - yield tr - return + if account._invest_params or (account.id.startswith('TIT') and account._params): + if not coming: + for tr in self.get_invest_history(account): + yield tr + return - if coming: - params = account._coming_params - else: - params = account._params + if coming: + params = account._coming_params + else: + params = account._params - if params is None: - return + if params is None: + return + params['token'] = self.page.build_token(params['token']) - params['token'] = self.page.build_token(params['token']) + if sel_tbl1 != None: + params['attribute($SEL_$tbl1)'] = str(sel_tbl1) - self.location(self.absurl('/cyber/internet/ContinueTask.do', base=True), data=params) + self.location(self.absurl('/cyber/internet/ContinueTask.do', base=True), data=params) - if not self.page or self.error_page.is_here() or self.page.no_operations(): - return + if not self.page or self.error_page.is_here() or self.page.no_operations(): + return - # Sort by values dates (see comment in TransactionsPage.get_history) - if len(self.page.doc.xpath('//a[@id="tcl4_srt"]')) > 0: - form = self.page.get_form(id='myForm') - form.url = self.absurl('/cyber/internet/Sort.do?property=tbl1&sortBlocId=blc2&columnName=dateValeur') - params['token'] = self.page.build_token(params['token']) - form.submit() + # Sort by values dates (see comment in TransactionsPage.get_history) + if len(self.page.doc.xpath('//a[@id="tcl4_srt"]')) > 0: + form = self.page.get_form(id='myForm') + form.url = self.absurl('/cyber/internet/Sort.do?property=tbl1&sortBlocId=blc2&columnName=dateValeur') + params['token'] = self.page.build_token(params['token']) + form.submit() - transactions_next_page = True + transactions_next_page = True - while transactions_next_page: - assert self.transactions_page.is_here() + while transactions_next_page: + assert self.transactions_page.is_here() - transaction_list = self.page.get_history(account, coming) - for tr in transaction_list: - # Add information about GoCardless - if 'GoCardless' in tr.label and tr._has_link: - self.set_gocardless_transaction_details(tr) - yield tr + transaction_list = self.page.get_history(account, coming) + for tr in transaction_list: + # Add information about GoCardless + if 'GoCardless' in tr.label and tr._has_link: + self.set_gocardless_transaction_details(tr) + yield tr - next_params = self.page.get_next_params() - # Go to the next transaction page only if it exists: - if next_params is None: - transactions_next_page = False - else: - self.location('/cyber/internet/Page.do', params=next_params) + next_params = self.page.get_next_params() + # Go to the next transaction page only if it exists: + if next_params is None: + transactions_next_page = False + else: + self.location('/cyber/internet/Page.do', params=next_params) + + if coming and account._coming_count: + for i in range(account._coming_count): + for tr in get_history_by_receipt(account, coming, sel_tbl1=i): + yield tr + else: + for tr in get_history_by_receipt(account, coming): + yield tr @need_login def go_investments(self, account, get_account=False): diff --git a/modules/banquepopulaire/pages.py b/modules/banquepopulaire/pages.py index 1323478cd6845940a2780fb1efa0212793e78032..4232785fce3aca3cc0ccbaa55d1d3f6417ab2af4 100644 --- a/modules/banquepopulaire/pages.py +++ b/modules/banquepopulaire/pages.py @@ -554,6 +554,7 @@ def iter_accounts(self, next_pages): account._next_debit = None account._params = None account._coming_params = None + account._coming_count = None account._invest_params = None if balance != u'' and len(tds[3].xpath('.//a')) > 0: account._params = params.copy() @@ -634,6 +635,7 @@ def iter_accounts(self, next_pages): account._coming_params = params.copy() account._coming_params['dialogActionPerformed'] = 'SELECTION_ENCOURS_CARTE' account._coming_params['attribute($SEL_$%s)' % tr.attrib['id'].split('_')[0]] = tr.attrib['id'].split('_', 1)[1] + account._coming_count = len(self.doc.xpath('//table[@id="tbl1"]/tbody/tr/td[5]/span[not(contains(text(), "(1)"))]')) elif account is None: raise BrokenPageError('Unable to find accounts on cards page') else: