diff --git a/modules/spirica/browser.py b/modules/spirica/browser.py index 47f45fcb2bf83fda6fe3fddd688602cb6f278ab5..d3305a588386cb5cab57ee3587036c19e2b36a49 100644 --- a/modules/spirica/browser.py +++ b/modules/spirica/browser.py @@ -79,7 +79,7 @@ def iter_history(self, account): return self.cache['trs'][account.id] def fill_from_list(self, invs, objects_list): - matching_fields = ['code', 'unitvalue', 'label'] + matching_fields = ['code', 'unitvalue', 'label', '_gestion_type'] for inv in invs: obj_from_list = [o for o in objects_list if all(getattr(o, field) == getattr(inv, field) for field in matching_fields)] assert len(obj_from_list) == 1 diff --git a/modules/spirica/pages.py b/modules/spirica/pages.py index b48df29d0bc876bbdd9f1452dd5bbc8cf5a0366c..f83c199421497a0a013426de1f965fd1b5712011 100644 --- a/modules/spirica/pages.py +++ b/modules/spirica/pages.py @@ -95,6 +95,7 @@ class TableInvestment(TableElement): col_unitvalue = u'Valeur de part' col_quantity = u'Nombre de parts' col_portfolio_share = u'%' + col__gestion_type = re.compile('Nom du profil') class ItemInvestment(ItemElement): @@ -115,6 +116,18 @@ def obj_portfolio_share(self): ps = MyDecimal(TableCell('portfolio_share', default=None))(self) return Eval(lambda x: x / 100, ps)(self) if not empty(ps) else NotAvailable + def obj__gestion_type(self): + if self.xpath('ancestor::tbody[ends-with(@id, "contratProfilTable_data")]'): + # investments are nested in profiles, get profile type + profile_table_el = self.xpath('ancestor::tr/ancestor::table[position() = 1]')[0] + profile_table = ProfileTableInvestment(self.page, self, profile_table_el) + gestion_type = profile_table.get_colnum('_gestion_type') + assert gestion_type + + path = 'ancestor::tr/preceding-sibling::tr[@data-ri][position() = 1][1]/td[%d]' % (gestion_type + 1) + return CleanText(path)(self) + return NotAvailable + class TableTransactionsInvestment(TableInvestment): item_xpath = './tbody/tr'