|
|
@ -39,6 +39,7 @@ from PyQt5.QtWidgets import (QMenu, QHeaderView, QLabel, QMessageBox, |
|
|
|
QPushButton, QComboBox, QVBoxLayout, QCalendarWidget, |
|
|
|
QGridLayout) |
|
|
|
|
|
|
|
from electrum.gui import messages |
|
|
|
from electrum.address_synchronizer import TX_HEIGHT_LOCAL, TX_HEIGHT_FUTURE |
|
|
|
from electrum.i18n import _ |
|
|
|
from electrum.util import (block_explorer_URL, profiler, TxMinedInfo, |
|
|
@ -49,7 +50,7 @@ from electrum.logging import get_logger, Logger |
|
|
|
from .custom_model import CustomNode, CustomModel |
|
|
|
from .util import (read_QIcon, MONOSPACE_FONT, Buttons, CancelButton, OkButton, |
|
|
|
filename_field, MyTreeView, AcceptFileDragDrop, WindowModalDialog, |
|
|
|
CloseButton, webopen) |
|
|
|
CloseButton, webopen, WWLabel) |
|
|
|
|
|
|
|
if TYPE_CHECKING: |
|
|
|
from electrum.wallet import Abstract_Wallet |
|
|
@ -547,40 +548,72 @@ class HistoryList(MyTreeView, AcceptFileDragDrop): |
|
|
|
return datetime.datetime(date.year, date.month, date.day) |
|
|
|
|
|
|
|
def show_summary(self): |
|
|
|
h = self.parent.wallet.get_detailed_history()['summary'] |
|
|
|
if not h: |
|
|
|
fx = self.parent.fx |
|
|
|
show_fiat = fx and fx.is_enabled() and fx.get_history_config() |
|
|
|
if not show_fiat: |
|
|
|
self.parent.show_message(_("Enable fiat exchange rate with history.")) |
|
|
|
return |
|
|
|
h = self.wallet.get_detailed_history(fx=fx) |
|
|
|
summary = h['summary'] |
|
|
|
if not summary: |
|
|
|
self.parent.show_message(_("Nothing to summarize.")) |
|
|
|
return |
|
|
|
start_date = h.get('start_date') |
|
|
|
end_date = h.get('end_date') |
|
|
|
start = summary['begin'] |
|
|
|
end = summary['end'] |
|
|
|
flow = summary['flow'] |
|
|
|
start_date = start.get('date') |
|
|
|
end_date = end.get('date') |
|
|
|
format_amount = lambda x: self.parent.format_amount(x.value) + ' ' + self.parent.base_unit() |
|
|
|
format_fiat = lambda x: str(x) + ' ' + self.parent.fx.ccy |
|
|
|
|
|
|
|
d = WindowModalDialog(self, _("Summary")) |
|
|
|
d.setMinimumSize(600, 150) |
|
|
|
vbox = QVBoxLayout() |
|
|
|
msg = messages.to_rtf(messages.MSG_CAPITAL_GAINS) |
|
|
|
vbox.addWidget(WWLabel(msg)) |
|
|
|
grid = QGridLayout() |
|
|
|
grid.addWidget(QLabel(_("Start")), 0, 0) |
|
|
|
grid.addWidget(QLabel(self.format_date(start_date)), 0, 1) |
|
|
|
grid.addWidget(QLabel(str(h.get('fiat_start_value')) + '/BTC'), 0, 2) |
|
|
|
grid.addWidget(QLabel(_("Initial balance")), 1, 0) |
|
|
|
grid.addWidget(QLabel(format_amount(h['start_balance'])), 1, 1) |
|
|
|
grid.addWidget(QLabel(str(h.get('fiat_start_balance'))), 1, 2) |
|
|
|
grid.addWidget(QLabel(_("End")), 2, 0) |
|
|
|
grid.addWidget(QLabel(self.format_date(end_date)), 2, 1) |
|
|
|
grid.addWidget(QLabel(str(h.get('fiat_end_value')) + '/BTC'), 2, 2) |
|
|
|
grid.addWidget(QLabel(_("Final balance")), 4, 0) |
|
|
|
grid.addWidget(QLabel(format_amount(h['end_balance'])), 4, 1) |
|
|
|
grid.addWidget(QLabel(str(h.get('fiat_end_balance'))), 4, 2) |
|
|
|
grid.addWidget(QLabel(_("Income")), 5, 0) |
|
|
|
grid.addWidget(QLabel(format_amount(h.get('incoming'))), 5, 1) |
|
|
|
grid.addWidget(QLabel(str(h.get('fiat_incoming'))), 5, 2) |
|
|
|
grid.addWidget(QLabel(_("Expenditures")), 6, 0) |
|
|
|
grid.addWidget(QLabel(format_amount(h.get('outgoing'))), 6, 1) |
|
|
|
grid.addWidget(QLabel(str(h.get('fiat_outgoing'))), 6, 2) |
|
|
|
grid.addWidget(QLabel(_("Capital gains")), 7, 0) |
|
|
|
grid.addWidget(QLabel(str(h.get('fiat_capital_gains'))), 7, 2) |
|
|
|
grid.addWidget(QLabel(_("Unrealized gains")), 8, 0) |
|
|
|
grid.addWidget(QLabel(str(h.get('fiat_unrealized_gains', ''))), 8, 2) |
|
|
|
grid.addWidget(QLabel(_("Begin")), 0, 1) |
|
|
|
grid.addWidget(QLabel(_("End")), 0, 2) |
|
|
|
# |
|
|
|
grid.addWidget(QLabel(_("Date")), 1, 0) |
|
|
|
grid.addWidget(QLabel(self.format_date(start_date)), 1, 1) |
|
|
|
grid.addWidget(QLabel(self.format_date(end_date)), 1, 2) |
|
|
|
# |
|
|
|
grid.addWidget(QLabel(_("BTC balance")), 2, 0) |
|
|
|
grid.addWidget(QLabel(format_amount(start['BTC_balance'])), 2, 1) |
|
|
|
grid.addWidget(QLabel(format_amount(end['BTC_balance'])), 2, 2) |
|
|
|
# |
|
|
|
grid.addWidget(QLabel(_("BTC Fiat price")), 3, 0) |
|
|
|
grid.addWidget(QLabel(format_fiat(start.get('BTC_fiat_price'))), 3, 1) |
|
|
|
grid.addWidget(QLabel(format_fiat(end.get('BTC_fiat_price'))), 3, 2) |
|
|
|
# |
|
|
|
grid.addWidget(QLabel(_("Fiat balance")), 4, 0) |
|
|
|
grid.addWidget(QLabel(format_fiat(start.get('fiat_balance'))), 4, 1) |
|
|
|
grid.addWidget(QLabel(format_fiat(end.get('fiat_balance'))), 4, 2) |
|
|
|
# |
|
|
|
grid.addWidget(QLabel(_("Acquisition price")), 5, 0) |
|
|
|
grid.addWidget(QLabel(format_fiat(start.get('acquisition_price', ''))), 5, 1) |
|
|
|
grid.addWidget(QLabel(format_fiat(end.get('acquisition_price', ''))), 5, 2) |
|
|
|
# |
|
|
|
grid.addWidget(QLabel(_("Unrealized capital gains")), 6, 0) |
|
|
|
grid.addWidget(QLabel(format_fiat(start.get('unrealized_gains', ''))), 6, 1) |
|
|
|
grid.addWidget(QLabel(format_fiat(end.get('unrealized_gains', ''))), 6, 2) |
|
|
|
# |
|
|
|
grid2 = QGridLayout() |
|
|
|
grid2.addWidget(QLabel(_("BTC incoming")), 0, 0) |
|
|
|
grid2.addWidget(QLabel(format_amount(flow['BTC_incoming'])), 0, 1) |
|
|
|
grid2.addWidget(QLabel(_("Fiat incoming")), 1, 0) |
|
|
|
grid2.addWidget(QLabel(format_fiat(flow.get('fiat_incoming'))), 1, 1) |
|
|
|
grid2.addWidget(QLabel(_("BTC outgoing")), 2, 0) |
|
|
|
grid2.addWidget(QLabel(format_amount(flow['BTC_outgoing'])), 2, 1) |
|
|
|
grid2.addWidget(QLabel(_("Fiat outgoing")), 3, 0) |
|
|
|
grid2.addWidget(QLabel(format_fiat(flow.get('fiat_outgoing'))), 3, 1) |
|
|
|
# |
|
|
|
grid2.addWidget(QLabel(_("Realized capital gains")), 4, 0) |
|
|
|
grid2.addWidget(QLabel(format_fiat(flow.get('realized_capital_gains'))), 4, 1) |
|
|
|
vbox.addLayout(grid) |
|
|
|
vbox.addWidget(QLabel(_('Cash flow'))) |
|
|
|
vbox.addLayout(grid2) |
|
|
|
vbox.addLayout(Buttons(CloseButton(d))) |
|
|
|
d.setLayout(vbox) |
|
|
|
d.exec_() |
|
|
|