import pandas as pd from utils.file_initializer import ORDERS_FILE, MENU_FILE def add_to_order(table_id, customer_email, dish_name, spice_level, customizations): menu = pd.read_excel(MENU_FILE) orders = pd.read_excel(ORDERS_FILE) dish = menu[menu["Dish Name"] == dish_name].iloc[0] total_cost = dish["Price"] order_details = f"{dish_name} ({spice_level}) {customizations}" orders = orders.append( {"Table ID": table_id, "Customer Email": customer_email, "Order Details": order_details, "Total Cost": total_cost}, ignore_index=True ) orders.to_excel(ORDERS_FILE, index=False) return f"{dish_name} added to order!" def view_order(table_id, customer_email): orders = pd.read_excel(ORDERS_FILE) return orders[(orders["Table ID"] == table_id) & (orders["Customer Email"] == customer_email)] def place_order(table_id, customer_email): orders = pd.read_excel(ORDERS_FILE) table_orders = orders[(orders["Table ID"] == table_id) & (orders["Customer Email"] == customer_email)] if table_orders.empty: return "No items in the order." total_cost = table_orders["Total Cost"].sum() return f"Order placed successfully! Total Cost: {total_cost}"