Skip to content

Commit

Permalink
chore: Refactor EscPComandos.py to initialize printer settings in sep…
Browse files Browse the repository at this point in the history
…arate method
  • Loading branch information
alevilar committed Aug 31, 2024
1 parent e196647 commit f372424
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/common/EscPComandos.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import base64
from common.fiscalberry_logger import getLogger
from escpos.escpos import EscposIO
from escpos.constants import QR_ECLEVEL_H
from escpos.constants import QR_ECLEVEL_H,CD_KICK_2

logger = getLogger()

Expand Down Expand Up @@ -89,13 +89,14 @@ def printTexto(self, printer, texto):


def openDrawer(self, escpos: EscposIO, **kwargs):
escpos.printer.cashdraw(2)
escpos.printer.cashdraw(CD_KICK_2)


def printPedido(self, escpos: EscposIO, **kwargs):
"imprimir pedido de compras"

printer = escpos.printer
self.__initPrinter(printer)

encabezado = kwargs.get("encabezado", None)
items = kwargs.get("items", [])
Expand Down Expand Up @@ -196,6 +197,8 @@ def printFacturaElectronica(self, escpos: EscposIO, **kwargs):
"Imprimir Factura Electronica"

printer = escpos.printer

self.__initPrinter(printer)

# Secciones de la Factura
encabezado = kwargs.get("encabezado", None)
Expand Down Expand Up @@ -467,7 +470,9 @@ def printFacturaElectronica(self, escpos: EscposIO, **kwargs):
def printRemito(self, escpos: EscposIO, **kwargs):
"Imprimir remito"


printer = escpos.printer
self.__initPrinter(printer)

logger.info("Imprimiendo Remito en printer %s" % printer)

Expand Down Expand Up @@ -643,8 +648,7 @@ def printComanda(self, escpos: EscposIO, comanda, setHeader=None, setTrailer=Non

printer = escpos.printer

print("* * * * * * * * * ** * * * * * * * * * * * * * * * * * *")
print(comanda)
self.__initPrinter(printer)

printer.set(font='a', height=1, align='center', normal_textsize=True)

Expand Down Expand Up @@ -711,8 +715,16 @@ def print_plato(plato):

return True

def __initPrinter(printer):
# set all the params printer.set(align='left', font='a', bold=False, underline=?, width=?, height=?, density=?, invert=False, smooth=?, flip=?, normal_textsize=?, double_width=?, double_height=?, custom_size=?)

printer.set(align='left', font='a', bold=False, underline=False, width=1, height=1, density=9, invert=False, smooth=False, flip=False, normal_textsize=True, double_width=False, double_height=False, custom_size=False)

def printArqueo(self, escpos: EscposIO, **kwargs):
printer = escpos.printer

self.__initPrinter(printer)

encabezado: dict = kwargs.get('encabezado', None)

if encabezado is None:
Expand Down Expand Up @@ -920,6 +932,8 @@ def imprimirTitulo(titulo, ancho=1, alto=1):
saldo = "FALTANTE"
else:
saldo = ""

printer.set(invert=False)

printer.text(pad(f" Saldo {saldo}", self.desc_cols_ext , " ", "l")
+ "$" + pad(f"{abs(montoSaldo):,.2f}",self.price_cols - 1, " ", "r"))
Expand Down

0 comments on commit f372424

Please sign in to comment.