|
|
@@ -132,7 +132,7 @@ async def printer_order(order: OrderWeb, current_user: User = Depends(get_curren
|
|
|
|
|
|
#en caso contrario
|
|
|
else:
|
|
|
- if product.type == name_promo:
|
|
|
+ if product.type == name_promo and current_user.name != "Guest":
|
|
|
beers_for_promo += item.quantity
|
|
|
logger.debug(f"Added {item.quantity} beers for promotion calculation")
|
|
|
|
|
|
@@ -140,7 +140,7 @@ async def printer_order(order: OrderWeb, current_user: User = Depends(get_curren
|
|
|
|
|
|
logger.info(f"Added product {item.id} to table {table} with quantity {item.quantity} in fudo")
|
|
|
|
|
|
- if not fudo_product:
|
|
|
+ if not fudo_product:
|
|
|
error_msg = f"Error adding product {item.id} to table {table}."
|
|
|
product_errors.append(error_msg)
|
|
|
logger.error(error_msg)
|
|
|
@@ -163,21 +163,7 @@ async def printer_order(order: OrderWeb, current_user: User = Depends(get_curren
|
|
|
|
|
|
return error_response(error={"errors": product_errors}, message=ErrorResponse.PRODUCT_ADD_ERROR, status_code=424)
|
|
|
|
|
|
- # User validation
|
|
|
- try:
|
|
|
- user = user_data_service.get_by_id(order.customerId)
|
|
|
- if not user:
|
|
|
- logger.warning(f"User not found: {order.customerId}")
|
|
|
-
|
|
|
- return error_response(message=UserResponse.USER_NOT_FOUND.format(user_id=order.customerId), status_code=404)
|
|
|
-
|
|
|
- logger.info(f"Order customer validated: {user.email}")
|
|
|
-
|
|
|
-
|
|
|
- except Exception as e:
|
|
|
- error_msg = f"Error validating user {order.customerId}: {e}"
|
|
|
-
|
|
|
- return error_response(message=error_msg, status_code=500)
|
|
|
+
|
|
|
|
|
|
# Get active sale
|
|
|
try:
|
|
|
@@ -198,17 +184,17 @@ async def printer_order(order: OrderWeb, current_user: User = Depends(get_curren
|
|
|
|
|
|
# Update user reward progress
|
|
|
try:
|
|
|
- new_progress = user.reward_progress + beers_for_promo * 10
|
|
|
- user_data_service.set_reward_progress(user.id, new_progress)
|
|
|
+ new_progress = current_user.reward_progress + beers_for_promo * 10
|
|
|
+ user_data_service.set_reward_progress(current_user.id, new_progress)
|
|
|
|
|
|
- logger.info(f"Updated reward progress for user {user.email}: {user.reward_progress} -> {new_progress}")
|
|
|
+ logger.info(f"Updated reward progress for user {current_user.email}: {current_user.reward_progress} -> {new_progress}")
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
- error_msg = f"Error updating reward progress for user {user.id}: {e}"
|
|
|
+ error_msg = f"Error updating reward progress for user {current_user.id}: {e}"
|
|
|
logger.error(error_msg)
|
|
|
# Don't fail the order for this, just log it
|
|
|
- new_progress = user.reward_progress
|
|
|
+ new_progress = current_user.reward_progress
|
|
|
|
|
|
# Create sale record
|
|
|
try:
|
|
|
@@ -248,16 +234,16 @@ async def printer_order(order: OrderWeb, current_user: User = Depends(get_curren
|
|
|
print(list(map(lambda x: x.model_dump(), bar_items)))
|
|
|
|
|
|
if pizza_items:
|
|
|
- ps.print_order(Order(table=table, items=pizza_items, customerName=user.name, totalAmount=order.totalAmount, orderDate=order.orderDate), location=Locations.PIZZAS)
|
|
|
+ ps.print_order(Order(table=table, items=pizza_items, customerName=current_user.name, totalAmount=order.totalAmount, orderDate=order.orderDate), location=Locations.PIZZAS)
|
|
|
logger.info(f"Order pizza printed successfully for table {table}")
|
|
|
if burger_items:
|
|
|
- ps.print_order(Order(table=table, items=burger_items, customerName=user.name, totalAmount=order.totalAmount, orderDate=order.orderDate), location=Locations.BURGUER)
|
|
|
+ ps.print_order(Order(table=table, items=burger_items, customerName=current_user.name, totalAmount=order.totalAmount, orderDate=order.orderDate), location=Locations.BURGUER)
|
|
|
logger.info(f"Order burger 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)
|
|
|
+ ps.print_order(Order(table=table, items=bar_items, customerName=current_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)
|
|
|
+ ps.print_order(Order(table=table, items=coctelery_items, customerName=current_user.name, totalAmount=order.totalAmount, orderDate=order.orderDate), location=Locations.COCTELERY)
|
|
|
logger.info(f"Order coctelery printed successfully for table {table}")
|
|
|
|
|
|
|