From 95e921d12bda6201c2c76e0b4ba38c4bfced0dbf Mon Sep 17 00:00:00 2001 From: Guillaume Risbourg Date: Fri, 8 Nov 2019 15:28:58 +0100 Subject: [PATCH] [bp] Add conditions to filter out loans without any datas The loans filtered out had no info (because they were not ready yet or already refunded), so we do not retrieve them. Closes: 50494@sibi --- modules/bp/pages/accountlist.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/bp/pages/accountlist.py b/modules/bp/pages/accountlist.py index 8b52fa9d80..26d88bcafa 100644 --- a/modules/bp/pages/accountlist.py +++ b/modules/bp/pages/accountlist.py @@ -55,10 +55,18 @@ class item_account_generic(ItemElement): def condition(self): # For some loans the following xpath is absent and we don't want to skip them # Also a case of loan that is empty and has no information exists and will be ignored - return (len(self.el.xpath('.//span[@class="number"]')) > 0 or - (Field('type')(self) == Account.TYPE_LOAN and - (len(self.el.xpath('.//div//*[contains(text(),"pas la restitution de ces données.")]')) == 0 and - len(self.el.xpath('.//div[@class="amount"]/span[contains(text(), "Contrat résilié")]')) == 0))) + return ( + len(self.el.xpath('.//span[@class="number"]')) > 0 or + ( + Field('type')(self) == Account.TYPE_LOAN and + ( + not bool(self.el.xpath('.//div//*[contains(text(),"pas la restitution de ces données.")]')) + and not bool(self.el.xpath('.//div[@class="amount"]/span[contains(text(), "Contrat résilié")]')) + and not bool(self.el.xpath('.//div[@class="amount"]/span[contains(text(), "Remboursé intégralement")]')) + and not bool(self.el.xpath('.//div[@class="amount"]/span[contains(text(), "Prêt non débloqué")]')) + ) + ) + ) obj_id = obj_number = CleanText('.//abbr/following-sibling::text()') obj_currency = Coalesce(Currency('.//span[@class="number"]'), Currency('.//span[@class="thick"]')) -- GitLab