From e2ed74f36d02a653e7b449954f0f3ca6c04f1617 Mon Sep 17 00:00:00 2001 From: Maxime Pommier Date: Mon, 3 Jun 2019 16:18:44 +0200 Subject: [PATCH] [creditmutuel] Skip market account without information on their balance or history ("NC" unstead of the account balance number) --- modules/creditmutuel/pages.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/creditmutuel/pages.py b/modules/creditmutuel/pages.py index 4036844d73..5c022608b5 100644 --- a/modules/creditmutuel/pages.py +++ b/modules/creditmutuel/pages.py @@ -1210,14 +1210,25 @@ def add_por_accounts(self, accounts): acc.type = self.get_type(acc.label) acc._is_inv = True self.fill(acc) - accounts.append(acc) + # Some market account haven't any valorisation, neither history. We skip them. + if not empty(acc.balance): + accounts.append(acc) def fill(self, acc): self.send_form(acc) ele = self.browser.page.doc.xpath('.//table[has-class("fiche bourse")]')[0] - balance = CleanDecimal(ele.xpath('.//td[contains(@id, "Valorisation")]'), - default=Decimal(0), replace_dots=True)(ele) - acc.balance = balance + acc.balance if acc.balance else balance + + balance = CleanText('.//td[contains(@id, "Valorisation")]')(ele) + + # Valorisation will be filled with "NS" string if there isn't information + if balance == 'NS' and not acc.balance: + acc.balance = NotAvailable + else: + balance = CleanDecimal.French(default=0).filter(balance) + if acc.balance: + acc.balance += balance + else: + acc.balance = balance acc.valuation_diff = CleanDecimal(ele.xpath('.//td[contains(@id, "Variation")]'), default=Decimal(0), replace_dots=True)(ele) if balance: -- GitLab