From f204930d0e4989533b218733948da173da198337 Mon Sep 17 00:00:00 2001 From: aserrador Date: Tue, 21 Oct 2025 14:53:02 -0500 Subject: [PATCH] fix: Refactor --- Api/formats.py | 11 ----------- Api/main.py | 11 +++++++---- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Api/formats.py b/Api/formats.py index f1d381e..ccf00e7 100644 --- a/Api/formats.py +++ b/Api/formats.py @@ -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) diff --git a/Api/main.py b/Api/main.py index 1c5831c..1210cdb 100644 --- a/Api/main.py +++ b/Api/main.py @@ -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(