Exemple #1
0
    def finish_current_order_async(self, meal, order_type):
        try:
            new_order = OrdersService.create_new_order([meal], order_type)
        except:
            print("Creating new order failed.")
            raise

        if new_order == None:
            return

        new_order._price = new_order.calculate_price()

        self._set_breadcrumb_text(
            text=
            f"Letzte Bestellung: #{new_order.id} {meal.name} - {OrdersService.convert_timestamp(new_order.timestamp)} - {new_order.price_str}€"
        )

        #NotificationService.show_toast(
        #    title=REFS.ORDER_SUMMARY_TOAST[0],
        #    text=REFS.ORDER_SUMMARY_TOAST[1].format(new_order.id, new_order.meals[0].name, f"{new_order.price_str} {REFS.CURRENCY}")
        #)

        # Send Message to other station about order creation
        OrderMessagingService.notify_of_changes(
            changed_order=new_order, prefix=REFS.ORDER_CREATED_PREFIX)
Exemple #2
0
    def finish_current_order(self):
        """ Finished the current order
        """
        new_order = None

        # Grab the list of added meals from the Current Order View
        meals_list = self._current_order_view.added_meals
        order_form = self._current_order_view.order_form

        try:
            new_order = OrdersService.create_new_order(meals_list, order_form)
        except:
            print("Creating new order failed.")
            raise

        if new_order == None:
            return

        self.show_receipt(order=new_order)

        # Send Message to other station about order creation (fire and forget)
        OrderMessagingService.notify_of_changes(
            changed_order=new_order, prefix=REFS.ORDER_CREATED_PREFIX)

        # Reset Current Order View
        self._current_order_view.remove_all()
 def clear_history(self):
     if REFS.MAIN_STATION:
         if OrdersService.delete_from_table(
                 condition=
                 f"{REFS.ORDERS_TABLE_ACTIVE}='{REFS.ORDERS_TABLE_ACTIVE_FALSE}'",
                 confirm=True):
             self.update_view_and_database_content()
     else:
         OrderMessagingService.request_table_deletion(only_inactive=True)
    def on_tile_clicked_async(self, order, new_state):
        if REFS.MAIN_STATION:
            # If we are in CashDesk:
            OrdersService.update_order(order, active=True)

            # Send Message to other station about order creation (fire and forget)
            OrderMessagingService.notify_of_changes(
                changed_order=order, prefix=REFS.ORDER_CHANGED_PREFIX)

            self.show_view()
        else:
            OrderMessagingService.request_order_update(order=order,
                                                       state=new_state)
Exemple #5
0
    def initialize(self, debug: bool = False):
        """ Has to be called, when the GUI is finished with initialization.
        """
        self._main_cycle_thread()

        ##### Handler Registration

        # EncryptionHandler
        self._encryption_handler = EncryptionHandler(key=REFS.PUBLIC_KEY_16BIT)

        # Initialize database handler
        self._database_handler = DatabaseHandler(debug=debug)

        # Initialize network handler
        self._network_handler = NetworkHandler(main_station = REFS.MAIN_STATION)
        # Start continous receive-loop
        self._network_handler.start_receive_loop()

        self._secondary_cycle_thread()

        ##### Service Registration

        # Initialize meals service (which is using the database handler)
        self._meals_service = MealsService()
        self._orders_service = OrdersService()
        self._order_messaging_service = OrderMessagingService()

        # If the db connection has been established: trigger the event
        if self._database_handler.CONNECTION_READY:
            self._db_connection_ready_event()
    def _save_order(self):
        if REFS.MAIN_STATION:
            OrdersService.update_order(self._changed_order)

            # Send Message to other station about order creation (fire and forget)
            OrderMessagingService.notify_of_changes(
                changed_order=self._changed_order,
                prefix=REFS.ORDER_CHANGED_PREFIX)
        else:
            OrderMessagingService.request_order_update(
                order=self._changed_order, form=self._changed_order.form)

        self._order = self._changed_order.copy()

        self.form.config(text=OrdersService.convert_form(self._order.form))
        self.state.config(text=OrdersService.convert_status(self._order.state))
        self.state.config(
            background=REFS.ORDER_STATE_COLORS[self._order.state])

        if self._order.state != REFS.OPEN and self._order.state != REFS.CHANGED:
            self.edit.config(state="disabled")
 def reset_order_counter(self):
     if REFS.MAIN_STATION:
         if OrdersService.truncate_table():
             self.update_view_and_database_content()
     else:
         OrderMessagingService.request_table_deletion(only_inactive=False)