Commit 08d8f23e authored by ntome's avatar ntome Committed by ntome

modules: replace diff_percent field usage with diff_ratio

The name "diff_percent" was always wrong because we never put a
percentage in this field. It's been made an alias to the diff_ratio
field. Make modules use the proper field.
parent 75e4493b
......@@ -515,7 +515,7 @@ class LifeInsuranceIframe(LoggedPage, HTMLPage):
obj_code = Regexp(CleanText(TableCell('code')), r'(.{12})', default=NotAvailable)
obj_code_type = lambda self: Investment.CODE_TYPE_ISIN if Field('code')(self) is not NotAvailable else NotAvailable
def obj_diff_percent(self):
def obj_diff_ratio(self):
diff_percent = MyDecimal(TableCell('diff')(self)[0])(self)
return diff_percent/100 if diff_percent != NotAvailable else diff_percent
......
......@@ -217,7 +217,7 @@ class InvestmentPage(LoggedPage, JsonPage):
obj_unitprice = Env('unitprice', default=NotAvailable)
obj_valuation = MyDecimal(Dict('ValueInEuro'))
obj_diff = MyDecimal(Dict('ResultValueInEuro'))
obj_diff_percent = Eval(lambda x: x / 100, MyDecimal(Dict('ResultPercentageInEuro')))
obj_diff_ratio = Eval(lambda x: x / 100, MyDecimal(Dict('ResultPercentageInEuro')))
obj_original_currency = Env('o_currency', default=NotAvailable)
obj_original_unitvalue = Env('o_unitvalue', default=NotAvailable)
obj_original_unitprice = Env('o_unitprice', default=NotAvailable)
......
......@@ -1169,7 +1169,7 @@ class LifeInsuranceInvestments(LoggedPage, JsonPage):
return Eval(float_to_decimal, Dict('montantPlusValue/valeur'))(self)
return NotAvailable
def obj_diff_percent(self):
def obj_diff_ratio(self):
if Dict('tauxPlusValue')(self):
return Eval(lambda x: float_to_decimal(x) / 100, Dict('tauxPlusValue'))(self)
return NotAvailable
......
......@@ -833,7 +833,7 @@ class BGPIInvestmentPage(LoggedPage, HTMLPage):
CleanDecimal.French('.//span[@class="box"][span[span[text()="Répartition"]]]/span[2]/span')
)
def obj_diff_percent(self):
def obj_diff_ratio(self):
# Euro funds have '-' instead of a diff_percent value
if CleanText('.//span[@class="box"][span[span[text()="+/- value latente (%)"]]]/span[2]/span')(self) == '-':
return NotAvailable
......
......@@ -180,7 +180,7 @@ class InvestmentHistoryPage(LoggedPage, HTMLPage):
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.diff_percent = diff_percent / 100 if diff_percent else NotAvailable
inv.diff_ratio = diff_percent / 100 if diff_percent else NotAvailable
if is_isin_valid(inv.code):
inv.code_type = Investment.CODE_TYPE_ISIN
......
......@@ -385,7 +385,7 @@ class RetrieveInvestmentsPage(LoggedPage, JsonPage):
obj_valuation = CleanDecimal(Dict(
'holdingDetailInformation/0/holdingDetailMultipleCurrencyInformation/0/productHoldingMarketValueAmount'
), default=NotAvailable)
obj_diff_percent = CleanDecimal(Dict(
obj_diff_ratio = CleanDecimal(Dict(
'holdingDetailInformation/0/holdingDetailMultipleCurrencyInformation/0'
'/profitLossUnrealizedPercent'
), default=NotAvailable)
......@@ -443,7 +443,7 @@ class RetrieveInvestmentsPage(LoggedPage, JsonPage):
obj_unitprice = CleanDecimal(Dict(
'holdingSummaryMultipleCurrencyInformation/0/productHoldingUnitCostAverageAmount'
),default=NotAvailable)
obj_diff_percent = CleanDecimal(Dict(
obj_diff_ratio = CleanDecimal(Dict(
'holdingSummaryMultipleCurrencyInformation/0/profitLossUnrealizedPercent'
), default=NotAvailable)
obj_diff = CleanDecimal(Dict(
......@@ -546,7 +546,7 @@ class ScpiInvestmentPage(LoggedPage, HTMLPage):
obj_unitprice = CleanDecimal(TableCell('unitprice'), replace_dots=True)
obj_unitvalue = CleanDecimal(TableCell('unitvalue'), replace_dots=True)
def obj_diff_percent(self):
def obj_diff_ratio(self):
diff_percent = CleanDecimal(
Regexp(CleanText(TableCell('diff_percent')), r'\d+,\d+'),
replace_dots=True
......
......@@ -400,7 +400,7 @@ class ASVInvest(LoggedPage, HTMLPage):
else:
return NotAvailable
def obj_diff_percent(self):
def obj_diff_ratio(self):
diff = CleanDecimal(TableCell('diff_percent'), replace_dots=True, default=NotAvailable)(self)
if not diff:
return diff
......
......@@ -84,10 +84,10 @@ class PortfolioPage(LoggedPage, JsonPage):
return CleanDecimal(Dict('pam'))(self)
return NotAvailable
def obj_diff_percent(self):
def obj_diff_ratio(self):
if not Env('sign')(self):
return NotAvailable
# obj_diff_percent key can have several names:
# obj_diff_ratio key can have several names:
if Dict('plvPourcentage', default=None)(self):
return CleanDecimal(Dict('plvPourcentage'), sign=lambda x: Env('sign')(self))(self)
elif Dict('pourcentagePlv', default=None)(self):
......
......@@ -216,10 +216,10 @@ class DetailsPage(LoggedPage, HTMLPage):
class item(ItemInvestment):
obj_diff = MyDecimal(TableCell('diff'), default=NotAvailable)
obj_diff_percent = Eval(lambda x: x/100, MyDecimal(TableCell('diff_percent')))
obj_diff_ratio = Eval(lambda x: x/100, MyDecimal(TableCell('diff_percent')))
obj_unitprice = MyDecimal(TableCell('unitprice'))
def obj_diff_percent(self):
def obj_diff_ratio(self):
diff_percent = MyDecimal(TableCell('diff_percent'))(self)
if diff_percent:
return diff_percent / 100
......
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