示例#1
0
    def print_mayor(self,cuentas,comunidad):
        buffer = self.buffer
        doc = SimpleDocTemplate(buffer,
                                rightMargin=50,
                                leftMargin=50,
                                topMargin=50,
                                bottomMargin=50,
                                pagesize=self.pagesize,
                                )
        # Our container for 'Flowable' objects
        elements = [] 
        # A large collection of style sheets pre-made for us
        styles = getSampleStyleSheet()
        #styles.add(ParagraphStyle(name='RightAlign', fontName='Arial', alignment=TA_RIGHT))
        hcodigo = Paragraph('''<b>Cod.</b>''', styleBH)
        hcuenta = Paragraph('''<b>Cuenta.</b>''', styleBH)
        hdebe = Paragraph('''<b>Debe</b>''', styleBH)
        hhaber = Paragraph('''<b>Haber</b>''', styleBH)
        hsaldo = Paragraph('''<b>Saldo</b>''', styleBH)
            
        data = [[hcodigo, hcuenta, hdebe, hhaber,hsaldo]]
        cont=0
        
        for cuenta in cuentas:
            if cuenta[6]:
                array = [cuenta[0], (cuenta[1]), 
                        Paragraph(separador_de_miles(str(cuenta[3])),styleRIGTH),Paragraph(str(cuenta[4]),styleRIGTH),
                        Paragraph(str(cuenta[5]),styleRIGTH)]
            else:
                array = [Paragraph("<b>"+cuenta[0]+"</b>",styleN),Paragraph("<b>"+cuenta[1]+"</b>",styleN),
                         Paragraph(separador_de_miles(cuenta[3]),styleRIGTH),Paragraph(separador_de_miles(cuenta[4]),styleRIGTH),
                         Paragraph(separador_de_miles(cuenta[5]),styleRIGTH)]
            data.append(array)
                    # Create the table
        table = Table(data, colWidths=[1.8 * cm, 8.2 * cm, 2.7* cm, 2.7 * cm, 2.7 * cm], )
        
        table.setStyle(TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                                       ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))
        
        libro_mayor=Table([['',Paragraph('<b>LIBRO MAYOR - '+comunidad+' </b>', styleBH),''],['','','']],
                          colWidths=[1 * cm, 14 * cm,1*cm ]
                          )
      
        elements.append(libro_mayor)
        elements.append(table)
        doc.build(elements, onFirstPage=self._header_footer, onLaterPages=self._header_footer,
                  canvasmaker=NumberedCanvas)
 
        # Get the value of the BytesIO buffer and write it to the response.
        pdf = buffer.getvalue()
        buffer.close()
        return pdf
示例#2
0
    def print_cuentas_bancarias_comunidad(self,bancos,comunidad,asientos):
      
        buffer = self.buffer
        doc = SimpleDocTemplate(buffer,
                                rightMargin=50,
                                leftMargin=50,
                                topMargin=50,
                                bottomMargin=50,
                                pagesize=self.pagesize,
                                )
        
        # Our container for 'Flowable' objects
        elements = []
        cuentas_bancarias=Table([['',Paragraph('<b>CUENTAS BANCARIAS - '+comunidad.comunidad+' </b>', styleBH),''],['','','']],
                          colWidths=[1 * cm, 14 * cm,1*cm ]
                          )
        elements.append(cuentas_bancarias)
 
        # A large collection of style sheets pre-made for us
        styles = getSampleStyleSheet()
        t_widths=[3 * cm, 2.7 * cm, 2.7* cm,2.7* cm, 5* cm]
        
                
        hfecha = Paragraph('''<b>Fecha.</b>''', styleBH)
        hdebe = Paragraph('''<b>Debe</b>''', styleBH)
        hhaber = Paragraph('''<b>Haber</b>''', styleBH)
        hsaldo = Paragraph('''<b>Saldo</b>''', styleBH)
        hobs = Paragraph('''<b>Observacion</b>''', styleBH)

        t_head=[hfecha, hdebe, hhaber,hsaldo,hobs]
        
        data=[]
        
        for banco in bancos:
            categoria_table=Table([['','',''],
                                            ['',Paragraph(banco.cuenta_bancaria,styleBH),''],
                                            ], colWidths=[1 * cm, 14 * cm,1*cm ]
                              )
            elements.append(categoria_table)
            data=[t_head]
            
            for asiento in asientos:
                if asiento.cuenta_bancaria_id == banco.id:
                    array=[str(asiento.asiento_contable.fecha),Paragraph(separador_de_miles(asiento.debe),styleRIGTH),
                           Paragraph(separador_de_miles(asiento.haber),styleRIGTH), 
                           Paragraph(separador_de_miles(asiento.debe), styleRIGTH),
                           asiento.observacion ]
                    data.append(array)
                       
            table = Table(data, colWidths=t_widths )
            table.setStyle(TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                                           ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))
            elements.append(table)
                    
    
        doc.build(elements, onFirstPage=self._header_footer, onLaterPages=self._header_footer,
                  canvasmaker=NumberedCanvas)
 
        # Get the value of the BytesIO buffer and write it to the response.
        pdf = buffer.getvalue()
        buffer.close()
        return pdf
示例#3
0
    def print_inventario_comunidad(self,categorias,comunidad,detalles):
        buffer = self.buffer
        doc = SimpleDocTemplate(buffer,
                                rightMargin=50,
                                leftMargin=50,
                                topMargin=50,
                                bottomMargin=50,
                                pagesize=self.pagesize,
                                )
        # Our container for 'Flowable' objects
        elements = []
        inventario=Table([['',Paragraph('<b>INVENTARIO - '+comunidad.comunidad+' </b>', styleBH),''],['','','']],
                          colWidths=[1 * cm, 14 * cm,1*cm ]
                          )
        elements.append(inventario)
 
        # A large collection of style sheets pre-made for us
        styles = getSampleStyleSheet()
        t_widths=[7 * cm, 2.7 * cm, 2.7* cm, 2.7 * cm]
        
        data=[[Paragraph('<b>Descripcion</b>', styleBH),
              Paragraph('<b>Cantidad</b>', styleBH),
              Paragraph('<b>Total</b>', styleBH)
              ]]
        
        for c in categorias:
            array=[c.nombre,Paragraph(separador_de_miles(c.cantidad(comunidad.id)),styleRIGTH),Paragraph(separador_de_miles(c.total(comunidad.id)),styleRIGTH)]
            data.append(array)
        categoria_table=Table(data,colWidths=t_widths)    
        categoria_table.setStyle(TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                                           ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))
        elements.append(categoria_table)
        
                
        hdescripcion = Paragraph('''<b>Descripcion.</b>''', styleBH)
        hcantidad = Paragraph('''<b>Cantidad</b>''', styleBH)
        hprecio = Paragraph('''<b>Precio Unitario</b>''', styleBH)
        htotal = Paragraph('''<b>Total</b>''', styleBH)

        t_head=[hdescripcion, hcantidad, hprecio,htotal]
        
        data=[]
        
        for categoria in categorias:
            categoria_table=Table([['','',''],
                                            ['',Paragraph(categoria.nombre,styleBH),''],
                                            ], colWidths=[1 * cm, 14 * cm,1*cm ]
                              )
            elements.append(categoria_table)
            data=[t_head]
            
            for detalle in detalles:
                if detalle.categoria_id == categoria.id:
                    array=[detalle.descripcion,Paragraph(separador_de_miles(detalle.cantidad),styleRIGTH),
                           Paragraph(separador_de_miles(detalle.precio_unitario),styleRIGTH), 
                           Paragraph(separador_de_miles(detalle.precio_total()), styleRIGTH),]
                    data.append(array)
                       
            table = Table(data, colWidths=t_widths )
            table.setStyle(TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                                           ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))
            elements.append(table)
                    
    
        doc.build(elements, onFirstPage=self._header_footer, onLaterPages=self._header_footer,
                  canvasmaker=NumberedCanvas)
 
        # Get the value of the BytesIO buffer and write it to the response.
        pdf = buffer.getvalue()
        buffer.close()
        return pdf
示例#4
0
    def print_mayor_detalle(self,cuentas,comunidad,asientos):
        buffer = self.buffer
        doc = SimpleDocTemplate(buffer,
                                rightMargin=50,
                                leftMargin=50,
                                topMargin=50,
                                bottomMargin=50,
                                pagesize=self.pagesize,
                                )
        # Our container for 'Flowable' objects
        elements = [] 
        # A large collection of style sheets pre-made for us
        styles = getSampleStyleSheet()
        #styles.add(ParagraphStyle(name='RightAlign', fontName='Arial', alignment=TA_RIGHT))
        hfecha = Paragraph('''<b>Fecha.</b>''', styleBH)
        hdebe = Paragraph('''<b>Debe</b>''', styleBH)
        hhaber = Paragraph('''<b>Haber</b>''', styleBH)
        hsaldo = Paragraph('''<b>Saldo</b>''', styleBH)
        hconcepto = Paragraph('''<b>Concepto</b>''', styleBH)
        t_head=[hfecha, hdebe, hhaber,hsaldo,hconcepto]
        t_widths=[2.3 * cm, 2.7 * cm, 2.7* cm, 2.7 * cm, 6 * cm]
        data=[]
        
        libro_mayor=Table([['',Paragraph('<b>LIBRO MAYOR DETALLADO - '+comunidad+' </b>', styleBH),'']],
                          colWidths=[1 * cm, 14 * cm,1*cm ]
                          )
        
        elements.append(libro_mayor)
        for cuenta in cuentas:
            band=True
            contador=0
            for asiento in asientos:
                if cuenta[0] == asiento.cuenta_id:
                   if band:
                       band=False
                       cuenta_table=Table([['','',''],
                                            ['',Paragraph(cuenta[3]+" - "+cuenta[1]+" : "+str(cuenta[2]), styleBH),''],
                                            ],
                              colWidths=[1 * cm, 14 * cm,1*cm ]
                              )
                       data=[]
                       elements.append(cuenta_table)
                       data.append(t_head)
                   array=[asiento.asiento_contable.fecha,Paragraph(separador_de_miles(asiento.debe),styleRIGTH),
                           Paragraph(separador_de_miles(asiento.haber),styleRIGTH), 
                           Paragraph(separador_de_miles(saldo_anterior(asientos,contador)), styleRIGTH),
                                     asiento.observacion]
                   data.append(array)
                   contador+=1
            table = Table(data, colWidths=t_widths )
            table.setStyle(TableStyle([('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
                                           ('BOX', (0, 0), (-1, -1), 0.25, colors.black)]))
            elements.append(table)
           
        doc.build(elements, onFirstPage=self._header_footer, onLaterPages=self._header_footer,
                  canvasmaker=NumberedCanvas)
 
        # Get the value of the BytesIO buffer and write it to the response.
        pdf = buffer.getvalue()
        buffer.close()
        return pdf
示例#5
0
def separar(value):
   return separador_de_miles(value)