Beispiel #1
0
    def coupon_close(self, message=''):
        self._check_status()
        self._verify_coupon_open()

        if (self._customer_name or
            self._customer_address or
            self._customer_document):
            customer_name = self._customer_name or _("No client")
            customer_document = self._customer_document or _("No document")
            customer_address = self._customer_address or _("No address")
            self.send_command(CMD_IDENTIFY_CUSTOMER,
                              "%- 84s%- 84s%- 84s" % (customer_name,
                                                      customer_address,
                                                      customer_document))
        LINE_LEN = 48
        msg_len = len(message)
        if msg_len > LINE_LEN:
            l = []
            for i in range(0, msg_len, LINE_LEN):
                l.append(message[i:i+LINE_LEN])
            message = '\n'.join(l)
        try:
            self.send_command(CMD_CLOSE_COUPON, message + '\xff')
        except DriverError:
            raise CloseCouponError(_("It is not possible to close the "
                                     "coupon"))
        self._reset()
        return self._get_coupon_number()
Beispiel #2
0
 def coupon_close(self, message=''):
     self._check()
     self._check_coupon_is_opened()
     if not self.is_coupon_totalized:
         raise CloseCouponError(_("Isn't possible close the coupon "
                                  "since it isn't totalized yet!"))
     elif not self.has_payments:
         raise CloseCouponError(_("Isn't possible close the coupon "
                                  "since there is no payments added."))
     elif self.totalized_value > self.payments_total:
         raise CloseCouponError(_("The payments total value doesn't "
                                  "match the totalized value."))
     troco = self.payments_total - self.totalized_value
     if troco:
         self.write('Troco: %0.2f\n' % troco)
     self._feed_line()
     if message:
         self.write(message)
     self.write('\n')
     self._reset_flags()
     return 0
Beispiel #3
0
    def close(self, promotional_message=''):
        log.info('coupon_close(promotional_message=%r)' % (
            promotional_message))

        if not self._has_been_totalized:
            raise CloseCouponError(_("You must totalize the coupon before "
                                     "closing it"))
        if not self.payments_total_value:
            raise CloseCouponError(_("It is not possible close the coupon "
                                     "since there are no payments defined."))
        if self.totalized_value > self.payments_total_value:
            raise CloseCouponError(_("Isn't possible close the coupon since "
                                     "the payments total (%.2f) doesn't "
                                     "match the totalized value (%.2f).")
                                   % (self.payments_total_value,
                                      self.totalized_value))
        res = self._driver.coupon_close(
            self._format_text(promotional_message))
        self._has_been_totalized = False
        self.payments_total_value = Decimal("0.0")
        self.totalized_value = Decimal("0.0")
        return res
Beispiel #4
0
    def coupon_close(self, message=''):
        self._check_status()
        self._verify_coupon_open()

        if (self._customer_name or self._customer_address
                or self._customer_document):
            customer_name = self._customer_name or _("No client")
            customer_document = self._customer_document or _("No document")
            customer_address = self._customer_address or _("No address")
            self.send_command(
                CMD_IDENTIFY_CUSTOMER, "%- 84s%- 84s%- 84s" %
                (customer_name, customer_address, customer_document))
        message = message.encode(self.coupon_printer_charset)
        try:
            self.send_command(CMD_CLOSE_COUPON, message + '\xff')
        except DriverError:
            raise CloseCouponError(
                _("It is not possible to close the "
                  "coupon"))
        self._reset()
        return self._get_coupon_number()
Beispiel #5
0
    def coupon_close(self, message=''):
        self._check_status()
        self._verify_coupon_open()

        if (self._customer_name or self._customer_address
                or self._customer_document):
            customer_name = self._customer_name or _("No client")
            customer_document = self._customer_document or _("No document")
            customer_address = self._customer_address or _("No address")
            self.send_command(
                CMD_IDENTIFY_CUSTOMER, "%- 84s%- 84s%- 84s" %
                (customer_name, customer_address, customer_document))
        # NOTE: Do not try to encode the message again. It was already
        # encoded by printers.fiscal before. By doing that we would be
        # encoding it twice.
        try:
            self.send_command(CMD_CLOSE_COUPON, message + '\xff')
        except DriverError:
            raise CloseCouponError(
                _("It is not possible to close the "
                  "coupon"))
        self._reset()
        return self._get_coupon_number()