From 3a5d7d7d0f76c00fd5e1ae403de06e00f3662563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 29 Dec 2019 21:57:59 +0100 Subject: [PATCH] fixed that baruser get endsum not only from month --- geruecht/baruser/routes.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/geruecht/baruser/routes.py b/geruecht/baruser/routes.py index 5b8da89..2ecfaff 100644 --- a/geruecht/baruser/routes.py +++ b/geruecht/baruser/routes.py @@ -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")