Add basic support for "sale" price

This commit is contained in:
Lance Edgar 2023-10-18 21:31:08 -05:00
parent d933a6acbc
commit 7edceac934
2 changed files with 33 additions and 14 deletions

View file

@ -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

View file

@ -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,