parent
fcc76a639f
commit
f296986924
|
@ -233,4 +233,31 @@ def _deleteTransactJob(**kwargs):
|
||||||
userController.deleteTransactJob(from_user, to_user, date)
|
userController.deleteTransactJob(from_user, to_user, date)
|
||||||
return jsonify({"ok": "ok"})
|
return jsonify({"ok": "ok"})
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
return jsonify({"error": str(err)}), 409
|
return jsonify({"error": str(err)}), 409
|
||||||
|
|
||||||
|
@user.route("/user/storno", methods=['POST'])
|
||||||
|
@login_required(groups=[USER])
|
||||||
|
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
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
if 'accToken' in kwargs:
|
||||||
|
accToken = kwargs['accToken']
|
||||||
|
user = accToken.user
|
||||||
|
data = request.get_json()
|
||||||
|
amount = int(data['amount'])
|
||||||
|
|
||||||
|
date = datetime.now()
|
||||||
|
userController.addCredit(user.uid, amount, year=date.year, month=date.month)
|
||||||
|
accToken.user = userController.getUser(accToken.user.uid)
|
||||||
|
retVal = accToken.user.toJSON()
|
||||||
|
retVal['creditList'] = {credit.year: credit.toJSON() for credit in accToken.user.geruechte}
|
||||||
|
return jsonify(retVal)
|
||||||
|
except Exception as err:
|
||||||
|
return jsonify({"error": str(err)}), 409
|
||||||
|
|
Loading…
Reference in New Issue