Commit 133b2574 authored by Vincent Texier's avatar Vincent Texier

[enh] #798 fix bad source amount in transfer view and transaction sent field in db

parent 9b7affb8
......@@ -114,8 +114,7 @@ class TransferController(QObject):
controller.view.label_source_identifier.setText(
"{}:{}".format(source.identifier, source.noffset)
)
amount = source.amount * (10 ** source.base) / 100
controller.view.spinbox_amount.setValue(amount)
controller.set_amount_value(source.amount, source.base)
controller.view.spinbox_amount.setDisabled(True)
controller.view.spinbox_relative.setDisabled(True)
controller.view.button_source_check.setEnabled(True)
......@@ -174,15 +173,8 @@ class TransferController(QObject):
controller.refresh()
current_base = controller.model.current_base()
current_base_amount = resent_transfer.amount / pow(
10, resent_transfer.amount_base - current_base
)
relative = controller.model.quant_to_rel(current_base_amount / 100)
controller.view.set_spinboxes_parameters(current_base_amount / 100, relative)
controller.view.change_relative_amount(relative)
controller.view.change_quantitative_amount(current_base_amount / 100)
# display transaction amount
controller.set_amount_value(resent_transfer.amount, resent_transfer.amount_base)
connections_processor = ConnectionsProcessor.instanciate(app)
wallet_index = connections_processor.connections().index(connection)
......@@ -382,3 +374,19 @@ class TransferController(QObject):
qmessagebox.setWindowTitle("Check source condition")
qmessagebox.setText(message)
qmessagebox.exec()
def set_amount_value(self, amount, base):
"""
Set quantitative and relative amounts from amount and base given
:param int amount: Amount to display
:param int base: Base of the amount given
:return:
"""
# calculate amount for current base
current_base = self.model.current_base()
current_base_amount = amount / pow(10, base - current_base)
# display quantitative and relative amounts
relative = self.model.quant_to_rel(current_base_amount / 100)
self.view.set_spinboxes_parameters(current_base_amount / 100, relative)
self.view.change_relative_amount(relative)
self.view.change_quantitative_amount(current_base_amount / 100)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment