diff --git a/Api/main.py b/Api/main.py index 3b0f6d5..cfa4448 100644 --- a/Api/main.py +++ b/Api/main.py @@ -1,6 +1,6 @@ from fastapi import FastAPI, Response from escpos.printer import Dummy -from escpos.printer import Network +# from escpos.printer import Network import sys import json @@ -25,12 +25,13 @@ class Info(BaseModel): def print_bill(data, address, waiter): d = data # Crea una instancia de la impresora ficticia - printer = Network(str(address)) - printer.open() - # printer = Dummy() + # printer = Network(str(address)) + # printer.open() + printer = Dummy() # Imprime el encabezado printer.set(align='center', bold=False, height=1, width=1) printer.text(d["shop_name"]+'\n') + printer.text(d["shop_nit"]+'\n') printer.text(d["shop_address"]+'\n') printer.set(align='left', bold=False, height=1, width=1) printer.textln('===============================================') @@ -92,7 +93,7 @@ def print_bill(data, address, waiter): QR.save(temp_filename) printer.image(f"{temp_filename}") printer.set(align='left', bold=False, height=1, width=1) - text = str(payment["statement"])+" $"+str(payment["amount"]) + text = str("CUFE: " + d['cufe']) printer.textln(text) printer.set(align='center', bold=False, height=1, width=1) printer.text("Sigue nuestras redes sociales\n") @@ -107,13 +108,12 @@ def print_bill(data, address, waiter): printer.text(str(waiter)+'\n') # Corta el papel (solo para impresoras que soportan esta función) - printer.cut() - printer.close() + # printer.cut() + # printer.close() # Obtiene el contenido del ticket de prueba - # ticket_contenido = printer.output - # raise Exception(ticket_contenido) + ticket_contenido = printer.output # Imprime el contenido en la consola - # sys.stdout.write(ticket_contenido.decode('utf-8', errors='ignore')) + sys.stdout.write(ticket_contenido.decode('utf-8', errors='ignore')) def print_customer_order(data, address, waiter): diff --git a/Api/test/fixtures/bill.json b/Api/test/fixtures/bill.json index 5025886..49d8ce9 100644 --- a/Api/test/fixtures/bill.json +++ b/Api/test/fixtures/bill.json @@ -1,6 +1,8 @@ {"shop_name": "SE", + "shop_nit": "902929200", "shop_address": "Calle Arriba 1234", "fe_cufe": "https://catalogo-vpfe.dian.gov.co/document/searchqr?documentkey=936ef10e23f9fbae2d2c70869050b907b7af55a7d2c80a9f2e906450a8f98b20a88f7e4219fd0d02962f6e639b29ba20", + "cufe": "936ef10e23f9fbae2d2c70869050b907b7af55a7d2c80a9f2e906450a8f98b20a88f7e4219fd0d02962f6e639b29ba20", "invoice": { "invoice_number": "FPES2068", "resolution": {