From d933a6acbc821511c864392dbc95f83adb1e481d Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 12 Oct 2023 17:23:51 -0500 Subject: [PATCH] Move the '@' button next to main input not really needed on the 10-key, so replace that with minus sign this also adds feature to select a line item, then click ITEM to re-ring the same item (and honor set quantity) --- wuttapos/controls/tenkey.py | 2 +- wuttapos/views/pos.py | 91 +++++++++++++++++++++++-------------- 2 files changed, 58 insertions(+), 35 deletions(-) diff --git a/wuttapos/controls/tenkey.py b/wuttapos/controls/tenkey.py index d983186..3bc7098 100644 --- a/wuttapos/controls/tenkey.py +++ b/wuttapos/controls/tenkey.py @@ -53,7 +53,7 @@ class WuttaTenkeyMenu(WuttaControl): ] if not self.simple: row1.extend([ - self.make_tenkey_button("@"), + self.make_tenkey_button("-"), ]) row2 = [ diff --git a/wuttapos/views/pos.py b/wuttapos/views/pos.py index f7ed1be..ff17052 100644 --- a/wuttapos/views/pos.py +++ b/wuttapos/views/pos.py @@ -78,8 +78,10 @@ class POSView(WuttaView): """ # clear set (@) quantity if clear_quantity: - self.set_quantity.data = None - self.set_quantity.value = None + if self.set_quantity.data: + self.set_quantity.data = None + self.set_quantity.value = None + self.set_quantity_button.visible = True # clear/focus main input self.main_input.value = '' @@ -114,6 +116,15 @@ class POSView(WuttaView): if not self.attempt_add_product(): self.item_lookup(value) + elif self.selected_item: + row = self.selected_item.data['row'] + if row.product_uuid: + if self.attempt_add_product(uuid=row.product_uuid): + self.clear_item_selection() + self.page.update() + else: + self.item_lookup() + else: self.item_lookup() @@ -504,37 +515,9 @@ class POSView(WuttaView): self.customer_lookup() def tenkey_char(self, key): - - if key == '@': - quantity = self.main_input.value - valid = False - - if self.set_quantity.data is not None: - quantity = self.set_quantity.data - self.show_snackbar(f"QUANTITY ALREADY SET: {quantity}", bgcolor='yellow') - - else: - try: - quantity = decimal.Decimal(quantity) - valid = True - except decimal.InvalidOperation: - pass - - if valid and quantity: - self.set_quantity.data = quantity - self.set_quantity.value = self.app.render_quantity(quantity) + " @ " - self.main_input.value = "" - self.main_input.focus() - - else: - self.show_snackbar(f"INVALID @ QUANTITY: {quantity}", bgcolor='yellow') - - self.page.update() - - else: # normal char - self.main_input.value = f"{self.main_input.value or ''}{key}" - self.main_input.focus() - self.page.update() + self.main_input.value = f"{self.main_input.value or ''}{key}" + self.main_input.focus() + self.page.update() def tenkey_enter(self, e): self.main_submit() @@ -630,6 +613,7 @@ class POSView(WuttaView): elif self.set_quantity.data is not None: self.set_quantity.data = None self.set_quantity.value = None + self.set_quantity_button.visible = True elif self.selected_item: self.clear_item_selection() self.main_input.focus() @@ -743,6 +727,13 @@ class POSView(WuttaView): self.set_quantity = ft.Text(value=None, data=None, weight=ft.FontWeight.BOLD, size=40) + self.set_quantity_button = self.make_button("@", + font_size=40, + height=70, + width=70, + bgcolor='green', + on_click=self.set_quantity_click) + return [ self.build_header(), @@ -751,7 +742,12 @@ class POSView(WuttaView): self.make_logo_image(height=80), ft.Row( [ - self.set_quantity, + ft.Row( + [ + self.set_quantity, + self.set_quantity_button, + ], + ), self.main_input, self.make_button("⌫", font_size=40, bgcolor='green', height=70, width=70, @@ -799,6 +795,33 @@ class POSView(WuttaView): kwargs.setdefault('size', 24) return ft.Text(*args, **kwargs) + def set_quantity_click(self, e): + quantity = self.main_input.value + valid = False + + if self.set_quantity.data is not None: + quantity = self.set_quantity.data + self.show_snackbar(f"QUANTITY ALREADY SET: {quantity}", bgcolor='yellow') + + else: + try: + quantity = decimal.Decimal(quantity) + valid = True + except decimal.InvalidOperation: + pass + + if valid and quantity: + self.set_quantity.data = quantity + self.set_quantity.value = self.app.render_quantity(quantity) + " @ " + self.set_quantity_button.visible = False + self.main_input.value = "" + self.main_input.focus() + + else: + self.show_snackbar(f"INVALID @ QUANTITY: {quantity}", bgcolor='yellow') + + self.page.update() + def make_tender_button(self, tender, **kwargs): if isinstance(tender, self.model.Tender): info = {'tender_code': tender.code,