diff --git a/wuttapos/app.py b/wuttapos/app.py index dd4b410..e0139b6 100644 --- a/wuttapos/app.py +++ b/wuttapos/app.py @@ -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():