Exemple #1
0
    def deactivate(self):
        self.uimanager.remove_ui(self.pos_ui)

        # Re enable toolbar
        self.uimanager.get_widget('/toolbar').show()
        self.uimanager.get_widget('/menubar/ViewMenu/ToggleToolbar').show()

        # one PosApp is created everytime the pos is opened. If we dont
        # disconnect, the callback from this instance would still be called, but
        # its no longer valid.
        CloseLoanWizardFinishEvent.disconnect(self._on_CloseLoanWizardFinishEvent)
Exemple #2
0
    def deactivate(self):
        self.uimanager.remove_ui(self.pos_ui)

        # Re enable toolbar
        self.uimanager.get_widget('/toolbar').show()
        self.uimanager.get_widget('/menubar/ViewMenu/ToggleToolbar').show()

        # one PosApp is created everytime the pos is opened. If we dont
        # disconnect, the callback from this instance would still be called, but
        # its no longer valid.
        CloseLoanWizardFinishEvent.disconnect(
            self._on_CloseLoanWizardFinishEvent)
Exemple #3
0
    def finish(self):
        for loan in self.models:
            for item in loan.loaned_items:
                original = self.original_items[item]
                sale_quantity = item.sale_quantity - original.sale_quantity
                if sale_quantity > 0:
                    self._sold_items.append((item.sellable, sale_quantity, item.price))

        if self._create_sale and self._sold_items:
            user = api.get_current_user(self.store)
            sale = Sale(
                store=self.store,
                # Even if there is more than one loan, they are always from the
                # same (client, branch)
                branch=self.models[0].branch,
                client=self.models[0].client,
                salesperson=user.person.salesperson,
                group=PaymentGroup(store=self.store),
                coupon_id=None,
            )

            for sellable, quantity, price in self._sold_items:
                sale.add_sellable(
                    sellable,
                    quantity,
                    price,
                    # Quantity was already decreased on loan
                    quantity_decreased=quantity,
                )

            sale.order()
            info(
                _("Close loan details..."),
                _("A sale was created from loan items. You can confirm " "that sale in the Till application later."),
            )
        else:
            sale = None

        for model in self.models:
            model.sync_stock()
            if model.can_close():
                model.close()

        self.retval = self.models
        self.close()
        CloseLoanWizardFinishEvent.emit(self.models, sale, self)
Exemple #4
0
    def finish(self):
        for loan in self.models:
            for item in loan.loaned_items:
                original = self.original_items[item]
                sale_quantity = item.sale_quantity - original.sale_quantity
                if sale_quantity > 0:
                    self._sold_items.append(
                        (item.sellable, sale_quantity, item.price))

        if self._create_sale and self._sold_items:
            user = api.get_current_user(self.store)
            sale = Sale(
                store=self.store,
                # Even if there is more than one loan, they are always from the
                # same (client, branch)
                branch=self.models[0].branch,
                station=api.get_current_station(self.store),
                client=self.models[0].client,
                salesperson=user.person.sales_person,
                group=PaymentGroup(store=self.store),
                coupon_id=None)

            for sellable, quantity, price in self._sold_items:
                sale.add_sellable(
                    sellable,
                    quantity,
                    price,
                    # Quantity was already decreased on loan
                    quantity_decreased=quantity)

            sale.order(user)
            info(
                _("Close loan details..."),
                _("A sale was created from loan items. You can confirm "
                  "that sale in the Till application later."))
        else:
            sale = None

        for model in self.models:
            model.sync_stock(api.get_current_user(self.store))
            if model.can_close():
                model.close()

        self.retval = self.models
        self.close()
        CloseLoanWizardFinishEvent.emit(self.models, sale, self)
Exemple #5
0
    def activate(self, refresh=True):
        # Admin app doesn't have anything to print/export
        for widget in (self.window.Print, self.window.ExportSpreadSheet):
            widget.set_visible(False)

        # Hide toolbar specially for pos
        self.uimanager.get_widget('/toolbar').hide()
        self.uimanager.get_widget('/menubar/ViewMenu/ToggleToolbar').hide()

        self.check_open_inventory()
        self._update_parameter_widgets()
        self._update_widgets()
        # This is important to do after the other calls, since
        # it emits signals that disable UI which might otherwise
        # be enabled.
        self._printer.run_initial_checks()

        CloseLoanWizardFinishEvent.connect(self._on_CloseLoanWizardFinishEvent)
Exemple #6
0
    def activate(self, params):
        # Admin app doesn't have anything to print/export
        for widget in (self.window.Print, self.window.ExportSpreadSheet):
            widget.set_visible(False)

        # Hide toolbar specially for pos
        self.uimanager.get_widget('/toolbar').hide()
        self.uimanager.get_widget('/menubar/ViewMenu/ToggleToolbar').hide()

        self.check_open_inventory()
        self._update_parameter_widgets()
        self._update_widgets()
        # This is important to do after the other calls, since
        # it emits signals that disable UI which might otherwise
        # be enabled.
        self._printer.run_initial_checks()

        CloseLoanWizardFinishEvent.connect(self._on_CloseLoanWizardFinishEvent)