def completeOrder(): """ DESCRIPTION: This route is for completing the order/payment for a specific table/customer REQUEST TYPE: POST PARAMETERS: JSON object containing payment details RETURNS: order ID of the order just closed """ #order no is accessed from the session #if it doesn't exist then, table is empty orderNo = None values = request.get_json(silent=True) if 'orderNo' in session: orderNo = session["orderNo"] #if waitress is closing the order then the order number is sent as a parameter else: orderNo = values["orderNo"] ''' elif 'role' in session: orderNo = request.args.get('orderNo') if orderNo is None: return json.dumps({ "error": "limited arguments" }) else: return json.dumps({ "error": "Unauthorized" }) ''' # orderNo = request.args.get('orderNo') print(values) print(orderNo) #update the order status to completed if Mongo_Client.UpdateOrder(orderNo, values): print("order updated") #remove the order number for session session.pop("orderNo", None) #clear the order id from the table colectition for the resoective tabel Mongo_Client.ClearTableWithOrderNo(orderNo) return json.dumps({"success": True, "orderId": orderNo}) else: return json.dumps({"error": "Database Error"})
def addTip(): """ DESCRIPTION: This route is for adding tip for an order REQUEST TYPE: POST PARAMETERS: JSON containing tip amount RETURNS: success/error message """ values = request.get_json(silent=True) if Mongo_Client.UpdateOrder(values["orderId"], {"tip": values["tip"]}): session.pop("orderNo", None) return json.dumps({"success": True}) else: return json.dumps({"error": "Database Error"})