- add paying

This commit is contained in:
Ulrich Knechtelsdorfer
2016-04-06 23:38:48 +02:00
parent 10f6eea47a
commit 9cf32cc82a
4 changed files with 27 additions and 11 deletions

View File

@@ -195,6 +195,8 @@ def get_debt(name=None):
deposits = get_deposits(get_user_by_name(name).id)
for deposit in deposits:
debt -= deposit.amount
debt = round(debt, 2)
return debt
@@ -216,6 +218,16 @@ def get_deposits(userid = None):
deposits.append(d)
return deposits
def add_deposit(username, amount):
consumerid = query_db("SELECT ID FROM USERS WHERE NAME = ?", [username], one=True)
consumerid = int(consumerid[0])
query_db("INSERT INTO DEPOSITS (USERID, AMOUNT, TIME) VALUES (?, ?, ?)", (str(consumerid), amount, datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
get_db().commit()
print "deposit"
return
##for testing only
def generate_test_users():