From c7a3feee1c6b050fefa38a71a2edc580bec08d93 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 22 Jul 2023 20:49:06 +0000 Subject: [PATCH] finish ticket --- api.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/api.py b/api.py index 51c2044..a955475 100644 --- a/api.py +++ b/api.py @@ -4,8 +4,9 @@ import sys import json from pydantic import BaseModel - from time import sleep +from datetime import datetime + app = FastAPI( title="Print Server FastAPI", description="Server that receive request for printing", @@ -25,6 +26,9 @@ def imprimir_ticket_de_prueba(data, address): #printer = Dummy() # Imprime el encabezado + printer.set(align='center', bold=False, height=1, width=1) + printer.text("Pedido Por: " + str(d['user'])+ '\n') + printer.text(str(datetime.now())+'\n') printer.set(align='center', bold=False, height=2, width=2, custom_size=True) printer.text('========================\n') text = 'MESA: ' + str(d['table'] + "\n") @@ -38,16 +42,19 @@ def imprimir_ticket_de_prueba(data, address): if combination_pizza and pizza < 2: printer.set(align='center', bold=False, height=2, width=2, custom_size=True) pizza += 1 - if pizza == 2: - printer.text('\n') elif pizza >=2: combination_pizza = False printer.set(align='left', bold=False, height=2, width=2, custom_size=True) else: printer.set(align='left', bold=False, height=2, width=2, custom_size=True) + text = line['product'] +" "+str(line['quantity'])+"\n" printer.text(text) + if pizza == 2: + printer.text('\n') + pizza = 0 + combination_pizza = False else: printer.set(align='left', bold=True, height=2, width=2, custom_size=True) printer.text("\nPIZZA COMBINADA\n")