Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,33 +2,6 @@
|
|
| 2 |
import gradio as gr
|
| 3 |
from datetime import datetime
|
| 4 |
|
| 5 |
-
def generate_invoice(customer_name, table_number, items, wishes):
|
| 6 |
-
total = sum(item['price'] for item in items)
|
| 7 |
-
invoice = f"""
|
| 8 |
-
-----------------------------------------
|
| 9 |
-
Restaurant Invoice
|
| 10 |
-
-----------------------------------------
|
| 11 |
-
Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
| 12 |
-
Customer Name: {customer_name}
|
| 13 |
-
Table Number: {table_number}
|
| 14 |
-
-----------------------------------------
|
| 15 |
-
Items Ordered:
|
| 16 |
-
"""
|
| 17 |
-
for item in items:
|
| 18 |
-
invoice += f"- {item['name']} (${item['price']})\n"
|
| 19 |
-
|
| 20 |
-
invoice += f"""
|
| 21 |
-
-----------------------------------------
|
| 22 |
-
Total Amount: ${total:.2f}
|
| 23 |
-
-----------------------------------------
|
| 24 |
-
Customer Wishes:
|
| 25 |
-
{wishes}
|
| 26 |
-
-----------------------------------------
|
| 27 |
-
Thank you for dining with us!
|
| 28 |
-
Have a great day!
|
| 29 |
-
"""
|
| 30 |
-
return invoice
|
| 31 |
-
|
| 32 |
# Dynamic menu data
|
| 33 |
menu = {
|
| 34 |
"Bread": [
|
|
@@ -57,13 +30,41 @@ def render_menu():
|
|
| 57 |
rendered_menu += f"- {item['name']} (${item['price']})\n"
|
| 58 |
return rendered_menu
|
| 59 |
|
| 60 |
-
def
|
| 61 |
-
selected_items =
|
| 62 |
items = [item for category in menu.values() for item in category if item['name'] in selected_items]
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
with gr.Blocks() as demo:
|
| 69 |
gr.Markdown("""# Restaurant Invoice Generator
|
|
@@ -78,7 +79,7 @@ with gr.Blocks() as demo:
|
|
| 78 |
menu_display = gr.Textbox(show_label=False, interactive=False, value=render_menu())
|
| 79 |
|
| 80 |
selected_items = gr.Textbox(label="Selected Items (comma-separated)", placeholder="e.g., Roti, Paneer Butter Masala")
|
| 81 |
-
wishes = gr.Textbox(label="Special Wishes", placeholder="e.g., Extra spicy, Less salt
|
| 82 |
|
| 83 |
generate_invoice_btn = gr.Button("Generate Invoice")
|
| 84 |
|
|
@@ -91,3 +92,4 @@ with gr.Blocks() as demo:
|
|
| 91 |
)
|
| 92 |
|
| 93 |
demo.launch()
|
|
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from datetime import datetime
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# Dynamic menu data
|
| 6 |
menu = {
|
| 7 |
"Bread": [
|
|
|
|
| 30 |
rendered_menu += f"- {item['name']} (${item['price']})\n"
|
| 31 |
return rendered_menu
|
| 32 |
|
| 33 |
+
def generate_invoice(customer_name, table_number, selected_items, wishes):
|
| 34 |
+
selected_items = selected_items.split(', ')
|
| 35 |
items = [item for category in menu.values() for item in category if item['name'] in selected_items]
|
| 36 |
+
total = sum(item['price'] for item in items)
|
| 37 |
+
invoice = f"""
|
| 38 |
+
-----------------------------------------
|
| 39 |
+
Restaurant Invoice
|
| 40 |
+
-----------------------------------------
|
| 41 |
+
Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
| 42 |
+
Customer Name: {customer_name}
|
| 43 |
+
Table Number: {table_number}
|
| 44 |
+
-----------------------------------------
|
| 45 |
+
Items Ordered:
|
| 46 |
+
"""
|
| 47 |
+
for item in items:
|
| 48 |
+
invoice += f"- {item['name']} (${item['price']})\n"
|
| 49 |
|
| 50 |
+
invoice += f"""
|
| 51 |
+
-----------------------------------------
|
| 52 |
+
Total Amount: ${total:.2f}
|
| 53 |
+
-----------------------------------------
|
| 54 |
+
Customer Wishes:
|
| 55 |
+
"""
|
| 56 |
+
for wish in wishes.split(', '):
|
| 57 |
+
invoice += f"- {wish}\n"
|
| 58 |
+
|
| 59 |
+
invoice += """
|
| 60 |
+
-----------------------------------------
|
| 61 |
+
Thank you for dining with us!
|
| 62 |
+
Have a great day!
|
| 63 |
+
"""
|
| 64 |
+
return invoice
|
| 65 |
+
|
| 66 |
+
def place_order(customer_name, table_number, selected_items, wishes):
|
| 67 |
+
return generate_invoice(customer_name, table_number, selected_items, wishes)
|
| 68 |
|
| 69 |
with gr.Blocks() as demo:
|
| 70 |
gr.Markdown("""# Restaurant Invoice Generator
|
|
|
|
| 79 |
menu_display = gr.Textbox(show_label=False, interactive=False, value=render_menu())
|
| 80 |
|
| 81 |
selected_items = gr.Textbox(label="Selected Items (comma-separated)", placeholder="e.g., Roti, Paneer Butter Masala")
|
| 82 |
+
wishes = gr.Textbox(label="Special Wishes (comma-separated)", placeholder="e.g., Extra spicy, Less salt")
|
| 83 |
|
| 84 |
generate_invoice_btn = gr.Button("Generate Invoice")
|
| 85 |
|
|
|
|
| 92 |
)
|
| 93 |
|
| 94 |
demo.launch()
|
| 95 |
+
|