option for transfer sale to other sale
This commit is contained in:
parent
372b706ade
commit
19d28390e6
|
@ -242,13 +242,13 @@ class ButtonsStacked(QWidget):
|
|||
method='action_payment_term'
|
||||
)
|
||||
|
||||
self.button_transfer_to_folio = CustomButton(
|
||||
id='button_transfer_to_folio',
|
||||
self.button_transfer = CustomButton(
|
||||
id='button_transfer',
|
||||
parent=parent,
|
||||
title='TRANSFERIR A FOLIO',
|
||||
icon=get_icon('transfer_to_folio'),
|
||||
title='TRANSFERIR',
|
||||
icon=get_icon('transfer'),
|
||||
name_style='toolbar',
|
||||
method='action_transfer_to_folio'
|
||||
method='action_transfer_sale'
|
||||
)
|
||||
|
||||
if pos_user not in ('order', 'salesman'):
|
||||
|
@ -259,7 +259,7 @@ class ButtonsStacked(QWidget):
|
|||
hbox.addWidget(self.stacked, 0)
|
||||
if pos_user in ('cashier', 'frontend_admin'):
|
||||
if parent._hotel_activated:
|
||||
hbox.addWidget(self.button_transfer_to_folio, 0)
|
||||
hbox.addWidget(self.button_transfer, 0)
|
||||
hbox.addWidget(self.button_payment_term, 0)
|
||||
if parent.environment == 'retail':
|
||||
if pos_user == 'cashier' and getattr(parent, 'button_to_draft_active', None):
|
||||
|
|
|
@ -131,6 +131,8 @@ class QuickDialog(QDialog):
|
|||
|
||||
if kind in ('info', 'error'):
|
||||
self.show()
|
||||
self.adjustSize()
|
||||
self.setMinimumSize(500, 200)
|
||||
|
||||
def exec(self, args=None):
|
||||
res = None
|
||||
|
|
|
@ -10,7 +10,7 @@ from .commons.dialogs import HelpDialog, QuickDialog
|
|||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import (
|
||||
QCheckBox, QTextEdit, QVBoxLayout, QGridLayout, QLineEdit, QPlainTextEdit,
|
||||
QScrollArea, QHBoxLayout, QDoubleSpinBox, QLabel, QWidget
|
||||
QScrollArea, QHBoxLayout, QDoubleSpinBox, QLabel, QWidget, QDialog
|
||||
)
|
||||
|
||||
from .proxy import Report
|
||||
|
@ -43,7 +43,8 @@ __all__ = [
|
|||
'DialogReports', 'DialogFixedDiscounts', 'DialogFixedDiscountsManual',
|
||||
'DialogExpenses', 'DialogInfoProduct', 'DialogAdvance',
|
||||
'DialogDeleteProduct', 'DialogCollection', 'DialogTestPrinter',
|
||||
'SearchFolio'
|
||||
'DialogSaleToTransfer', 'DialogSearchFolioTransfer',
|
||||
'DialogSearchSaleTransfer'
|
||||
]
|
||||
|
||||
WIZARDS = {
|
||||
|
@ -297,7 +298,60 @@ class SearchParty(SearchWindow):
|
|||
title=title, fill=True)
|
||||
|
||||
|
||||
class SearchFolio(SearchWindow):
|
||||
class DialogSaleToTransfer(QuickDialog):
|
||||
def __init__(self, parent):
|
||||
|
||||
buttons_layout_filter = QHBoxLayout()
|
||||
self.pushButtonSale = CustomButton(
|
||||
id='button_search_sale',
|
||||
parent=self,
|
||||
# icon=get_icon('history'),
|
||||
title='VENTA',
|
||||
name_style='start',
|
||||
record='sale',
|
||||
method='show_table_sale',
|
||||
size='small',
|
||||
)
|
||||
buttons_layout_filter.addWidget(self.pushButtonSale)
|
||||
|
||||
if parent._hotel_activated:
|
||||
self.pushButtonFolio = CustomButton(
|
||||
id='button_search_folio',
|
||||
parent=self,
|
||||
# icon=get_icon('history'),
|
||||
title='FOLIO',
|
||||
name_style='start',
|
||||
record='folio',
|
||||
method='show_table_folio',
|
||||
size='small',
|
||||
)
|
||||
buttons_layout_filter.addWidget(self.pushButtonFolio)
|
||||
|
||||
self.table_sale = parent.dialog_search_sale_transfer
|
||||
self.table_folio = parent.dialog_search_folio_transfer
|
||||
|
||||
super(DialogSaleToTransfer, self).__init__(parent, 'form', widgets=[buttons_layout_filter])
|
||||
self.setWindowTitle("TRANSFERIR VENTA")
|
||||
width, height = get_screen()
|
||||
self.setFixedSize(int(width * 0.4), int(height * 0.2))
|
||||
|
||||
def show_table_sale(self, *args):
|
||||
fields = ['party.name', 'number', 'sale_date', 'description']
|
||||
sales = self.parent.Sale.find(
|
||||
[('state', 'in', ['draft', 'quotation'])],
|
||||
fields=fields)
|
||||
self.table_sale.show()
|
||||
self.table_sale.set_from_values(sales)
|
||||
self.close()
|
||||
|
||||
def show_table_folio(self, *args):
|
||||
folios = self.parent.Folio.get_current_folios()
|
||||
self.table_folio.show()
|
||||
self.table_folio.set_from_values(folios)
|
||||
self.close()
|
||||
|
||||
|
||||
class DialogSearchFolioTransfer(SearchWindow):
|
||||
def __init__(self, parent):
|
||||
headers = OrderedDict()
|
||||
headers['id'] = {'desc': 'ID', 'type': 'char'}
|
||||
|
@ -309,10 +363,30 @@ class SearchFolio(SearchWindow):
|
|||
|
||||
title = 'BUSCAR FOLIO'
|
||||
methods = {
|
||||
'on_selected_method': 'on_selected_folio',
|
||||
'on_selected_method': 'on_selected_folio_transfer',
|
||||
# 'on_return_method': 'on_search_folio',
|
||||
}
|
||||
super(SearchFolio, self).__init__(parent, headers, None, methods,
|
||||
super(DialogSearchFolioTransfer, self).__init__(parent, headers, None, methods,
|
||||
filter_column=[1, 2], cols_width=[10, 220, 670, 220, 220, 220],
|
||||
title=title, fill=True)
|
||||
|
||||
|
||||
class DialogSearchSaleTransfer(SearchWindow):
|
||||
def __init__(self, parent):
|
||||
headers = OrderedDict()
|
||||
headers['id'] = {'desc': 'ID', 'type': 'char'}
|
||||
headers['number'] = {'desc': 'NUMERO', 'type': 'char'}
|
||||
headers['party.name'] = {'desc': 'TERCERO', 'type': 'char'}
|
||||
headers['sale_date'] = {'desc': 'FECHA VENTA', 'type': 'char'}
|
||||
headers['description'] = {'desc': 'DESCRIPCION', 'type': 'char'}
|
||||
|
||||
title = 'BUSCAR VENTA'
|
||||
methods = {
|
||||
'on_selected_method': 'on_selected_sale_transfer',
|
||||
# 'on_return_method': 'on_search_folio',
|
||||
}
|
||||
|
||||
super(DialogSearchSaleTransfer, self).__init__(parent, headers, None, methods,
|
||||
filter_column=[1, 2], cols_width=[10, 220, 670, 220, 220, 220],
|
||||
title=title, fill=True)
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ from .dialogs import (
|
|||
DialogFixedDiscounts, DialogFixedDiscountsManual, DialogComboProduct,
|
||||
DialogSplitSale, DialogExpenses, DialogInfoProduct, DialogAdvance,
|
||||
DialogDeleteProduct, DialogCollection, DialogTestPrinter,
|
||||
SearchFolio
|
||||
DialogSaleToTransfer, DialogSearchFolioTransfer,
|
||||
DialogSearchSaleTransfer
|
||||
)
|
||||
from .constants import DIALOG_REPLY_YES
|
||||
from .version import __version__
|
||||
|
@ -172,7 +173,9 @@ class FrontWindow(QMainWindow):
|
|||
if self._commission_activated:
|
||||
self.dialog_agent = DialogAgent(self)
|
||||
if self._hotel_activated:
|
||||
self.dialog_search_folio = SearchFolio(self)
|
||||
self.dialog_search_folio_transfer = DialogSearchFolioTransfer(self)
|
||||
self.dialog_search_sale_transfer = DialogSearchSaleTransfer(self)
|
||||
self.dialog_sale_to_transfer = DialogSaleToTransfer(self)
|
||||
if self.environment == 'restaurant' and self._sale_pos_restaurant:
|
||||
self.dialog_combine_product = CombineProduct(self)
|
||||
self.dialog_combo_product = DialogComboProduct(self)
|
||||
|
|
55
app/main.py
55
app/main.py
|
@ -1025,16 +1025,14 @@ class AppWindow(FrontWindow):
|
|||
self.do_invoice.start()
|
||||
try:
|
||||
if self.print_receipt == 'automatic':
|
||||
_copies = self.shop['invoice_copies']
|
||||
# _copies = self.shop['invoice_copies']
|
||||
if self.environment == 'restaurant':
|
||||
for n in range(_copies):
|
||||
self.action_print_sale()
|
||||
self.action_print_sale()
|
||||
else:
|
||||
if not is_credit:
|
||||
self.print_invoice(copies=_copies, open_box=True)
|
||||
except Exception as e:
|
||||
print('Error', e)
|
||||
logging.error(sys.exc_info()[0])
|
||||
self.print_invoice(open_box=True)
|
||||
except Exception:
|
||||
logging.exception('Error de impresion venta o factura')
|
||||
|
||||
if self.sale_automatic and self.type_pos_user not in ('cashier', 'order'):
|
||||
self.create_new_sale()
|
||||
|
@ -3419,10 +3417,8 @@ class AppWindow(FrontWindow):
|
|||
if self.environment == 'restaurant':
|
||||
self.menu_dash.setDisabled(True)
|
||||
|
||||
def action_transfer_to_folio(self):
|
||||
folios = self.Folio.get_current_folios()
|
||||
self.dialog_search_folio.show()
|
||||
self.dialog_search_folio.set_from_values(folios)
|
||||
def action_transfer_sale(self):
|
||||
self.dialog_sale_to_transfer.show()
|
||||
|
||||
def key_pressed(self, text):
|
||||
if self._state == 'disabled':
|
||||
|
@ -3729,12 +3725,41 @@ class AppWindow(FrontWindow):
|
|||
def action_test_print(self):
|
||||
self.dialog_test_printer.exec_()
|
||||
|
||||
def on_selected_folio(self):
|
||||
folio_id = self.dialog_search_folio.get_id()
|
||||
def on_selected_folio_transfer(self):
|
||||
sale = self.store.store
|
||||
folio_id = self.dialog_search_folio_transfer.get_id()
|
||||
if not folio_id:
|
||||
return
|
||||
sale_id = self.sale_id
|
||||
current_row = self.dialog_search_folio.current_row
|
||||
current_row = self.dialog_search_folio_transfer.current_row
|
||||
guest = current_row['main_guest.name']
|
||||
party = sale['party']['name']
|
||||
number = sale['number']
|
||||
room = current_row['room.code']
|
||||
msg = f"\n\n HABITACION: {room} \n HUESPED: {guest}"
|
||||
dialog = self.dialog('confirm_transfer_sale', response=True, extra_message=msg)
|
||||
dialog.adjustSize()
|
||||
response = dialog.exec_()
|
||||
if response == DIALOG_REPLY_NO:
|
||||
return
|
||||
result = self.Sale.transfer_to_folio(args=[sale_id, folio_id])
|
||||
if result == 'ok':
|
||||
self.dialog('transfer_folio', extra_message='\n' + current_row['main_guest.name'])
|
||||
self.dialog('transfer_sale', extra_message='\n' + current_row['main_guest.name'])
|
||||
self.change_view_to('start_front')
|
||||
|
||||
def on_selected_sale_transfer(self):
|
||||
target_sale_id = self.dialog_search_sale_transfer.get_id()
|
||||
if not target_sale_id:
|
||||
return
|
||||
current_row = self.dialog_search_sale_transfer.current_row
|
||||
print(current_row, 'hisdhid')
|
||||
msg = f"\n\n VENTA: {current_row['number']} \n CLIENTE: {current_row['party.name']} \n DESCRIPCION: {current_row['description']}"
|
||||
dialog = self.dialog('confirm_transfer_sale', response=True, extra_message=msg)
|
||||
dialog.adjustSize()
|
||||
response = dialog.exec_()
|
||||
if response == DIALOG_REPLY_NO:
|
||||
return
|
||||
result = self.Sale.transfer_to_sale(args=[self.sale_id, target_sale_id])
|
||||
if result == 'ok':
|
||||
self.dialog('transfer_sale', extra_message='\n' + current_row['party.name'])
|
||||
self.change_view_to('start_front')
|
||||
|
|
|
@ -241,7 +241,8 @@ class Receipt(object):
|
|||
return {"error": msg}
|
||||
try:
|
||||
if type_doc in ('invoice', 'quotation') or self._environment == 'retail':
|
||||
self._print_sale(sale, type_doc, open_box)
|
||||
for copie in range(self.invoice_copies):
|
||||
self._print_sale(sale, type_doc, open_box)
|
||||
else:
|
||||
self._print_sale_verification(sale)
|
||||
except Exception:
|
||||
|
|
|
@ -71,5 +71,6 @@ class StackMessages(QWidget):
|
|||
'error_server': ('error', 'Error'),
|
||||
'print_error': ('error', 'Error de Impresión'),
|
||||
'test_printer': ('error', 'Resultado Test: '),
|
||||
'transfer_folio': ('info', 'VENTA TRANSFERIDA A FOLIO DE: ')
|
||||
'transfer_sale': ('info', 'VENTA TRANSFERIDA A: '),
|
||||
'confirm_transfer_sale': ('question', 'ESTA SEGURO QUE DESEA TRANSFERIR ESTA VENTA?')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue