From 7edceac93450d76215c309a64f3cf2bf25b1b417 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 18 Oct 2023 21:31:08 -0500 Subject: [PATCH] Add basic support for "sale" price --- wuttapos/controls/txnitem.py | 7 +++++-- wuttapos/views/pos.py | 40 +++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/wuttapos/controls/txnitem.py b/wuttapos/controls/txnitem.py index 4ffe91d..7eae879 100644 --- a/wuttapos/controls/txnitem.py +++ b/wuttapos/controls/txnitem.py @@ -143,8 +143,11 @@ class WuttaTxnItem(WuttaControl): self.sales_total_style.weight = None else: if (self.row.row_type == self.enum.POS_ROW_TYPE_SELL - and self.row.txn_price < self.row.reg_price): - self.sales_total_style.color = 'blue' + and self.row.txn_price_adjusted): + self.sales_total_style.color = 'orange' + elif (self.row.row_type == self.enum.POS_ROW_TYPE_SELL + and self.row.cur_price and self.row.cur_price < self.row.reg_price): + self.sales_total_style.color = 'green' else: self.sales_total_style.color = None self.sales_total_style.decoration = None diff --git a/wuttapos/views/pos.py b/wuttapos/views/pos.py index ff17052..d22f5f0 100644 --- a/wuttapos/views/pos.py +++ b/wuttapos/views/pos.py @@ -1166,12 +1166,28 @@ class POSView(WuttaView): self.clear_item_selection() self.reset() - price_override = ft.TextField(value=self.main_input.value, + row = self.selected_item.data['row'] + + price = f'{row.txn_price:0.2f}' + if self.main_input.value: + try: + price = decimal.Decimal(self.main_input.value) + except decimal.InvalidOperation: + pass + else: + price = f'{price:0.2f}' + + price_override = ft.TextField(value=price, text_size=32, text_style=ft.TextStyle(weight=ft.FontWeight.BOLD), autofocus=True, on_submit=confirm) + current_price = self.app.render_currency(row.cur_price) + if current_price: + current_price += ' [{}]'.format(self.enum.PRICE_TYPE.get(row.cur_price_type, + row.cur_price_type)) + dlg = ft.AlertDialog( modal=True, title=ft.Text("Adjust Price"), @@ -1183,25 +1199,25 @@ class POSView(WuttaView): [ ft.Text("Reg Price:", size=32, weight=ft.FontWeight.BOLD), - ft.Text(self.app.render_currency(self.selected_item.data['row'].reg_price), + ft.Text(self.app.render_currency(row.reg_price), size=32, weight=ft.FontWeight.BOLD), ], ), ft.Row(), + ft.Row( + [ + ft.Text("Cur Price:", + size=32, weight=ft.FontWeight.BOLD), + ft.Text(current_price, + size=32, weight=ft.FontWeight.BOLD), + ], + ), + ft.Row(), + ft.Row(), ft.Row( [ ft.Text("Txn Price:", size=32, weight=ft.FontWeight.BOLD), - ft.Text(self.app.render_currency(self.selected_item.data['row'].txn_price), - size=32, weight=ft.FontWeight.BOLD), - ], - ), - ft.Row(), - ft.Row(), - ft.Row( - [ - ft.Text("New Price:", - size=32, weight=ft.FontWeight.BOLD), ft.VerticalDivider(), ft.Text("$", size=32, weight=ft.FontWeight.BOLD), price_override,