Feat(WIP): Lineas Eliminadas
This commit is contained in:
parent
d1482056c0
commit
bff20cbd72
22
Api/main.py
22
Api/main.py
@ -1,6 +1,6 @@
|
|||||||
from fastapi import FastAPI, Response
|
from fastapi import FastAPI, Response
|
||||||
from escpos.printer import Dummy
|
from escpos.printer import Dummy
|
||||||
# from escpos.printer import Network
|
from escpos.printer import Network
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@ -119,9 +119,9 @@ def print_bill(data, address, waiter):
|
|||||||
def print_customer_order(data, address, waiter):
|
def print_customer_order(data, address, waiter):
|
||||||
d = data
|
d = data
|
||||||
# Crea una instancia de la impresora ficticia
|
# Crea una instancia de la impresora ficticia
|
||||||
# printer = Network(str(address))
|
printer = Network(str(address))
|
||||||
# printer.open()
|
printer.open()
|
||||||
printer = Dummy()
|
# printer = Dummy()
|
||||||
# Imprime el encabezado
|
# Imprime el encabezado
|
||||||
printer.set(align='center', bold=False, height=1, width=1)
|
printer.set(align='center', bold=False, height=1, width=1)
|
||||||
format_date_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
format_date_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
@ -183,14 +183,20 @@ def print_customer_order(data, address, waiter):
|
|||||||
printer.text("\nPIZZA COMBINADA\n")
|
printer.text("\nPIZZA COMBINADA\n")
|
||||||
combination_pizza = True
|
combination_pizza = True
|
||||||
pizza = 0
|
pizza = 0
|
||||||
|
# if d["deleted_lines"]:
|
||||||
|
# for line in d["deleted_lines"]:
|
||||||
|
# text = line['product'] + " " + str(
|
||||||
|
# line['quantity']) + " " + str(
|
||||||
|
# line['unit'])
|
||||||
|
# printer.text(text)
|
||||||
# Corta el papel (solo para impresoras que soportan esta función)
|
# Corta el papel (solo para impresoras que soportan esta función)
|
||||||
# printer.cut()
|
printer.cut()
|
||||||
# printer.close()
|
printer.close()
|
||||||
# Obtiene el contenido del ticket de prueba
|
# Obtiene el contenido del ticket de prueba
|
||||||
ticket_contenido = printer.output
|
# ticket_contenido = printer.output
|
||||||
|
|
||||||
# Imprime el contenido en la consola
|
# Imprime el contenido en la consola
|
||||||
sys.stdout.write(ticket_contenido.decode('utf-8', errors='replace'))
|
# sys.stdout.write(ticket_contenido.decode('utf-8', errors='replace'))
|
||||||
|
|
||||||
|
|
||||||
@app.post("/print_bill")
|
@app.post("/print_bill")
|
||||||
|
13
Api/test/fixtures/customer_order_deleted_lines.json
vendored
Normal file
13
Api/test/fixtures/customer_order_deleted_lines.json
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"party": "00-Consumidor Final",
|
||||||
|
"tax_identifier_type": "NIT",
|
||||||
|
"tax_identifier_code": "222222222",
|
||||||
|
"address": "Dg 74A #C-2-56",
|
||||||
|
"city": "Medellín",
|
||||||
|
"zone": "SALON",
|
||||||
|
"table": "SL5",
|
||||||
|
"lines": [],
|
||||||
|
"deleted_lines": [
|
||||||
|
{"product": "Playa Girón", "quantity": -1.0, "unit": "Media Unidad"},
|
||||||
|
{"product": "Ciclobi", "quantity": -1.0, "unit": "Media Unidad"}
|
||||||
|
]}
|
@ -43,13 +43,30 @@ def test_print_customer_order():
|
|||||||
assert response.content.decode() == "!Impresion Realizada!"
|
assert response.content.decode() == "!Impresion Realizada!"
|
||||||
|
|
||||||
|
|
||||||
|
def test_print_customer_order_deleted_lines():
|
||||||
|
test_info = {
|
||||||
|
"content": str(
|
||||||
|
json.dumps(
|
||||||
|
load_json(
|
||||||
|
'test/fixtures/customer_order_deleted_lines.json')
|
||||||
|
)),
|
||||||
|
"ip_printer": "192.168.1.110",
|
||||||
|
"user_name": "Juan"
|
||||||
|
}
|
||||||
|
|
||||||
|
response = client.post("/order_kitchen", json=test_info)
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert response.content.decode() == "!Impresion Realizada!"
|
||||||
|
|
||||||
|
|
||||||
def test_print_bar_order():
|
def test_print_bar_order():
|
||||||
test_info = {
|
test_info = {
|
||||||
"content": str(
|
"content": str(
|
||||||
json.dumps(
|
json.dumps(
|
||||||
load_json('test/fixtures/customer_order.json')
|
load_json('test/fixtures/customer_order.json')
|
||||||
)),
|
)),
|
||||||
"ip_printer": "192.168.1.100",
|
"ip_printer": "192.168.1.110",
|
||||||
"user_name": "Juan"
|
"user_name": "Juan"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user