From 2c3d462d5b93f59e6dfacac114b8aeed7b4d27db Mon Sep 17 00:00:00 2001 From: Vincent Ardisson Date: Wed, 17 Oct 2018 19:06:41 +0200 Subject: [PATCH] weboob.capabilities.bank: rename diff_percent and keep a compat alias diff_percent was a misleading name because the ratio was expressed on 1, not on 100, thus it wasn't a percentage. For reference to suckers: a percentage is a ratio multiplied by 100. We create a temporary alias so apps using the old field have compatibility. "diff_percent" will soon be removed. --- weboob/capabilities/bank.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/weboob/capabilities/bank.py b/weboob/capabilities/bank.py index 8217283e86..83e5fa701c 100644 --- a/weboob/capabilities/bank.py +++ b/weboob/capabilities/bank.py @@ -297,7 +297,7 @@ class Account(BaseAccount): number = StringField('Shown by the bank to identify your account ie XXXXX7489') # market and lifeinssurance accounts valuation_diff = DecimalField('+/- values total') - valuation_diff_percent = DecimalField('+/- values ratio') + valuation_diff_ratio = DecimalField('+/- values ratio') # parent account # - A checking account parent of a card account @@ -311,6 +311,15 @@ class Account(BaseAccount): def __repr__(self): return "<%s id=%r label=%r>" % (type(self).__name__, self.id, self.label) + # compatibility alias + @property + def valuation_diff_percent(self): + return self.valuation_diff_ratio + + @valuation_diff_percent.setter + def valuation_diff_percent(self, value): + self.valuation_diff_ratio = value + class Loan(Account): """ @@ -450,7 +459,7 @@ class Investment(BaseObject): valuation = DecimalField('Total current valuation of the Investment') vdate = DateField('Value date of the valuation amount') diff = DecimalField('Difference between the buy cost and the current valuation') - diff_percent = DecimalField('Difference in ratio (1 meaning 100%) between the buy cost and the current valuation') + diff_ratio = DecimalField('Difference in ratio (1 meaning 100%) between the buy cost and the current valuation') portfolio_share = DecimalField('Ratio (1 meaning 100%) of the current amount relative to the total') # International @@ -463,6 +472,15 @@ class Investment(BaseObject): def __repr__(self): return '' % (self.label, self.code, self.valuation) + # compatibility alias + @property + def diff_percent(self): + return self.diff_ratio + + @diff_percent.setter + def diff_percent(self, value): + self.diff_ratio = value + class PocketCondition(Enum): UNKNOWN = 0 -- GitLab