From d54e07e81412b73f7254df7de560e17d6aac6358 Mon Sep 17 00:00:00 2001
From: Vincent Texier <vit@free.fr>
Date: Sun, 31 Jan 2016 10:29:34 +0100
Subject: [PATCH] refs #335 Fix broken referentials after merge and add
 informations about "Past UD"

---
 src/sakia/core/money/quant_zerosum.py    |  8 ++++----
 src/sakia/core/money/quantitative.py     |  8 ++++----
 src/sakia/core/money/relative.py         |  8 ++++----
 src/sakia/core/money/relative_to_past.py | 24 ++++++++++++++++++++++++
 src/sakia/core/money/relative_zerosum.py |  8 ++++----
 src/sakia/gui/informations_tab.py        | 12 ++++++++----
 6 files changed, 48 insertions(+), 20 deletions(-)

diff --git a/src/sakia/core/money/quant_zerosum.py b/src/sakia/core/money/quant_zerosum.py
index c77a009a..e023c4c2 100644
--- a/src/sakia/core/money/quant_zerosum.py
+++ b/src/sakia/core/money/quant_zerosum.py
@@ -37,12 +37,12 @@ class QuantitativeZSum(BaseReferential):
     def units(self):
         return QCoreApplication.translate("QuantitativeZSum", QuantitativeZSum._UNITS_STR_).format(self.community.short_currency)
 
-    @classmethod
-    def formula(cls):
+    @property
+    def formula(self):
         return QCoreApplication.translate('QuantitativeZSum', QuantitativeZSum._FORMULA_STR_)
 
-    @classmethod
-    def description(cls):
+    @property
+    def description(self):
         return QCoreApplication.translate("QuantitativeZSum", QuantitativeZSum._DESCRIPTION_STR_)
 
     @property
diff --git a/src/sakia/core/money/quantitative.py b/src/sakia/core/money/quantitative.py
index ac6cfcb8..55434344 100644
--- a/src/sakia/core/money/quantitative.py
+++ b/src/sakia/core/money/quantitative.py
@@ -27,12 +27,12 @@ class Quantitative(BaseReferential):
     def units(self):
         return QCoreApplication.translate("Quantitative", Quantitative._UNITS_STR_).format(self.community.short_currency)
 
-    @classmethod
-    def formula(cls):
+    @property
+    def formula(self):
         return QCoreApplication.translate('Quantitative', Quantitative._FORMULA_STR_)
 
-    @classmethod
-    def description(cls):
+    @property
+    def description(self):
         return QCoreApplication.translate("Quantitative", Quantitative._DESCRIPTION_STR_)
 
     @property
diff --git a/src/sakia/core/money/relative.py b/src/sakia/core/money/relative.py
index 697ec8be..fd651ebc 100644
--- a/src/sakia/core/money/relative.py
+++ b/src/sakia/core/money/relative.py
@@ -38,12 +38,12 @@ class Relative(BaseReferential):
     def units(self):
         return QCoreApplication.translate("Relative", Relative._UNITS_STR_).format(self.community.short_currency)
 
-    @classmethod
-    def formula(cls):
+    @property
+    def formula(self):
         return QCoreApplication.translate('Relative', Relative._FORMULA_STR_)
 
-    @classmethod
-    def description(cls):
+    @property
+    def description(self):
         return QCoreApplication.translate("Relative", Relative._DESCRIPTION_STR_)
 
     @property
diff --git a/src/sakia/core/money/relative_to_past.py b/src/sakia/core/money/relative_to_past.py
index 8fdae53c..daaef168 100644
--- a/src/sakia/core/money/relative_to_past.py
+++ b/src/sakia/core/money/relative_to_past.py
@@ -7,6 +7,23 @@ class RelativeToPast(BaseReferential):
     _NAME_STR_ = QT_TRANSLATE_NOOP('RelativeToPast', 'Past UD')
     _REF_STR_ = QT_TRANSLATE_NOOP('RelativeToPast', "{0} {1}UD({2}) {3}")
     _UNITS_STR_ = QT_TRANSLATE_NOOP('RelativeToPast', "UD({0}) {1}")
+    _FORMULA_STR_ = QT_TRANSLATE_NOOP('RelativeToPast',
+                                      """R = Q / UD(t)
+                                        <br >
+                                        <table>
+                                        <tr><td>R</td><td>Relative value</td></tr>
+                                        <tr><td>Q</td><td>Quantitative value</td></tr>
+                                        <tr><td>UD</td><td>Universal Dividend</td></tr>
+                                        <tr><td>t</td><td>Time when the value appeared</td></tr>
+                                        </table>"""
+                                      )
+    _DESCRIPTION_STR_ = QT_TRANSLATE_NOOP('RelativeToPast',
+                                          """Relative referential using UD at the Time when the value appeared.
+                                          Relative value R is calculated by dividing the quantitative value Q by the
+                                           Universal Dividend UD at the Time when the value appeared.
+                                          All past UD created are displayed with a value of 1 UD.
+                                          This referential is practical to remember what was the value at the Time.
+                                          """.replace('\n', '<br >'))
 
     def __init__(self, amount, community, app, block_number=None):
         super().__init__(amount, community, app, block_number)
@@ -19,6 +36,13 @@ class RelativeToPast(BaseReferential):
     def units(self):
         return QCoreApplication.translate("RelativeToPast", RelativeToPast._UNITS_STR_).format('t',
                                                                                                self.community.short_currency)
+    @property
+    def formula(self):
+        return QCoreApplication.translate('RelativeToPast', RelativeToPast._FORMULA_STR_)
+
+    @property
+    def description(self):
+        return QCoreApplication.translate("RelativeToPast", RelativeToPast._DESCRIPTION_STR_)
 
     @property
     def diff_units(self):
diff --git a/src/sakia/core/money/relative_zerosum.py b/src/sakia/core/money/relative_zerosum.py
index 1495fa29..5837cac2 100644
--- a/src/sakia/core/money/relative_zerosum.py
+++ b/src/sakia/core/money/relative_zerosum.py
@@ -36,12 +36,12 @@ class RelativeZSum(BaseReferential):
     def units(self):
         return QCoreApplication.translate("RelativeZSum", RelativeZSum._UNITS_STR_).format(self.community.short_currency)
 
-    @classmethod
-    def formula(cls):
+    @property
+    def formula(self):
         return QCoreApplication.translate('RelativeZSum', RelativeZSum._FORMULA_STR_)
 
-    @classmethod
-    def description(cls):
+    @property
+    def description(self):
         return QCoreApplication.translate("RelativeZSum", RelativeZSum._DESCRIPTION_STR_)
 
     @property
diff --git a/src/sakia/gui/informations_tab.py b/src/sakia/gui/informations_tab.py
index 46c17eb4..e541aee3 100644
--- a/src/sakia/gui/informations_tab.py
+++ b/src/sakia/gui/informations_tab.py
@@ -206,11 +206,15 @@ class InformationsTabWidget(QWidget, Ui_InformationsTabWidget):
         </table>
         """
         templates = []
-        for ref in Referentials:
+        for ref_class in Referentials:
+            ref = ref_class(0, self.community, self.app, None)
+            # print(ref_class.__class__.__name__)
+            # if ref_class.__class__.__name__ == 'RelativeToPast':
+            #     continue
             templates.append(ref_template.format(self.tr('Name'), ref.translated_name(),
-                                        self.tr('Units'), ref.units(self.community.currency),
-                                        self.tr('Formula'), ref.formula(),
-                                        self.tr('Description'), ref.description()
+                                        self.tr('Units'), ref.units,
+                                        self.tr('Formula'), ref.formula,
+                                        self.tr('Description'), ref.description
                                         )
                              )
 
-- 
GitLab