|
|
@@ -3,6 +3,7 @@ from logging import getLogger
|
|
|
from threading import Thread
|
|
|
from uuid import uuid4
|
|
|
|
|
|
+from enums.locations import Locations
|
|
|
from fastapi import HTTPException, APIRouter, Depends
|
|
|
from fastapi.responses import JSONResponse
|
|
|
|
|
|
@@ -18,6 +19,7 @@ from config.mails import PRINTER_DISCONNECTED_MAIL
|
|
|
from config.messages import ErrorResponse, SuccessResponse, UserResponse
|
|
|
from config.settings import DEVELOPMENT
|
|
|
from auth.security import get_current_user
|
|
|
+from data.product_category import CAT_ITEMS
|
|
|
|
|
|
logger = getLogger(__name__)
|
|
|
|
|
|
@@ -221,15 +223,21 @@ async def printer_order(order: OrderWeb, current_user: User = Depends(get_curren
|
|
|
|
|
|
# Print order
|
|
|
try:
|
|
|
- order_for_print = Order(
|
|
|
- table=table,
|
|
|
- items=[Item(name=product.name, price=product.price or 0, quantity=item.quantity) for product, item in zip(products, items)],
|
|
|
- customerName=user.name,
|
|
|
- totalAmount=order.totalAmount,
|
|
|
- orderDate=order.orderDate
|
|
|
- )
|
|
|
+ kitchen_items = [ Item(name=item.name, price=product.price, quantity=item.quantity) for product, item in zip(items, products) if CAT_ITEMS.get(item.type, Locations.BAR) == Locations.KITCHEN]
|
|
|
+ bar_items = [ Item(name=item.name, price=product.price, quantity=item.quantity) for product, item in zip(items, products) if CAT_ITEMS.get(item.type, Locations.BAR) == Locations.BAR]
|
|
|
+ coctelery_items = [ Item(name=item.name, price=product.price, quantity=item.quantity) for product, item in zip(items, products) if CAT_ITEMS.get(item.type, Locations.COCTELERY) == Locations.COCTELERY]
|
|
|
+
|
|
|
+ if kitchen_items:
|
|
|
+ ps.print_order(Order(table=table, items=kitchen_items, customerName=user.name, totalAmount=order.totalAmount, orderDate=order.orderDate), location=Locations.KITCHEN)
|
|
|
+ logger.info(f"Order kitchen printed successfully for table {table}")
|
|
|
+ if bar_items:
|
|
|
+ ps.print_order(Order(table=table, items=bar_items, customerName=user.name, totalAmount=order.totalAmount, orderDate=order.orderDate), location=Locations.BAR)
|
|
|
+ logger.info(f"Order bar printed successfully for table {table}")
|
|
|
+ if coctelery_items:
|
|
|
+ ps.print_order(Order(table=table, items=coctelery_items, customerName=user.name, totalAmount=order.totalAmount, orderDate=order.orderDate), location=Locations.COCTELERY)
|
|
|
+ logger.info(f"Order coctelery printed successfully for table {table}")
|
|
|
|
|
|
- ps.print_order(order_for_print)
|
|
|
+ # ps.print_order(order_for_print, location=CAT_ITEMS.get())
|
|
|
|
|
|
logger.info(f"Order printed successfully for table {table}")
|
|
|
|