Do not void txn if there is none
This commit is contained in:
parent
207de81e51
commit
a7ab1b5882
|
@ -841,39 +841,63 @@ class POSView(WuttaView):
|
|||
session.close()
|
||||
|
||||
self.clear_all()
|
||||
self.main_input.value = ''
|
||||
self.main_input.focus()
|
||||
self.page.update()
|
||||
|
||||
def cancel(e):
|
||||
dlg.open = False
|
||||
self.main_input.focus()
|
||||
self.page.update()
|
||||
|
||||
dlg = ft.AlertDialog(
|
||||
# modal=True,
|
||||
title=ft.Text("Confirm VOID"),
|
||||
content=ft.Text("Really VOID this transaction?"),
|
||||
actions=[
|
||||
ft.Container(content=ft.Text("Yes, VOID",
|
||||
size=self.default_font_size,
|
||||
color='black',
|
||||
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=confirm),
|
||||
ft.Container(content=ft.Text("Cancel",
|
||||
size=self.default_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),
|
||||
])
|
||||
session = self.app.make_session()
|
||||
batch = self.get_current_batch(session, create=False)
|
||||
session.close()
|
||||
|
||||
if batch:
|
||||
|
||||
dlg = ft.AlertDialog(
|
||||
title=ft.Text("Confirm VOID"),
|
||||
content=ft.Text("Really VOID this transaction?"),
|
||||
actions=[
|
||||
ft.Container(content=ft.Text("Yes, VOID",
|
||||
size=self.default_font_size,
|
||||
color='black',
|
||||
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=confirm),
|
||||
ft.Container(content=ft.Text("Cancel",
|
||||
size=self.default_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),
|
||||
])
|
||||
|
||||
else: # nothing to void
|
||||
|
||||
dlg = ft.AlertDialog(
|
||||
title=ft.Text("No Transaction"),
|
||||
content=ft.Text("You do not have a transaction open currently.", size=20),
|
||||
actions=[
|
||||
ft.Container(content=ft.Text("Close",
|
||||
size=self.default_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
|
||||
|
|
Loading…
Reference in a new issue