fix #3963
This commit is contained in:
parent
51630416fc
commit
a3554dc2b7
|
@ -143,18 +143,16 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop):
|
|||
h = self.summary
|
||||
start_date = h.get('start_date')
|
||||
end_date = h.get('end_date')
|
||||
if start_date is None or end_date is None:
|
||||
self.parent.show_message(_("Nothing to summarize."))
|
||||
return
|
||||
format_amount = lambda x: self.parent.format_amount(x.value) + ' ' + self.parent.base_unit()
|
||||
format_date = lambda x: x.isoformat(' ')[:-3] if x else _("None")
|
||||
d = WindowModalDialog(self, _("Summary"))
|
||||
d.setMinimumSize(600, 150)
|
||||
vbox = QVBoxLayout()
|
||||
grid = QGridLayout()
|
||||
grid.addWidget(QLabel(_("Start")), 0, 0)
|
||||
grid.addWidget(QLabel(start_date.isoformat(' ')), 0, 1)
|
||||
grid.addWidget(QLabel(format_date(start_date)), 0, 1)
|
||||
grid.addWidget(QLabel(_("End")), 1, 0)
|
||||
grid.addWidget(QLabel(end_date.isoformat(' ')), 1, 1)
|
||||
grid.addWidget(QLabel(format_date(end_date)), 1, 1)
|
||||
grid.addWidget(QLabel(_("Initial balance")), 2, 0)
|
||||
grid.addWidget(QLabel(format_amount(h['start_balance'])), 2, 1)
|
||||
grid.addWidget(QLabel(str(h.get('start_fiat_balance'))), 2, 2)
|
||||
|
|
|
@ -520,6 +520,8 @@ class FxThread(ThreadJob):
|
|||
return "%s" % (self.ccy_amount_str(value, True))
|
||||
|
||||
def history_rate(self, d_t):
|
||||
if d_t is None:
|
||||
return Decimal('NaN')
|
||||
rate = self.exchange.historical_rate(self.ccy, d_t)
|
||||
# Frequently there is no rate for today, until tomorrow :)
|
||||
# Use spot quotes in that case
|
||||
|
|
|
@ -1055,8 +1055,8 @@ class Abstract_Wallet(PrintError):
|
|||
start_date = timestamp_to_datetime(from_timestamp)
|
||||
end_date = timestamp_to_datetime(to_timestamp)
|
||||
else:
|
||||
start_date = out[0]['date']
|
||||
end_date = out[-1]['date']
|
||||
start_date = None
|
||||
end_date = None
|
||||
summary = {
|
||||
'start_date': start_date,
|
||||
'end_date': end_date,
|
||||
|
@ -1071,10 +1071,8 @@ class Abstract_Wallet(PrintError):
|
|||
summary['fiat_income'] = Fiat(fiat_income, fx.ccy)
|
||||
summary['fiat_expenditures'] = Fiat(fiat_expenditures, fx.ccy)
|
||||
summary['unrealized_gains'] = Fiat(unrealized, fx.ccy)
|
||||
if start_date:
|
||||
summary['start_fiat_balance'] = Fiat(fx.historical_value(start_balance, start_date), fx.ccy)
|
||||
if end_date:
|
||||
summary['end_fiat_balance'] = Fiat(fx.historical_value(end_balance, end_date), fx.ccy)
|
||||
summary['start_fiat_balance'] = Fiat(fx.historical_value(start_balance, start_date), fx.ccy)
|
||||
summary['end_fiat_balance'] = Fiat(fx.historical_value(end_balance, end_date), fx.ccy)
|
||||
else:
|
||||
summary = {}
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue