fix reporting.py
This commit is contained in:
parent
383b24303a
commit
4b6283a7a8
|
@ -61,25 +61,16 @@ SSH_PORT = 23
|
||||||
|
|
||||||
|
|
||||||
def money(value):
|
def money(value):
|
||||||
if type(value) != int:
|
if type(value) is int:
|
||||||
value = int(value)
|
value = int(value)
|
||||||
return '{:,}'.format(value)
|
return '{:,}'.format(value)
|
||||||
|
|
||||||
|
|
||||||
dev_printers = {}
|
dev_printers = {}
|
||||||
if os.name == 'posix' and pyudev:
|
if os.name == 'posix' and os.path.exists('/dev/usb'):
|
||||||
# context = pyudev.Context()
|
for fl in os.listdir('/dev/usb'):
|
||||||
# for device in context.list_devices():
|
|
||||||
# if device.subsystem == 'usbmisc':
|
|
||||||
# # print(device.subsystem, device.sys_path.split('2-1/')[1][0:5], device.device_node)
|
|
||||||
# dev_printers[str(device.sys_path.split('2-1/')[1][0:5])] = device.device_node
|
|
||||||
try:
|
|
||||||
files_usb = os.listdir('/dev/usb')
|
|
||||||
for fl in files_usb:
|
|
||||||
if 'lp' in fl:
|
if 'lp' in fl:
|
||||||
dev_printers['usb'] = fl
|
dev_printers['usb'] = fl
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Receipt(object):
|
class Receipt(object):
|
||||||
|
@ -105,6 +96,8 @@ class Receipt(object):
|
||||||
self._delta_locale = context.get('delta_locale')
|
self._delta_locale = context.get('delta_locale')
|
||||||
self._environment = environment
|
self._environment = environment
|
||||||
self.order_copies = context.get('order_copies')
|
self.order_copies = context.get('order_copies')
|
||||||
|
self.invoice_copies = context.get('invoice_copies')
|
||||||
|
self.order_kind = 'dispatch' if environment == 'restaurant' else 'command'
|
||||||
|
|
||||||
self._row_characters = _ROW_CHARACTERS
|
self._row_characters = _ROW_CHARACTERS
|
||||||
if context.get('row_characters'):
|
if context.get('row_characters'):
|
||||||
|
@ -156,9 +149,9 @@ class Receipt(object):
|
||||||
except Exception:
|
except Exception:
|
||||||
host, port = self._device, None
|
host, port = self._device, None
|
||||||
if port:
|
if port:
|
||||||
self._printer = printer.Network(host, port=int(port), timeout=60)
|
self._printer = printer.Network(host, port=int(port), timeout=15)
|
||||||
else:
|
else:
|
||||||
self._printer = printer.Network(host, timeout=60)
|
self._printer = printer.Network(host, timeout=15)
|
||||||
elif self._interface == 'ssh':
|
elif self._interface == 'ssh':
|
||||||
self._printer = FileSSH(*self._device.split('@'))
|
self._printer = FileSSH(*self._device.split('@'))
|
||||||
self._printer.open()
|
self._printer.open()
|
||||||
|
@ -212,15 +205,6 @@ class Receipt(object):
|
||||||
|
|
||||||
def set_printer(self):
|
def set_printer(self):
|
||||||
try:
|
try:
|
||||||
status = self.check_status(self._interface, self._device)
|
|
||||||
if not status:
|
|
||||||
msg = f'''
|
|
||||||
Impresora no esta disponible;
|
|
||||||
revisa la configuracion o conexion de impresora
|
|
||||||
interface: {self._interface}, device: {self._device}
|
|
||||||
'''
|
|
||||||
print(msg)
|
|
||||||
return msg
|
|
||||||
if self._interface == 'usb':
|
if self._interface == 'usb':
|
||||||
if OS_NAME == 'posix':
|
if OS_NAME == 'posix':
|
||||||
self._printer = printer.File(
|
self._printer = printer.File(
|
||||||
|
@ -237,13 +221,6 @@ class Receipt(object):
|
||||||
self._printer = printer.Network(host, port=int(port), timeout=15)
|
self._printer = printer.Network(host, port=int(port), timeout=15)
|
||||||
else:
|
else:
|
||||||
self._printer = printer.Network(host, timeout=15)
|
self._printer = printer.Network(host, timeout=15)
|
||||||
# elif self._interface == 'ssh':
|
|
||||||
# self._printer = FileSSH(*self._device.split('@'))
|
|
||||||
# self._printer.open()
|
|
||||||
# elif self._interface == 'cups':
|
|
||||||
# self.conn = cups.Connection()
|
|
||||||
# self._file = open(TEMP_INVOICE_FILE, 'w')
|
|
||||||
# self._printer = CupsPrinter(self._file, self._row_characters)
|
|
||||||
if not self._printer:
|
if not self._printer:
|
||||||
msg = "Warning: Can not found Printer!"
|
msg = "Warning: Can not found Printer!"
|
||||||
self.logger.info("Warning: Can not found Printer!")
|
self.logger.info("Warning: Can not found Printer!")
|
||||||
|
@ -413,7 +390,7 @@ class Receipt(object):
|
||||||
|
|
||||||
def print_header_sale_verification(self, sale):
|
def print_header_sale_verification(self, sale):
|
||||||
title = 'VERIFICACION DE CUENTA'
|
title = 'VERIFICACION DE CUENTA'
|
||||||
msg = """ESTIMADO CLIENTE UNA VEZ REALICE EL \n PAGO DE LA CUENTA POR \n FAVOR EXIJA SU RESPECTIVA FACTURA"""
|
msg = """ESTIMADO CLIENTE UNA VEZ REALICE EL \n PAGO DE LA CUENTA POR \n FAVOR EXIJA SU RESPECTIVA FACTURA \n PROPINA VOLUNTARIA"""
|
||||||
self._printer.ln(2)
|
self._printer.ln(2)
|
||||||
self._printer.set(custom_size=True, width=2, height=2, align='center')
|
self._printer.set(custom_size=True, width=2, height=2, align='center')
|
||||||
self._printer.text(title)
|
self._printer.text(title)
|
||||||
|
|
Loading…
Reference in New Issue