Cleanup the dev startup logic a bit

This commit is contained in:
Lance Edgar 2023-09-24 17:45:33 -05:00
parent 8f937d040a
commit 27dca66a0f

View file

@ -65,18 +65,31 @@ def main(page: ft.Page):
handler = app.get_batch_handler('pos')
session = app.make_session()
user = session.get(model.User, page.shared['user_uuid'])
# TODO: should also filter this by terminal
batch = handler.get_current_batch(user, create=False)
if batch:
page.shared['txn_display'] = batch.id_str
page.shared['cust_uuid'] = batch.customer_uuid
if batch.customer:
key = app.get_customer_key_field()
value = getattr(batch.customer, key)
page.shared['cust_display'] = str(value or '') or None
if user:
# TODO: should also filter this by terminal
batch = handler.get_current_batch(user, create=False)
if batch:
page.shared['txn_display'] = batch.id_str
page.shared['cust_uuid'] = batch.customer_uuid
if batch.customer:
key = app.get_customer_key_field()
value = getattr(batch.customer, key)
page.shared['cust_display'] = str(value or '') or None
else:
page.shared['cust_display'] = None
else:
page.shared['txn_display'] = None
page.shared['cust_uuid'] = None
page.shared['cust_display'] = None
else:
page.shared['user_uuid'] = None
page.shared['user_display'] = None
page.shared['txn_display'] = None
page.shared['cust_uuid'] = None
page.shared['cust_display'] = None
session.close()
else:
page.shared['user_display'] = None
def clean_exit():
if not config.production():