diff --git a/src/cutecoin/core/money/__init__.py b/src/cutecoin/core/money/__init__.py index 7f550e496d3ae0cbdda2fdb51b188952db76195e..05a4b506a6ff4f03c503992f6cae11774a6a4ab1 100644 --- a/src/cutecoin/core/money/__init__.py +++ b/src/cutecoin/core/money/__init__.py @@ -1,9 +1,3 @@ -from enum import Enum - -class RefType(Enum): - q = 0 - r = 1 - from .quantitative import Quantitative from .relative import Relative from .quant_zerosum import QuantitativeZSum diff --git a/src/cutecoin/core/money/quant_zerosum.py b/src/cutecoin/core/money/quant_zerosum.py index e71f5e908a9d20eba32f3b555c38d5c6151c6cd0..340c350a35fceb8ea52f5586a10a298b423db8b8 100644 --- a/src/cutecoin/core/money/quant_zerosum.py +++ b/src/cutecoin/core/money/quant_zerosum.py @@ -1,4 +1,4 @@ -from PyQt5.QtCore import QCoreApplication, QT_TRANSLATE_NOOP +from PyQt5.QtCore import QCoreApplication, QT_TRANSLATE_NOOP, QLocale from . import Quantitative @@ -24,7 +24,7 @@ class QuantitativeZSum: def diff_units(cls, currency): return QuantitativeZSum.units(currency) - def compute(self): + def value(self): """ Return quantitative value of amount minus the average value @@ -43,8 +43,15 @@ class QuantitativeZSum: return Quantitative(self.amount, self.community, self.app).compute() def localized(self, pretty_print=False): - value = self.compute() - return QCoreApplication.translate("Quantitative", Quantitative._REF_STR_).format(value, self.community.currency) + value = self.value() + if pretty_print: + pass + else: + strvalue = QLocale().toString(float(value), 'f', 0) + return QCoreApplication.translate("QuantitativeZSum", + QuantitativeZSum._REF_STR_) \ + .format(strvalue, + self.community.short_currency) def diff_localized(self, pretty_print=False): - return Quantitative(self.amount, self.community, self.app).amount_to_str(pretty_print) \ No newline at end of file + return Quantitative(self.amount, self.community, self.app).localized(pretty_print) \ No newline at end of file diff --git a/src/cutecoin/core/money/quantitative.py b/src/cutecoin/core/money/quantitative.py index c104b4ba71393792500f9dc243e5a4ec3e79011c..aae9074975bc8bdfb3eaca9ccb0ed897abd2e563 100644 --- a/src/cutecoin/core/money/quantitative.py +++ b/src/cutecoin/core/money/quantitative.py @@ -1,7 +1,7 @@ from PyQt5.QtCore import QCoreApplication, QT_TRANSLATE_NOOP, QObject, QLocale -class Quantitative(QObject): +class Quantitative(): _NAME_STR_ = QT_TRANSLATE_NOOP('Quantitative', 'Units') _REF_STR_ = QT_TRANSLATE_NOOP('Quantitative', "{0} {1}") _UNITS_STR_ = QT_TRANSLATE_NOOP('Quantitative', "{0}") @@ -13,7 +13,7 @@ class Quantitative(QObject): @classmethod def translated_name(cls): - return QCoreApplication.translate('Quantitative', 'UD') + return QCoreApplication.translate('Quantitative', Quantitative._NAME_STR_) @classmethod def units(cls, currency): @@ -23,7 +23,7 @@ class Quantitative(QObject): def diff_units(cls, currency): return Quantitative.units(currency) - def compute(self): + def value(self): """ Return quantitative value of amount @@ -34,11 +34,26 @@ class Quantitative(QObject): return int(self.amount) def differential(self): - return self.compute() + return self.value() def localized(self, pretty_print=False): - return QCoreApplication.translate("Quantitative", Quantitative._REF_STR_).format(self.amount, self.currency) + value = self.value() + if pretty_print: + pass + else: + strvalue = QLocale().toString(float(value), 'f', 0) + return QCoreApplication.translate("Quantitative", + Quantitative._REF_STR_) \ + .format(strvalue, + self.community.short_currency) def diff_localized(self, pretty_print=False): - strvalue = QLocale().toString(float(self.amount), 'f', 0) - return QCoreApplication.translate("Quantitative", Quantitative._REF_STR_).format(strvalue, self.currency) + value = self.differential() + if pretty_print: + pass + else: + strvalue = QLocale().toString(float(value), 'f', 0) + return QCoreApplication.translate("Quantitative", + Quantitative._REF_STR_) \ + .format(strvalue, + self.community.short_currency) diff --git a/src/cutecoin/core/money/relative.py b/src/cutecoin/core/money/relative.py index 1b184b172bf214a7ec0844624083873b3fce1132..bcc29ffe8b84d306f20a3bdca6fc75a4b63aa97e 100644 --- a/src/cutecoin/core/money/relative.py +++ b/src/cutecoin/core/money/relative.py @@ -1,7 +1,7 @@ from PyQt5.QtCore import QObject, QCoreApplication, QT_TRANSLATE_NOOP, QLocale -class Relative(QObject): +class Relative(): _NAME_STR_ = QT_TRANSLATE_NOOP('Relative', 'UD') _REF_STR_ = QT_TRANSLATE_NOOP('Relative', "{0} UD {1}") _UNITS_STR_ = QT_TRANSLATE_NOOP('Relative', "UD {0}") @@ -23,7 +23,7 @@ class Relative(QObject): def diff_units(self, currency): return self.units(currency) - def compute(self): + def value(self): """ Return relaive value of amount type @@ -37,16 +37,16 @@ class Relative(QObject): return 0 def differential(self): - return self.compute() + return self.value() def localized(self, pretty_print=False): - value = self.compute() + value = self.value() if pretty_print: pass else: strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) return QCoreApplication.translate("Relative", Relative._REF_STR_).format(strvalue, - self.community.currency) + self.community.short_currency) def diff_localized(self, pretty_print=False): value = self.differential() @@ -55,4 +55,4 @@ class Relative(QObject): else: strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) return QCoreApplication.translate("Relative", Relative._REF_STR_).format(strvalue, - self.community.currency) + self.community.short_currency) diff --git a/src/cutecoin/core/money/relative_zerosum.py b/src/cutecoin/core/money/relative_zerosum.py index 7487ef54a319b3398d8c0fce60dddd419df36752..b414830430c531f612ba4db2bb33060ef07c7683 100644 --- a/src/cutecoin/core/money/relative_zerosum.py +++ b/src/cutecoin/core/money/relative_zerosum.py @@ -1,5 +1,5 @@ -from PyQt5.QtCore import QCoreApplication, QT_TRANSLATE_NOOP -from . import relative +from PyQt5.QtCore import QCoreApplication, QT_TRANSLATE_NOOP, QLocale +from .relative import Relative class RelativeZSum: @@ -42,11 +42,22 @@ class RelativeZSum: return relative_value - relative_median def differential(self): - return relative.compute(self.amount, self.community) + return Relative(self.amount, self.community, self.app).value() def localized(self, pretty_print=False): - value = self.compute(self.amount, self.community) - return QCoreApplication.translate("RelativeZSum", RelativeZSum._REF_STR_).format(value, self.community) + value = self.value() + if pretty_print: + pass + else: + strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) + return QCoreApplication.translate("RelativeZSum", RelativeZSum._REF_STR_).format(strvalue, + self.community.short_currency) def diff_localized(self, pretty_print=False): - return relative.amount_to_str(self.amount, self.community, pretty_print) \ No newline at end of file + value = self.differential() + if pretty_print: + pass + else: + strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) + return QCoreApplication.translate("RelativeZSum", RelativeZSum._REF_STR_).format(strvalue, + self.community.short_currency) diff --git a/src/cutecoin/gui/wallets_tab.py b/src/cutecoin/gui/wallets_tab.py index 77a12f9d07d5126596c8d6e5f3e8e1c4c16e61dd..06fae7b645d43f4b4cfa7349e9bda5618ab862e8 100644 --- a/src/cutecoin/gui/wallets_tab.py +++ b/src/cutecoin/gui/wallets_tab.py @@ -147,18 +147,16 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab): # set infos in label self.label_balance.setText( - self.tr("{:} {:}") + self.tr("{:}") .format( - localized_amount, - self.account.current_ref.units(self.community.currency) + localized_amount ) ) self.label_balance_range.setText( - self.tr("in [{:} ; {:}] {:}") + self.tr("in [{:} ; {:}]") .format( localized_minimum, - localized_maximum, - self.account.current_ref.units(self.community.currency) + localized_maximum ) )