Commit d7857b7c authored by Baptiste Delpey's avatar Baptiste Delpey Committed by Romain Bignon

[spirica] fix when life insurance are splited in different gestions

parent 26ca1f86
......@@ -79,7 +79,7 @@ class SpiricaBrowser(LoginBrowser):
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
......
......@@ -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 @@ class ItemInvestment(ItemElement):
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'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment