parent
877d8692b1
commit
bdea338ce7
|
@ -1,4 +1,4 @@
|
|||
Copyright (C) 2016-2020 Oscar Alvarez.
|
||||
Copyright (C) 2016-2023 Oscar Alvarez.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
1
INSTALL
1
INSTALL
|
@ -36,7 +36,6 @@ The following packages must be installed using PIP
|
|||
pip3 install requests
|
||||
pip3 install simplejson
|
||||
pip3 install escpos
|
||||
pip3 install packaging
|
||||
|
||||
|
||||
For Windows add:
|
||||
|
|
|
@ -35,7 +35,6 @@ Los siguientes paquetes se deben instalar usando PIP
|
|||
pip3 install paramiko
|
||||
pip3 install orjson
|
||||
pip3 install escpos
|
||||
pip3 install packaging
|
||||
pip3 install PySide6>=6.4.1
|
||||
|
||||
|
||||
|
|
|
@ -136,8 +136,6 @@ class ButtonsFunction(QGridLayout):
|
|||
|
||||
self.values.extend([
|
||||
['button_party', 'CLIENTE', 'action_party'],
|
||||
# ['button_cancel', 'CANCELAR', 'action_cancel'],
|
||||
# ['button_search_sale', 'BUSCAR ORDEN', 'action_search_sale'],
|
||||
['button_print_sale', 'IMPRIMIR', 'action_print_sale'],
|
||||
['button_delivery_party', 'DOMICILIARIO', 'action_delivery_party'],
|
||||
['button_position', 'POSICION', 'action_position'],
|
||||
|
@ -244,7 +242,7 @@ class ButtonsStacked(QWidget):
|
|||
method='action_payment_term'
|
||||
)
|
||||
|
||||
if pos_user != 'order':
|
||||
if pos_user not in ('order', 'salesman'):
|
||||
self.stacked.addWidget(self.button_accept)
|
||||
self.stacked.addWidget(self.button_checkout)
|
||||
self.stacked.addWidget(self.button_payment_method)
|
||||
|
@ -253,7 +251,7 @@ class ButtonsStacked(QWidget):
|
|||
if pos_user in ('cashier', 'frontend_admin'):
|
||||
hbox.addWidget(self.button_payment_term, 0)
|
||||
if parent.enviroment == 'retail':
|
||||
if pos_user == 'cashier':
|
||||
if pos_user == 'cashier' and getattr(parent, 'button_to_draft_active', None):
|
||||
self.button_to_draft = CustomButton(
|
||||
id='button_to_draft',
|
||||
parent=parent,
|
||||
|
@ -262,9 +260,8 @@ class ButtonsStacked(QWidget):
|
|||
name_style='toolbar',
|
||||
method='button_to_force_draft_pressed'
|
||||
)
|
||||
# hbox.addWidget(self.button_to_draft, 0)
|
||||
elif pos_user in ('order' ,'salesman'):
|
||||
|
||||
hbox.addWidget(self.button_to_draft, 0)
|
||||
elif pos_user in ('order', 'salesman'):
|
||||
self.button_send_order = CustomButton(
|
||||
id='button_send_to_pay',
|
||||
icon=get_icon('draft'),
|
||||
|
|
|
@ -6,7 +6,6 @@ import logging
|
|||
import base64
|
||||
import platform
|
||||
import time
|
||||
from packaging.version import parse as parse_version
|
||||
from decimal import Decimal
|
||||
from datetime import datetime, timedelta, date
|
||||
from collections import OrderedDict
|
||||
|
|
26
app/main.py
26
app/main.py
|
@ -157,7 +157,7 @@ class AppWindow(FrontWindow):
|
|||
orders, sale_number = self.Sale.get_order2print(args)
|
||||
result = self.receipt_order.print_orders(orders, kind='command')
|
||||
if result:
|
||||
self.Sale.mark_commanded({'sale_id': sale['id']})
|
||||
self.Sale.mark_commanded({'sale_id': sale['id'], 'lines_ids': result})
|
||||
except Exception as e:
|
||||
print(e)
|
||||
traceback.print_exc()
|
||||
|
@ -203,8 +203,8 @@ class AppWindow(FrontWindow):
|
|||
|
||||
def set_printers_usb(self, PATH_PRINTERS):
|
||||
for usb_dev in os.listdir(PATH_PRINTERS):
|
||||
# fix me return for set printer default usb
|
||||
return
|
||||
# # fix me return for set printer default usb
|
||||
# return
|
||||
if 'lp' not in usb_dev:
|
||||
continue
|
||||
path_device = os.path.join(PATH_PRINTERS, usb_dev)
|
||||
|
@ -266,6 +266,7 @@ class AppWindow(FrontWindow):
|
|||
self.set_default_printer()
|
||||
|
||||
def set_default_printer(self, printer=None):
|
||||
print(self.active_usb_printers, 'validate printers')
|
||||
if self.active_usb_printers:
|
||||
self.printer_sale_name = self.active_usb_printers[0]
|
||||
if not printer and self.printer_sale_name:
|
||||
|
@ -1063,7 +1064,8 @@ class AppWindow(FrontWindow):
|
|||
if self.print_receipt == 'automatic':
|
||||
_copies = self.shop['invoice_copies']
|
||||
if self.enviroment == 'restaurant':
|
||||
self.action_print_sale()
|
||||
for n in range(_copies):
|
||||
self.action_print_sale()
|
||||
else:
|
||||
if not is_credit:
|
||||
self.print_invoice(copies=_copies, open_box=True)
|
||||
|
@ -1073,11 +1075,6 @@ class AppWindow(FrontWindow):
|
|||
print('Error', e)
|
||||
logging.error(sys.exc_info()[0])
|
||||
|
||||
# if not is_credit and self._commission_activated:
|
||||
# agent_id = self.field_agent_ask.get_id()
|
||||
# if self.auto_print_commission and agent_id:
|
||||
# self.print_equivalent_invoice(self._sale['id'])
|
||||
|
||||
if self.sale_automatic and self.type_pos_user not in ('cashier', 'order'):
|
||||
self.create_new_sale()
|
||||
else:
|
||||
|
@ -1096,8 +1093,8 @@ class AppWindow(FrontWindow):
|
|||
data = self.Sale.get_data(args)
|
||||
if not data:
|
||||
return
|
||||
# set type_doc
|
||||
for i in range(copies):
|
||||
continue
|
||||
msg = self.receipt_sale.print_sale(data, type_doc, open_box)
|
||||
if isinstance(msg, dict) and msg.get('error'):
|
||||
self.dialog('print_error', extra_message=msg['error'])
|
||||
|
@ -1253,7 +1250,7 @@ class AppWindow(FrontWindow):
|
|||
total_amount = int(self._get_total_amount())
|
||||
value = int((self._config['tip_rate'] / 100) * total_amount)
|
||||
self.field_tip_amount_ask.setText(str(value))
|
||||
# else:
|
||||
|
||||
result = self.dialog_tip_amount.exec_()
|
||||
if result == 0:
|
||||
self.field_tip_amount_invoice.setChecked(False)
|
||||
|
@ -1806,7 +1803,7 @@ class AppWindow(FrontWindow):
|
|||
reversion,
|
||||
kind)
|
||||
if result:
|
||||
self.Sale.mark_commanded({'sale_id': sale_id})
|
||||
self.Sale.mark_commanded({'sale_id': sale_id, 'lines_ids': result})
|
||||
except Exception as e:
|
||||
print(e, 'error')
|
||||
logging.error('Printing order fail!')
|
||||
|
@ -2175,7 +2172,7 @@ class AppWindow(FrontWindow):
|
|||
self.message_bar.set('system_ready')
|
||||
if self.type_pos_user in ('cashier', 'order', 'salesman'):
|
||||
self.table_sale_lines.setEnabled(True)
|
||||
|
||||
|
||||
if self.enviroment == 'restaurant':
|
||||
if sale.get('table_assigned.'):
|
||||
self.field_table_assigned.setText(
|
||||
|
@ -2336,7 +2333,7 @@ class AppWindow(FrontWindow):
|
|||
list_price = 0
|
||||
qty_text = self.dialog_combo_product.label_qty_add.text()
|
||||
try:
|
||||
qty = int(qty_text) + 1
|
||||
qty = int(qty_text) + 1
|
||||
except:
|
||||
qty = 1
|
||||
self.dialog_combo_product.label_qty_add.setText(str(qty))
|
||||
|
@ -3451,7 +3448,6 @@ class AppWindow(FrontWindow):
|
|||
self.action_position()
|
||||
elif key == Qt.Key_Semicolon and self._commission_activated:
|
||||
sale = self.get_current_sale()
|
||||
print(sale, 'this is sale')
|
||||
if sale['state'] == 'draft' and self._state not in ['checkout', 'payment']:
|
||||
self.action_agent()
|
||||
elif key == Qt.Key_QuoteDbl:
|
||||
|
|
|
@ -66,13 +66,12 @@ def money(value):
|
|||
|
||||
|
||||
dev_printers = {}
|
||||
# if os.name == 'posix' and pyudev:
|
||||
# context = pyudev.Context()
|
||||
# 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
|
||||
# pass
|
||||
if os.name == 'posix' and pyudev:
|
||||
context = pyudev.Context()
|
||||
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
|
||||
|
||||
|
||||
class Receipt(object):
|
||||
|
@ -452,27 +451,28 @@ class Receipt(object):
|
|||
|
||||
def print_tasks(self, data):
|
||||
for value in data.values():
|
||||
self._printer = None
|
||||
self.config_printer(value['printer'])
|
||||
self.set_printer()
|
||||
title = value['sale'] + ' - ' + value['work_station']
|
||||
self._printer.set(custom_size=True, width=2,
|
||||
height=2, align='center')
|
||||
self._printer.textln(title)
|
||||
self._printer.set(bold=False, custom_size=True, width=1,
|
||||
height=2, align='left')
|
||||
self._printer.ln(2)
|
||||
for ln in value['lines']:
|
||||
line_ = str(int(ln['qty'])) + ' ' + ln['name']
|
||||
self._printer.textln(line_)
|
||||
# if ln.get('description'):
|
||||
# self._printer.textln(ln.get('description'))
|
||||
if ln.get('note'):
|
||||
self._printer.textln('NOTA:' + ln.get('note'))
|
||||
try:
|
||||
self._printer = None
|
||||
self.config_printer(value['printer'])
|
||||
self.set_printer()
|
||||
title = value['sale'] + ' - ' + value['work_station']
|
||||
self._printer.set(custom_size=True, width=2,
|
||||
height=2, align='center')
|
||||
self._printer.textln(title)
|
||||
self._printer.set(bold=False, custom_size=True, width=1,
|
||||
height=2, align='left')
|
||||
self._printer.ln(2)
|
||||
self._printer.cut()
|
||||
# if value['printer']['interface'] != 'network':
|
||||
self._printer.close()
|
||||
for ln in value['lines']:
|
||||
line_ = str(int(ln['qty'])) + ' ' + ln['name']
|
||||
self._printer.textln(line_)
|
||||
if ln.get('note'):
|
||||
self._printer.textln('NOTA:' + ln.get('note'))
|
||||
self._printer.ln(2)
|
||||
self._printer.cut()
|
||||
self._printer.close()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
traceback.print_exc()
|
||||
|
||||
def print_header(self, short=False):
|
||||
if not short:
|
||||
|
@ -853,7 +853,7 @@ class Receipt(object):
|
|||
for order in orders.values():
|
||||
try:
|
||||
self._printer = None
|
||||
if dev_printers.get(order['host']):
|
||||
if dev_printers.get(order['host']) and kind != 'command':
|
||||
host = dev_printers[order['host']]
|
||||
else:
|
||||
host = order['host']
|
||||
|
@ -886,12 +886,14 @@ class Receipt(object):
|
|||
if not self._printer:
|
||||
self.logger.info(
|
||||
"Warning: Interface not found for printer!")
|
||||
res.append(None)
|
||||
# res.append(None)
|
||||
return False
|
||||
|
||||
self.logger.info("Info: Printer is OK!")
|
||||
try:
|
||||
res.append(self._print_order(order, reversion))
|
||||
self._print_order(order, reversion)
|
||||
# if True:
|
||||
res.extend(order['lines_ids'])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
traceback.print_exc()
|
||||
|
@ -900,16 +902,13 @@ class Receipt(object):
|
|||
print(e)
|
||||
traceback.print_exc()
|
||||
self.logger.info("Warning: Can not found Printer!")
|
||||
res.append(None)
|
||||
return all(res)
|
||||
return res
|
||||
|
||||
def _print_order(self, order, reversion):
|
||||
print(self.order_copies, 'cantidad de copias')
|
||||
for copie in range(self.order_copies):
|
||||
self.print_body_order(order, reversion)
|
||||
self._print_info_consumer(order)
|
||||
self._printer.cut()
|
||||
# self._row_characters = order['row_characters']
|
||||
return True
|
||||
|
||||
def print_body_order(self, order, reversion):
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = "6.0.20"
|
||||
__version__ = "6.0.21"
|
||||
|
|
|
@ -43,6 +43,10 @@ auto_print_commission=False
|
|||
|
||||
active_timeout=True
|
||||
|
||||
#button_to_draft_active=True
|
||||
|
||||
#server_printer=True
|
||||
|
||||
timeout=10000
|
||||
|
||||
tablet_mode=False
|
||||
|
|
1
setup.py
1
setup.py
|
@ -71,7 +71,6 @@ setup(
|
|||
'paramiko',
|
||||
'orjson',
|
||||
'escpos',
|
||||
'packaging',
|
||||
'PySide6>=6.4.1'
|
||||
]
|
||||
)
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
import os
|
||||
|
||||
pat = '/dev/usb/lp2'
|
||||
|
||||
print(os.path.exists(pat))
|
||||
|
||||
from app.reporting import Receipt
|
||||
|
||||
fake_data = {
|
||||
"12": {
|
||||
"printer": {
|
||||
"device": "172.16.10.31",
|
||||
"interface": "network",
|
||||
"profile": "",
|
||||
"row_characters": None
|
||||
},
|
||||
"sale": 'RES00234',
|
||||
"work_station": 'POSTRES',
|
||||
"lines": [
|
||||
{
|
||||
"name": "ASADO DE CARNE HAMBURGUESA",
|
||||
"description": "ASAR CARNE DE HAMBURGUESA",
|
||||
"qty": 1.0,
|
||||
"note": 'sin salsa'
|
||||
},
|
||||
{
|
||||
"name": "PREPARACION DE ENSALADA DE VEGETALES",
|
||||
"description": "ENSALADA DE VEGETALES Y VERDURAS",
|
||||
"qty": 1.0,
|
||||
"note": 'sin salsa'
|
||||
}
|
||||
]
|
||||
},
|
||||
# "13": {
|
||||
# "printer": {
|
||||
# "device": "/dev/usb/lp0",
|
||||
# "interface": "usb",
|
||||
# "profile": "",
|
||||
# "row_characters": 48
|
||||
# },
|
||||
# "sale": {
|
||||
# "number": None
|
||||
# },
|
||||
# "lines": [
|
||||
# {
|
||||
# "name": "PREPARACION DE PAPAS",
|
||||
# "description": "PAPAS A LA FRANCESA",
|
||||
# "qty": 1.0,
|
||||
# "note": 'sin salsa'
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
}
|
||||
|
||||
receipt = Receipt(context={}, environment='restaurant')
|
||||
receipt.print_tasks(fake_data)
|
Loading…
Reference in New Issue