コード例 #1
0
ファイル: ecfdomain.py プロジェクト: sarkis89/stoq
    def get_tax_constant_for_device(self, sellable):
        """
        Returns a tax_constant for a device
        Raises DeviceError if a constant is not found

        @param sellable: sellable which has the tax codes
        @type sellable: :class:`stoqlib.domain.sellable.Sellable`
        @returns: the tax constant
        @rtype: :class:`DeviceConstant`
        """

        sellable_constant = sellable.get_tax_constant()
        if sellable_constant is None:
            raise DeviceError("No tax constant set for sellable %r" % sellable)

        store = self.store
        if sellable_constant.tax_type == TaxType.CUSTOM:
            constant = DeviceConstant.get_custom_tax_constant(
                self, sellable_constant.tax_value, store)
            if constant is None:
                raise DeviceError(_(
                    "fiscal printer is missing a constant for the custom "
                    "tax constant '%s'") % (sellable_constant.description, ))
        else:
            constant = DeviceConstant.get_tax_constant(
                self, sellable_constant.tax_type, store)
            if constant is None:
                raise DeviceError(_(
                    "fiscal printer is missing a constant for tax "
                    "constant '%s'") % (sellable_constant.description, ))

        return constant
コード例 #2
0
    def _validate_printer(self):
        if self._printer is None:
            raise DeviceError(
                _("This operation requires a connected fiscal printer"))

        if not self._printer_verified:
            log.info('ecfui._validate_printer')
            if not self._printer.check_serial():
                raise DeviceError(
                    _("Fiscalprinters serial number is different!"))

            self._printer_verified = True
コード例 #3
0
    def _validate_printer(self):
        if self._printer is None:
            raise DeviceError(
                _("This operation requires a connected fiscal printer"))
        # Check fiscal printer setup. If something went wrong with the setup,
        # block the till
        if not self._printer._driver.setup_complete():
            raise DeviceError(_("An error occurred during fiscal printer setup"))

        if not self._printer_verified:
            log.info('ecfui._validate_printer')
            if not self._printer.check_serial():
                raise DeviceError(
                    _("Fiscalprinters serial number is different!"))

            self._printer_verified = True
コード例 #4
0
    def _get_payment_method_constant(self, payment):
        constant = self._printer.get_payment_constant(payment)
        if not constant:
            raise DeviceError(
                _("The payment method used in this sale (%s) is not "
                  "configured in the fiscal printer.") % (payment.method.method_name, ))

        return constant