Små utseendemessige ting.

Transaksjonsbeløpene vises med 'in'/'out' istedenfor fortegn i
ShowUserMenu.
This commit is contained in:
Øystein Ingmar Skartsæterhagen 2010-05-08 21:18:40 +00:00
parent 2de1b2b019
commit 90283a81b5
1 changed files with 7 additions and 4 deletions

View File

@ -186,9 +186,9 @@ class TransferMenu(Menu):
user1 = self.input_user('From user> ') user1 = self.input_user('From user> ')
user2 = self.input_user('To user> ') user2 = self.input_user('To user> ')
t1 = Transaction(user1, amount, t1 = Transaction(user1, amount,
'Transfer to '+user2.name) 'transfer to '+user2.name)
t2 = Transaction(user2, -amount, t2 = Transaction(user2, -amount,
'Transfer from '+user1.name) 'transfer from '+user1.name)
t1.perform_transaction() t1.perform_transaction()
t2.perform_transaction() t2.perform_transaction()
self.session.add(t1) self.session.add(t1)
@ -304,8 +304,10 @@ class ShowUserMenu(Menu):
return return
print 'Transactions:' print 'Transactions:'
for t in user.transactions: for t in user.transactions:
string = ' * %s: %d kr, ' % \ string = ' * %s: %s %d kr, ' % \
(t.time.strftime('%Y-%m-%d %H:%M'), t.amount) (t.time.strftime('%Y-%m-%d %H:%M'),
{True:'in', False:'out'}[t.amount<0],
abs(t.amount))
if t.purchase: if t.purchase:
string += 'purchase (' string += 'purchase ('
string += ', '.join(map(lambda e: e.product.name, string += ', '.join(map(lambda e: e.product.name,
@ -421,6 +423,7 @@ class ProductListMenu(Menu):
product_list = session.query(Product).all() product_list = session.query(Product).all()
line_format = '%-20s %6s %-15s' line_format = '%-20s %6s %-15s'
print line_format % ('name', 'price', 'bar code') print line_format % ('name', 'price', 'bar code')
print '-------------------------------------------'
for p in product_list: for p in product_list:
print line_format % (p.name, p.price, p.bar_code) print line_format % (p.name, p.price, p.bar_code)
self.pause() self.pause()