From 4236adc5529157e641bfb9af8c0bf98d95642ec2 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Wed, 28 Feb 2018 09:50:28 +0100 Subject: [PATCH] fix date filtering --- gui/qt/history_list.py | 12 ++++++------ lib/wallet.py | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gui/qt/history_list.py b/gui/qt/history_list.py index 9edbd61d47a0..c87e92c6d013 100644 --- a/gui/qt/history_list.py +++ b/gui/qt/history_list.py @@ -195,12 +195,12 @@ def on_update(self): r = self.wallet.get_full_history(domain=self.get_domain(), from_timestamp=self.start_timestamp, to_timestamp=self.end_timestamp, fx=fx) self.transactions = r['transactions'] self.summary = r['summary'] - if not self.years and self.start_timestamp is None and self.end_timestamp is None: - start_date = self.summary.get('start_date') - end_date = self.summary.get('end_date') - if start_date and end_date: - self.years = [str(i) for i in range(start_date.year, end_date.year + 1)] - self.period_combo.insertItems(1, self.years) + if not self.years and self.transactions: + from datetime import date + start_date = self.transactions[0].get('date') or date.today() + end_date = self.transactions[-1].get('date') or date.today() + self.years = [str(i) for i in range(start_date.year, end_date.year + 1)] + self.period_combo.insertItems(1, self.years) item = self.currentItem() current_tx = item.data(0, Qt.UserRole) if item else None self.clear() diff --git a/lib/wallet.py b/lib/wallet.py index ed11694d78f7..83533cde7a16 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -990,9 +990,9 @@ def get_full_history(self, domain=None, from_timestamp=None, to_timestamp=None, fiat_expenditures = 0 h = self.get_history(domain) for tx_hash, height, conf, timestamp, value, balance in h: - if from_timestamp and timestamp < from_timestamp: + if from_timestamp and (timestamp or time.time()) < from_timestamp: continue - if to_timestamp and timestamp >= to_timestamp: + if to_timestamp and (timestamp or time.time()) >= to_timestamp: continue item = { 'txid':tx_hash, @@ -1029,7 +1029,7 @@ def get_full_history(self, domain=None, from_timestamp=None, to_timestamp=None, income += value # fiat computations if fx is not None: - date = timestamp_to_datetime(time.time() if conf <= 0 else timestamp) + date = timestamp_to_datetime(timestamp) fiat_value = self.get_fiat_value(tx_hash, fx.ccy) fiat_default = fiat_value is None fiat_value = - fiat_value if fiat_value is not None else value / Decimal(COIN) * self.price_at_timestamp(tx_hash, fx.timestamp_rate)