From 6f0e0d915f90ffa6fb88e382caee46272efd4b5f Mon Sep 17 00:00:00 2001 From: Quentin Defenouillere Date: Thu, 28 Feb 2019 11:29:08 +0100 Subject: [PATCH] [caissedepargne] Added balance xpath for specific Life Insurances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some LI on crédit coopératif did not have any balance so the accounts were skipped because there was an xpath that we did not handle yet. An example of these life insurances is "ACTIPLUS". --- modules/caissedepargne/pages.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/caissedepargne/pages.py b/modules/caissedepargne/pages.py index f3c2170cac..f55085ca53 100644 --- a/modules/caissedepargne/pages.py +++ b/modules/caissedepargne/pages.py @@ -300,6 +300,7 @@ def _add_account(self, accounts, link, label, account_type, balance): account.type = Account.TYPE_CAPITALISATION balance = balance or self.get_balance(account) + account.balance = Decimal(FrenchTransaction.clean_amount(balance)) if balance and balance is not NotAvailable else NotAvailable account.currency = account.get_currency(balance) if balance and balance is not NotAvailable else NotAvailable @@ -324,8 +325,15 @@ def get_balance(self, account): if len(balance) > 0: balance = CleanText('.')(balance[0]) balance = balance if balance != u'' else NotAvailable - else: # sometimes the accounts are attached but no info is available - balance = NotAvailable + else: + # Specific xpath for some Life Insurances: + balance = page.doc.xpath('//tr[td[contains(text(), $id)]]/td/div[contains(@id, "Solde")]', id=account.id) + if len(balance) > 0: + balance = CleanText('.')(balance[0]) + balance = balance if balance != u'' else NotAvailable + else: + # sometimes the accounts are attached but no info is available + balance = NotAvailable self.go_list() return balance -- GitLab