diff --git a/modules/cragr/browser.py b/modules/cragr/browser.py index 0fa032db76436ea96a3816951ebbc71aa0b0b607..46c010dc8076e4291438603c85eecec3616c3af8 100644 --- a/modules/cragr/browser.py +++ b/modules/cragr/browser.py @@ -1290,9 +1290,6 @@ def iter_subscription(self): # We have been logged out. self.do_login() - # Some subscriptions exist in 2 occurences in the page: e.g. one account has regular bank statement reports + deffered statements - # We use this variable not to parse a subscription twice and cause trouble - parsed_subscription_ids = [] for contract in self.iter_spaces(): self.token_page.go() token = self.page.get_token() @@ -1303,9 +1300,8 @@ def iter_subscription(self): except HTTPNotFound: continue self.page.submit(token) - for sub in self.page.iter_subscription(parsed_subscription_ids=parsed_subscription_ids): + for sub in self.page.iter_subscription(): sub._contract = contract - parsed_subscription_ids.append(sub.id) yield sub @need_login diff --git a/modules/cragr/document_pages.py b/modules/cragr/document_pages.py index d6657fd71ea7a54fd4b8333fc256a4173168d2a8..2e07749dfffb8f1530b638700743bd09e1e8d5a4 100644 --- a/modules/cragr/document_pages.py +++ b/modules/cragr/document_pages.py @@ -43,25 +43,20 @@ def has_error(self): @method class iter_subscription(ListElement): + # Some subscriptions exist in 2 occurences in the page: e.g. one account has regular bank statement reports + deffered statements + # there might be duplicate, but not a big deal weboob is good and will keep only one subscription. + ignore_duplicate = True item_xpath = '//div[contains(text(), "RELEVES DE COMPTES")]/following-sibling::table//tr//div[contains(@class, "table")]' class item(ItemElement): klass = Subscription - def get_account_information(self): + def parse(self, el): raw = CleanText('./a')(self) # raw = account_name account_id account_owner m = re.match(r'([A-Za-z ]+) (\d+) (.+)$', raw) assert m, 'Format of line is not: ACT 123456789 M. First Last' - return m.groups() - - def condition(self): - # We check if the subscription hasn't been already parsed - _, account_id, _ = self.get_account_information() - return account_id not in Env('parsed_subscription_ids')(self) - - def parse(self, el): - self.env['account_name'], self.env['account_id'], self.env['account_owner'] = self.get_account_information() + self.env['account_name'], self.env['account_id'], self.env['account_owner'] = m.groups() obj_label = Format('%s %s', Env('account_name'), Env('account_owner')) obj_subscriber = Env('account_owner')