show expired status in invoices tab
This commit is contained in:
parent
38e7d8ebe5
commit
47c491624e
@ -83,6 +83,8 @@ def format_status(x):
|
|||||||
return _('Unpaid')
|
return _('Unpaid')
|
||||||
elif x == PR_PAID:
|
elif x == PR_PAID:
|
||||||
return _('Paid')
|
return _('Paid')
|
||||||
|
elif x == PR_EXPIRED:
|
||||||
|
return _('Expired')
|
||||||
|
|
||||||
|
|
||||||
class StatusBarButton(QPushButton):
|
class StatusBarButton(QPushButton):
|
||||||
@ -927,7 +929,7 @@ class ElectrumWindow(QMainWindow):
|
|||||||
if not status:
|
if not status:
|
||||||
return False, msg
|
return False, msg
|
||||||
|
|
||||||
self.invoices[pr.get_id()] = (pr.get_domain(), pr.get_memo(), pr.get_amount(), PR_PAID, tx.hash())
|
self.invoices[pr.get_id()] = (pr.get_domain(), pr.get_memo(), pr.get_amount(), pr.get_expiration_date(), PR_PAID, tx.hash())
|
||||||
self.wallet.storage.put('invoices', self.invoices)
|
self.wallet.storage.put('invoices', self.invoices)
|
||||||
self.update_invoices_tab()
|
self.update_invoices_tab()
|
||||||
self.payment_request = None
|
self.payment_request = None
|
||||||
@ -965,7 +967,7 @@ class ElectrumWindow(QMainWindow):
|
|||||||
pr = self.payment_request
|
pr = self.payment_request
|
||||||
pr_id = pr.get_id()
|
pr_id = pr.get_id()
|
||||||
if pr_id not in self.invoices:
|
if pr_id not in self.invoices:
|
||||||
self.invoices[pr_id] = (pr.get_domain(), pr.get_memo(), pr.get_amount(), PR_UNPAID, None)
|
self.invoices[pr_id] = (pr.get_domain(), pr.get_memo(), pr.get_amount(), pr.get_expiration_date(), PR_UNPAID, None)
|
||||||
self.wallet.storage.put('invoices', self.invoices)
|
self.wallet.storage.put('invoices', self.invoices)
|
||||||
self.update_invoices_tab()
|
self.update_invoices_tab()
|
||||||
else:
|
else:
|
||||||
@ -1144,10 +1146,12 @@ class ElectrumWindow(QMainWindow):
|
|||||||
l.clear()
|
l.clear()
|
||||||
for key, value in invoices.items():
|
for key, value in invoices.items():
|
||||||
try:
|
try:
|
||||||
domain, memo, amount, status, tx_hash = value
|
domain, memo, amount, expiration_date, status, tx_hash = value
|
||||||
except:
|
except:
|
||||||
invoices.pop(key)
|
invoices.pop(key)
|
||||||
continue
|
continue
|
||||||
|
if status == PR_UNPAID and expiration_date and expiration_date < time.time():
|
||||||
|
status = PR_EXPIRED
|
||||||
item = QTreeWidgetItem( [ domain, memo, self.format_amount(amount), format_status(status)] )
|
item = QTreeWidgetItem( [ domain, memo, self.format_amount(amount), format_status(status)] )
|
||||||
l.addTopLevelItem(item)
|
l.addTopLevelItem(item)
|
||||||
|
|
||||||
@ -1334,7 +1338,7 @@ class ElectrumWindow(QMainWindow):
|
|||||||
return
|
return
|
||||||
k = self.invoices_list.indexOfTopLevelItem(item)
|
k = self.invoices_list.indexOfTopLevelItem(item)
|
||||||
key = self.invoices.keys()[k]
|
key = self.invoices.keys()[k]
|
||||||
domain, memo, value, status, tx_hash = self.invoices[key]
|
domain, memo, value, expiration, status, tx_hash = self.invoices[key]
|
||||||
menu = QMenu()
|
menu = QMenu()
|
||||||
menu.addAction(_("Details"), lambda: self.show_invoice(key))
|
menu.addAction(_("Details"), lambda: self.show_invoice(key))
|
||||||
if status == PR_UNPAID:
|
if status == PR_UNPAID:
|
||||||
|
|||||||
@ -256,6 +256,9 @@ class PaymentRequest:
|
|||||||
def has_expired(self):
|
def has_expired(self):
|
||||||
return self.details.expires and self.details.expires < int(time.time())
|
return self.details.expires and self.details.expires < int(time.time())
|
||||||
|
|
||||||
|
def get_expiration_date(self):
|
||||||
|
return self.details.expires
|
||||||
|
|
||||||
def get_amount(self):
|
def get_amount(self):
|
||||||
return sum(map(lambda x:x[1], self.outputs))
|
return sum(map(lambda x:x[1], self.outputs))
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user