Ejemplo n.º 1
0
    def finish(self):
        missing = get_missing_items(self.model, self.store)
        if missing:
            # We want to close the checkout, so the user will be back to the
            # list of items in the sale.
            self.close()
            run_dialog(MissingItemsDialog, self, self.model, missing)
            return False

        group = self.model.group
        # FIXME: This is set too late on Sale.confirm(). If PaymentGroup don't
        #        have a payer, we won't be able to print bills/booklets.
        group.payer = self.model.client and self.model.client.person

        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            # If this is the second time the user is trying to confirm, an
            # error message is being displayed saying that the payment can't be
            # created twice, so we clear the payments created to avoid the message
            # TODO: Create the payments on the wizard finish event (here)
            self.payment_group.clear_unused()
            return

        self.retval = True
        self.close()
        retval = ConfirmSaleWizardFinishEvent.emit(self.model)
        if retval is not None:
            self.retval = retval

        if sysparam.get_bool('PRINT_SALE_DETAILS_ON_POS'):
            self.print_sale_details()
Ejemplo n.º 2
0
    def finish(self):
        missing = get_missing_items(self.model, self.store)
        if missing:
            # We want to close the checkout, so the user will be back to the
            # list of items in the sale.
            self.close()
            run_dialog(MissingItemsDialog, self, self.model, missing)
            return False

        group = self.model.group
        # FIXME: This is set too late on Sale.confirm(). If PaymentGroup don't
        #        have a payer, we won't be able to print bills/booklets.
        group.payer = self.model.client and self.model.client.person

        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            # If this is the second time the user is trying to confirm, an
            # error message is being displayed saying that the payment can't be
            # created twice, so we clear the payments created to avoid the message
            # TODO: Create the payments on the wizard finish event (here)
            self.payment_group.clear_unused()
            return

        self.retval = True
        self.close()
        retval = ConfirmSaleWizardFinishEvent.emit(self.model)
        if retval is not None:
            self.retval = retval

        if sysparam.get_bool('PRINT_SALE_DETAILS_ON_POS'):
            self.print_sale_details()
Ejemplo n.º 3
0
    def finish(self):
        missing = get_missing_items(self.model, self.store)
        if missing:
            run_dialog(MissingItemsDialog, self, self.model, missing)
            return False

        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            return

        # FIXME: If any issue happen at any point of the "send process",
        # trying to issue it again would make some products have their stock
        # decreased twice. Make sure we undo it first.
        # The issue itself was related to missing stock. Why get_missing_items
        # failed above?
        self.store.savepoint('before_send_transfer')
        try:
            self.model.send()
        except Exception as e:
            warning(_("An error happened when trying to confirm the transfer"),
                    str(e))
            self.store.rollback_to_savepoint('before_send_transfer')
            raise

        self.retval = self.model
        self.close()

        StockTransferWizardFinishEvent.emit(self.model)
        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        self._receipt_dialog(self.model)
Ejemplo n.º 4
0
    def finish(self):
        missing = get_missing_items(self.model, self.store)
        if missing:
            run_dialog(MissingItemsDialog, self, self.model, missing)
            return False

        # If this wizard is for a purchase return, the items are automatically
        # added so the tax check escaped. So we do it now.
        if self.receiving_order is not None:
            missing_tax_info = []
            for item in self.model.get_items():
                sellable = item.sellable
                try:
                    sellable.check_taxes_validity()
                except TaxError:
                    missing_tax_info.append(sellable.description)
            if missing_tax_info:
                warning(_("There are some items with missing tax information"),
                        ', '.join(missing_tax_info))
                return False

        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            return

        self.retval = self.model
        self.model.confirm()
        self.close()

        StockDecreaseWizardFinishEvent.emit(self.model)
        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        self._receipt_dialog()
Ejemplo n.º 5
0
    def finish(self):
        missing = get_missing_items(self.model, self.store)
        if missing:
            run_dialog(MissingItemsDialog, self, self.model, missing)
            return False

        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            return

        # FIXME: If any issue happen at any point of the "send process",
        # trying to issue it again would make some products have their stock
        # decreased twice. Make sure we undo it first.
        # The issue itself was related to missing stock. Why get_missing_items
        # failed above?
        self.store.savepoint('before_send_transfer')
        try:
            self.model.send()
        except Exception as e:
            warning(_("An error happened when trying to confirm the transfer"),
                    str(e))
            self.store.rollback_to_savepoint('before_send_transfer')
            raise

        self.retval = self.model
        self.close()

        StockTransferWizardFinishEvent.emit(self.model)
        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        self._receipt_dialog(self.model)
Ejemplo n.º 6
0
    def finish(self):
        missing = get_missing_items(self.model, self.store)
        if missing:
            run_dialog(MissingItemsDialog, self, self.model, missing)
            return False

        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            return

        self.retval = self.model
        self.model.confirm()
        self.close()

        StockDecreaseWizardFinishEvent.emit(self.model)
        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        self._receipt_dialog()
Ejemplo n.º 7
0
    def finish(self):
        missing = get_missing_items(self.model, self.store)
        if missing:
            run_dialog(MissingItemsDialog, self, self.model, missing)
            return False

        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            return

        self.retval = self.model
        self.model.confirm()
        self.close()

        StockDecreaseWizardFinishEvent.emit(self.model)
        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        self._receipt_dialog()
Ejemplo n.º 8
0
    def finish(self):
        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            return

        login_user = api.get_current_user(self.store)
        self.model.return_(method_name=u'credit' if self.credit else u'money',
                           login_user=login_user)
        SaleReturnWizardFinishEvent.emit(self.model)
        self.retval = self.model
        self.close()

        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        if self.credit:
            if yesno(_(u'Would you like to print the credit letter?'),
                     Gtk.ResponseType.YES, _(u"Print Letter"), _(u"Don't print")):
                print_report(ClientCreditReport, self.model.client)
Ejemplo n.º 9
0
    def finish(self):
        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            return

        for payment in self.model.group.payments:
            if payment.is_preview():
                # Set payments created on SaleReturnPaymentStep as pending
                payment.set_pending()

        total_amount = self.model.total_amount
        # If the user chose to create credit for the client instead of returning
        # money, there is no need to display this messages.
        if not self.credit:
            if total_amount == 0:
                info(
                    _("The client does not have a debt to this sale anymore. "
                      "Any existing unpaid installment will be cancelled."))
            elif total_amount < 0:
                info(
                    _("A reversal payment to the client will be created. "
                      "You can see it on the Payable Application."))

        login_user = api.get_current_user(self.store)
        self.model.return_(method_name=u'credit' if self.credit else u'money',
                           login_user=login_user)
        SaleReturnWizardFinishEvent.emit(self.model)
        self.retval = self.model
        self.close()

        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        if self.credit:
            if yesno(_(u'Would you like to print the credit letter?'),
                     Gtk.ResponseType.YES, _(u"Print Letter"),
                     _(u"Don't print")):
                print_report(ClientCreditReport, self.model.client)
Ejemplo n.º 10
0
    def finish(self):
        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            return

        for payment in self.model.group.payments:
            if payment.is_preview():
                # Set payments created on SaleReturnPaymentStep as pending
                payment.set_pending()

        total_amount = self.model.total_amount
        # If the user chose to create credit for the client instead of returning
        # money, there is no need to display this messages.
        if not self.credit:
            if total_amount == 0:
                info(_("The client does not have a debt to this sale anymore. "
                       "Any existing unpaid installment will be cancelled."))
            elif total_amount < 0:
                info(_("A reversal payment to the client will be created. "
                       "You can see it on the Payable Application."))

        login_user = api.get_current_user(self.store)
        self.model.return_(method_name=u'credit' if self.credit else u'money',
                           login_user=login_user)
        SaleReturnWizardFinishEvent.emit(self.model)
        self.retval = self.model
        self.close()

        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        if self.credit:
            if yesno(_(u'Would you like to print the credit letter?'),
                     gtk.RESPONSE_YES, _(u"Print Letter"), _(u"Don't print")):
                print_report(ClientCreditReport, self.model.client)
Ejemplo n.º 11
0
    def finish(self):
        missing = get_missing_items(self.model, self.store)
        if missing:
            run_dialog(MissingItemsDialog, self, self.model, missing)
            return False

        # If this wizard is for a purchase return, the items are automatically
        # added so the tax check escaped. So we do it now.
        if self.receiving_order is not None:
            missing_tax_info = []
            for item in self.model.get_items():
                sellable = item.sellable
                try:
                    sellable.check_taxes_validity()
                except TaxError:
                    missing_tax_info.append(sellable.description)
            if missing_tax_info:
                warning(_("There are some items with missing tax information"),
                        ', '.join(missing_tax_info))
                return False

        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            return

        self.retval = self.model
        self.store.confirm(self.model)
        self.model.confirm()
        self.close()

        StockDecreaseWizardFinishEvent.emit(self.model)
        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        self._receipt_dialog()