Add way to remove customer from txn

This commit is contained in:
Lance Edgar 2023-09-25 22:18:36 -05:00
parent 6caee556df
commit 207de81e51

View file

@ -194,6 +194,15 @@ class POSView(WuttaView):
self.customer_info()
def remove(e):
dlg.open = False
self.page.update()
# cf. https://github.com/flet-dev/flet/issues/1670
time.sleep(0.1)
self.remove_customer_prompt()
def replace(e):
dlg.open = False
self.page.update()
@ -220,16 +229,16 @@ class POSView(WuttaView):
title=ft.Text("Customer Already Selected"),
content=ft.Text("What would you like to do?", size=20),
actions=[
ft.Container(content=ft.Text("View Info",
ft.Container(content=ft.Text("Remove",
size=font_size,
weight=ft.FontWeight.BOLD),
height=self.default_button_size,
width=self.default_button_size * 2.5,
alignment=ft.alignment.center,
bgcolor='blue',
bgcolor='red',
border=ft.border.all(1, 'black'),
border_radius=ft.border_radius.all(5),
on_click=view_info),
on_click=remove),
ft.Container(content=ft.Text("Replace",
size=font_size,
color='black',
@ -241,6 +250,16 @@ class POSView(WuttaView):
border=ft.border.all(1, 'black'),
border_radius=ft.border_radius.all(5),
on_click=replace),
ft.Container(content=ft.Text("View Info",
size=font_size,
weight=ft.FontWeight.BOLD),
height=self.default_button_size,
width=self.default_button_size * 2.5,
alignment=ft.alignment.center,
bgcolor='blue',
border=ft.border.all(1, 'black'),
border_radius=ft.border_radius.all(5),
on_click=view_info),
ft.Container(content=ft.Text("Cancel",
size=font_size,
# color='black',
@ -257,6 +276,67 @@ class POSView(WuttaView):
dlg.open = True
self.page.update()
def remove_customer_prompt(self):
def remove(e):
session = self.app.make_session()
handler = self.get_batch_handler()
batch = self.get_current_batch(session)
handler.set_customer(batch, None)
session.commit()
session.close()
self.page.session.set('cust_uuid', None)
self.page.session.set('cust_display', None)
self.informed_refresh()
dlg.open = False
self.main_input.value = ''
self.main_input.focus()
self.page.snack_bar = ft.SnackBar(ft.Text("CUSTOMER REMOVED",
color='black',
weight=ft.FontWeight.BOLD),
bgcolor='yellow',
duration=1500)
self.page.snack_bar.open = True
self.page.update()
def cancel(e):
dlg.open = False
self.main_input.value = ''
self.main_input.focus()
self.page.update()
font_size = self.default_font_size * 0.8
dlg = ft.AlertDialog(
title=ft.Text("Remove Customer"),
content=ft.Text("Really remove the customer from this transaction?", size=20),
actions=[
ft.Container(content=ft.Text("Remove",
size=font_size,
weight=ft.FontWeight.BOLD),
height=self.default_button_size,
width=self.default_button_size * 2.5,
alignment=ft.alignment.center,
bgcolor='red',
border=ft.border.all(1, 'black'),
border_radius=ft.border_radius.all(5),
on_click=remove),
ft.Container(content=ft.Text("Cancel",
size=font_size,
weight=ft.FontWeight.BOLD),
height=self.default_button_size,
width=self.default_button_size * 2.5,
alignment=ft.alignment.center,
border=ft.border.all(1, 'black'),
border_radius=ft.border_radius.all(5),
on_click=cancel),
])
self.page.dialog = dlg
dlg.open = True
self.page.update()
def attempt_set_customer(self, entry=None):
session = self.app.make_session()