Display tax info per line, and totals
This commit is contained in:
parent
d15f521679
commit
fb4206e5a9
|
@ -65,6 +65,8 @@ class WuttaTxnItem(WuttaControl):
|
|||
|
||||
self.sales_total = ft.TextSpan(style=self.sales_total_style)
|
||||
|
||||
self.tax_flag = ft.TextSpan(style=self.major_style)
|
||||
|
||||
# set initial text display values
|
||||
self.refresh(update=False)
|
||||
|
||||
|
@ -83,6 +85,8 @@ class WuttaTxnItem(WuttaControl):
|
|||
ft.Text(
|
||||
spans=[
|
||||
self.sales_total,
|
||||
ft.TextSpan(" "),
|
||||
self.tax_flag,
|
||||
],
|
||||
),
|
||||
|
||||
|
@ -115,11 +119,13 @@ class WuttaTxnItem(WuttaControl):
|
|||
if self.row.void:
|
||||
self.major_style.color = 'red'
|
||||
self.major_style.decoration = ft.TextDecoration.LINE_THROUGH
|
||||
self.major_style.weight = None
|
||||
self.minor_style.color = 'red'
|
||||
self.minor_style.decoration = ft.TextDecoration.LINE_THROUGH
|
||||
else:
|
||||
self.major_style.color = None
|
||||
self.major_style.decoration = None
|
||||
self.major_style.weight = ft.FontWeight.BOLD
|
||||
self.minor_style.color = None
|
||||
self.minor_style.decoration = None
|
||||
|
||||
|
@ -127,16 +133,19 @@ class WuttaTxnItem(WuttaControl):
|
|||
self.quantity.text = self.app.render_quantity(self.row.quantity)
|
||||
self.txn_price.text = self.app.render_currency(self.row.txn_price)
|
||||
self.sales_total.text = self.app.render_currency(self.row.sales_total)
|
||||
self.tax_flag.text = f"T{self.row.tax_code}" if self.row.tax_code else ""
|
||||
|
||||
if self.row.void:
|
||||
self.sales_total_style.color = 'red'
|
||||
self.sales_total_style.decoration = ft.TextDecoration.LINE_THROUGH
|
||||
self.sales_total_style.weight = None
|
||||
else:
|
||||
if self.row.txn_price < self.row.reg_price:
|
||||
self.sales_total_style.color = 'green'
|
||||
self.sales_total_style.color = 'blue'
|
||||
else:
|
||||
self.sales_total_style.color = None
|
||||
self.sales_total_style.decoration = None
|
||||
self.sales_total_style.weight = ft.FontWeight.BOLD
|
||||
|
||||
if update:
|
||||
self.update()
|
||||
|
|
|
@ -98,6 +98,7 @@ class POSView(WuttaView):
|
|||
self.page.session.set('cust_uuid', customer.uuid)
|
||||
self.page.session.set('cust_display', handler.get_screen_cust_display(customer=customer))
|
||||
self.informed_refresh()
|
||||
self.refresh_totals( batch)
|
||||
|
||||
self.show_snackbar(f"CUSTOMER SET: {customer}", bgcolor='green')
|
||||
|
||||
|
@ -111,6 +112,32 @@ class POSView(WuttaView):
|
|||
else:
|
||||
self.item_lookup()
|
||||
|
||||
def refresh_totals(self, batch):
|
||||
reg = ft.TextStyle(size=22)
|
||||
bold = ft.TextStyle(size=24, weight=ft.FontWeight.BOLD)
|
||||
|
||||
self.subtotals.spans.clear()
|
||||
|
||||
self.subtotals.spans.append(ft.TextSpan("Sales ", style=reg))
|
||||
total = self.app.render_currency(batch.sales_total or 0)
|
||||
self.subtotals.spans.append(ft.TextSpan(total, style=bold))
|
||||
|
||||
for btax in sorted(batch.taxes.values(),
|
||||
key=lambda t: t.tax_code):
|
||||
if btax.tax_total:
|
||||
self.subtotals.spans.append(ft.TextSpan(f" Tax {btax.tax_code} ", style=reg))
|
||||
total = self.app.render_currency(btax.tax_total)
|
||||
self.subtotals.spans.append(ft.TextSpan(total, style=bold))
|
||||
|
||||
if batch.tender_total:
|
||||
self.subtotals.spans.append(ft.TextSpan(f" Tend ", style=reg))
|
||||
total = self.app.render_currency(batch.tender_total)
|
||||
self.subtotals.spans.append(ft.TextSpan(total, style=bold))
|
||||
|
||||
self.txn_balance.value = self.app.render_currency(batch.get_balance() or 0)
|
||||
|
||||
self.totals_row.bgcolor = 'orange'
|
||||
|
||||
def attempt_add_product(self, uuid=None, record_badscan=False):
|
||||
session = self.app.make_session()
|
||||
handler = self.get_batch_handler()
|
||||
|
@ -143,7 +170,7 @@ class POSView(WuttaView):
|
|||
else:
|
||||
self.add_row_item(row)
|
||||
self.items.scroll_to(offset=-1, duration=100)
|
||||
self.txn_total.value = self.app.render_currency(batch.get_balance())
|
||||
self.refresh_totals(batch)
|
||||
self.reset()
|
||||
|
||||
else:
|
||||
|
@ -154,6 +181,7 @@ class POSView(WuttaView):
|
|||
self.show_snackbar(f"PRODUCT NOT FOUND: {entry}", bgcolor='yellow')
|
||||
|
||||
session.commit()
|
||||
self.refresh_totals(batch)
|
||||
session.close()
|
||||
self.page.update()
|
||||
return bool(row)
|
||||
|
@ -547,15 +575,27 @@ class POSView(WuttaView):
|
|||
height=800,
|
||||
)
|
||||
|
||||
self.txn_total = ft.Text("", size=40)
|
||||
self.subtotals = ft.Text(spans=[])
|
||||
|
||||
self.txn_balance = ft.Text("", size=40, weight=ft.FontWeight.BOLD)
|
||||
|
||||
self.totals_row = ft.Container(
|
||||
ft.Row(
|
||||
[
|
||||
self.subtotals,
|
||||
self.txn_balance,
|
||||
],
|
||||
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
|
||||
),
|
||||
padding=ft.padding.only(10, 0, 10, 0),
|
||||
)
|
||||
|
||||
self.items_column = ft.Column(
|
||||
controls=[
|
||||
ft.Container(
|
||||
content=self.items,
|
||||
padding=ft.padding.only(10, 0, 10, 0)),
|
||||
ft.Row([self.txn_total],
|
||||
alignment=ft.MainAxisAlignment.END),
|
||||
self.totals_row,
|
||||
],
|
||||
expand=1,
|
||||
)
|
||||
|
@ -789,7 +829,7 @@ class POSView(WuttaView):
|
|||
self.add_row_item(row)
|
||||
self.items.scroll_to(offset=-1, duration=100)
|
||||
|
||||
self.txn_total.value = self.app.render_currency(batch.get_balance())
|
||||
self.refresh_totals(batch)
|
||||
|
||||
else:
|
||||
self.page.session.set('txn_display', None)
|
||||
|
@ -866,7 +906,7 @@ class POSView(WuttaView):
|
|||
|
||||
# update screen to reflect new balance
|
||||
batch = row.batch
|
||||
self.txn_total.value = self.app.render_currency(batch.get_balance())
|
||||
self.refresh_totals(batch)
|
||||
|
||||
# update item display
|
||||
self.selected_item.data['row'] = row
|
||||
|
@ -1094,6 +1134,7 @@ class POSView(WuttaView):
|
|||
session = self.app.make_session()
|
||||
handler = self.get_batch_handler()
|
||||
user = self.get_current_user(session)
|
||||
batch = self.get_current_batch(session, user=user)
|
||||
|
||||
# void line
|
||||
row = self.selected_item.data['row']
|
||||
|
@ -1116,7 +1157,7 @@ class POSView(WuttaView):
|
|||
self.selected_item.content.row = row
|
||||
self.selected_item.content.refresh()
|
||||
self.clear_item_selection()
|
||||
self.txn_total.value = self.app.render_currency(row.batch.get_balance())
|
||||
self.refresh_totals(batch)
|
||||
|
||||
session.close()
|
||||
self.reset()
|
||||
|
@ -1235,7 +1276,7 @@ class POSView(WuttaView):
|
|||
# update screen to reflect new items/balance
|
||||
for row in rows:
|
||||
self.add_row_item(row)
|
||||
self.txn_total.value = self.app.render_currency(batch.get_balance())
|
||||
self.refresh_totals(batch)
|
||||
|
||||
# executed batch means txn was finalized
|
||||
if batch.executed:
|
||||
|
@ -1249,7 +1290,7 @@ class POSView(WuttaView):
|
|||
bs.open = False
|
||||
bs.update()
|
||||
self.clear_all()
|
||||
self.page.update()
|
||||
self.reset()
|
||||
|
||||
bs = ft.BottomSheet(
|
||||
ft.Container(
|
||||
|
@ -1305,7 +1346,11 @@ class POSView(WuttaView):
|
|||
|
||||
def clear_all(self):
|
||||
self.items.controls.clear()
|
||||
self.txn_total.value = None
|
||||
|
||||
self.subtotals.spans.clear()
|
||||
self.txn_balance.value = None
|
||||
self.totals_row.bgcolor = None
|
||||
|
||||
self.page.session.set('txn_display', None)
|
||||
self.page.session.set('cust_uuid', None)
|
||||
self.page.session.set('cust_display', None)
|
||||
|
|
Loading…
Reference in a new issue