Feat: Impresion de CUFE Factura electronica colombia
This commit is contained in:
parent
458ff6f89f
commit
d1482056c0
20
Api/main.py
20
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
|
||||||
|
|
||||||
@ -25,12 +25,13 @@ class Info(BaseModel):
|
|||||||
def print_bill(data, address, waiter):
|
def print_bill(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)
|
||||||
printer.text(d["shop_name"]+'\n')
|
printer.text(d["shop_name"]+'\n')
|
||||||
|
printer.text(d["shop_nit"]+'\n')
|
||||||
printer.text(d["shop_address"]+'\n')
|
printer.text(d["shop_address"]+'\n')
|
||||||
printer.set(align='left', bold=False, height=1, width=1)
|
printer.set(align='left', bold=False, height=1, width=1)
|
||||||
printer.textln('===============================================')
|
printer.textln('===============================================')
|
||||||
@ -92,7 +93,7 @@ def print_bill(data, address, waiter):
|
|||||||
QR.save(temp_filename)
|
QR.save(temp_filename)
|
||||||
printer.image(f"{temp_filename}")
|
printer.image(f"{temp_filename}")
|
||||||
printer.set(align='left', bold=False, height=1, width=1)
|
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.textln(text)
|
||||||
printer.set(align='center', bold=False, height=1, width=1)
|
printer.set(align='center', bold=False, height=1, width=1)
|
||||||
printer.text("Sigue nuestras redes sociales\n")
|
printer.text("Sigue nuestras redes sociales\n")
|
||||||
@ -107,13 +108,12 @@ def print_bill(data, address, waiter):
|
|||||||
printer.text(str(waiter)+'\n')
|
printer.text(str(waiter)+'\n')
|
||||||
|
|
||||||
# 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
|
||||||
# raise Exception(ticket_contenido)
|
|
||||||
# Imprime el contenido en la consola
|
# 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):
|
def print_customer_order(data, address, waiter):
|
||||||
|
2
Api/test/fixtures/bill.json
vendored
2
Api/test/fixtures/bill.json
vendored
@ -1,6 +1,8 @@
|
|||||||
{"shop_name": "SE",
|
{"shop_name": "SE",
|
||||||
|
"shop_nit": "902929200",
|
||||||
"shop_address": "Calle Arriba 1234",
|
"shop_address": "Calle Arriba 1234",
|
||||||
"fe_cufe": "https://catalogo-vpfe.dian.gov.co/document/searchqr?documentkey=936ef10e23f9fbae2d2c70869050b907b7af55a7d2c80a9f2e906450a8f98b20a88f7e4219fd0d02962f6e639b29ba20",
|
"fe_cufe": "https://catalogo-vpfe.dian.gov.co/document/searchqr?documentkey=936ef10e23f9fbae2d2c70869050b907b7af55a7d2c80a9f2e906450a8f98b20a88f7e4219fd0d02962f6e639b29ba20",
|
||||||
|
"cufe": "936ef10e23f9fbae2d2c70869050b907b7af55a7d2c80a9f2e906450a8f98b20a88f7e4219fd0d02962f6e639b29ba20",
|
||||||
"invoice": {
|
"invoice": {
|
||||||
"invoice_number": "FPES2068",
|
"invoice_number": "FPES2068",
|
||||||
"resolution": {
|
"resolution": {
|
||||||
|
Loading…
Reference in New Issue
Block a user