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:
def differential(self):
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()
if pretty_print:
if international_system:
pass
else:
strvalue = QLocale().toString(float(value), 'f', 0)
localized_value = QLocale().toString(float(value), 'f', 0)
if units:
return QCoreApplication.translate("QuantitativeZSum",
QuantitativeZSum._REF_STR_) \
.format(strvalue,
self.community.short_currency)
.format(localized_value,
self.community.short_currency if units else "")
else:
return localized_value
def diff_localized(self, pretty_print=False):
return Quantitative(self.amount, self.community, self.app).localized(pretty_print)
\ No newline at end of file
def diff_localized(self, units=False, international_system=False):
return Quantitative(self.amount, self.community, self.app).localized(units, international_system)
\ No newline at end of file
......@@ -36,24 +36,32 @@ class Quantitative():
def differential(self):
return self.value()
def localized(self, pretty_print=False):
def localized(self, units=False, international_system=False):
value = self.value()
if pretty_print:
if international_system:
pass
else:
strvalue = QLocale().toString(float(value), 'f', 0)
localized_value = QLocale().toString(float(value), 'f', 0)
if units:
return QCoreApplication.translate("Quantitative",
Quantitative._REF_STR_) \
.format(strvalue,
self.community.short_currency)
.format(localized_value,
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()
if pretty_print:
if international_system:
pass
else:
strvalue = QLocale().toString(float(value), 'f', 0)
localized_value = QLocale().toString(float(value), 'f', 0)
if units:
return QCoreApplication.translate("Quantitative",
Quantitative._REF_STR_) \
.format(strvalue,
self.community.short_currency)
.format(localized_value,
self.community.short_currency if units else "")
else:
return localized_value
......@@ -39,20 +39,30 @@ class Relative():
def differential(self):
return self.value()
def localized(self, pretty_print=False):
def localized(self, units=False, international_system=False):
value = self.value()
if pretty_print:
if international_system:
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.short_currency)
localized_value = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma'])
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()
if pretty_print:
if international_system:
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.short_currency)
localized_value = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma'])
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:
def differential(self):
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()
if pretty_print:
if international_system:
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)
localized_value = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma'])
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()
if pretty_print:
if international_system:
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)
localized_value = QLocale().toString(float(value), 'f', self.app.preferences['digits_after_comma'])
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):
maximum = self.community.monetary_mass
# if referential type is quantitative...
# display int values
localized_amount = self.account.current_ref(amount, self.community, self.app).localized()
localized_minimum = self.account.current_ref(maximum, self.community, self.app).localized()
localized_maximum = self.account.current_ref(0, 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(0, self.community, self.app).localized(units=True)
localized_maximum = self.account.current_ref(maximum, self.community, self.app).localized(units=True)
# set infos in label
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