def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_iz = listado.tabla_celda_just_izquierdo()

    lista = [[
        Par("Nro. de Orden", head),
        Par("Fecha de Elaboración", head),
        Par("Alias de Usuario", head),
        Par("Nombre", head)
    ]]
    for i in range(0, cant):
        lista.append([
            Par(str(datos[i][0]), body_ce),
            Par(datos[i][1], body_ce),
            Par(datos[i][9], body_ce),
            Par(str(datos[i][11]), body_iz)
        ])

    listado.listado(self.titulo, lista, [70, 125, 75, 150], A4)
def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_iz = listado.tabla_celda_just_izquierdo()

    lista = [[
        Par("Código", head),
        Par("Nombre", head),
        Par("País", head),
        Par("Símbolo", head)
    ]]

    for i in range(0, cant):
        lista.append([
            Par(str(datos[i][0]), body_ce),
            Par(datos[i][1], body_iz),
            Par(datos[i][3], body_iz),
            Par(datos[i][4], body_ce)
        ])

    listado.listado(self.titulo, lista, [100, 150, 150, 100], A4)
Exemple #3
0
def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_de = listado.tabla_celda_just_derecho()
    body_iz = listado.tabla_celda_just_izquierdo()

    lista = [[
        Par("Cód. Moneda", head),
        Par("Moneda", head),
        Par("Fecha", head),
        Par("Compra", head),
        Par("Venta", head)
    ]]

    for i in range(0, cant):
        lista.append([
            Par(str(datos[i][0]), body_ce),
            Par(datos[i][1], body_iz),
            Par(datos[i][2], body_ce),
            Par(str(datos[i][3]), body_de),
            Par(str(datos[i][4]), body_de)
        ])

    listado.listado(self.titulo, lista, [70, 100, 100, 70, 70], A4)
def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4, landscape

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_iz = listado.tabla_celda_just_izquierdo()

    lista = [[
        Par("Nro. Est.", head),
        Par("Nombre", head),
        Par("Ciudad", head),
        Par("Barrio", head),
        Par("Dirección", head),
        Par("Activo", head)
    ]]

    for i in range(0, cant):
        estado = "Activo" if datos[i][8] == 1 else "Inactivo"

        lista.append([
            Par(str(datos[i][0]), body_ce),
            Par(datos[i][1], body_iz),
            Par(datos[i][4], body_iz),
            Par(datos[i][5], body_iz),
            Par(datos[i][6], body_iz),
            Par(estado, body_ce)
        ])

    listado.listado(self.titulo, lista, [75, 150, 100, 100, 250, 50],
                    landscape(A4))
Exemple #5
0
def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_iz = listado.tabla_celda_just_izquierdo()

    lista = [[
        Par("Empleado", head),
        Par("Beneficiario", head),
        Par("Edad", head),
        Par("Parentesco", head)
    ]]
    for i in range(0, cant):
        lista.append([
            Par(str(datos[i][3]), body_ce),
            Par(datos[i][9], body_ce),
            Par(datos[i][11], body_iz),
            Par(datos[i][15], body_iz)
        ])

    listado.listado(self.titulo, lista, [125, 125, 75, 100], A4)
Exemple #6
0
def genera_asistencia_empleado(datos, datos_tabla):
    ubicacion_archivo = dialogo_guardar("Asistencias")

    if ubicacion_archivo is not None:
        # Si no tiene la terminación .pdf se le agrega
        if ubicacion_archivo[-4:].lower() != ".pdf":
            ubicacion_archivo += ".pdf"

        story = []
        cabecera = cabecera_style()
        texto = tabla_celda_just_izquierdo()
        titulo = tabla_celda_just_derecho()

        parrafo = Par("Registro de Asistencias", cabecera)
        story.append(parrafo)
        story.append(Spacer(0, 20))

        # Generar encabezado
        tabla = Table([
            [Par("<b>Empleado:</b>", titulo), Par(datos[0], texto)],
            [Par("<b>Nro. C.I.:</b>", titulo), Par(datos[1], texto)],
            [Par("<b>Nro. Contrato:</b>", titulo), Par(datos[2], texto)],
            [Par("<b>Cargo:</b>", titulo), Par(datos[3], texto)]
        ], [100, 300])
        tabla.setStyle([
            ('ALIGN', (0, 0), (0, -1), 'RIGHT'),  # Alineación de la Primera Columna
            ('ALIGN', (1, 1), (-1, -1), 'LEFT'),  # Alineación de Otras Columnas
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),  # Alineación Vertical de la Tabla
            ('TOPPADDING', (0, 0), (-1, -1), 1),  # Espacio Arriba
            ('BOTTOMPADDING', (0, 0), (-1, -1), 3),  # Espacio Abajo
            ('LEFTPADDING', (0, 0), (-1, -1), 3),  # Espacio a la Izquierda
            ('RIGHTPADDING', (0, 0), (-1, -1), 3),  # Espacio a la Derecha
        ])
        story.append(tabla)
        story.append(Spacer(0, 20))

        # Generar Tabla de Asistencias
        tabla = Table(datos_tabla, [125, 75, 50, 175, 75])
        tabla = tabla_style(tabla)
        story.append(tabla)

        doc = SimpleDocTemplate(
            ubicacion_archivo,
            pagesize=A4,  # Tamaño de Página (landscape(A4) hoja horizontal)
            leftMargin=3 * cm,  # Margen Izquierdo
            rightMargin=3 * cm,  # Margen Derecho
            topMargin=2.5 * cm,  # Margen Superior
            bottomMargin=2.5 * cm,  # Margen Inferior
            allowSplitting=1,
            title="Registro de Asistencias",
            author="Sistema Distribuidora"
        )

        try:  # Generar Archivo
            doc.build(story)
            popen(ubicacion_archivo)
        except PermissionError as e:
            error_permiso_archivo(str(e))
    def on_btn_aprobar_clicked(self, objeto):
        self.encabezado_guardado = False
        self.guardar_encabezado("1")

        # Generar Orden en formato PDF
        orden = self.obj("txt_00").get_text()
        proveedor = [
            self.obj("txt_01_2").get_text(),
            self.obj("txt_01_1").get_text(),
            self.obj("txt_01_3").get_text(),
            self.obj("txt_01_4").get_text()
        ]

        # Obtención de los datos de la Tabla, los detalles de la Orden
        datos = self.obj("grilla").get_model()
        cant = len(datos)

        from clases.listado import tabla_celda_titulo
        from clases.listado import tabla_celda_centrado
        from clases.listado import tabla_celda_just_izquierdo
        from clases.listado import tabla_celda_just_derecho
        from informes.compra_ordenes import genera_orden_compra
        from reportlab.platypus import Paragraph as Par

        head = tabla_celda_titulo()
        body_ce = tabla_celda_centrado()
        body_iz = tabla_celda_just_izquierdo()
        body_de = tabla_celda_just_derecho()

        lista = [[
            Par("Cód. Ítem", head),
            Par("Código de Barras", head),
            Par("Nombre", head),
            Par("Cantidad", head)
        ]]
        for i in range(0, cant):
            codbar = "" if datos[i][1] is None else datos[i][1]
            lista.append([
                Par(str(datos[i][0]), body_ce),
                Par(codbar, body_iz),
                Par(datos[i][2], body_ce),
                Par(str(datos[i][5]), body_de)
            ])

        # Obtención de la Forma de Pago del Combo de Pago
        model = self.obj("cmb_pago").get_model()
        active = self.obj("cmb_pago").get_active()
        pago = model[active][1]

        datos = [orden, proveedor, pago, lista]
        genera_orden_compra(datos)
        self.guardar_cerrar()
def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4, landscape

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_iz = listado.tabla_celda_just_izquierdo()

    lista = [[Par("Nro. Tarjeta", head), Par("Banco", head), Par("Titular", head),
        Par("Fecha de Vencimiento", head), Par("Tipo", head)]]
    for i in range(0, cant):
        lista.append([Par(datos[i][0], body_ce), Par(datos[i][4], body_iz),
            Par(datos[i][10], body_iz), Par(datos[i][15], body_ce),
            Par(datos[i][14], body_ce)])

    listado.listado(self.titulo, lista, [125, 170, 170, 150, 75], landscape(A4))
Exemple #9
0
def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_de = listado.tabla_celda_just_derecho()
    body_iz = listado.tabla_celda_just_izquierdo()

    lista = [[Par("Código", head), Par("Descripción", head),
        Par("Tipo de Denominación", head), Par("Valor", head)]]

    for i in range(0, cant):
        lista.append([Par(str(datos[i][0]), body_ce), Par(datos[i][1], body_iz),
            Par(datos[i][3], body_iz), Par(str(datos[i][4]), body_de)])

    listado.listado(self.titulo, lista, [75, 150, 150, 100], A4)
Exemple #10
0
def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4, landscape

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_iz = listado.tabla_celda_just_izquierdo()
    body_de = listado.tabla_celda_just_derecho()

    lista = [[
        Par("Código", head),
        Par("Código de Barras", head),
        Par("Nombre", head),
        Par("Presentación", head),
        Par("Precio de Costo", head),
        Par("Precio de Venta", head),
        Par("Estado", head)
    ]]

    for i in range(0, cant):
        codbar = "" if datos[i][1] is None else datos[i][1]
        estado = "Activo" if datos[i][21] == 1 else "Inactivo"

        lista.append([
            Par(str(datos[i][0]), body_ce),
            Par(codbar, body_iz),
            Par(datos[i][2], body_iz),
            Par(datos[i][13], body_iz),
            Par(str(datos[i][17]), body_de),
            Par(str(datos[i][18]), body_de),
            Par(estado, body_ce)
        ])

    listado.listado(self.titulo, lista, [75, 100, 175, 100, 100, 100, 50],
                    landscape(A4))
Exemple #11
0
def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4, landscape

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_iz = listado.tabla_celda_just_izquierdo()
    body_de = listado.tabla_celda_just_derecho()

    lista = [[Par("Nro. Cheque", head), Par("Banco", head), Par("Titular", head),
        Par("Fecha de Emisión", head), Par("Fecha de Cobro", head), Par("Monto", head)]]

    for i in range(0, cant):
        lista.append([Par(str(datos[i][1]), body_ce), Par(datos[i][6], body_iz),
            Par(datos[i][12], body_iz), Par(datos[i][15], body_ce),
            Par(datos[i][16], body_ce), Par(str(datos[i][17]), body_de)])

    listado.listado(self.titulo, lista, [100, 150, 150, 110, 110, 70], landscape(A4))
Exemple #12
0
def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_de = listado.tabla_celda_just_derecho()
    body_iz = listado.tabla_celda_just_izquierdo()

    listafila = [Par("Código", head), Par(self.titulodos, head)]
    if self.tabla in ("conceptopagos", "impuestos", "monedas", "motivoajustes",
                      "motivosalidas", "motivosanciones", "paises",
                      "presentaciones", "sistematablas", "tipocalles"):
        listafila.append(Par(self.titulotres, head))
        tamanos = [100, 200, 100]
    else:
        tamanos = [100, 300]

    lista = [listafila]
    for i in range(0, cant):
        listafila = [Par(str(datos[i][0]), body_ce), Par(datos[i][1], body_iz)]

        if self.tabla in ("conceptopagos", "impuestos", "monedas",
                          "motivoajustes", "motivosalidas", "motivosanciones",
                          "paises", "presentaciones", "sistematablas",
                          "tipocalles", "zonaventas"):
            if self.tabla == "impuestos": estilo = body_de
            elif self.tabla == "paises": estilo = body_iz
            else: estilo = body_ce
            listafila.append(Par(str(datos[i][2]), estilo))

        lista.append(listafila)

    listado.listado(self.titulo, lista, tamanos, A4)
def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4, landscape

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_iz = listado.tabla_celda_just_izquierdo()
    body_de = listado.tabla_celda_just_derecho()

    lista = [[
        Par("Nro. Timbrado", head),
        Par("Nro. Establecimiento", head),
        Par("Nro. Caja", head),
        Par("Fecha de Emisión", head),
        Par("Fecha de Vencimiento", head),
        Par("Desde", head),
        Par("Hasta", head),
        Par("Estado", head)
    ]]

    for i in range(0, cant):
        lista.append([
            Par(str(datos[i][0]), body_ce),
            Par(Op.cadenanumeros(datos[i][9], 3), body_ce),
            Par(Op.cadenanumeros(datos[i][7], 3), body_ce),
            Par(datos[i][1], body_iz),
            Par(datos[i][2], body_iz),
            Par(str(datos[i][3]), body_de),
            Par(str(datos[i][4]), body_de),
            Par(datos[i][20], body_ce)
        ])

    listado.listado(self.titulo, lista, [100, 100, 100, 125, 125, 50, 50, 50],
                    landscape(A4))
def listar_grilla(self):
    from clases import listado
    from reportlab.platypus import Paragraph as Par
    from reportlab.lib.pagesizes import A4

    datos = self.obj("grilla").get_model()
    cant = len(datos)

    head = listado.tabla_celda_titulo()
    body_ce = listado.tabla_celda_centrado()
    body_de = listado.tabla_celda_just_derecho()
    body_iz = listado.tabla_celda_just_izquierdo()

    listafila = [
        Par("Código", head),
        Par(self.titulodos, head),
        Par(self.titulotres, head)
    ]
    if self.tabla == "categorias":
        listafila.append(Par("Porc.", head))
        tamanos = [100, 200, 100, 50]
    else:
        tamanos = [100, 200, 100]

    lista = [listafila]
    for i in range(0, cant):
        listafila = [
            Par(str(datos[i][0]), body_ce),
            Par(datos[i][1], body_iz),
            Par(datos[i][2], body_iz)
        ]

        if self.tabla == "categorias":
            listafila.append(Par(str(datos[i][3]), body_de))

        lista.append(listafila)

    listado.listado(self.titulo, lista, tamanos, A4)
Exemple #15
0
    def preparar_pdf(self, grilla):
        head = tabla_celda_titulo()
        body_ce = tabla_celda_centrado(9)
        body_iz = tabla_celda_just_izquierdo(9)

        datos = grilla.get_model()
        cant = len(datos)

        if self.obj("chk_empleado").get_active():  # De un empleado específico
            encabezado = [self.obj("txt_01_1").get_text(), self.obj("txt_01_2").get_text(),
                self.obj("txt_02").get_text(), self.obj("txt_02_1").get_text()]

            lista = [[Par("Fecha", head), Par("Hora", head), Par("", head),
                Par("Observaciones", head), Par("Usuario", head)]]

            for i in range(0, cant):
                lista.append([Par(datos[i][6], body_iz), Par(datos[i][7], body_ce),
                    Par(datos[i][8], body_ce), Par(datos[i][10], body_iz),
                    Par(datos[i][11], body_iz)])

            genera_asistencia_empleado(encabezado, lista)

        else:
            lista = [[Par("Nro. Contrato", head), Par("Nro. C.I.", head),
                Par("Empleado", head), Par("Cargo", head),
                Par("Fecha", head), Par("Hora", head), Par("", head),
                Par("Observaciones", head), Par("Usuario", head)]]

            for i in range(0, cant):
                lista.append([Par(datos[i][0], body_ce), Par(datos[i][3], body_ce),
                    Par(datos[i][4], body_iz), Par(datos[i][5], body_iz),
                    Par(datos[i][6], body_iz), Par(datos[i][7], body_ce),
                    Par(datos[i][8], body_ce), Par(datos[i][10], body_iz),
                    Par(datos[i][11], body_iz)])

            listado("Asistencias", lista, [70, 70, 145, 70, 100, 70, 50, 120, 70], landscape(A4))
    def preparar_pdf(self, grilla):
        datos = grilla.get_model()
        cant = len(datos)

        ubicacion_archivo = dialogo_guardar("Notas de Débito por Ventas")

        if ubicacion_archivo is not None:
            # Si no tiene la terminación .pdf se le agrega
            if ubicacion_archivo[-4:].lower() != ".pdf":
                ubicacion_archivo += ".pdf"

            story = []
            cabecera = cabecera_style()
            parrafo = parrafo_bodytext()
            head = tabla_celda_titulo()
            body_ce = tabla_celda_centrado()
            body_iz = tabla_celda_just_izquierdo()
            body_de = tabla_celda_just_derecho()

            story.append(Par("Notas de Débito por Ventas", cabecera))
            story.append(Spacer(0, 20))

            if self.obj("chk_01").get_active():  # Nro. de Timbrado
                story.append(
                    Par(
                        "Notas de Débito por el Timbrado Nro. <b>" +
                        self.obj("txt_timb").get_text() + "</b>, del " +
                        "Establecimiento Nro. <b>" +
                        self.obj("txt_estab").get_text() + "</b>" +
                        " y la Caja Nro. <b>" +
                        self.obj("txt_caja").get_text() + "</b>", parrafo))

            if self.obj("chk_02").get_active():  # Nro. de Nota de Debito
                story.append(
                    Par(
                        "Números de Nota de Débito entre <b>" +
                        str(self.obj("txt_nro_ini").get_value_as_int()) +
                        "</b> y <b>" +
                        str(self.obj("txt_nro_fin").get_value_as_int()) +
                        "</b>", parrafo))

            if self.obj("chk_03").get_active():  # Cliente
                story.append(
                    Par(
                        "Notas de Débito del Cliente <b>" +
                        self.obj("txt_cliente_02").get_text() + "</b>",
                        parrafo))

            if self.obj("chk_04").get_active():  # Vendedor
                story.append(
                    Par(
                        "Notas de Débito del Vendedor <b>" +
                        self.obj("txt_vendedor_02").get_text() + "</b>",
                        parrafo))

            if self.obj("chk_05").get_active():  # Fecha
                story.append(
                    Par(
                        "Notas de Débito expedidas entre el " + "<b>" +
                        cadena_fecha(self.fecha_ini) + "</b> y el " + "<b>" +
                        cadena_fecha(self.fecha_fin) + "</b>", parrafo))

            if self.obj("chk_06").get_active():  # Total
                if self.idTotal == 1:  # Entre
                    tipo, segundo = "entre", " y <b>" + \
                    str(self.obj("txt_total_fin").get_value()) + "</b>"
                elif self.idTotal == 2:  # Mayor que
                    tipo, segundo = "mayor que", ""
                elif self.idTotal == 3:  # Mayor o igual que
                    tipo, segundo = "mayor o igual que", ""
                elif self.idTotal == 4:  # Menor que
                    tipo, segundo = "menor que", ""
                elif self.idTotal == 5:  # Menor o igual que
                    tipo, segundo = "menor o igual que", ""
                story.append(
                    Par(
                        "Notas de Débito expedidas por un Monto " + tipo +
                        " <b>" + str(self.obj("txt_total_ini").get_value()) +
                        " </b>" + segundo, parrafo))

            story.append(Spacer(0, 20))

            lista = [[
                Par("Nro. Timbrado", head),
                Par("Nro. Nota de Débito", head),
                Par("Fecha de Expedición", head),
                Par("Nro. Doc. Cliente", head),
                Par("Cliente", head),
                Par("Total", head)
            ]]

            for i in range(0, cant):
                lista.append([
                    Par(str(datos[i][0]), body_ce),
                    Par(datos[i][1], body_ce),
                    Par(datos[i][2], body_ce),
                    Par(datos[i][3], body_ce),
                    Par(datos[i][4], body_iz),
                    Par(str(datos[i][5]), body_de)
                ])

            tabla = Table(lista, [100, 100, 150, 100, 175, 75])
            tabla = tabla_style(tabla)
            story.append(tabla)

            doc = SimpleDocTemplate(
                ubicacion_archivo,
                pagesize=landscape(A4),
                leftMargin=3 * cm,  # Margen Izquierdo
                rightMargin=3 * cm,  # Margen Derecho
                topMargin=2.5 * cm,  # Margen Superior
                bottomMargin=2.5 * cm,  # Margen Inferior
                allowSplitting=1,
                title="Notas de Débito por Ventas",
                author="Sistema Distribuidora")

            try:  # Generar Archivo
                doc.build(story)
                popen(ubicacion_archivo)
            except PermissionError as e:
                error_permiso_archivo(str(e))
    def preparar_pdf(self, grilla):
        datos = grilla.get_model()
        cant = len(datos)

        ubicacion_archivo = dialogo_guardar("Facturas de Compra")

        if ubicacion_archivo is not None:
            # Si no tiene la terminación .pdf se le agrega
            if ubicacion_archivo[-4:].lower() != ".pdf":
                ubicacion_archivo += ".pdf"

            story = []
            cabecera = cabecera_style()
            parrafo = parrafo_bodytext()
            head = tabla_celda_titulo()
            body_ce = tabla_celda_centrado()
            body_iz = tabla_celda_just_izquierdo()
            body_de = tabla_celda_just_derecho()

            story.append(Par("Facturas de Compra", cabecera))
            story.append(Spacer(0, 20))

            if self.obj("chk_01").get_active():  # Proveedor
                story.append(Par("Facturas del Proveedor <b>" +
                self.obj("txt_prov_02").get_text() + "</b>", parrafo))

            if self.obj("chk_02").get_active():  # Tipo de Factura
                model = self.obj("cmb_tipo_fact").get_model()
                active = self.obj("cmb_tipo_fact").get_active()
                story.append(Par("<b>" + model[active][1] + "</b>", parrafo))

            if self.obj("chk_03").get_active():  # Fecha
                story.append(Par("Facturas expedidas entre el " +
                "<b>" + cadena_fecha(self.fecha_ini) + "</b> y el " +
                "<b>" + cadena_fecha(self.fecha_fin) + "</b>", parrafo))

            if self.obj("chk_04").get_active():  # Total
                if self.idTotal == 1:  # Entre
                    tipo, segundo = "entre", " y <b>" + \
                    str(self.obj("txt_total_fin").get_value()) + "</b>"
                elif self.idTotal == 2:  # Mayor que
                    tipo, segundo = "mayor que", ""
                elif self.idTotal == 3:  # Mayor o igual que
                    tipo, segundo = "mayor o igual que", ""
                elif self.idTotal == 4:  # Menor que
                    tipo, segundo = "menor que", ""
                elif self.idTotal == 5:  # Menor o igual que
                    tipo, segundo = "menor o igual que", ""
                story.append(Par("Facturas expedidas por un Monto " + tipo + " <b>" +
                str(self.obj("txt_total_ini").get_value()) + " </b>" + segundo, parrafo))

            story.append(Spacer(0, 20))

            lista = [[Par("Nro. Timbrado", head), Par("Nro. Factura", head),
                Par("Fecha", head), Par("Tipo de Factura", head),
                Par("Nro. Doc. Prov.", head), Par("Proveedor", head), Par("Total", head)]]

            for i in range(0, cant):
                lista.append([Par(str(datos[i][0]), body_ce), Par(datos[i][1], body_ce),
                    Par(datos[i][2], body_ce), Par(datos[i][3], body_ce), Par(datos[i][4], body_ce),
                    Par(datos[i][5], body_iz), Par(str(datos[i][6]), body_de)])

            tabla = Table(lista, [100, 100, 150, 100, 100, 125, 75])
            tabla = tabla_style(tabla)
            story.append(tabla)

            doc = SimpleDocTemplate(
                ubicacion_archivo,
                pagesize=landscape(A4),
                leftMargin=3 * cm,  # Margen Izquierdo
                rightMargin=3 * cm,  # Margen Derecho
                topMargin=2.5 * cm,  # Margen Superior
                bottomMargin=2.5 * cm,  # Margen Inferior
                allowSplitting=1,
                title="Facturas de Compra",
                author="Sistema Distribuidora"
            )

            try:  # Generar Archivo
                doc.build(story)
                popen(ubicacion_archivo)
            except PermissionError as e:
                error_permiso_archivo(str(e))
Exemple #18
0
def genera_comprobante_pago(datos_conexion, nro_comp):
    ubicacion_archivo = dialogo_guardar("Comprobante de Pago")

    if ubicacion_archivo is not None:
        # Si no tiene la terminación .pdf se le agrega
        if ubicacion_archivo[-4:].lower() != ".pdf":
            ubicacion_archivo += ".pdf"

        story = []
        titulo = tabla_celda_titulo()
        texto = tabla_celda_just_izquierdo()
        numero = tabla_celda_just_derecho()
        centro = tabla_celda_centrado()

        tabla = Table([[
            Paragraph(
                "<b><font size=15>Distribuidora María Auxiliadora</font></b><br/><br/>"
                +
                "<i><font size=12>Productos y Servicios S.A.</font></i><br/><br/><br/>"
                + "<font size=8>Caaguazú - Paraguay</font>", centro),
            Paragraph(
                "RUC:<br/><br/>" +
                "<b><font size=15>RECIBO DE PAGO</font></b><br/><br/>" +
                "<i><font size=7>Liquidación de Sueldo y Otras Remuneraciones<br/>"
                +
                "(Conforme al Art. 235 del Código Laboral)</font></i><br/><br/>"
                + "<b><font size=15>" + cadenanumeros(nro_comp, 7) +
                "</font></b>", centro),
        ]], [350, 150])
        tabla.setStyle([
            ('VALIGN', (0, 0), (-1, -1),
             'MIDDLE'),  # Alineación Vertical de la Tabla
            ('BOX', (0, 0), (-1, -1), 0.25,
             colors.black),  # Borde Exterior de la Tabla
            ('INNERGRID', (0, 0), (-1, -1), 0.25,
             colors.black),  # Grilla Interior de la Tabla
        ])
        story.append(tabla)
        story.append(Spacer(0, 20))

        # Establece la conexión con la Base de Datos
        conexion = conectar(datos_conexion)
        cursor = consultar(
            conexion, "idEmpleado, NroDocumento, " +
            "NombreApellido, FechaInicio, FechaFin, TotalPagar",
            "comprobantepagos_s", " WHERE NroComprobante = " + nro_comp)
        datos_comp = cursor.fetchall()

        # Buscar otros datos del Empleado
        cursor = consultar(conexion, "DireccionPrincipal", "personas_s",
                           " WHERE idPersona = " + str(datos_comp[0][0]))
        datos_empl = cursor.fetchall()
        if cursor.rowcount > 0:
            direccion = "" if datos_empl[0][0] is None else datos_empl[0][0]
        else:
            direccion = ""

        # Buscar datos de la Empresa
        cursor = consultar(conexion, "NroPatronalIPS, NroPatronalMJT",
                           "empresas_s", " ORDER BY idEmpresa")
        datos_empr = cursor.fetchall()
        if cursor.rowcount > 0:
            ips = "" if datos_empr[0][0] is None else datos_empr[0][0]
            mjt = "" if datos_empr[0][1] is None else datos_empr[0][1]
        else:
            ips = mjt = ""

        tabla = Table(
            [[
                Paragraph("<b>Lugar y Fecha:</b>", texto),
                Paragraph("Caaguazú, " + fecha_hoy(), texto), '', ''
            ],
             [
                 Paragraph("<b>Trabajador:</b>", texto),
                 Paragraph(datos_comp[0][2], texto),
                 Paragraph("<b>C.I. Nro.:</b>", texto),
                 Paragraph(datos_comp[0][1], texto)
             ],
             [
                 Paragraph("<b>Dirección:</b>", texto),
                 Paragraph(direccion, texto), '', ''
             ],
             [
                 Paragraph("<b>Sucursal:</b>", texto),
                 Paragraph("Caaguazú", texto), '', ''
             ],
             [
                 Paragraph("<b>Periodo de Pago:</b>", texto),
                 Paragraph(
                     "Desde " + mysql_fecha(datos_comp[0][3]) + " hasta " +
                     mysql_fecha(datos_comp[0][4]), texto), '', ''
             ],
             [
                 Paragraph("<b>Nro. Patronal:</b>", texto),
                 Paragraph(ips + " / " + str(mjt), texto), '', ''
             ]], [100, 275, 50, 75])
        tabla.setStyle([
            ('SPAN', (1, 0), (-1, 0)),  # Combina columnas, primera fila
            ('ALIGN', (0, 0), (0, -1),
             'RIGHT'),  # Alineación de la Primera Columna
            ('ALIGN', (1, 1), (-1, -1),
             'LEFT'),  # Alineación de Otras Columnas
            ('VALIGN', (0, 0), (-1, -1),
             'MIDDLE'),  # Alineación Vertical de la Tabla
            ('TOPPADDING', (0, 0), (-1, -1), 1),  # Espacio Arriba
            ('BOTTOMPADDING', (0, 0), (-1, -1), 3),  # Espacio Abajo
            ('LEFTPADDING', (0, 0), (-1, -1), 3),  # Espacio a la Izquierda
            ('RIGHTPADDING', (0, 0), (-1, -1), 3),  # Espacio a la Derecha
            ('SPAN', (1, 2), (-1, 2)),  # Combina columnas, segunda fila
            ('SPAN', (1, 3), (-1, 3)),  # Combina columnas, tercera fila
            ('SPAN', (1, 4), (-1, 4)),  # Combina columnas, cuarta fila
            ('SPAN', (1, 5), (-1, 5)),  # Combina columnas, quinta fila
        ])
        story.append(tabla)
        story.append(Spacer(0, 20))

        cursor = consultar(conexion, "Cantidad, Concepto, Monto",
                           "comprobantepagos_detalles_s",
                           " WHERE NroComprobante = " + nro_comp)
        datos_det = cursor.fetchall()
        cant = cursor.rowcount
        lista = [[
            Paragraph("Cantidad", titulo),
            Paragraph("Descripción", titulo),
            Paragraph("Importe", titulo)
        ]]

        for i in range(0, cant):
            cantidad = "" if datos_det[i][0] is None else str(datos_det[i][0])
            lista.append([
                Paragraph(cantidad, centro),
                Paragraph(datos_det[i][1], texto),
                Paragraph(str(datos_det[i][2]), numero)
            ])

        if cant < 16:  # Completar hasta 16 casillas
            for i in range(cant, 16):
                lista.append(["", "", ""])

        # Total a Pagar
        lista.append([
            Paragraph("Total a Pagar:", numero), '',
            Paragraph(str(datos_comp[0][5]), numero)
        ])

        tabla = Table(lista, [100, 300, 100])
        tabla = tabla_style(tabla)
        tabla.setStyle([
            ('SPAN', (0, -1), (-2, -1)),  # Combina columnas, última fila
        ])
        story.append(tabla)

        #ubicacion_archivo = path.join(path.expanduser("~"), "Desktop", "listado.pdf")
        doc = SimpleDocTemplate(
            ubicacion_archivo,
            pagesize=A4,  # Tamaño de Página (landscape(A4) hoja horizontal)
            leftMargin=3 * cm,  # Margen Izquierdo
            rightMargin=3 * cm,  # Margen Derecho
            topMargin=2.5 * cm,  # Margen Superior
            bottomMargin=2.5 * cm,  # Margen Inferior
            allowSplitting=1,
            title="Comprobante de Pago Nro. " + cadenanumeros(nro_comp, 7),
            author="Sistema Distribuidora")

        try:  # Generar Archivo
            doc.build(story)
            popen(ubicacion_archivo)
        except PermissionError as e:
            error_permiso_archivo(str(e))