Commit c958471e authored by Sylvie Ye's avatar Sylvie Ye Committed by Romain Bignon

[spirica] add _invest_type for item investment

Investments with type 'Fonds en euros' don't have PRM.

Closes: 500979@redmine
parent f21434f4
......@@ -81,8 +81,10 @@ class SpiricaBrowser(LoginBrowser):
def fill_from_list(self, invs, objects_list):
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
for name, field_value in obj_from_list[0].iter_fields():
if field_value:
setattr(inv, name, field_value)
# Some investments don't have PRM
if inv._invest_type != 'Fonds en euros':
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
for name, field_value in obj_from_list[0].iter_fields():
if field_value:
setattr(inv, name, field_value)
......@@ -106,6 +106,7 @@ class ItemInvestment(ItemElement):
obj_unitvalue = MyDecimal(TableCell('unitvalue', default=None))
obj_vdate = Date(CleanText(TableCell('vdate', default="")), dayfirst=True, default=NotAvailable)
obj_code = Regexp(CleanText('.//td[contains(text(), "Isin")]'), ':[\s]+([\w]+)', default=NotAvailable)
obj__invest_type = Regexp(CleanText('.//td[contains(text(), "Type")]'), ':[\s]+([\w ]+)', default=NotAvailable)
def obj_valuation(self):
valuation = MyDecimal(TableCell('valuation', default=None))(self)
......
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