The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

Commit 5337729d authored by Quentin Defenouillere's avatar Quentin Defenouillere Committed by Vincent A

[fortuneo] Corrected Life Insurance balance & investment values

The code had to be adapted to handle the fact that Life Insurances have
a '.' for decimal separator on InvestmentPage, not a ',' like other
accounts.
On the investments table, some values have a ',' some others have a '.'
so we need to verify the format in order to call CleanDecimal.French()
or .SI() accordingly.

Closes: 13308@zendesk, 13320@zendesk, 13331@zendesk, 13333@zendesk
parent 38ac3501
......@@ -171,26 +171,32 @@ def get_investments(self, account):
inv = Investment()
inv.id = re.search('cdReferentiel=(.*)', cols[self.COL_LABEL].find('a').attrib['href']).group(1)
inv.code = re.match('^[A-Z]+[0-9]+(.*)$', inv.id).group(1)
inv.label = CleanText(None).filter(cols[self.COL_LABEL])
inv.quantity = self.parse_decimal(cols[self.COL_QUANTITY])
inv.unitprice = self.parse_decimal(cols[self.COL_UNITPRICE])
inv.unitvalue = self.parse_decimal(cols[self.COL_UNITVALUE])
inv.quantity = self.parse_decimal(cols[self.COL_QUANTITY], True)
inv.unitprice = self.parse_decimal(cols[self.COL_UNITPRICE], False)
inv.unitvalue = self.parse_decimal(cols[self.COL_UNITVALUE], False)
inv.vdate = Date(CleanText(cols[self.COL_DATE], default=NotAvailable), dayfirst=True, default=NotAvailable)(self.doc)
inv.valuation = self.parse_decimal(cols[self.COL_VALUATION])
inv.diff = self.parse_decimal(cols[self.COL_PERF])
diff_percent = self.parse_decimal(cols[self.COL_PERF_PERCENT])
inv.valuation = self.parse_decimal(cols[self.COL_VALUATION], False)
inv.diff = self.parse_decimal(cols[self.COL_PERF], True)
diff_percent = self.parse_decimal(cols[self.COL_PERF_PERCENT], True)
inv.diff_ratio = diff_percent / 100 if diff_percent else NotAvailable
if is_isin_valid(inv.code):
code = re.match('^[A-Z]+[0-9]+(.*)$', inv.id).group(1)
if is_isin_valid(code):
inv.code = CleanText().filter(code)
inv.code_type = Investment.CODE_TYPE_ISIN
else:
inv.code = inv.code_type = NotAvailable
yield inv
def parse_decimal(self, string):
def parse_decimal(self, string, replace_dots):
string = CleanText(None).filter(string)
if string == '-' or string == '*':
if string in ('-', '*'):
return NotAvailable
return CleanDecimal(None, replace_dots=True).filter(string)
# Decimal separators can be ',' or '.' depending on the column
if replace_dots:
return CleanDecimal.French().filter(string)
return CleanDecimal.SI().filter(string)
def select_period(self):
assert isinstance(self.browser.page, type(self))
......@@ -256,7 +262,6 @@ def get_investments(self, account):
return iter([])
def select_period(self):
# form = self.get_form(name='ConsultationHistoriqueOperationsForm')
try:
form = self.get_form(xpath='//form[@name="ConsultationHistoriqueOperationsForm" '
' or @name="form_historique_titres" '
......@@ -512,7 +517,11 @@ def get_list(self):
account.currency = investment_page.get_currency()
elif balance:
account.currency = account.get_currency(balance)
account.balance = CleanDecimal(None, replace_dots=True).filter(balance)
if account.type == Account.TYPE_LIFE_INSURANCE:
# Life Insurance balance uses '.' instead of ','
account.balance = CleanDecimal.SI().filter(balance)
else:
account.balance = CleanDecimal.French().filter(balance)
if account.type in (Account.TYPE_CHECKING, Account.TYPE_SAVINGS):
# Need a token sent by SMS to customers
......
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