Record bad scans in transaction; tweak snackbar etc.
This commit is contained in:
parent
39abb0d648
commit
4058f2df67
|
@ -95,6 +95,7 @@ class POSView(WuttaView):
|
||||||
|
|
||||||
self.page.snack_bar = ft.SnackBar(ft.Text(f"CUSTOMER SET: {customer}",
|
self.page.snack_bar = ft.SnackBar(ft.Text(f"CUSTOMER SET: {customer}",
|
||||||
color='black',
|
color='black',
|
||||||
|
size=20,
|
||||||
weight=ft.FontWeight.BOLD),
|
weight=ft.FontWeight.BOLD),
|
||||||
bgcolor='green',
|
bgcolor='green',
|
||||||
duration=1500)
|
duration=1500)
|
||||||
|
@ -110,22 +111,22 @@ class POSView(WuttaView):
|
||||||
else:
|
else:
|
||||||
self.item_lookup()
|
self.item_lookup()
|
||||||
|
|
||||||
def attempt_add_product(self, uuid=None):
|
def attempt_add_product(self, uuid=None, record_badscan=False):
|
||||||
session = self.app.make_session()
|
session = self.app.make_session()
|
||||||
handler = self.get_batch_handler()
|
handler = self.get_batch_handler()
|
||||||
batch = self.get_current_batch(session)
|
batch = self.get_current_batch(session)
|
||||||
entry = self.main_input.value
|
entry = self.main_input.value
|
||||||
|
|
||||||
kw = {}
|
quantity = 1
|
||||||
if self.set_quantity.data is not None:
|
if self.set_quantity.data is not None:
|
||||||
kw['quantity'] = self.set_quantity.data
|
quantity = self.set_quantity.data
|
||||||
|
|
||||||
product = None
|
product = None
|
||||||
if uuid:
|
if uuid:
|
||||||
product = session.get(self.model.Product, uuid)
|
product = session.get(self.model.Product, uuid)
|
||||||
assert product
|
assert product
|
||||||
|
|
||||||
row = handler.process_entry(batch, product or entry, **kw)
|
row = handler.process_entry(batch, product or entry, quantity=quantity)
|
||||||
|
|
||||||
if row:
|
if row:
|
||||||
session.commit()
|
session.commit()
|
||||||
|
@ -135,8 +136,13 @@ class POSView(WuttaView):
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
if record_badscan:
|
||||||
|
handler.record_badscan(batch, entry, quantity=quantity)
|
||||||
|
|
||||||
self.page.snack_bar = ft.SnackBar(ft.Text(f"PRODUCT NOT FOUND: {entry}",
|
self.page.snack_bar = ft.SnackBar(ft.Text(f"PRODUCT NOT FOUND: {entry}",
|
||||||
color='black',
|
color='black',
|
||||||
|
size=20,
|
||||||
weight=ft.FontWeight.BOLD),
|
weight=ft.FontWeight.BOLD),
|
||||||
bgcolor='yellow',
|
bgcolor='yellow',
|
||||||
duration=1500)
|
duration=1500)
|
||||||
|
@ -208,6 +214,7 @@ class POSView(WuttaView):
|
||||||
session.close()
|
session.close()
|
||||||
self.page.snack_bar = ft.SnackBar(ft.Text(f"CUSTOMER NOT FOUND: {entry}",
|
self.page.snack_bar = ft.SnackBar(ft.Text(f"CUSTOMER NOT FOUND: {entry}",
|
||||||
color='black',
|
color='black',
|
||||||
|
size=20,
|
||||||
weight=ft.FontWeight.BOLD),
|
weight=ft.FontWeight.BOLD),
|
||||||
bgcolor='yellow',
|
bgcolor='yellow',
|
||||||
duration=1500)
|
duration=1500)
|
||||||
|
@ -370,6 +377,7 @@ class POSView(WuttaView):
|
||||||
dlg.open = False
|
dlg.open = False
|
||||||
self.page.snack_bar = ft.SnackBar(ft.Text("CUSTOMER REMOVED",
|
self.page.snack_bar = ft.SnackBar(ft.Text("CUSTOMER REMOVED",
|
||||||
color='black',
|
color='black',
|
||||||
|
size=20,
|
||||||
weight=ft.FontWeight.BOLD),
|
weight=ft.FontWeight.BOLD),
|
||||||
bgcolor='yellow',
|
bgcolor='yellow',
|
||||||
duration=1500)
|
duration=1500)
|
||||||
|
@ -422,6 +430,7 @@ class POSView(WuttaView):
|
||||||
else: # customer not found
|
else: # customer not found
|
||||||
self.page.snack_bar = ft.SnackBar(ft.Text(f"CUSTOMER NOT FOUND: {entry}",
|
self.page.snack_bar = ft.SnackBar(ft.Text(f"CUSTOMER NOT FOUND: {entry}",
|
||||||
color='black',
|
color='black',
|
||||||
|
size=20,
|
||||||
weight=ft.FontWeight.BOLD),
|
weight=ft.FontWeight.BOLD),
|
||||||
bgcolor='yellow',
|
bgcolor='yellow',
|
||||||
duration=1500)
|
duration=1500)
|
||||||
|
@ -504,6 +513,7 @@ class POSView(WuttaView):
|
||||||
quantity = self.set_quantity.data
|
quantity = self.set_quantity.data
|
||||||
self.page.snack_bar = ft.SnackBar(ft.Text(f"QUANTITY ALREADY SET: {quantity}",
|
self.page.snack_bar = ft.SnackBar(ft.Text(f"QUANTITY ALREADY SET: {quantity}",
|
||||||
color='black',
|
color='black',
|
||||||
|
size=20,
|
||||||
weight=ft.FontWeight.BOLD),
|
weight=ft.FontWeight.BOLD),
|
||||||
bgcolor='yellow',
|
bgcolor='yellow',
|
||||||
duration=1500)
|
duration=1500)
|
||||||
|
@ -525,6 +535,7 @@ class POSView(WuttaView):
|
||||||
else:
|
else:
|
||||||
self.page.snack_bar = ft.SnackBar(ft.Text(f"INVALID @ QUANTITY: {quantity}",
|
self.page.snack_bar = ft.SnackBar(ft.Text(f"INVALID @ QUANTITY: {quantity}",
|
||||||
color='black',
|
color='black',
|
||||||
|
size=20,
|
||||||
weight=ft.FontWeight.BOLD),
|
weight=ft.FontWeight.BOLD),
|
||||||
bgcolor='yellow',
|
bgcolor='yellow',
|
||||||
duration=1500)
|
duration=1500)
|
||||||
|
@ -639,15 +650,15 @@ class POSView(WuttaView):
|
||||||
[
|
[
|
||||||
ft.Row(
|
ft.Row(
|
||||||
[
|
[
|
||||||
meta_button("MGR", bgcolor='blue', on_click=self.not_supported),
|
meta_button("ITEM", bgcolor='blue', on_click=self.item_click),
|
||||||
meta_button("VOID", bgcolor='red', on_click=self.void_click),
|
meta_button("VOID", bgcolor='red', on_click=self.void_click),
|
||||||
],
|
],
|
||||||
spacing=0,
|
spacing=0,
|
||||||
),
|
),
|
||||||
ft.Row(
|
ft.Row(
|
||||||
[
|
[
|
||||||
meta_button("ITEM", bgcolor='blue', on_click=self.item_click),
|
|
||||||
meta_button("CUST", bgcolor='blue', on_click=self.customer_click),
|
meta_button("CUST", bgcolor='blue', on_click=self.customer_click),
|
||||||
|
meta_button("MGR", bgcolor='blue', on_click=self.not_supported),
|
||||||
],
|
],
|
||||||
spacing=0,
|
spacing=0,
|
||||||
),
|
),
|
||||||
|
@ -797,6 +808,7 @@ class POSView(WuttaView):
|
||||||
if feature:
|
if feature:
|
||||||
text += f": {feature}"
|
text += f": {feature}"
|
||||||
self.page.snack_bar = ft.SnackBar(ft.Text(text, color='black',
|
self.page.snack_bar = ft.SnackBar(ft.Text(text, color='black',
|
||||||
|
size=20,
|
||||||
weight=ft.FontWeight.BOLD),
|
weight=ft.FontWeight.BOLD),
|
||||||
bgcolor='yellow',
|
bgcolor='yellow',
|
||||||
duration=1500)
|
duration=1500)
|
||||||
|
@ -804,6 +816,11 @@ class POSView(WuttaView):
|
||||||
self.page.update()
|
self.page.update()
|
||||||
|
|
||||||
def add_row_item(self, row):
|
def add_row_item(self, row):
|
||||||
|
|
||||||
|
# TODO: row types ugh
|
||||||
|
if row.row_type not in ('sell',):
|
||||||
|
return
|
||||||
|
|
||||||
quantity = self.app.render_quantity(row.quantity)
|
quantity = self.app.render_quantity(row.quantity)
|
||||||
pretty_price = self.app.render_currency(row.txn_price)
|
pretty_price = self.app.render_currency(row.txn_price)
|
||||||
self.items.controls.append(
|
self.items.controls.append(
|
||||||
|
@ -903,17 +920,32 @@ class POSView(WuttaView):
|
||||||
def tender_click(self, e):
|
def tender_click(self, e):
|
||||||
model = self.model
|
model = self.model
|
||||||
session = self.app.make_session()
|
session = self.app.make_session()
|
||||||
handler = self.get_batch_handler()
|
|
||||||
user = session.get(model.User, self.page.session.get('user_uuid'))
|
|
||||||
batch = handler.get_current_batch(user)
|
|
||||||
|
|
||||||
# tender / execute batch
|
# tender / execute batch
|
||||||
tender = e.control.content.value
|
tender = e.control.content.value
|
||||||
handler.tender_and_execute(batch, user, tender)
|
try:
|
||||||
session.commit()
|
handler = self.get_batch_handler()
|
||||||
session.close()
|
user = session.get(model.User, self.page.session.get('user_uuid'))
|
||||||
|
batch = handler.get_current_batch(user)
|
||||||
|
handler.tender_and_execute(batch, user, tender)
|
||||||
|
|
||||||
|
except Exception as error:
|
||||||
|
session.rollback()
|
||||||
|
log.exception("failed to execute batch")
|
||||||
|
self.page.snack_bar = ft.SnackBar(ft.Text(f"ERROR: {error}",
|
||||||
|
color='black',
|
||||||
|
size=20,
|
||||||
|
weight=ft.FontWeight.BOLD),
|
||||||
|
bgcolor='red',
|
||||||
|
duration=1500)
|
||||||
|
self.page.snack_bar.open = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
session.commit()
|
||||||
|
self.clear_all()
|
||||||
|
finally:
|
||||||
|
session.close()
|
||||||
|
|
||||||
self.clear_all()
|
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def clear_all(self):
|
def clear_all(self):
|
||||||
|
@ -925,5 +957,6 @@ class POSView(WuttaView):
|
||||||
self.informed_refresh()
|
self.informed_refresh()
|
||||||
|
|
||||||
def main_submit(self, e=None):
|
def main_submit(self, e=None):
|
||||||
self.attempt_add_product()
|
if self.main_input.value:
|
||||||
|
self.attempt_add_product(record_badscan=True)
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
Loading…
Reference in a new issue