Cleanup some logic for tracking current txn/cust
This commit is contained in:
parent
1fd78d0c2f
commit
6caee556df
|
@ -74,10 +74,9 @@ class POSView(WuttaView):
|
||||||
handler = self.get_batch_handler()
|
handler = self.get_batch_handler()
|
||||||
handler.set_customer(batch, customer)
|
handler.set_customer(batch, customer)
|
||||||
|
|
||||||
key_field = self.app.get_customer_key_field()
|
self.page.session.set('txn_display', handler.get_screen_txn_display(batch))
|
||||||
customer_key = getattr(customer, key_field)
|
|
||||||
self.page.session.set('cust_uuid', customer.uuid)
|
self.page.session.set('cust_uuid', customer.uuid)
|
||||||
self.page.session.set('cust_display', str(customer_key or ''))
|
self.page.session.set('cust_display', handler.get_screen_cust_display(customer=customer))
|
||||||
self.informed_refresh()
|
self.informed_refresh()
|
||||||
|
|
||||||
self.page.snack_bar = ft.SnackBar(ft.Text(f"CUSTOMER SET: {customer}",
|
self.page.snack_bar = ft.SnackBar(ft.Text(f"CUSTOMER SET: {customer}",
|
||||||
|
@ -685,16 +684,27 @@ class POSView(WuttaView):
|
||||||
|
|
||||||
def did_mount(self):
|
def did_mount(self):
|
||||||
session = self.app.make_session()
|
session = self.app.make_session()
|
||||||
batch = self.get_current_batch(session)
|
batch = self.get_current_batch(session, create=False)
|
||||||
self.page.session.set('txn_display', batch.id_str)
|
if batch:
|
||||||
|
|
||||||
self.items.controls.clear()
|
handler = self.get_batch_handler()
|
||||||
for row in batch.active_rows():
|
self.page.session.set('txn_display', handler.get_screen_txn_display(batch))
|
||||||
self.add_row_item(row)
|
self.page.session.set('cust_uuid', batch.customer_uuid)
|
||||||
|
self.page.session.set('cust_display', handler.get_screen_cust_display(batch=batch))
|
||||||
|
|
||||||
self.items.scroll_to(offset=-1, duration=100)
|
self.items.controls.clear()
|
||||||
|
for row in batch.active_rows():
|
||||||
|
self.add_row_item(row)
|
||||||
|
self.items.scroll_to(offset=-1, duration=100)
|
||||||
|
|
||||||
self.txn_total.value = self.app.render_currency(batch.sales_total)
|
self.txn_total.value = self.app.render_currency(batch.sales_total)
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.page.session.set('txn_display', None)
|
||||||
|
self.page.session.set('cust_uuid', None)
|
||||||
|
self.page.session.set('cust_display', None)
|
||||||
|
|
||||||
|
self.informed_refresh()
|
||||||
|
|
||||||
session.commit()
|
session.commit()
|
||||||
session.close()
|
session.close()
|
||||||
|
@ -747,16 +757,10 @@ class POSView(WuttaView):
|
||||||
|
|
||||||
# void current batch
|
# void current batch
|
||||||
handler.void_batch(batch, user)
|
handler.void_batch(batch, user)
|
||||||
session.flush()
|
|
||||||
self.clear_all()
|
|
||||||
|
|
||||||
# make new batch
|
|
||||||
batch = handler.get_current_batch(user, create=True)
|
|
||||||
self.page.session.set('txn_display', batch.id_str)
|
|
||||||
|
|
||||||
session.commit()
|
session.commit()
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
|
self.clear_all()
|
||||||
self.main_input.focus()
|
self.main_input.focus()
|
||||||
self.page.update()
|
self.page.update()
|
||||||
|
|
||||||
|
@ -805,17 +809,10 @@ class POSView(WuttaView):
|
||||||
# tender / execute batch
|
# tender / execute batch
|
||||||
tender = e.control.content.value
|
tender = e.control.content.value
|
||||||
handler.tender_and_execute(batch, user, tender)
|
handler.tender_and_execute(batch, user, tender)
|
||||||
self.clear_all()
|
|
||||||
|
|
||||||
# make new batch
|
|
||||||
batch = handler.get_current_batch(user, create=True)
|
|
||||||
self.page.session.set('txn_display', batch.id_str)
|
|
||||||
self.header.update_txn_display()
|
|
||||||
self.header.update()
|
|
||||||
|
|
||||||
session.commit()
|
session.commit()
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
|
self.clear_all()
|
||||||
self.main_input.focus()
|
self.main_input.focus()
|
||||||
self.page.update()
|
self.page.update()
|
||||||
|
|
||||||
|
@ -840,7 +837,10 @@ class POSView(WuttaView):
|
||||||
model = self.model
|
model = self.model
|
||||||
|
|
||||||
user = session.get(model.User, self.page.session.get('user_uuid'))
|
user = session.get(model.User, self.page.session.get('user_uuid'))
|
||||||
batch = handler.get_current_batch(user)
|
batch, created = handler.get_current_batch(user, return_created=True)
|
||||||
|
if created:
|
||||||
|
self.page.session.set('txn_display', handler.get_screen_txn_display(batch))
|
||||||
|
self.informed_refresh()
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if self.set_quantity.data is not None:
|
if self.set_quantity.data is not None:
|
||||||
|
|
Loading…
Reference in a new issue