Skip to content

Commit

Permalink
refs #335 Fix broken referentials after merge and add informations ab…
Browse files Browse the repository at this point in the history
…out "Past UD"
  • Loading branch information
vtexier committed Jan 31, 2016
1 parent b46c02e commit d54e07e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/sakia/core/money/quant_zerosum.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ def translated_name(cls):
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
Expand Down
8 changes: 4 additions & 4 deletions src/sakia/core/money/quantitative.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def translated_name(cls):
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
Expand Down
8 changes: 4 additions & 4 deletions src/sakia/core/money/relative.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def translated_name(cls):
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
Expand Down
24 changes: 24 additions & 0 deletions src/sakia/core/money/relative_to_past.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -19,6 +36,13 @@ def translated_name(cls):
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):
Expand Down
8 changes: 4 additions & 4 deletions src/sakia/core/money/relative_zerosum.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ def translated_name(cls):
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
Expand Down
12 changes: 8 additions & 4 deletions src/sakia/gui/informations_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,15 @@ async def refresh_labels(self):
</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
)
)

Expand Down

0 comments on commit d54e07e

Please sign in to comment.