route for baruser to storno, ##164
This commit is contained in:
parent
0035a2517d
commit
7038928e49
|
@ -95,6 +95,37 @@ def _getUsers(**kwargs):
|
||||||
retVal = ldap.getAllUser()
|
retVal = ldap.getAllUser()
|
||||||
return jsonify(retVal)
|
return jsonify(retVal)
|
||||||
|
|
||||||
|
@baruser.route("/bar/storno", methods=['POST'])
|
||||||
|
@login_required(groups=[BAR])
|
||||||
|
def _storno(**kwargs):
|
||||||
|
""" Function for Baruser to storno amount
|
||||||
|
|
||||||
|
This function added to the user with the posted userID the posted amount.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
JSON-File with userID and the amount
|
||||||
|
or ERROR 401 Permission Denied
|
||||||
|
"""
|
||||||
|
data = request.get_json()
|
||||||
|
userID = data['userId']
|
||||||
|
amount = int(data['amount'])
|
||||||
|
|
||||||
|
date = datetime.now()
|
||||||
|
userController.addCredit(userID, amount, year=date.year, month=date.month)
|
||||||
|
user = userController.getUser(userID)
|
||||||
|
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'
|
||||||
|
dic = user.toJSON()
|
||||||
|
dic['amount'] = abs(all)
|
||||||
|
dic['type'] = type
|
||||||
|
|
||||||
|
return jsonify(dic)
|
||||||
|
|
||||||
@baruser.route("/barGetUser", methods=['POST'])
|
@baruser.route("/barGetUser", methods=['POST'])
|
||||||
@login_required(groups=[BAR])
|
@login_required(groups=[BAR])
|
||||||
|
|
Loading…
Reference in New Issue