add option reservation and advance in sales
This commit is contained in:
parent
becba27458
commit
b83ccbfc7c
|
@ -127,6 +127,7 @@ class ButtonsFunction(QGridLayout):
|
|||
['button_position', 'POSICION', 'action_position'],
|
||||
['button_print_order', 'ENVIAR ORDEN', 'action_send_order'],
|
||||
['button_channel', 'CANALES', 'action_source'],
|
||||
['button_advance', 'ANTICIPO', 'action_add_advance'],
|
||||
])
|
||||
|
||||
if self.parent.enviroment == 'restaurant':
|
||||
|
|
|
@ -302,10 +302,6 @@ class FieldNumeric(QLineEdit):
|
|||
def __str__(self):
|
||||
return self.format_text()
|
||||
|
||||
# def format_text(self, text_):
|
||||
# amount = float(text_)
|
||||
# return "{:,}".format(round(amount, self.digits))
|
||||
|
||||
def setText(self, amount):
|
||||
if not amount:
|
||||
text = ''
|
||||
|
@ -326,6 +322,7 @@ class FieldNumeric(QLineEdit):
|
|||
amount = amount.replace(',', '')
|
||||
text = "{0:,.2f}".format(float(amount))
|
||||
self.setText(text)
|
||||
self.setCursorPosition(len(text)-3)
|
||||
|
||||
def show(self):
|
||||
pass
|
||||
|
|
|
@ -30,7 +30,7 @@ __all__ = [
|
|||
'DialogManageTables', 'DialogHistoricSales', 'DialogSaleForm',
|
||||
'DialogCancelInvoice', 'DialogForceAssign', 'CombineProduct',
|
||||
'DialogReports', 'DialogFixedDiscounts', 'DialogFixedDiscountsManual', 'DialogExpenses',
|
||||
'DialogInfoProduct',
|
||||
'DialogInfoProduct', 'DialogAdvance'
|
||||
]
|
||||
|
||||
WIZARDS = {
|
||||
|
@ -223,9 +223,20 @@ class SearchSale(SearchWindow):
|
|||
method='action_search_sale',
|
||||
size='mini_button',
|
||||
)
|
||||
self.pushButtonReservation = CustomButton(
|
||||
id='button_search_sale_reservation',
|
||||
parent=self,
|
||||
# icon=get_icon('history'),
|
||||
title='RESERVA',
|
||||
name_style='start',
|
||||
record='reservation',
|
||||
method='action_search_sale',
|
||||
size='mini_button',
|
||||
)
|
||||
|
||||
self.buttons_layout_filter.addWidget(self.pushButtonCash)
|
||||
self.buttons_layout_filter.addWidget(self.pushButtonCredit)
|
||||
self.buttons_layout_filter.addWidget(self.pushButtonReservation)
|
||||
widgets_to_create = self.buttons_layout_filter
|
||||
super(SearchSale, self).__init__(parent, headers, None, methods,
|
||||
filter_column=[2, 3, 4, 5, 6, 7], cols_width=widths,
|
||||
|
@ -645,7 +656,6 @@ class DialogStock(QuickDialog):
|
|||
self.setFixedSize(int(width * 0.4), int(height * 0.3))
|
||||
|
||||
|
||||
|
||||
class DialogGlobalDiscount(QuickDialog):
|
||||
def __init__(self, parent):
|
||||
field = 'global_discount_ask'
|
||||
|
@ -683,6 +693,18 @@ class DialogPrintInvoice(QuickDialog):
|
|||
super(DialogPrintInvoice, self).__init__(parent, 'action', data=view)
|
||||
|
||||
|
||||
class DialogAdvance(QuickDialog):
|
||||
def __init__(self, parent):
|
||||
data = [
|
||||
('amount_ask', {'name': 'VALOR'}),
|
||||
('reservation_ask', {
|
||||
'name': 'RESERVA',
|
||||
'type': 'checkbox',
|
||||
'placeholder': 'RESERVA',
|
||||
}),
|
||||
]
|
||||
super(DialogAdvance, self).__init__(parent, 'action', data=data)
|
||||
|
||||
class DialogVoucher(QuickDialog):
|
||||
def __init__(self, parent):
|
||||
data = ('voucher_ask', {'name': 'NUMERO DE COMPROBANTE'})
|
||||
|
|
|
@ -19,7 +19,7 @@ from .dialogs import (
|
|||
DialogHistoricSales, DialogSaleForm, DialogSource, DialogReports,
|
||||
DialogDeliveryParty, TipAmount, DeliveryAmount, DialogSalesmanCode,
|
||||
DialogFixedDiscounts, DialogFixedDiscountsManual, DialogComboProduct, DialogSplitSale, DialogExpenses,
|
||||
DialogInfoProduct
|
||||
DialogInfoProduct, DialogAdvance
|
||||
)
|
||||
from .constants import DIALOG_REPLY_YES
|
||||
from .version import __version__
|
||||
|
@ -169,6 +169,7 @@ class FrontWindow(QMainWindow):
|
|||
self.dialog_comment = Comment(self)
|
||||
self.dialog_payment = DialogPayment(self)
|
||||
self.dialog_voucher = DialogVoucher(self)
|
||||
self.dialog_advance = DialogAdvance(self)
|
||||
self.dialog_print_invoice = DialogPrintInvoice(self)
|
||||
self.dialog_global_discount = DialogGlobalDiscount(self)
|
||||
self.dialog_auth_discount = DialogAuthDiscounts(self)
|
||||
|
|
72
app/main.py
72
app/main.py
|
@ -10,7 +10,7 @@ from decimal import Decimal
|
|||
from datetime import datetime, timedelta, date
|
||||
from collections import OrderedDict
|
||||
from PyQt5.QtCore import Qt, QSize
|
||||
from PyQt5.QtWidgets import (QLabel, QHBoxLayout, QVBoxLayout, QWidget)
|
||||
from PyQt5.QtWidgets import (QLabel, QHBoxLayout, QVBoxLayout, QWidget, QInputDialog, QLineEdit)
|
||||
from paramiko import Agent
|
||||
from app.commons.image import Image
|
||||
from .frontwindow import FrontWindow
|
||||
|
@ -393,7 +393,7 @@ class AppWindow(FrontWindow):
|
|||
left_invoice.addWidget(self.field_sale_date, 0)
|
||||
|
||||
# LEFT TABLE COMPONENTS
|
||||
button_functions = ButtonsFunction(self)
|
||||
self.buttons_function = ButtonsFunction(self)
|
||||
|
||||
info_fields = [
|
||||
('party', {
|
||||
|
@ -656,7 +656,7 @@ class AppWindow(FrontWindow):
|
|||
values = self.get_product_by_categories_dash()
|
||||
self.menu_dash = MenuDash(self, values, 'on_selected_item')
|
||||
self.order_front.hide()
|
||||
vbox_order_front.addLayout(button_functions, 0)
|
||||
vbox_order_front.addLayout(self.buttons_function, 0)
|
||||
vbox_order_front.addLayout(self.grid_info, 0)
|
||||
self.panel_right.addWidget(self.menu_dash, 1)
|
||||
_panel_right_box = QVBoxLayout()
|
||||
|
@ -667,7 +667,7 @@ class AppWindow(FrontWindow):
|
|||
else:
|
||||
vbox_left.addLayout(self.grid_info, 1)
|
||||
self.panel_right.addLayout(self.grid_amounts, 1)
|
||||
self.panel_right.addLayout(button_functions, 1)
|
||||
self.panel_right.addLayout(self.buttons_function, 1)
|
||||
self.panel_right.addWidget(self.buttons_stacked, 0)
|
||||
self.panel_right.addWidget(self.table_payment)
|
||||
|
||||
|
@ -1064,6 +1064,7 @@ class AppWindow(FrontWindow):
|
|||
return
|
||||
if self.enviroment == 'retail':
|
||||
self.Sale.quote({'id': self._sale['id']})
|
||||
self.load_sale(self._sale['id'])
|
||||
self.set_state('accept')
|
||||
|
||||
def button_checkout_pressed(self):
|
||||
|
@ -1404,6 +1405,52 @@ class AppWindow(FrontWindow):
|
|||
def action_info_product(self):
|
||||
self.dialog_info_product.show()
|
||||
|
||||
def action_add_advance(self):
|
||||
if self._sale.get('state') == 'quotation':
|
||||
self.dialog_payment.exec_()
|
||||
flag = True
|
||||
# dialog_advance.addAction
|
||||
while flag:
|
||||
res = self.dialog_advance.exec_()
|
||||
amount = self.field_amount_ask.text()
|
||||
reservation = self.field_reservation_ask.isChecked()
|
||||
if res == 0 or (res==1 and amount.isdigit()):
|
||||
flag = False
|
||||
if res == 1:
|
||||
journal = self.journal
|
||||
voucher_number = None
|
||||
if journal.get('require_voucher'):
|
||||
res = self.dialog_voucher.exec_()
|
||||
if res == 0:
|
||||
self.dialog_voucher.close()
|
||||
return
|
||||
voucher_number = self.field_voucher_ask.text()
|
||||
if voucher_number is None or voucher_number == '':
|
||||
return self.add_payment(amount)
|
||||
self.field_voucher_ask.setText('')
|
||||
|
||||
res = self.Sale.faster_add_payment({
|
||||
'sale_id': self._sale['id'],
|
||||
'journal_id': journal['id'],
|
||||
'cash_received': to_numeric(float(amount)),
|
||||
'voucher_number': voucher_number,
|
||||
'extra_paid': False,
|
||||
}, ctx={'advance': True, 'reservation': reservation})
|
||||
|
||||
if res.get('msg') not in ('missing_money', 'ok'):
|
||||
self.dialog(res['msg'])
|
||||
return
|
||||
residual_amount = res.get('residual_amount')
|
||||
change = res.get('change')
|
||||
paid_amount = res.pop('paid_amount')
|
||||
self.store.set({
|
||||
'residual_amount': residual_amount,
|
||||
'change': change,
|
||||
'paid_amount': paid_amount,
|
||||
})
|
||||
if res['id']:
|
||||
self.table_payment_lines.add_record(res)
|
||||
|
||||
def action_print_sale(self):
|
||||
number = self.field_invoice_number.text()
|
||||
if not number:
|
||||
|
@ -1762,6 +1809,8 @@ class AppWindow(FrontWindow):
|
|||
|
||||
def search_sales_by_domain(self, _type='cash'):
|
||||
delta = str(datetime.now() - timedelta(1))
|
||||
if _type == 'reservation':
|
||||
delta = str(datetime.now() - timedelta(30))
|
||||
shop_id = self.shop['id']
|
||||
|
||||
if self.type_pos_user == 'cashier':
|
||||
|
@ -1797,12 +1846,18 @@ class AppWindow(FrontWindow):
|
|||
('shop', '=', shop_id),
|
||||
('create_date', '>=', delta),
|
||||
]
|
||||
print(_type, 'this type')
|
||||
if _type == 'cash':
|
||||
dom.append(['payment_term', '=', self.default_payment_term['id']])
|
||||
else:
|
||||
dom.append(['reservation', '!=', True])
|
||||
elif _type == 'credit':
|
||||
dom.append(['reservation', '!=', True])
|
||||
dom.append(['payment_term', '!=', self.default_payment_term['id']])
|
||||
else:
|
||||
dom.append(('reservation', '=', True))
|
||||
# dom.append(['payment_method', '!=', 'all_paid'])
|
||||
fields = self.dialog_search_sales.fields_names
|
||||
print(dom, 'dom', _type)
|
||||
sales = self.Sale.find(dom, fields=fields, order=[('id', 'DESC')])
|
||||
self.dialog_search_sales.set_from_values(sales)
|
||||
if self.enviroment == 'retail':
|
||||
|
@ -2932,7 +2987,7 @@ class AppWindow(FrontWindow):
|
|||
'cash_received': to_numeric(amount),
|
||||
'voucher_number': voucher_number,
|
||||
'extra_paid': False,
|
||||
})
|
||||
}, ctx={'advance': False, 'reservation': False})
|
||||
|
||||
if res.get('msg') not in ('missing_money', 'ok'):
|
||||
self.dialog(res['msg'])
|
||||
|
@ -2965,6 +3020,7 @@ class AppWindow(FrontWindow):
|
|||
|
||||
def set_state(self, state='add'):
|
||||
self._state = state
|
||||
print('state', state)
|
||||
state = STATES[state]
|
||||
self._re = state['re']
|
||||
if not self.type_pos_user == 'order':
|
||||
|
@ -3012,6 +3068,7 @@ class AppWindow(FrontWindow):
|
|||
self.action_read_weight()
|
||||
|
||||
def key_special_pressed(self, value):
|
||||
print('especial presed2222')
|
||||
self.clear_amount_text()
|
||||
self.clear_input_text()
|
||||
if value not in ['-', '/', '*']:
|
||||
|
@ -3021,6 +3078,7 @@ class AppWindow(FrontWindow):
|
|||
self.sign_text_changed(value)
|
||||
|
||||
def key_backspace_pressed(self):
|
||||
print('backspace presed2222')
|
||||
if self._sign or self._state in ('checkout', 'payment'):
|
||||
self._amount_text = self._amount_text[:-1]
|
||||
self.amount_text_changed()
|
||||
|
@ -3136,7 +3194,7 @@ class AppWindow(FrontWindow):
|
|||
if not data:
|
||||
return
|
||||
_record = None
|
||||
print(line, 'this line')
|
||||
print(line, 'this line', data)
|
||||
update_base_price = self.dialog_product_edit.checkbox_base.isChecked()
|
||||
if update_base_price:
|
||||
data['update_base_price'] = update_base_price
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 32 32" style="enable-background:new 0 0 32 32;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}
|
||||
</style>
|
||||
<circle cx="20.5" cy="10.5" r="4.5"/>
|
||||
<path d="M29.9,16.5C29.7,16.2,29.4,16,29,16c-2.2,0-4.3,1-5.6,2.8L22.5,20c-1.1,1.3-2.8,2-4.5,2h-3c-0.6,0-1-0.4-1-1s0.4-1,1-1h1.9
|
||||
c1.6,0,3.1-1.3,3.1-2.9c0,0,0-0.1,0-0.1c0-0.5-0.5-1-1-1l-6.1,0c-3.6,0-6.5,1.6-8.1,4.2l-2.7,4.2c-0.2,0.3-0.2,0.7,0,1l3,5
|
||||
c0.1,0.2,0.4,0.4,0.6,0.5c0.1,0,0.1,0,0.2,0c0.2,0,0.4-0.1,0.6-0.2c3.8-2.5,8.2-3.8,12.7-3.8c3.3,0,6.3-1.8,7.9-4.7l2.7-4.8
|
||||
C30,17.2,30,16.8,29.9,16.5z"/>
|
||||
<path d="M14,10.5c0-2.5,1.5-4.7,3.6-5.8C16.9,3.1,15.3,2,13.5,2C11,2,9,4,9,6.5s2,4.5,4.5,4.5c0.2,0,0.3,0,0.5-0.1
|
||||
C14,10.8,14,10.7,14,10.5z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -1 +1 @@
|
|||
__version__ = "5.0.49"
|
||||
__version__ = "5.0.50"
|
Loading…
Reference in New Issue