diff --git a/modules/creditmutuel/pages.py b/modules/creditmutuel/pages.py index 7d990fca01c069251ad0b2bf2d3ff5450d9081a7..aabdcc29e55099f1fbc1fe92ee7ea08e8b74b7d4 100644 --- a/modules/creditmutuel/pages.py +++ b/modules/creditmutuel/pages.py @@ -262,6 +262,16 @@ def parse(self, el): for td in el.xpath('./td[2] | ./td[3]'): try: balance = CleanDecimal('.', replace_dots=True)(td) + has_child_def_card = CleanText('.//following-sibling::tr[1]//span[contains(text(), "Dépenses cartes prélevées")]')(el) + if Field('type')(self) == Account.TYPE_CHECKING and not has_child_def_card: + # the present day, real balance (without comings) is displayed in the operations page of the account + # need to limit requests to checking accounts with no def cards + details_page_link = Link('.//a', default=None)(self) + if details_page_link: + coming_page = self.page.browser.open(details_page_link).page + balance_without_comings = coming_page.get_balance() + if not empty(balance_without_comings): + balance = balance_without_comings except InvalidOperation: continue else: @@ -731,6 +741,9 @@ def get_coming_link(self): def has_more_operations(self): return bool(self.doc.xpath('//a/span[contains(text(), "Plus d\'opérations")]')) + def get_balance(self): + return CleanDecimal.French('//span[contains(text(), "Dont opérations enregistrées")]', default=NotAvailable)(self.doc) + class CardsOpePage(OperationsPage): def select_card(self, card_number):