fixed that baruser get endsum not only from month

This commit is contained in:
Tim Gröger 2019-12-29 21:57:59 +01:00
parent 16e50ea751
commit 3a5d7d7d0f
1 changed files with 11 additions and 4 deletions

View File

@ -29,15 +29,16 @@ def _bar():
if geruecht is not None:
month = geruecht.getMonth(datetime.now().month)
amount = month[0] - month[1]
all = geruecht.getSchulden()
if amount != 0:
if amount >= 0:
if all >= 0:
type = 'credit'
else:
type = 'amount'
dic[user.uid] = {"username": user.uid,
"firstname": user.firstname,
"lastname": user.lastname,
"amount": abs(month[0] - month[1]),
"amount": abs(all),
"locked": user.locked,
"type": type
}
@ -66,10 +67,16 @@ def _baradd():
date = datetime.now()
userController.addAmount(userID, amount, year=date.year, month=date.month)
user = userController.getUser(userID)
month = user.getGeruecht(year=date.year).getMonth(month=date.month)
geruecht = user.getGeruecht(year=date.year)
month = geruecht.getMonth(month=date.month)
amount = abs(month[0] - month[1])
all = geruecht.getSchulden()
if all >= 0:
type = 'credit'
else:
type = 'amount'
return jsonify({"userId": user.uid, "amount": amount, 'locked': user.locked})
return jsonify({"userId": user.uid, "amount": abs(all), 'locked': user.locked, 'type': type})
return jsonify({"error", "permission denied"}), 401
@baruser.route("/barGetUsers")