Add stub logic to kick drawer for "no sale" and based on txn tenders

This commit is contained in:
Lance Edgar 2023-10-06 20:34:41 -05:00
parent 61a06ec5de
commit d15f521679

View file

@ -619,7 +619,7 @@ class POSView(WuttaView):
[
meta_button("Adjust\nPrice", font_size=30, bgcolor='yellow',
on_click=self.adjust_price_click),
meta_button("TODO", bgcolor='blue', on_click=self.not_supported),
meta_button("NO SALE", bgcolor='yellow', on_click=self.nosale_click),
],
spacing=0,
),
@ -958,6 +958,22 @@ class POSView(WuttaView):
dlg.open = True
self.page.update()
def nosale_click(self, e):
session = self.app.make_session()
batch = self.get_current_batch(session, create=False)
session.close()
if batch:
self.show_snackbar("TRANSACTION IN PROGRESS", bgcolor='yellow')
self.page.update()
return
self.kick_drawer()
def kick_drawer(self):
self.show_snackbar("TODO: Drawer Kick", bgcolor='yellow')
self.page.update()
def add_row_item(self, row):
# TODO: row types ugh
@ -1065,7 +1081,7 @@ class POSView(WuttaView):
# nothing to void if no batch
if not batch:
self.show_snackbar("No transaction", bgcolor='yellow')
self.show_snackbar("NO TRANSACTION", bgcolor='yellow')
self.reset()
return
@ -1202,10 +1218,6 @@ class POSView(WuttaView):
# tender / execute batch
try:
# TODO: still need support for the following:
# - if balance remains, update display (i.e. show this tender)
# - if this tender overpays, how to handle change back?
# apply tender amount to batch
# nb. this *may* execute the batch!
# nb. we negate the amount supplied by user
@ -1273,6 +1285,13 @@ class POSView(WuttaView):
# txn finalized but no change back; clear screen
self.clear_all()
# kick drawer if accepting any tender which requires
# that, or if we are giving change back
first_row = rows[0]
if ((first_row.tender and first_row.tender.kick_drawer)
or last_row.row_type == self.enum.POS_ROW_TYPE_CHANGE_BACK):
self.kick_drawer()
finally:
session.close()