fix: Refactor

This commit is contained in:
2025-10-21 14:53:02 -05:00
parent 9d874486ae
commit f204930d0e
2 changed files with 7 additions and 15 deletions

View File

@@ -254,14 +254,3 @@ class CustomerOrderPrinter(TicketPrinter):
"""Muestra la salida cuando no hay impresora real"""
ticket_content = self.printer.output
sys.stdout.write(ticket_content.decode('utf-8', errors='ignore'))
# Funciones de interfaz para mantener compatibilidad
def print_bill(data, address, waiter):
printer = BillPrinter(address)
printer.print_bill(data, waiter)
def print_customer_order(data, address, waiter):
printer = CustomerOrderPrinter(address)
printer.print_order(data, waiter)

View File

@@ -3,7 +3,7 @@ import logging
from typing import Dict, Any, Tuple
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from formats import print_bill, print_customer_order
from formats import BillPrinter, CustomerOrderPrinter
# Configurar logging
logging.basicConfig(level=logging.INFO)
@@ -54,7 +54,8 @@ def print_ticket_bill(info: PrintRequest) -> PrintResponse:
"""Print bill ticket"""
try:
data, address, waiter = _parse_request_data(info)
print_bill(data, address, waiter)
printer = BillPrinter(address)
printer.print_bill(data, waiter)
logger.info(f"Bill printed successfully for {waiter}")
return PrintResponse(
@@ -72,7 +73,8 @@ def print_ticket_kitchen(info: PrintRequest) -> PrintResponse:
"""Print kitchen order"""
try:
data, address, waiter = _parse_request_data(info)
print_customer_order(data, address, waiter)
printer = CustomerOrderPrinter(address)
printer.print_order(data, waiter)
logger.info(f"Kitchen order printed successfully for {waiter}")
return PrintResponse(
@@ -91,7 +93,8 @@ def print_ticket_bar(info: PrintRequest) -> PrintResponse:
"""Print bar order"""
try:
data, address, waiter = _parse_request_data(info)
print_customer_order(data, address, waiter)
printer = CustomerOrderPrinter(address)
printer.print_order(data, waiter)
logger.info(f"Bar order printed successfully for {waiter}")
return PrintResponse(