Add dynamic currency display in history
This commit is contained in:
parent
23652b27f8
commit
0cbc429f4c
|
@ -57,6 +57,11 @@ class History:
|
||||||
amount
|
amount
|
||||||
base
|
base
|
||||||
}
|
}
|
||||||
|
node {
|
||||||
|
peer {
|
||||||
|
currency
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
@ -107,11 +112,15 @@ class History:
|
||||||
baseBalance = self.historyDoc['balance']['base']
|
baseBalance = self.historyDoc['balance']['base']
|
||||||
balance = balance*pow(10,baseBalance)/100
|
balance = balance*pow(10,baseBalance)/100
|
||||||
|
|
||||||
|
# Get currency
|
||||||
|
currency = self.historyDoc['node']['peer']['currency']
|
||||||
|
if currency == 'g1': currency = 'Ḡ1'
|
||||||
|
|
||||||
# Get terminal size
|
# Get terminal size
|
||||||
rows = int(os.popen('stty size', 'r').read().split()[1])
|
rows = int(os.popen('stty size', 'r').read().split()[1])
|
||||||
|
|
||||||
print('-'.center(rows, '-'))
|
print('-'.center(rows, '-'))
|
||||||
print("\033[1m{: <20} | {: <45} | {: <7} | {: <30}\033[0m".format(" Date"," De / À (clé publique)","Montant (Ḡ1)","Commentaire"))
|
print("\033[1m{: <20} | {: <45} | {: <7} | {: <30}\033[0m".format(" Date"," De / À (clé publique)","Montant ({0})".format(currency),"Commentaire"))
|
||||||
for t in trans:
|
for t in trans:
|
||||||
if t[0] == "received":
|
if t[0] == "received":
|
||||||
color = "green"
|
color = "green"
|
||||||
|
@ -125,7 +134,7 @@ class History:
|
||||||
print('-'.center(rows, '-'))
|
print('-'.center(rows, '-'))
|
||||||
print(colored("| {: <18} | {: <45} | {: <12} | {: <30}".format(date, *t[2:]), color))
|
print(colored("| {: <18} | {: <45} | {: <12} | {: <30}".format(date, *t[2:]), color))
|
||||||
print('-'.center(rows, '-'))
|
print('-'.center(rows, '-'))
|
||||||
print('\033[1mSolde du compte: {0} Ḡ1\033[0m'.format(balance).center(rows, ' '))
|
print('\033[1mSolde du compte: {0} {1}\033[0m'.format(balance,currency).center(rows, ' '))
|
||||||
print('-'.center(rows, '-'))
|
print('-'.center(rows, '-'))
|
||||||
print(colored('Reçus', 'green'), '-', colored('En cours de réception', 'yellow'), '-', colored('Envoyé', 'blue'), '-', colored("En cours d'envoi", 'red'))
|
print(colored('Reçus', 'green'), '-', colored('En cours de réception', 'yellow'), '-', colored('Envoyé', 'blue'), '-', colored("En cours d'envoi", 'red'))
|
||||||
|
|
||||||
|
|
Reference in New Issue