Commit 3b3705d6 authored by Martin Sicot's avatar Martin Sicot Committed by Romain Bignon

[credimutuel] Handle nested investments

Sometimes when one invest is splitted underneath in several sub
investments we now retrieve the data correctly.
parent 910d3d26
......@@ -1218,13 +1218,21 @@ class PorPage(LoggedPage, HTMLPage):
class item(ItemElement):
klass = Investment
def condition(self):
return not any(not x.isdigit() for x in Attr('.', 'id')(self))
obj_label = CleanText(TableCell('label'), default=NotAvailable)
obj_code = CleanText('.//td[1]/a/@title') & Regexp(pattern=r'^([^ ]+)')
obj_quantity = CleanDecimal(TableCell('quantity'), default=Decimal(0), replace_dots=True)
obj_unitprice = CleanDecimal(TableCell('unitprice'), default=Decimal(0), replace_dots=True)
obj_valuation = CleanDecimal(TableCell('valuation'), default=Decimal(0), replace_dots=True)
obj_diff = CleanDecimal(TableCell('diff'), default=Decimal(0), replace_dots=True)
def obj_code(self):
code = Regexp(CleanText('.//td[1]/a/@title'), r'^([^ ]+)')(self)
if 'masquer' in code:
return Regexp(CleanText('./following-sibling::tr[1]//a/@title'), r'^([^ ]+)')(self)
return code
def obj_unitvalue(self):
r = CleanText(TableCell('unitvalue'))(self)
if r[-1] == '%':
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