Beispiel #1
0
    def addItem(self,
                description,
                quantity,
                price,
                iva,
                itemNegative=False,
                discount=0,
                discountDescription='',
                discountNegative=True):
        if type(description) in types.StringTypes:
            description = [description]
        if itemNegative:
            sign = 'R'
        else:
            sign = 'M'
        quantityStr = str(int(quantity * 1000))
        if self.model == "epsonlx300+":
            bultosStr = str(int(quantity))
        else:
            bultosStr = "00001"  # No se usa en TM220AF ni TM300AF ni TMU220AF
        if self._currentDocumentType != 'A':
            # enviar con el iva incluido
            priceUnitStr = str(int(round(price * 100, 0)))
        else:
            if self.model == "tm-220-af" or self.model == "tm-t900fa" or self.model == 'sm-srp-270':
                # enviar sin el iva (factura A)
                priceUnitStr = "%0.4f" % (price / ((100.0 + iva) / 100.0))
            else:
                # enviar sin el iva (factura A)
                priceUnitStr = str(
                    int(round((price / ((100 + iva) / 100)) * 100, 0)))

        if self.model == 'tm-2000-af':
            #le restamos dos ceros, ya que esta fiscal usa el comando @TIQUEITEM en lugar de @TIQUEITEM2 y dicho comando acepta 2 decimales en lugar de 4.
            priceUnitStr[:-2]
        ivaStr = str(int(iva * 100))
        extraparams = self._currentDocument in (
            self.CURRENT_DOC_BILL_TICKET,
            self.CURRENT_DOC_CREDIT_TICKET) and ["", "", ""] or []
        if self._getCommandIndex() == 0:
            for d in description[:-1]:
                self._sendCommand(self.CMD_PRINT_TEXT_IN_FISCAL,
                                  [formatText(d)[:20]])
        reply = self._sendCommand(
            self.CMD_PRINT_LINE_ITEM[self._getCommandIndex()], [
                formatText(description[-1][:20]), quantityStr, priceUnitStr,
                ivaStr, sign, bultosStr, "0" * 8
            ] + extraparams)
        if discount:
            discountStr = str(int(discount * 100))
            self._sendCommand(
                self.CMD_PRINT_LINE_ITEM[self._getCommandIndex()], [
                    formatText(discountDescription[:20]), "1000", discountStr,
                    ivaStr, 'R', "0", "0" * 8
                ] + extraparams)
        return reply
 def addItem(self,
             description,
             quantity,
             price,
             iva,
             discount,
             discountDescription,
             negative=False):
     if type(description) in types.StringTypes:
         description = [description]
     if negative:
         sign = 'R'
     else:
         sign = 'M'
     quantityStr = str(int(quantity * 1000))
     if self.model == "epsonlx300+":
         bultosStr = str(int(quantity))
     else:
         bultosStr = "0" * 5  # No se usa en TM220AF ni TM300AF ni TMU220AF
     if self._currentDocumentType != 'A':
         # enviar con el iva incluido
         priceUnitStr = str(int(round(price * 100, 0)))
     else:
         if self.model == "tm-220-af":
             # enviar sin el iva (factura A)
             priceUnitStr = "%0.4f" % (price / ((100.0 + iva) / 100.0))
         else:
             # enviar sin el iva (factura A)
             priceUnitStr = str(
                 int(round((price / ((100 + iva) / 100)) * 100, 0)))
     ivaStr = str(int(iva * 100))
     extraparams = self._currentDocument in (
         self.CURRENT_DOC_BILL_TICKET,
         self.CURRENT_DOC_CREDIT_TICKET) and ["", "", ""] or []
     if self._getCommandIndex() == 0:
         for d in description[:-1]:
             self._sendCommand(self.CMD_PRINT_TEXT_IN_FISCAL,
                               [formatText(d)[:20]])
     reply = self._sendCommand(
         self.CMD_PRINT_LINE_ITEM[self._getCommandIndex()], [
             formatText(description[-1][:20]), quantityStr, priceUnitStr,
             ivaStr, sign, bultosStr, "0" * 8
         ] + extraparams)
     if discount:
         discountStr = str(int(discount * 100))
         self._sendCommand(
             self.CMD_PRINT_LINE_ITEM[self._getCommandIndex()], [
                 formatText(discountDescription[:20]), "1000", discountStr,
                 ivaStr, 'R', "0", "0"
             ] + extraparams)
     return reply
    def addAdditional(self, description, amount, iva, negative=False):
        """Agrega un adicional a la FC.
            @param description  Descripción
            @param amount       Importe (sin iva en FC A, sino con IVA)
            @param iva          Porcentaje de Iva
            @param negative True->Descuento, False->Recargo"""
        if negative:
            if not description:
                description = "Descuento"
            sign = 'R'
        else:
            if not description:
                description = "Recargo"
            sign = 'M'

        quantityStr = "1000"
        bultosStr = "0"
        priceUnit = amount
        if self._currentDocumentType != 'A':
            # enviar con el iva incluido
            priceUnitStr = str(int(round(priceUnit * 100, 0)))
        else:
            # enviar sin el iva (factura A)
            priceUnitStr = str(
                int(round((priceUnit / ((100 + iva) / 100)) * 100, 0)))
        ivaStr = str(int(iva * 100))
        extraparams = self._currentDocument in (
            self.CURRENT_DOC_BILL_TICKET,
            self.CURRENT_DOC_CREDIT_TICKET) and ["", "", ""] or []
        reply = self._sendCommand(
            self.CMD_PRINT_LINE_ITEM[self._getCommandIndex()], [
                formatText(description[:20]), quantityStr, priceUnitStr,
                ivaStr, sign, bultosStr, "0"
            ] + extraparams)
        return reply
Beispiel #4
0
 def addPerception(self, description, amount):
     tipoPerc = 'O'
     montoPerc = str(int(amount * 100))
     status = self._sendCommand(
         self.CMD_PERCEPTIONS,
         [formatText(description)[:20], tipoPerc, montoPerc])
     return status
Beispiel #5
0
    def addPerception(self, description, price, iva, porcPerc):
		priceUnit = price
		
		if iva == '**.**' :
			tipoPerc = 'O'
			montoPerc = str(int(priceUnit * 100))
			alicPerc = str(int(porcPerc * 100))
		else: 	
		    tipoPerc = 'T'
		    montoPerc = str(int(iva * 100))
		    alicPerc = str(int(priceUnit * 100))
		
		if self.model == "epsonlx300+":
			reply = self._sendCommand(self.CMD_PERCEPTIONS, [formatText(description)[:20],tipoPerc, montoPerc, alicPerc])
		else:
			reply = self._sendCommand(self.CMD_PERCEPTIONS, [formatText(description)[:20],tipoPerc, montoPerc])
		return reply
Beispiel #6
0
    def addReturnRecharge(self, description, price, iva, tasaAjusteInternos, itemNegative=False):
        if itemNegative:
            sign = 'D'
        else:
            sign = 'R'
			
        paymentStr = str(int(price * 100))
        status = self._sendCommand(self.CMD_ADD_PAYMENT[self._getCommandIndex()],
                                   [formatText(description)[:20], paymentStr, sign])
	return status
Beispiel #7
0
    def _setCustomerData(self,
                         name=" ",
                         address=" ",
                         doc=" ",
                         docType=" ",
                         ivaType="T"):
        # limpio el header y trailer:

        # self.setHeader()
        # self.setTrailer()
        doc = str(doc)
        doc = doc.replace("-", "").replace(".", "")
        if doc and docType != "3" and filter(lambda x: x not in string.digits,
                                             doc):
            # Si tiene letras se blanquea el DNI para evitar errores, excepto que sea
            # docType="3" (Pasaporte)
            doc, docType = " ", " "
        if not doc.strip():
            docType = " "

        if ivaType != "C" and (not doc or docType != "C"):
            raise ValidationError(
                "Error, si el tipo de IVA del cliente NO es consumidor final, "
                "debe ingresar su número de CUIT.")
        parameters = [
            self._formatText(name, 'customerName'),
            doc or " ",
            ivaType,  # Iva Comprador
            docType or " ",  # Tipo de Doc.
        ]
        if self.model in ["715v1", "715v2", "320"]:
            parameters.append(
                self._formatText(address, 'custAddressSize')
                or " ")  # Domicilio
        else:
            parameters.append(formatText(address) or " ")
        return self._sendCommand(self.CMD_SET_CUSTOMER_DATA, parameters)
Beispiel #8
0
 def _formatText(self, text, context):
     sizeDict = self.textSizeDict.get(self.model)
     if not sizeDict:
         sizeDict = self.textSizeDict["615"]
     return formatText(text)[:sizeDict.get(context, 20)]
 def printNonFiscalText(self, text):
     return self._sendCommand(self.CMD_PRINT_NON_FISCAL_TEXT,
                              [formatText(text[:40] or " ")])
 def addPayment(self, description, payment):
     paymentStr = str(int(payment * 100))
     status = self._sendCommand(
         self.CMD_ADD_PAYMENT[self._getCommandIndex()],
         [formatText(description)[:20], paymentStr, 'T'])
     return status
 def _openBillCreditTicket(self,
                           type,
                           name,
                           address,
                           doc,
                           docType,
                           ivaType,
                           isCreditNote,
                           reference=None):
     if not doc or filter(lambda x: x not in string.digits + "-.", doc or "") or not \
             docType in self.docTypeNames:
         doc, docType = "", ""
     else:
         doc = doc.replace("-", "").replace(".", "")
         docType = self.docTypeNames[docType]
     self._type = type
     if self.model == "epsonlx300+":
         parameters = [
             isCreditNote and "N"
             or "F",  # Por ahora no soporto ND, que sería "D"
             "C",
             type,  # Tipo de FC (A/B/C)
             "1",  # Copias - Ignorado
             "P",  # "P" la impresora imprime la lineas(hoja en blanco) o "F" preimpreso
             "17",  # Tamaño Carac - Ignorado
             "I",  # Responsabilidad en el modo entrenamiento - Ignorado
             self.ivaTypes.get(ivaType, "F"),  # Iva Comprador
             formatText(name[:40]),  # Nombre
             formatText(name[40:80]),  # Segunda parte del nombre - Ignorado
             formatText(docType) or (isCreditNote and "-" or ""),
             # Tipo de Doc. - Si es NC obligado pongo algo
             doc or (isCreditNote and "-"
                     or ""),  # Nro Doc - Si es NC obligado pongo algo
             "N",  # No imprime leyenda de BIENES DE USO
             formatText(address[:self.ADDRESS_SIZE] or "-"),  # Domicilio
             formatText(address[self.ADDRESS_SIZE:self.ADDRESS_SIZE *
                                2]),  # Domicilio 2da linea
             formatText(address[self.ADDRESS_SIZE * 2:self.ADDRESS_SIZE *
                                3]),  # Domicilio 3ra linea
             (isCreditNote or self.ivaTypes.get(ivaType, "F") != "F")
             and "-" or "",
             # Remito primera linea - Es obligatorio si el cliente no es consumidor final
             "",  # Remito segunda linea
             "C",  # No somos una farmacia
         ]
     else:
         parameters = [
             isCreditNote and "M" or "T",  # Ticket NC o Factura
             "C",  # Tipo de Salida - Ignorado
             type,  # Tipo de FC (A/B/C)
             "1",  # Copias - Ignorado
             "P",  # Tipo de Hoja - Ignorado
             "17",  # Tamaño Carac - Ignorado
             "E",  # Responsabilidad en el modo entrenamiento - Ignorado
             self.ivaTypes.get(ivaType, "F"),  # Iva Comprador
             formatText(name[:40]),  # Nombre
             formatText(name[40:80]),  # Segunda parte del nombre - Ignorado
             formatText(docType) or (isCreditNote and "-" or ""),
             # Tipo de Doc. - Si es NC obligado pongo algo
             doc or (isCreditNote and "-"
                     or ""),  # Nro Doc - Si es NC obligado pongo algo
             "N",  # No imprime leyenda de BIENES DE USO
             formatText(address[:self.ADDRESS_SIZE] or "-"),  # Domicilio
             formatText(address[self.ADDRESS_SIZE:self.ADDRESS_SIZE *
                                2]),  # Domicilio 2da linea
             formatText(address[self.ADDRESS_SIZE * 2:self.ADDRESS_SIZE *
                                3]),  # Domicilio 3ra linea
             (isCreditNote or self.ivaTypes.get(ivaType, "F") != "F")
             and "-" or "",
             # Remito primera linea - Es obligatorio si el cliente no es consumidor final
             "",  # Remito segunda linea
             "C",  # No somos una farmacia
         ]
     if isCreditNote:
         self._currentDocument = self.CURRENT_DOC_CREDIT_TICKET
     else:
         self._currentDocument = self.CURRENT_DOC_BILL_TICKET
     # guardo el tipo de FC (A/B/C)
     self._currentDocumentType = type
     return self._sendCommand(self.CMD_OPEN_BILL_TICKET, parameters)
Beispiel #12
0
 def _openBillCreditTicket(self,
                           type,
                           name,
                           address,
                           doc,
                           docType,
                           ivaType,
                           isCreditNote,
                           reference=None):
     if not docType:
         docType, doc = '-', '-'
     if doc and not isinstance(doc, basestring):
         doc = str(doc)
     if not doc or not docType in self.docTypeNames:
         doc, docType = "", ""
     else:
         doc = doc.replace("-", "").replace(".", "")
     if not ivaType:
         ivaType = 'F'  # Default is Consumidor Final
     self._type = type
     # Remito primera linea - Es obligatorio si el cliente no es consumidor final
     if not reference:
         if (isCreditNote or self.ivaTypes.get(ivaType, "F") != "F"):
             reference = "-"
         else:
             reference = ""
     if self.model == "epsonlx300+":
         parameters = [
             isCreditNote and "N"
             or "F",  # Por ahora no soporto ND, que sería "D". 
             #Nota de crédito no es soportada por esta impresora
             "C",
             type,  # Tipo de FC (A/B/C)
             "1",  # Copias - Ignorado
             "P",  # "P" la impresora imprime la lineas(hoja en blanco) o "F" preimpreso
             "17",  # Tamaño Carac - Ignorado
             "I",  # Responsabilidad en el modo entrenamiento - Ignorado
             ivaType or
             "F",  # Iva Comprador - El char del tipo de Iva ya fue obtenido en el TraductorFiscal
             formatText(name[:40]),  # Nombre
             formatText(name[40:80]),  # Segunda parte del nombre - Ignorado
             docType or (isCreditNote and "-" or ""),
             # Tipo de Doc. - Si es NC obligado pongo algo
             doc or (isCreditNote and "-"
                     or ""),  # Nro Doc - Si es NC obligado pongo algo
             "N",  # No imprime leyenda de BIENES DE USO
             formatText(address[:self.ADDRESS_SIZE] or "-"),  # Domicilio
             formatText(address[self.ADDRESS_SIZE:self.ADDRESS_SIZE *
                                2]),  # Domicilio 2da linea
             formatText(address[self.ADDRESS_SIZE * 2:self.ADDRESS_SIZE *
                                3]),  # Domicilio 3ra linea
             reference,  # Remito primera linea
             "",  # Remito segunda linea
             "C",  # No somos una farmacia
         ]
     else:
         parameters = [
             isCreditNote and "M" or "T",  # Ticket NC o Factura
             "C",  # Tipo de Salida - Ignorado
             type,  # Tipo de FC (A/B/C)
             "1",  # Copias - Ignorado
             "P",  # Tipo de Hoja - Ignorado
             "17",  # Tamaño Carac - Ignorado
             "E",  # Responsabilidad en el modo entrenamiento - Ignorado
             ivaType or
             "F",  # Iva Comprador - El char del tipo de Iva ya fue obtenido en el TraductorFiscal
             formatText(name[:40]),  # Nombre
             formatText(name[40:80]),  # Segunda parte del nombre - Ignorado
             docType or (isCreditNote and "-" or ""),
             # Tipo de Doc. - Si es NC obligado pongo algo
             doc or (isCreditNote and "-"
                     or ""),  # Nro Doc - Si es NC obligado pongo algo
             "N",  # No imprime leyenda de BIENES DE USO
             formatText(address[:self.ADDRESS_SIZE] or "-"),  # Domicilio
             formatText(address[self.ADDRESS_SIZE:self.ADDRESS_SIZE *
                                2]),  # Domicilio 2da linea
             formatText(address[self.ADDRESS_SIZE * 2:self.ADDRESS_SIZE *
                                3]),  # Domicilio 3ra linea
             reference,  # Remito primera linea
             "",  # Remito segunda linea
             "C",  # No somos una farmacia
         ]
     if isCreditNote:
         self._currentDocument = self.CURRENT_DOC_CREDIT_TICKET
     else:
         self._currentDocument = self.CURRENT_DOC_BILL_TICKET
     # guardo el tipo de FC (A/B/C)
     self._currentDocumentType = type
     return self._sendCommand(self.CMD_OPEN_BILL_TICKET, parameters)