From cfeaa4bed03ea40fa6dbdfeec340c043dbcfa519 Mon Sep 17 00:00:00 2001 From: Christophe Francois Date: Mon, 2 Nov 2020 16:14:44 +0100 Subject: [PATCH] [creditmutuel] Fix issue with duplicate accounts Market accounts are separated in a stock and a liquidities account, with the same number. Following a change in the page, we would add '.1' to the ID of both accounts, so there were duplicate IDs. We use the label to add '.1' only to the liquidities accounts' IDs. --- modules/creditmutuel/pages.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/creditmutuel/pages.py b/modules/creditmutuel/pages.py index 5f43dd8621..d0d5c83378 100644 --- a/modules/creditmutuel/pages.py +++ b/modules/creditmutuel/pages.py @@ -1618,12 +1618,10 @@ def condition(self): # This values are defined for other types of accounts obj__is_inv = True - - # IDs on the old page were differentiated with 5 digits in front of the ID, but not here. - # We still need to differentiate them so we add ".1" at the end. - obj_id = Format('%s.1', Env('id')) - - obj_label = Base(TableCell('raw_label'), CleanText('.', children=False)) + obj_label = Coalesce( + Base(TableCell('raw_label'), CleanText('.', children=False)), + Base(TableCell('raw_label'), CleanText('./span[not(.//a)]')), + ) obj_number = Base(TableCell('raw_label'), CleanText('./a', replace=[(' ', '')])) obj_balance = Env('balance') @@ -1631,7 +1629,14 @@ def condition(self): obj_valuation_diff = CleanDecimal.French(TableCell('valuation_diff'), default=NotAvailable) - obj__link_id = Regexp(Link('.//a', default=NotAvailable), r'ddp=([^&]*)', default=NotAvailable) + obj__link_id = Regexp(Link('.//a', default=''), r'ddp=([^&]*)', default=NotAvailable) + + # IDs on the old page were differentiated with 5 digits in front of the ID, but not here. + # We still need to differentiate them so we add ".1" at the end of the liquidities account. + def obj_id(self): + if 'LIQUIDITE' in CleanText(TableCell('raw_label'))(self): + return Format('%s.1', Env('id'))(self) + return Env('id')(self) def obj_type(self): return self.page.get_type(Field('label')(self)) -- GitLab