コード例 #1
0
 def rnc_cedula_validation(self, fiscal_id):
     invalid_fiscal_id_message = (500, u"RNC/Cédula invalido",
                                  u"El número de RNC/C´ula no es valido.")
     if not is_identification(fiscal_id):
         return invalid_fiscal_id_message
     else:
         request_params = self.get_marcos_api_request_params()
         if request_params[0] == 1:
             res = requests.get('{}/rnc/{}'.format(request_params[1],
                                                   fiscal_id),
                                proxies=request_params[2])
             print('{}/rnc/{}'.format(request_params[1], fiscal_id))
             if res.status_code == 200:
                 dgii_data = res.json()
                 if len(dgii_data) > 0:
                     dgii_data["vat"] = dgii_data['rnc']
                     dgii_data[
                         "comment"] = u"Nombre Comercial: {}, regimen de pago: {},  estatus: {}, categoria: {}".format(
                             dgii_data['comercial_name'],
                             dgii_data.get('payment_regimen', ""),
                             dgii_data['status'], dgii_data['category'])
                 else:
                     dgii_data["vat"] = fiscal_id
                 if len(fiscal_id) == 9:
                     dgii_data.update({"company_type": u"company"})
                     dgii_data.update({"is_company": u"True"})
                 else:
                     dgii_data.update({"company_type": u"person"})
                 return (1, dgii_data)
             else:
                 return invalid_fiscal_id_message
コード例 #2
0
    def generate_txt(self):
        if not self.company_id.vat:
            raise exceptions.ValidationError(
                u"Para poder generar el 606 primero debe especificar el RNC/"
                u"Cédula de la compañia.")

        company_fiscal_identificacion = re.sub("[^0-9]", "",
                                               self.company_id.vat)

        if not (company_fiscal_identificacion
                or not is_identification(company_fiscal_identificacion)):
            raise exceptions.ValidationError("Debe configurar el RNC de su"
                                             "empresa!")

        path = '/tmp/606{}.txt'.format(company_fiscal_identificacion)
        file = io.open(path, 'w', encoding="utf-8", newline='\r\n')
        lines = []

        header = "606"
        header += company_fiscal_identificacion.rjust(11)
        header += str(self.year)
        header += str(self.month).zfill(2)
        header += "{:.2f}".format(self.CANTIDAD_REGISTRO).zfill(12)
        header += "{:.2f}".format(self.TOTAL_MONTO_FACTURADO).zfill(16)
        header += "{:.2f}".format(self.RETENCION_RENTA).zfill(12)
        lines.append(header)

        for line in self.report_lines:
            ln = ""
            ln += line.RNC_CEDULA.rjust(11)
            ln += line.TIPO_IDENTIFICACION
            ln += line.TIPO_BIENES_SERVICIOS_COMPRADOS
            ln += line.NUMERO_COMPROBANTE_FISCAL
            ln += line.NUMERO_COMPROBANTE_MODIFICADO
            ln += line.FECHA_COMPROBANTE.replace("-", "")
            ln += line.FECHA_PAGO.replace(
                "-", "") if line.FECHA_PAGO else "".rjust(8)
            ln += "{:.2f}".format(line.ITBIS_FACTURADO).zfill(12)
            ln += "{:.2f}".format(abs(line.ITBIS_RETENIDO)).zfill(12)
            ln += "{:.2f}".format(line.MONTO_FACTURADO).zfill(12)
            ln += "{:.2f}".format(line.RETENCION_RENTA).zfill(12)
            lines.append(ln)

        for line in lines:
            file.write(line + "\n")

        file.close()
        file = open(path, 'rb')
        report = base64.b64encode(file.read())
        report_name = 'DGII_606_{}_{}{}.TXT'.format(
            company_fiscal_identificacion, str(self.year),
            str(self.month).zfill(2))
        self.write({'txt': report, 'txt_name': report_name})
コード例 #3
0
    def generate_txt(self):
        if not self.company_id.vat:
            raise exceptions.ValidationError(
                u"Para poder generar el 609 primero debe especificar el RNC/"
                u"Cédula de la compañia.")

        company_fiscal_identificacion = re.sub("[^0-9]", "",
                                               self.company_id.vat)

        if not (company_fiscal_identificacion or not
                is_identification(company_fiscal_identificacion)):
            raise exceptions.ValidationError(u"¡Debe configurar el RNC de"
                                             " su empresa!")

        path = '/tmp/609{}.txt'.format(company_fiscal_identificacion)
        file = io.open(path, 'w', encoding="utf-8", newline='\r\n')
        lines = []

        header = "609"
        header += company_fiscal_identificacion.rjust(11)
        header += str(self.year)
        header += str(self.month).zfill(2)
        header += "{:.2f}".format(self.TOTAL_MONTO_FACTURADO).zfill(16)
        lines.append(header)

        for line in self.report_lines:
            ln = ""
            ln += line.RAZON_SOCIAL.rjust(30)
            ln += line.TIPO_BIENES_SERVICIOS_COMPRADOS
            ln += line.FECHA_FACTURA.replace("-", "")
            ln += line.FECHA_RETENCION_ISR if line.FECHA_RETENCION_ISR else "".rjust(8)
            ln += "{:.2f}".format(line.ISR_RETENCION).zfill(12)
            ln += "{:.2f}".format(line.MONTO_FACTURADO).zfill(12)
            lines.append(ln)

        for line in lines:
            file.write(line + "\n")

        file.close()
        file = open(path, 'rb')
        report = base64.b64encode(file.read())
        report_name = 'DGII_609_{}_{}{}.TXT'.format(
                                                company_fiscal_identificacion,
                                                str(self.year),
                                                str(self.month).zfill(2))
        self.write({'txt': report, 'txt_name': report_name})
コード例 #4
0
    def generate_txt(self):
        if not self.company_id.vat:
            raise exceptions.ValidationError(
                u"Para poder generar el 608 primero debe especificar el RNC/"
                u"Cédula de la compañia.")

        company_fiscal_identificacion = re.sub("[^0-9]", "",
                                               self.company_id.vat)

        if not (company_fiscal_identificacion or not
                is_identification(company_fiscal_identificacion)):
            raise exceptions.ValidationError(u"¡Debe configurar el RNC de"
                                             " su empresa!")

        path = '/tmp/608{}.txt'.format(company_fiscal_identificacion)
        file = io.open(path, 'w', encoding="utf-8", newline='\r\n')
        lines = []

        header = "608"
        header += company_fiscal_identificacion.rjust(11)
        header += str(self.year)
        header += str(self.month).zfill(2)
        header += str(self.CANTIDAD_REGISTRO).zfill(6)
        lines.append(header)

        for line in self.report_lines:
            ln = ""
            ln += line.NUMERO_COMPROBANTE_FISCAL
            ln += line.FECHA_COMPROBANTE.replace("-", "")
            ln += "{}".format(line.TIPO_ANULACION).zfill(2)
            lines.append(ln)

        for line in lines:
            file.write(line + "\n")

        file.close()
        file = open(path, 'rb')
        report = base64.b64encode(file.read())
        report_name = 'DGII_608_{}_{}{}.TXT'.format(
                                                company_fiscal_identificacion,
                                                str(self.year),
                                                str(self.month).zfill(2))
        self.write({'txt': report, 'txt_name': report_name})
コード例 #5
0
 def is_identification(self, value):
     return is_identification(value)