1075 lines
39 KiB
Python
1075 lines
39 KiB
Python
|
|
from .commons.dialogs import HelpDialog, QuickDialog
|
|
from PyQt5.QtCore import Qt
|
|
from PyQt5.QtWidgets import (
|
|
QCheckBox, QTextEdit, QVBoxLayout, QGridLayout, QLineEdit, QPlainTextEdit,
|
|
QScrollArea, QHBoxLayout, QDoubleSpinBox, QLabel,
|
|
)
|
|
|
|
from .proxy import FastReport
|
|
from .buttonpad import ButtonsFunction
|
|
from .constants import alignCenter, alignLeft, FRACTIONS, TYPE_VEHICLE
|
|
from .commons.forms import FieldMoney, ComboBox, GridForm
|
|
from .commons.search_window import SearchWindow
|
|
from collections import OrderedDict
|
|
from .manage_tables import ManageTables
|
|
from app.commons.menu_buttons import GridButtons
|
|
from app.commons.table import TableView
|
|
from .commons.custom_button import CustomButton
|
|
from .tools import get_icon, get_screen
|
|
|
|
__all__ = [
|
|
'ControlPanel', 'SearchSale', 'SearchParty', 'SearchProduct', 'EditLine',
|
|
'Comment', 'Position', 'DialogPayment', 'DialogTaxes', 'DialogChannel',
|
|
'DialogTableMoneyCount', 'DialogTableDeliveryParty', 'DialogDeliveryParty',
|
|
'Help', 'DeliveryPartySelected', 'DialogPrintInvoice', 'DialogStock',
|
|
'DialogAuthDiscounts', 'DialogSalesmanCode', 'DialogAgent',
|
|
'DialogOrder', 'DialogGlobalDiscount', 'DialogVoucher', 'DialogConsumer',
|
|
'DialogManageTables', 'DialogTableSaleConsumer', 'SaleConsumerSelected',
|
|
'DialogCancelInvoice', 'DialogForceAssign', 'AdditionProduct',
|
|
'DialogReports', 'DialogFixedDiscounts',
|
|
]
|
|
|
|
WIZARDS = {
|
|
'square_box_report': {
|
|
'name': 'sale_pos_frontend.sale_square_box_report',
|
|
'ctx_fields': ('company', 'shop'),
|
|
'fields': [
|
|
('date', {
|
|
'name': 'FECHA',
|
|
'type': 'date',
|
|
}),
|
|
('turn', {
|
|
'name': 'TURNO',
|
|
'type': 'selection',
|
|
'values': [('', ''), ('1', '1'), ('2', '2'), ('3', '3')],
|
|
}),
|
|
],
|
|
},
|
|
'delivery_report': {
|
|
'fields': [
|
|
('date', {
|
|
'name': 'FECHA',
|
|
'type': 'date',
|
|
}),
|
|
],
|
|
}
|
|
}
|
|
|
|
|
|
def create_vbox(parent, values, method, columns=4):
|
|
vbox_ = QVBoxLayout()
|
|
|
|
grid = QGridLayout()
|
|
grid.setSpacing(2)
|
|
if isinstance(method, str):
|
|
method = getattr(parent, method)
|
|
grid_buttons = GridButtons(parent, values, columns, action=method,
|
|
style='standard_button')
|
|
|
|
vbox_.setObjectName('grid_buttons')
|
|
scroll_area = QScrollArea()
|
|
scroll_area.setWidgetResizable(True)
|
|
scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
|
scroll_area.setWidget(grid_buttons)
|
|
grid.addWidget(scroll_area)
|
|
vbox_.addLayout(grid)
|
|
return vbox_
|
|
|
|
|
|
class ControlPanel(QuickDialog):
|
|
def __init__(self, parent):
|
|
vbox_ = QVBoxLayout()
|
|
grid = QGridLayout()
|
|
scroll_area = QScrollArea()
|
|
scroll_area.setLayout(parent.menu_control_panel)
|
|
grid.addWidget(scroll_area)
|
|
vbox_.addLayout(grid)
|
|
width, height = get_screen()
|
|
super(ControlPanel, self).__init__(parent, 'action', widgets=[vbox_])
|
|
self.setFixedSize(width * 0.5, height * 0.5)
|
|
self.setWindowTitle('PANEL DE CONTROL')
|
|
|
|
|
|
class DialogReports(QuickDialog):
|
|
def __init__(self, parent):
|
|
super(DialogReports, self).__init__(parent, 'action')
|
|
vbox = QVBoxLayout()
|
|
grid = QGridLayout()
|
|
scroll_area = QScrollArea()
|
|
_reports = [
|
|
('button_square_box', 'CUADRE DE CAJA', 'action_square_box_report'),
|
|
('button_terminal_journal', 'PAGOS ELECTRONICOS', 'action_terminal_journal_report'),
|
|
('button_delivery_report', 'ENTREGA DOMICILIARIOS', 'action_delivery_report'),
|
|
]
|
|
self.reports = ButtonsFunction(parent, values=_reports)
|
|
self.parent = parent
|
|
scroll_area.setLayout(self.reports)
|
|
grid.addWidget(scroll_area)
|
|
vbox.addLayout(grid)
|
|
width, height = get_screen()
|
|
self.setFixedSize(width * 0.5, height * 0.5)
|
|
self.setWindowTitle('REPORTES')
|
|
self.add_widget(vbox)
|
|
|
|
def open_wizard(self, report, add_fields=None, open_print=False):
|
|
vbox = QVBoxLayout()
|
|
wiz_report = WIZARDS[report]
|
|
fields = wiz_report['fields']
|
|
print(fields)
|
|
if add_fields:
|
|
fields.append(add_fields)
|
|
fields = OrderedDict(fields)
|
|
self.form = GridForm(self, fields, col=2)
|
|
vbox.addLayout(self.form)
|
|
dialog = QuickDialog(self, 'action', widgets=[vbox])
|
|
result = dialog.exec()
|
|
store = self.form.getStore()
|
|
values = {}
|
|
for cf in wiz_report.get('ctx_fields', []):
|
|
values[cf] = self.parent.ctx[cf]
|
|
|
|
values.update(store)
|
|
if result == 1:
|
|
if open_print:
|
|
return values
|
|
else:
|
|
report_name = wiz_report['name']
|
|
self.open_report(report_name, values)
|
|
|
|
def open_report(self, report_name, data):
|
|
report = FastReport(self.parent.ctx)
|
|
values = {
|
|
'report_name': report_name,
|
|
'args': data,
|
|
}
|
|
result = report.get(values)
|
|
report.open(result)
|
|
|
|
|
|
class SearchSale(SearchWindow):
|
|
def __init__(self, parent):
|
|
headers = OrderedDict()
|
|
headers['id'] = {'desc': 'ID', 'type': 'char'}
|
|
headers['number'] = {'desc': 'NUMERO', 'type': 'char'}
|
|
headers['invoice_number'] = {'desc': 'FACTURA', 'type': 'char'}
|
|
headers['party.name'] = {'desc': 'CLIENTE', 'type': 'char'}
|
|
headers['salesman.rec_name'] = {'desc': 'VENDEDOR', 'type': 'char'}
|
|
widths = [20, 115, 115, 180, 160]
|
|
|
|
if parent._sale_pos_restaurant:
|
|
headers['kind_string'] = {'desc': 'CLASE', 'type': 'char'}
|
|
widths.append(110)
|
|
headers['consumer.rec_name'] = {'desc': 'CONSUMIDOR', 'type': 'char'}
|
|
widths.append(320)
|
|
else:
|
|
headers['sale_date'] = {'desc': 'FECHA', 'type': 'char'}
|
|
widths.append(80)
|
|
|
|
headers['position'] = {'desc': 'POSICION', 'type': 'char'}
|
|
widths.append(130)
|
|
headers['total_amount_cache'] = {'desc': 'VALOR TOTAL', 'type': 'number'}
|
|
widths.append(90)
|
|
|
|
title = ('SEARCH SALES...')
|
|
methods = {
|
|
'on_selected_method': 'on_selected_sale',
|
|
'on_return_method': 'on_selected_sale'
|
|
}
|
|
super(SearchSale, self).__init__(parent, headers, None, methods,
|
|
filter_column=[2, 3, 4, 5, 6, 7], cols_width=widths,
|
|
title=title, fill=True)
|
|
|
|
|
|
class SearchParty(SearchWindow):
|
|
def __init__(self, parent):
|
|
headers = OrderedDict()
|
|
headers['id'] = {'desc': 'ID', 'type': 'char'}
|
|
headers['id_number'] = {'desc': 'NUMERO ID', 'type': 'char'}
|
|
headers['name'] = {'desc': 'NOMBRE', 'type': 'char'}
|
|
headers['street'] = {'desc': 'DIRECCION', 'type': 'char'}
|
|
headers['phone'] = {'desc': 'TELEFONO', 'type': 'char'}
|
|
title = 'BUSCAR CLIENTE'
|
|
methods = {
|
|
'on_selected_method': 'on_selected_party',
|
|
'on_return_method': 'on_search_party',
|
|
}
|
|
super(SearchParty, self).__init__(parent, headers, None, methods,
|
|
filter_column=[], cols_width=[60, 120, 270, 190, 90],
|
|
title=title, fill=True)
|
|
|
|
|
|
class SearchProduct(SearchWindow):
|
|
def __init__(self, parent):
|
|
_cols_width = [10, 80]
|
|
headers = OrderedDict()
|
|
headers['id'] = {'desc': ('ID'), 'type': 'char'}
|
|
headers['code'] = {'desc': ('COD'), 'type': 'char'}
|
|
if parent._config.get('show_stock_pos') in ['icon', 'value']:
|
|
headers['quantity'] = {'desc': ('STOCK'), 'type': 'char'}
|
|
if parent._config['show_stock_pos'] == 'icon':
|
|
headers['quantity']['icon'] = 'stock'
|
|
headers['quantity']['type'] = 'icon'
|
|
_cols_width.append(60)
|
|
|
|
if not parent.cache_local:
|
|
headers['name'] = {'desc': 'NOMBRE', 'type': 'char'}
|
|
else:
|
|
headers['template.name'] = {'desc': 'NOMBRE', 'type': 'char'}
|
|
|
|
_cols_width.append(350)
|
|
|
|
if parent._config.get('show_description_pos'):
|
|
headers['description'] = {'desc': 'DESCRIPCION', 'type': 'char'}
|
|
_cols_width.append(300)
|
|
|
|
if parent._config.get('show_brand'):
|
|
headers['template.brand'] = {'desc': 'BRAND', 'type': 'char'}
|
|
_cols_width.append(100)
|
|
|
|
price = {'desc': ('PRICE'), 'type': 'number'}
|
|
if not parent._config.get('encoded_sale_price'):
|
|
headers['template.sale_price_w_tax'] = price
|
|
else:
|
|
price['type'] = 'char'
|
|
headers['encoded_sale_price'] = price
|
|
|
|
_cols_width.append(100)
|
|
|
|
if parent._config.get('show_location_pos'):
|
|
headers['location.name'] = {'desc': 'BODEGA', 'type': 'char'}
|
|
_cols_width.append(100)
|
|
|
|
if parent._config['show_product_image']:
|
|
headers['image'] = {'desc': 'IMAGEN', 'icon': 'image', 'type': 'icon'}
|
|
_cols_width.append(30)
|
|
|
|
methods = {
|
|
'on_selected_method': 'on_selected_product',
|
|
'on_return_method': 'on_search_product',
|
|
'image': parent.on_selected_icon_product,
|
|
'quantity': parent.on_selected_stock_product
|
|
}
|
|
fields_names = list(headers.keys())
|
|
try:
|
|
fields_names.remove('image')
|
|
except:
|
|
pass
|
|
self.fields_names = fields_names
|
|
super(SearchProduct, self).__init__(parent, headers, None, methods,
|
|
cols_width=_cols_width, fill=True)
|
|
|
|
|
|
class DialogManageTables(QuickDialog):
|
|
def __init__(self, parent):
|
|
self.parent = parent
|
|
if not parent._sale_pos_restaurant:
|
|
return
|
|
tables = parent.RestTables.find([
|
|
('shop', '=', parent.shop['id'])
|
|
])
|
|
self.manager = ManageTables(parent, tables)
|
|
width, height = get_screen()
|
|
super(DialogManageTables, self).__init__(parent, 'action',
|
|
widgets=[self.manager])
|
|
self.setFixedSize(width / 1.5, height / 1.5)
|
|
|
|
def exec_(self):
|
|
self.open_tables()
|
|
super(DialogManageTables, self).exec_()
|
|
|
|
def open_tables(self):
|
|
tables = self.parent.RestTables.find([
|
|
('shop', '=', self.parent.shop['id'])
|
|
])
|
|
self.manager.update_records(tables)
|
|
|
|
|
|
class DialogConsumer(QuickDialog):
|
|
def __init__(self, parent):
|
|
self._parent = parent
|
|
self._parent.state_consumer = {}
|
|
self._parent._consumer = None
|
|
vbox_consumer = QVBoxLayout()
|
|
grid = QGridLayout()
|
|
|
|
label_phone = QLabel('TELEFONO:')
|
|
label_phone.setObjectName('label_phone')
|
|
grid.addWidget(label_phone, 1, 1)
|
|
self._parent.form_consumer_phone = QLineEdit()
|
|
self._parent.form_consumer_phone.setObjectName('row_field_phone')
|
|
self._parent.form_consumer_phone.editingFinished.connect(
|
|
lambda: self._parent.update_consumer('phone'))
|
|
grid.addWidget(self._parent.form_consumer_phone, 1, 2)
|
|
|
|
label_consumer = QLabel('CONSUMIDOR:')
|
|
label_consumer.setObjectName('label_consumer')
|
|
grid.addWidget(label_consumer, 2, 1)
|
|
self._parent.form_consumer_name = QLineEdit()
|
|
self._parent.form_consumer_name.setObjectName('form_consumer_name')
|
|
self._parent.form_consumer_name.textChanged.connect(
|
|
lambda: self._parent.update_consumer('name'))
|
|
grid.addWidget(self._parent.form_consumer_name, 2, 2)
|
|
|
|
label_address = QLabel('DIRECCION:')
|
|
label_address.setObjectName('label_address')
|
|
grid.addWidget(label_address, 3, 1)
|
|
self._parent.form_consumer_address = QLineEdit()
|
|
self._parent.form_consumer_address.setObjectName('form_consumer_address')
|
|
self._parent.form_consumer_address.textChanged.connect(
|
|
lambda: self._parent.update_consumer('address'))
|
|
grid.addWidget(self._parent.form_consumer_address, 3, 2)
|
|
|
|
label_id_number = QLabel('NUMERO ID:')
|
|
label_id_number.setObjectName('label_id_number')
|
|
grid.addWidget(label_id_number, 4, 1)
|
|
self._parent.form_consumer_id_number = QLineEdit()
|
|
self._parent.form_consumer_id_number.setObjectName('form_consumer_id_number')
|
|
self._parent.form_consumer_id_number.textChanged.connect(
|
|
lambda: self._parent.update_consumer('id_number'))
|
|
grid.addWidget(self._parent.form_consumer_id_number, 4, 2)
|
|
|
|
label_notes = QLabel('NOTAS:')
|
|
label_notes.setObjectName('label_notes')
|
|
grid.addWidget(label_notes, 6, 1)
|
|
self._parent.form_consumer_notes = QPlainTextEdit()
|
|
self._parent.form_consumer_notes.setObjectName('form_consumer_notes')
|
|
self._parent.form_consumer_notes.textChanged.connect(
|
|
lambda: self._parent.update_consumer('notes')
|
|
)
|
|
grid.addWidget(self._parent.form_consumer_notes, 6, 2)
|
|
grid.setVerticalSpacing(15)
|
|
grid.addWidget(self.get_button(), 7, 1, 1, 2)
|
|
|
|
vbox_consumer.addLayout(grid)
|
|
super(DialogConsumer, self).__init__(parent, 'action',
|
|
widgets=[vbox_consumer])
|
|
self.setWindowTitle('CONSUMIDOR')
|
|
width, height = get_screen()
|
|
self.setGeometry(0, 0, width * 0.4, height * 0.7)
|
|
self.accepted.connect(self._parent.dialog_search_consumer_accepted)
|
|
|
|
def get_button(self):
|
|
self._parent.button_history_customer = CustomButton(
|
|
id='button_history_customer',
|
|
parent=self._parent,
|
|
icon=get_icon('history'),
|
|
title='HISTORIAL DE VENTAS',
|
|
name_style='toolbar',
|
|
method='button_sale_consumer_history'
|
|
)
|
|
self._parent.button_history_customer.setVisible(False)
|
|
return self._parent.button_history_customer
|
|
|
|
def clear(self, phone=True):
|
|
# FIXME
|
|
# if phone:
|
|
# self.form_consumer_phone.setText('')
|
|
# self.form_consumer_name.setText('')
|
|
# self.form_consumer_address.setText('')
|
|
# self.form_consumer_id_number.setText('')
|
|
# self.form_consumer_consumer_notes.clear()
|
|
# self.button_history_customer.setVisible(False)
|
|
pass
|
|
|
|
|
|
class DialogTableSaleConsumer(QuickDialog):
|
|
def __init__(self, parent):
|
|
col_sizes_tlines = [
|
|
field['width'] for field in parent.fields_sale_consumer
|
|
]
|
|
table = TableView('model_sale_consumer',
|
|
parent.model_sale_consumer, col_sizes_tlines,
|
|
method_selected_row=parent.sale_consumer_selected
|
|
)
|
|
|
|
width, height = get_screen()
|
|
table.horizontalHeader().setStretchLastSection(True)
|
|
vbox_ = QVBoxLayout()
|
|
|
|
layout = QVBoxLayout()
|
|
layout.addWidget(table)
|
|
layout.setAlignment(alignCenter)
|
|
|
|
vbox_.addLayout(layout)
|
|
vbox_.addSpacing(10)
|
|
super(DialogTableSaleConsumer, self).__init__(parent, 'action',
|
|
widgets=[vbox_])
|
|
self.setWindowTitle('VENTAS POR CONSUMIDOR')
|
|
self.setFixedSize(width * 0.6, height * 0.7)
|
|
|
|
|
|
class SaleConsumerSelected(QuickDialog):
|
|
def __init__(self, parent):
|
|
self._parent = parent
|
|
vbox_ = QVBoxLayout()
|
|
_fields = [
|
|
('party', {
|
|
'name': 'CLIENTE',
|
|
'readonly': True,
|
|
}),
|
|
('number', {
|
|
'name': 'NUMERO',
|
|
'readonly': True,
|
|
}),
|
|
('sale_date', {
|
|
'name': 'FECHA',
|
|
'readonly': True,
|
|
}),
|
|
('invoice_number', {
|
|
'name': 'FACTURA',
|
|
'readonly': True,
|
|
}),
|
|
('total_amount_cache', {
|
|
'name': 'TOTAL',
|
|
'readonly': True,
|
|
'type': 'money',
|
|
}),
|
|
]
|
|
fields = OrderedDict(_fields)
|
|
self.grid = GridForm(self, fields, col=2)
|
|
col_sizes_tlines = [field['width'] for field in parent.fields_sale_line]
|
|
self.table = TableView('model_sale_lines',
|
|
parent.model_sale_customer_lines, col_sizes_tlines
|
|
)
|
|
self.grid.addWidget(self.table, 4, 1, 1, 4)
|
|
vbox_.addLayout(self.grid)
|
|
super(SaleConsumerSelected, self).__init__(parent, 'action',
|
|
widgets=[vbox_])
|
|
|
|
self.grid.addWidget(self.get_button(), 5, 3, 3, 4)
|
|
width, height = get_screen()
|
|
self.setFixedSize(width * 0.5, height * 0.6)
|
|
|
|
def start(self, data):
|
|
self.sale_customer_selected = data['id']
|
|
self.field_party.setText(data['party']['name'])
|
|
self.field_number.setText(data['number'])
|
|
self.field_sale_date.setText(data['sale_date'])
|
|
self.field_total_amount_cache.setText(str(data['total_amount_cache']))
|
|
self.field_invoice_number.setText(str(data['invoice_number']))
|
|
self.table.model.reset()
|
|
for line in data['lines']:
|
|
self.table.model.add_record(line)
|
|
self.exec_()
|
|
|
|
def get_button(self):
|
|
button_duplicate_sale = CustomButton(
|
|
id='button_duplicate_sale',
|
|
parent=self,
|
|
icon=get_icon('duplicate_sale'),
|
|
title=('DUPLICAR VENTA'),
|
|
name_style='toolbar',
|
|
method='button_duplicate_sale'
|
|
)
|
|
return button_duplicate_sale
|
|
|
|
def button_duplicate_sale(self):
|
|
if self.sale_customer_selected:
|
|
res = self._parent.Sale.duplicate_sale({
|
|
'sale_id': self.sale_customer_selected,
|
|
})
|
|
self.dialog_search_consumer.close()
|
|
self.dialog_table_sale_consumer.close()
|
|
self.dialog_sale_consumer_selected.close()
|
|
# FIXME
|
|
# self.load_sale(res['sale_id'])
|
|
return res
|
|
|
|
|
|
class DialogAgent(QuickDialog):
|
|
def __init__(self, parent):
|
|
view = [
|
|
('agent_ask', {
|
|
'name': 'AGENTE',
|
|
'type': 'relation',
|
|
'model': parent.Agent,
|
|
'domain': [],
|
|
'fields': [
|
|
('id', 'ID'),
|
|
('party.rec_name', 'NOMBRE'),
|
|
('party.id_number', 'NUMERO ID'),
|
|
]
|
|
}),
|
|
('commission_ask', {'name': 'COMISION'}),
|
|
('commission_amount', {'name': 'VALOR', 'readonly': True}),
|
|
]
|
|
super(DialogAgent, self).__init__(parent, 'action', data=view)
|
|
|
|
|
|
class DialogCancelInvoice(QuickDialog):
|
|
def __init__(self, parent):
|
|
view = [
|
|
('password_for_cancel_ask', {
|
|
'name': 'INGRESE LA CONTRASEÑA',
|
|
'password': True
|
|
}),
|
|
]
|
|
super(DialogCancelInvoice, self).__init__(parent, 'action', data=view)
|
|
|
|
|
|
class DialogForceAssign(QuickDialog):
|
|
def __init__(self, parent):
|
|
field = 'password_force_assign_ask'
|
|
data = (field, {'name': 'CONTRASEÑA DE FORZAR ASIGNACION'})
|
|
super(DialogForceAssign, self).__init__(parent, 'action', data=[data])
|
|
|
|
|
|
class DialogOrder(QuickDialog):
|
|
def __init__(self, parent):
|
|
string = 'DESEA CONFIRMAR EL ENVIO DE LA ORDEN?'
|
|
super(DialogOrder, self).__init__(parent, 'action', string, data=[])
|
|
|
|
|
|
class DialogStock(QuickDialog):
|
|
def __init__(self, parent):
|
|
data = {
|
|
'name': 'stock',
|
|
'values': [],
|
|
'heads': ['BODEGA', 'CANTIDAD'],
|
|
}
|
|
label = 'STOCK POR PRODUCTO:'
|
|
super(DialogStock, self).__init__(parent, 'selection', label,
|
|
data, readonly=True)
|
|
|
|
|
|
class DialogGlobalDiscount(QuickDialog):
|
|
def __init__(self, parent):
|
|
field = 'global_discount_ask'
|
|
data = (field, {'name': 'DESCUENTO GLOBAL'})
|
|
super(DialogGlobalDiscount, self).__init__(parent, 'action', data=[data])
|
|
|
|
|
|
class DialogPrintInvoice(QuickDialog):
|
|
def __init__(self, parent):
|
|
view = [
|
|
('invoice_number_ask', {'name': 'ORDEN / FACTURA'}),
|
|
('type_ask', {
|
|
'name': 'TIPO',
|
|
'type': 'selection',
|
|
'values': [
|
|
('invoice', 'FACTURA'),
|
|
('order', 'ORDEN'),
|
|
# ('delivery', ('DELIVERY'))
|
|
],
|
|
}),
|
|
('printer_ask', {
|
|
'name': 'IMPRESORA',
|
|
'type': 'selection',
|
|
'values': [
|
|
(1, 'POS'),
|
|
(2, 'LASER')
|
|
],
|
|
}),
|
|
]
|
|
super(DialogPrintInvoice, self).__init__(parent, 'action', data=view)
|
|
|
|
|
|
class DialogVoucher(QuickDialog):
|
|
def __init__(self, parent):
|
|
data = ('voucher_ask', {'name': 'NUMERO DE COMPROBANTE'})
|
|
super(DialogVoucher, self).__init__(parent, 'action', data=[data])
|
|
|
|
|
|
class DialogAuthDiscounts(QuickDialog):
|
|
def __init__(self, parent):
|
|
vbox_discounts = create_vbox(
|
|
parent,
|
|
parent.discounts,
|
|
parent.on_selected_discount
|
|
)
|
|
width, height = get_screen()
|
|
super(DialogAuthDiscounts, self).__init__(parent, 'action',
|
|
size=(width * 0.8, height * 0.8), widgets=[vbox_discounts])
|
|
self.setWindowTitle('DESCUENTOS AUTORIZADOS')
|
|
|
|
|
|
class DialogFixedDiscounts(QuickDialog):
|
|
def __init__(self, parent):
|
|
widgets = create_vbox(
|
|
parent,
|
|
parent.discounts_fixed,
|
|
parent.on_selected_discount
|
|
)
|
|
width, height = get_screen()
|
|
super(DialogFixedDiscounts, self).__init__(parent, 'action',
|
|
widgets=[widgets])
|
|
self.setFixedSize(width * 0.8, height * 0.7)
|
|
self.setWindowTitle('DESCUENTO/BONO')
|
|
|
|
|
|
class DialogDeliveryParty(QuickDialog):
|
|
def __init__(self, parent):
|
|
vbox_ = create_vbox(
|
|
parent,
|
|
parent.delivery_parties,
|
|
parent.on_selected_delivery_party,
|
|
)
|
|
width, height = get_screen()
|
|
super(DialogDeliveryParty, self).__init__(parent, 'action',
|
|
widgets=[vbox_])
|
|
self.setWindowTitle('ESCOJE EL DOMICILIARIO')
|
|
self.setFixedSize(width * 0.8, height * 0.7)
|
|
|
|
|
|
class DeliveryPartySelected(QuickDialog):
|
|
def __init__(self, parent):
|
|
parent.state_delivery_party = {}
|
|
vbox_ = QVBoxLayout()
|
|
grid = QGridLayout()
|
|
|
|
label_delivery_party = QLabel('DOMICILIARIO:')
|
|
label_delivery_party.setAlignment(alignCenter)
|
|
label_delivery_party.setObjectName('label_delivery_party')
|
|
grid.addWidget(label_delivery_party, 1, 1)
|
|
parent.row_delivery_party = QLineEdit()
|
|
parent.row_delivery_party.setObjectName('row_delivery_party')
|
|
parent.row_delivery_party.textChanged.connect(
|
|
lambda: parent.update_delivery_party('delivery_party'))
|
|
grid.addWidget(parent.row_delivery_party, 1, 2)
|
|
|
|
label_id_number = QLabel('NUMERO ID:')
|
|
label_id_number.setAlignment(alignCenter)
|
|
label_id_number.setObjectName('label_id_number')
|
|
grid.addWidget(label_id_number, 2, 1)
|
|
parent.row_id_number = QLineEdit()
|
|
parent.row_id_number.setObjectName('row_id_number')
|
|
parent.row_id_number.textChanged.connect(
|
|
lambda: parent.update_delivery_party('id_number'))
|
|
grid.addWidget(parent.row_id_number, 2, 2)
|
|
|
|
label_number_plate = QLabel('PLACA:')
|
|
label_number_plate.setAlignment(alignCenter)
|
|
label_number_plate.setObjectName('label_number_plate')
|
|
grid.addWidget(label_number_plate, 3, 1)
|
|
parent.row_number_plate = QLineEdit()
|
|
parent.row_number_plate.setObjectName('row_number_plate')
|
|
parent.row_number_plate.textChanged.connect(
|
|
lambda: parent.update_delivery_party('number_plate'))
|
|
grid.addWidget(parent.row_number_plate, 3, 2)
|
|
|
|
label_phone = QLabel('TELEFONO:')
|
|
label_phone.setAlignment(alignCenter)
|
|
label_phone.setObjectName('label_phone')
|
|
grid.addWidget(label_phone, 4, 1)
|
|
parent.row_phone = QLineEdit()
|
|
parent.row_phone.setObjectName('row_phone')
|
|
parent.row_phone.textChanged.connect(
|
|
lambda: parent.update_delivery_party('row_phone'))
|
|
grid.addWidget(parent.row_phone, 4, 2)
|
|
|
|
label_type_vehicle = QLabel('TIPO DE VEHICULO:')
|
|
label_type_vehicle.setAlignment(alignCenter)
|
|
label_type_vehicle.setObjectName('label_type_vehicle')
|
|
grid.addWidget(label_type_vehicle, 5, 1)
|
|
parent.row_type_vehicle = ComboBox(parent,
|
|
'TIPO DE VEHICULO', {'values': TYPE_VEHICLE})
|
|
parent.row_type_vehicle.setObjectName('row_type_vehicle')
|
|
parent.row_type_vehicle.currentIndexChanged.connect(
|
|
lambda: parent.update_delivery_party('type_vehicle'))
|
|
grid.addWidget(parent.row_type_vehicle, 5, 2)
|
|
|
|
label_delivery_party_active = QLabel('ACTIVO:')
|
|
label_delivery_party_active.setAlignment(alignCenter)
|
|
label_delivery_party_active.setObjectName('label_delivery_party_active')
|
|
grid.addWidget(label_delivery_party_active, 6, 1)
|
|
parent.row_delivery_party_active = QCheckBox()
|
|
parent.row_delivery_party_active.setObjectName('row_delivery_party_active')
|
|
parent.row_delivery_party_active.stateChanged.connect(
|
|
lambda: parent.update_delivery_party('delivery_party_active'))
|
|
grid.addWidget(parent.row_delivery_party_active, 6, 2)
|
|
|
|
vbox_.addLayout(grid)
|
|
super(DeliveryPartySelected, self).__init__(parent, 'action',
|
|
widgets=[vbox_])
|
|
self.accepted.connect(parent.dialog_delivery_party_accepted)
|
|
|
|
|
|
class DialogTableDeliveryParty(QuickDialog):
|
|
def __init__(self, parent):
|
|
self._parent = parent
|
|
col_sizes_tlines = [field['width'] for field in parent.fields_delivery_party]
|
|
table = TableView('model_delivery_party',
|
|
parent.model_delivery_party, col_sizes_tlines,
|
|
method_selected_row=parent.delivery_party_selected
|
|
)
|
|
width, height = get_screen()
|
|
table.setFixedSize(width/2.2, height/2.2)
|
|
vbox_ = QVBoxLayout()
|
|
|
|
grid = QGridLayout()
|
|
grid.addWidget(table, 1, 1, 1, 2)
|
|
grid.setVerticalSpacing(20)
|
|
grid.addWidget(self.get_button(), 2, 1, 1, 2)
|
|
grid.setAlignment(alignCenter)
|
|
|
|
vbox_.addLayout(grid)
|
|
super(DialogTableDeliveryParty, self).__init__(parent, 'action',
|
|
widgets=[vbox_])
|
|
width, height = get_screen()
|
|
self.setGeometry(0, 0, width / 1.8, height / 1.5)
|
|
self.setWindowTitle('DOMICILIARIO')
|
|
|
|
def get_button(self):
|
|
self._parent.button_create_delivery_party = CustomButton(
|
|
id='button_create_delivery_party',
|
|
parent=self._parent,
|
|
icon=get_icon('delivery_party'),
|
|
title='NUEVO DOMICILIARIO',
|
|
name_style='toolbar',
|
|
method='button_create_delivery_party'
|
|
)
|
|
return self._parent.button_create_delivery_party
|
|
|
|
|
|
class DialogTableMoneyCount(QuickDialog):
|
|
def __init__(self, parent):
|
|
self._parent = parent
|
|
col_sizes_tlines = [160, 120, 180]
|
|
table = TableView('model_money_count', parent.model_money_count,
|
|
col_sizes_tlines, selection_edit=True)
|
|
|
|
width, height = get_screen()
|
|
table.setFixedSize(width/3.3, height/3)
|
|
vbox_ = QVBoxLayout()
|
|
label, field = self.get_fields()
|
|
|
|
layout1 = QVBoxLayout()
|
|
layout1.addWidget(table)
|
|
layout1.setAlignment(alignCenter)
|
|
layout2 = QHBoxLayout()
|
|
label.setAlignment(alignCenter)
|
|
field.setAlignment(alignLeft)
|
|
layout2.addWidget(label)
|
|
layout2.addWidget(field)
|
|
layout2.setAlignment(alignCenter)
|
|
|
|
vbox_.addLayout(layout1)
|
|
vbox_.addSpacing(20)
|
|
vbox_.addLayout(layout2)
|
|
vbox_.addSpacing(20)
|
|
super(DialogTableMoneyCount, self).__init__(parent, 'action',
|
|
widgets=[vbox_])
|
|
width, height = get_screen()
|
|
self.setGeometry(0, 0, width * 0.4, height * 0.6)
|
|
self.setWindowTitle('CONTEO DE DINERO')
|
|
self.accepted.connect(parent.dialog_money_count_accepted)
|
|
|
|
def get_fields(self):
|
|
label_amount = QLabel('TOTAL DINERO:')
|
|
label_amount.setObjectName('label_price')
|
|
self._parent.row_field_total_money = FieldMoney(self,
|
|
'row_field_total_money', {}, readonly=True)
|
|
self._parent.row_field_total_money.setObjectName('row_field_total_money')
|
|
self._parent.row_field_total_money.textChanged.connect(
|
|
lambda: self._parent.update_sale_line('unit_price')
|
|
)
|
|
self._parent.row_field_total_money.setAlignment(alignLeft)
|
|
return label_amount, self._parent.row_field_total_money
|
|
|
|
|
|
class DialogTaxes(QuickDialog):
|
|
def __init__(self, parent):
|
|
if parent.shop_taxes:
|
|
taxes = [(str(e['id']), e['name']) for e in parent.shop_taxes]
|
|
else:
|
|
taxes = []
|
|
data = {
|
|
'name': 'tax',
|
|
'values': taxes,
|
|
'heads': ['ID', 'VALOR'],
|
|
}
|
|
string = 'ESCOJA EL IMPUESTO'
|
|
super(DialogTaxes, self).__init__(parent, 'selection', string, data)
|
|
|
|
|
|
class DialogChannel(QuickDialog):
|
|
def __init__(self, parent):
|
|
vbox_ = create_vbox(parent, parent.channels, parent.on_selected_channel)
|
|
super(DialogChannel, self).__init__(parent, 'action', widgets=[vbox_],
|
|
buttons=False)
|
|
self.setWindowTitle('SELECCIONE EL CANAL')
|
|
width, height = get_screen()
|
|
self.setFixedSize(width * 0.6, height * 0.7)
|
|
|
|
|
|
class DialogPaymentTerm(QuickDialog):
|
|
def __init__(self, parent):
|
|
vbox_ = create_vbox(parent, parent._payment_terms,
|
|
parent.on_selected_payment_term)
|
|
super(DialogPaymentTerm, self).__init__(parent, 'action', widgets=[vbox_])
|
|
self.setWindowTitle('SELECCION LA FORMA DE PAGO')
|
|
|
|
|
|
class DialogPayment(QuickDialog):
|
|
def __init__(self, parent):
|
|
vbox_ = create_vbox(parent, parent._journals, parent.on_selected_payment)
|
|
width, height = get_screen()
|
|
super(DialogPayment, self).__init__(parent, 'action', widgets=[vbox_])
|
|
self.setWindowTitle('SELECCIONE EL MEDIO DE PAGO:')
|
|
self.setFixedSize(width * 0.8, height * 0.7)
|
|
|
|
|
|
class Position(QuickDialog):
|
|
def __init__(self, parent):
|
|
field = 'position_ask'
|
|
data = (field, {'name': 'POSICION'})
|
|
super(Position, self).__init__(parent, 'action', data=[data])
|
|
|
|
|
|
class Comment(QuickDialog):
|
|
def __init__(self, parent):
|
|
field = 'comment'
|
|
data = (field, {'name': 'COMENTARIO', 'type': 'text'})
|
|
super(Comment, self).__init__(parent, 'action', data=[data])
|
|
|
|
|
|
class TipAmount(QuickDialog):
|
|
def __init__(self, parent):
|
|
field = 'tip_amount_ask'
|
|
data = (field, {'name': 'VALOR PROPINA'})
|
|
super(TipAmount, self).__init__(parent, 'action', data=[data])
|
|
|
|
|
|
class DeliveryAmount(QuickDialog):
|
|
def __init__(self, parent):
|
|
field = 'delivery_amount_ask'
|
|
data = (field, {'name': 'VALOR DEL DOMICILO'})
|
|
super(DeliveryAmount, self).__init__(parent, 'action', data=[data])
|
|
|
|
|
|
class DialogSalesmanCode(QuickDialog):
|
|
def __init__(self, parent):
|
|
field = 'salesman_code_ask'
|
|
data = (field, {'name': 'CODIGO VENDEDOR', 'password': True})
|
|
super(DialogSalesmanCode, self).__init__(parent, 'action', data=[data])
|
|
|
|
|
|
class EditLine(QuickDialog):
|
|
def __init__(self, parent):
|
|
self._parent = parent
|
|
self._parent.state_line = {}
|
|
vbox_product = QVBoxLayout()
|
|
grid = QGridLayout()
|
|
qty = 2
|
|
width, height = get_screen()
|
|
parent.label_product = QLabel()
|
|
parent.label_product.setAlignment(alignCenter)
|
|
parent.label_product.setObjectName('label_product')
|
|
vbox_product.addWidget(parent.label_product)
|
|
parent.row_field_description = QLineEdit()
|
|
parent.row_field_description.setObjectName('row_field_description')
|
|
parent.row_field_description.textChanged.connect(
|
|
lambda: parent.update_sale_line('description')
|
|
)
|
|
grid.addWidget(parent.row_field_description, 1, 1, 1, 2)
|
|
|
|
if parent._config.get('show_fractions'):
|
|
label_fraction = QLabel('FRACCION:')
|
|
label_fraction.setObjectName('label_fraction')
|
|
grid.addWidget(label_fraction, 2, 1)
|
|
parent.field_combobox_fraction = ComboBox(parent, 'fraction',
|
|
{'values': FRACTIONS})
|
|
grid.addWidget(parent.field_combobox_fraction, 2, 2)
|
|
parent.field_combobox_fraction.currentIndexChanged.connect(
|
|
lambda: parent.update_sale_line('qty_fraction')
|
|
)
|
|
|
|
label_qty = QLabel('CANTIDAD:')
|
|
label_qty.setObjectName('label_qty')
|
|
grid.addWidget(label_qty, 3, 1)
|
|
parent.row_field_qty = QDoubleSpinBox()
|
|
parent.row_field_qty.setObjectName('row_field_qty')
|
|
parent.row_field_qty.setMinimum(0)
|
|
parent.row_field_qty.setMaximum(100000)
|
|
if parent._config.get('decimals_digits_quantity'):
|
|
qty = parent._config['decimals_digits_quantity']
|
|
|
|
parent.row_field_qty.setDecimals(qty)
|
|
parent.row_field_qty.setAlignment(alignCenter)
|
|
grid.addWidget(parent.row_field_qty, 3, 2)
|
|
parent.row_field_qty.valueChanged.connect(
|
|
lambda: parent.update_sale_line('quantity')
|
|
)
|
|
|
|
label_price = QLabel('PRECIO:')
|
|
label_price.setObjectName('label_price')
|
|
grid.addWidget(label_price, 4, 1)
|
|
parent.row_field_price = FieldMoney(self, 'row_field_price', {}, readonly=False)
|
|
parent.row_field_price.setObjectName('row_field_price')
|
|
grid.addWidget(parent.row_field_price, 4, 2)
|
|
parent.row_field_price.textChanged.connect(
|
|
lambda: parent.update_sale_line('unit_price')
|
|
)
|
|
|
|
parent.row_field_note = QTextEdit('')
|
|
parent.row_field_note.setObjectName('row_field_note')
|
|
grid.addWidget(parent.row_field_note, 5, 1, 5, 2)
|
|
parent.row_field_note.textChanged.connect(
|
|
lambda: parent.update_sale_line('note')
|
|
)
|
|
button_delete = CustomButton(
|
|
parent,
|
|
id='button_delete',
|
|
size='small',
|
|
icon=get_icon('delete_line'),
|
|
title='ELIMINAR',
|
|
method='action_delete_line',
|
|
name_style='mini_button',
|
|
)
|
|
button_addition = CustomButton(
|
|
parent,
|
|
id='button_addition',
|
|
size='small',
|
|
icon=get_icon('addition-product'),
|
|
title=('COMBINAR'),
|
|
method='action_addition_line',
|
|
name_style='mini_button',
|
|
)
|
|
button_discounts = CustomButton(
|
|
parent,
|
|
id='button_discount',
|
|
size='small',
|
|
icon=get_icon('discount'),
|
|
title=('DESCUENTO/BONO'),
|
|
method='action_discount_line',
|
|
name_style='mini_button',
|
|
)
|
|
button_combo = CustomButton(
|
|
parent,
|
|
id='button_combo',
|
|
size='small',
|
|
icon=get_icon('combo'),
|
|
title=('COMBO'),
|
|
method='action_combo',
|
|
name_style='mini_button',
|
|
)
|
|
hbox = QHBoxLayout()
|
|
vbox_product.addLayout(grid, 1)
|
|
vbox_product.addLayout(hbox, 0)
|
|
hbox.addWidget(button_delete, 0)
|
|
hbox.addWidget(button_discounts, 0)
|
|
hbox.addWidget(button_combo, 0)
|
|
|
|
if parent.enviroment == 'restaurant':
|
|
hbox.addWidget(button_addition, 0)
|
|
super(EditLine, self).__init__(parent, 'action',
|
|
widgets=[vbox_product])
|
|
self.setFixedSize(width * 0.5, height * 0.7)
|
|
self.accepted.connect(parent.dialog_product_edit_accepted)
|
|
|
|
|
|
class AdditionProduct(QuickDialog):
|
|
def __init__(self, parent):
|
|
self.box = QVBoxLayout()
|
|
width, height = get_screen()
|
|
self.method_action = getattr(parent, 'on_selected_item_mix')
|
|
self.parent = parent
|
|
|
|
self.box.setObjectName('grid_buttons')
|
|
self.filter_field = QLineEdit()
|
|
self.filter_field.setObjectName('field_filter_addition')
|
|
self.filter_field.setPlaceholderText('BUSCAR...')
|
|
self.filter_field.textChanged.connect(self.filter_products)
|
|
self.box.addWidget(self.filter_field)
|
|
|
|
super(AdditionProduct, self).__init__(parent, 'action', widgets=[self.box])
|
|
self.setWindowTitle('SELECCIONE LA COMBINACION')
|
|
self.setFixedSize(width * 0.8, height * 0.9)
|
|
|
|
def set_buttons(self, values):
|
|
self.values = values
|
|
self.set_products(values)
|
|
|
|
def set_products(self, values):
|
|
grid_buttons = GridButtons(
|
|
self.parent,
|
|
values,
|
|
5,
|
|
action=self.method_action,
|
|
style='standard_button'
|
|
)
|
|
if hasattr(self, 'scroll_area'):
|
|
_ = self.box.removeWidget(self.scroll_area)
|
|
self.scroll_area = QScrollArea()
|
|
self.scroll_area.setWidgetResizable(True)
|
|
self.scroll_area.setWidget(grid_buttons)
|
|
self.box.addWidget(self.scroll_area)
|
|
|
|
def filter_products(self, text):
|
|
if len(text) == 0:
|
|
self.set_products(self.values)
|
|
return
|
|
if len(text) <= 2:
|
|
return
|
|
filtered = []
|
|
text_list = text.upper().split(' ')
|
|
for v in self.values:
|
|
for t in text_list:
|
|
if t in v['rec_name']:
|
|
filtered.append(v)
|
|
|
|
self.set_products(filtered)
|
|
|
|
|
|
class DialogComboProduct(QuickDialog):
|
|
def __init__(self, parent):
|
|
self.box = QVBoxLayout()
|
|
self.box.setObjectName('grid_buttons')
|
|
width, height = get_screen()
|
|
self.method_action = getattr(parent, 'on_selected_item_combo')
|
|
self.parent = parent
|
|
label = QLabel('SELECCIONE LOS PRODUCTOS')
|
|
label.setObjectName('label_combo_product')
|
|
self.box.addWidget(label)
|
|
super(DialogComboProduct, self).__init__(
|
|
parent, 'action', widgets=[self.box]
|
|
)
|
|
self.setWindowTitle('PRODUCTO EN COMBO')
|
|
self.setFixedSize(width * 0.7, height * 0.6)
|
|
|
|
def set_buttons(self, values):
|
|
self.values = values
|
|
self.set_products(values)
|
|
|
|
def set_products(self, values):
|
|
grid_buttons = GridButtons(
|
|
self.parent,
|
|
values,
|
|
4,
|
|
action=self.method_action,
|
|
style='standard_button'
|
|
)
|
|
if hasattr(self, 'scroll_area'):
|
|
_ = self.box.removeWidget(self.scroll_area)
|
|
self.scroll_area = QScrollArea()
|
|
self.scroll_area.setWidgetResizable(True)
|
|
self.scroll_area.setWidget(grid_buttons)
|
|
self.box.addWidget(self.scroll_area)
|
|
|
|
|
|
class Help(HelpDialog):
|
|
|
|
def __init__(self, parent):
|
|
super(Help, self).__init__(parent)
|
|
shortcuts = [
|
|
('PANEL DE CONTROL', 'F1'),
|
|
('BUSCAR PRODUCTO', 'F2'),
|
|
('MEDIO DE PAGO', 'F3'),
|
|
('BUSCAR CLIENTE', 'F4'),
|
|
('DESCUENTO GLOBAL', 'F5'),
|
|
('IMPRIMIR ORDEN', 'F6'),
|
|
('IMPRIMIR FACTURA', 'F7'),
|
|
('PLAZO DE PAGO', 'F8'),
|
|
('BUSCAR ORDEN', 'F9'),
|
|
('CANCELAR VENTA', 'F10'),
|
|
('NUEVA VENTA', 'F11'),
|
|
('DOMICILIARIO', 'F12'),
|
|
('VENDEDOR', 'Home'),
|
|
('POSICION', 'Insert'),
|
|
('FACTURAR', 'End'),
|
|
('COMENTARIO', 'Quotation Marks'),
|
|
]
|
|
|
|
self.set_shortcuts(shortcuts)
|