Skip to content
Snippets Groups Projects
Commit 1d88659f authored by inso's avatar inso
Browse files

Fix some bugs with referentials and enhancements

parent 8e852220
No related branches found
No related tags found
No related merge requests found
...@@ -42,16 +42,20 @@ class QuantitativeZSum: ...@@ -42,16 +42,20 @@ class QuantitativeZSum:
def differential(self): def differential(self):
return Quantitative(self.amount, self.community, self.app).compute() return Quantitative(self.amount, self.community, self.app).compute()
def localized(self, pretty_print=False): def localized(self, units=False, international_system=False):
value = self.value() value = self.value()
if pretty_print: if international_system:
pass pass
else: else:
strvalue = QLocale().toString(float(value), 'f', 0) localized_value = QLocale().toString(float(value), 'f', 0)
if units:
return QCoreApplication.translate("QuantitativeZSum", return QCoreApplication.translate("QuantitativeZSum",
QuantitativeZSum._REF_STR_) \ QuantitativeZSum._REF_STR_) \
.format(strvalue, .format(localized_value,
self.community.short_currency) self.community.short_currency if units else "")
else:
return localized_value
def diff_localized(self, pretty_print=False): def diff_localized(self, units=False, international_system=False):
return Quantitative(self.amount, self.community, self.app).localized(pretty_print) return Quantitative(self.amount, self.community, self.app).localized(units, international_system)
\ No newline at end of file \ No newline at end of file
...@@ -36,24 +36,32 @@ class Quantitative(): ...@@ -36,24 +36,32 @@ class Quantitative():
def differential(self): def differential(self):
return self.value() return self.value()
def localized(self, pretty_print=False): def localized(self, units=False, international_system=False):
value = self.value() value = self.value()
if pretty_print: if international_system:
pass pass
else: else:
strvalue = QLocale().toString(float(value), 'f', 0) localized_value = QLocale().toString(float(value), 'f', 0)
if units:
return QCoreApplication.translate("Quantitative", return QCoreApplication.translate("Quantitative",
Quantitative._REF_STR_) \ Quantitative._REF_STR_) \
.format(strvalue, .format(localized_value,
self.community.short_currency) self.community.short_currency if units else "")
else:
return localized_value
def diff_localized(self, pretty_print=False): def diff_localized(self, units=False, international_system=False):
value = self.differential() value = self.differential()
if pretty_print: if international_system:
pass pass
else: else:
strvalue = QLocale().toString(float(value), 'f', 0) localized_value = QLocale().toString(float(value), 'f', 0)
if units:
return QCoreApplication.translate("Quantitative", return QCoreApplication.translate("Quantitative",
Quantitative._REF_STR_) \ Quantitative._REF_STR_) \
.format(strvalue, .format(localized_value,
self.community.short_currency) self.community.short_currency if units else "")
else:
return localized_value
...@@ -39,20 +39,30 @@ class Relative(): ...@@ -39,20 +39,30 @@ class Relative():
def differential(self): def differential(self):
return self.value() return self.value()
def localized(self, pretty_print=False): def localized(self, units=False, international_system=False):
value = self.value() value = self.value()
if pretty_print: if international_system:
pass pass
else: else:
strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) localized_value = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma'])
return QCoreApplication.translate("Relative", Relative._REF_STR_).format(strvalue,
self.community.short_currency)
def diff_localized(self, pretty_print=False): if units:
return QCoreApplication.translate("Relative", Relative._REF_STR_) \
.format(localized_value,
self.community.short_currency if units else "")
else:
return localized_value
def diff_localized(self, units=False, international_system=False):
value = self.differential() value = self.differential()
if pretty_print: if international_system:
pass pass
else: else:
strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) localized_value = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma'])
return QCoreApplication.translate("Relative", Relative._REF_STR_).format(strvalue,
self.community.short_currency) if units:
return QCoreApplication.translate("Relative", Relative._REF_STR_)\
.format(localized_value,
self.community.short_currency if units else "")
else:
return localized_value
...@@ -44,20 +44,30 @@ class RelativeZSum: ...@@ -44,20 +44,30 @@ class RelativeZSum:
def differential(self): def differential(self):
return Relative(self.amount, self.community, self.app).value() return Relative(self.amount, self.community, self.app).value()
def localized(self, pretty_print=False): def localized(self, units=False, international_system=False):
value = self.value() value = self.value()
if pretty_print: if international_system:
pass pass
else: else:
strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) localized_value = 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): if units:
return QCoreApplication.translate("RelativeZSum", RelativeZSum._REF_STR_)\
.format(localized_value,
self.community.short_currency if units else "")
else:
return localized_value
def diff_localized(self, units=False, international_system=False):
value = self.differential() value = self.differential()
if pretty_print:
if international_system:
pass pass
else: else:
strvalue = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma']) localized_value = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma'])
return QCoreApplication.translate("RelativeZSum", RelativeZSum._REF_STR_).format(strvalue,
self.community.short_currency) if units:
return QCoreApplication.translate("RelativeZSum", RelativeZSum._REF_STR_)\
.format(localized_value, self.community.short_currency if units else "")
else:
return localized_value
...@@ -141,9 +141,9 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab): ...@@ -141,9 +141,9 @@ class WalletsTabWidget(QWidget, Ui_WalletsTab):
maximum = self.community.monetary_mass maximum = self.community.monetary_mass
# if referential type is quantitative... # if referential type is quantitative...
# display int values # display int values
localized_amount = self.account.current_ref(amount, self.community, self.app).localized() localized_amount = self.account.current_ref(amount, self.community, self.app).localized(units=True)
localized_minimum = self.account.current_ref(maximum, self.community, self.app).localized() localized_minimum = self.account.current_ref(0, self.community, self.app).localized(units=True)
localized_maximum = self.account.current_ref(0, self.community, self.app).localized() localized_maximum = self.account.current_ref(maximum, self.community, self.app).localized(units=True)
# set infos in label # set infos in label
self.label_balance.setText( self.label_balance.setText(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment