def tabla_otros(self):
orden = self.orden_compra
p = ParagraphStyle('parrafos',
alignment = TA_CENTER,
fontSize = 8,
fontName="Times-Roman")
sub_total = Paragraph(u"SUBTOTAL: ",p)
igv = Paragraph(u"IGV: ",p)
total = Paragraph(u"TOTAL: ",p)
datos_otros = [[ Paragraph(u"LUGAR DE ENTREGA",p), Paragraph(u"PLAZO DE ENTREGA",p), Paragraph(u"FORMA DE PAGO",p),sub_total,orden.subtotal],
[Paragraph(EMPRESA.direccion(),p),Paragraph(u"INMEDIATA",p),Paragraph(orden.forma_pago.descripcion,p),igv,str(orden.igv)],
['','','',total,str(orden.total)],
]
tabla_otros = Table(datos_otros,colWidths=[5.5 * cm, 5 * cm, 5 * cm, 2 * cm, 2.5 * cm])
tabla_otros.setStyle(TableStyle(
[
('GRID', (0, 0), (2, 2), 1, colors.black),
('SPAN',(0,1),(0,2)),
('SPAN',(1,1),(1,2)),
('SPAN',(2,1),(2,2)),
('GRID', (4, 0), (4, 2), 1, colors.black),
('VALIGN',(0,1),(2,1),'MIDDLE'),
]
))
return tabla_otros
python类TableStyle()的实例源码
def cuadro_observaciones(self,pdf,y,orden):
p = ParagraphStyle('parrafos')
p.alignment = TA_JUSTIFY
p.fontSize = 10
p.fontName="Times-Roman"
obs=Paragraph("Observaciones: "+orden.observaciones,p)
observaciones = [[obs]]
tabla_observaciones = Table(observaciones,colWidths=[18.50 * cm], rowHeights=1.8 * cm)
tabla_observaciones.setStyle(TableStyle(
[
('GRID', (0, 0), (0, 2), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
('ALIGN',(0,0),(-1,-1),'LEFT'),
('VALIGN',(0,0),(-1,-1),'TOP'),
]
))
tabla_observaciones.wrapOn(pdf, 800, 600)
tabla_observaciones.drawOn(pdf, 40,y-58)
def detalle(self,pdf,y,cotizacion):
encabezados = ('Nro', 'Descripción', 'Unidad','Cantidad')
detalles = cotizacion.detallecotizacion_set.all()
lista_detalles = []
for detalle in detalles:
tupla_producto = (detalle.nro_detalle, detalle.detalle_requerimiento.producto.descripcion, detalle.detalle_requerimiento.producto.unidad_medida.descripcion, detalle.cantidad)
lista_detalles.append(tupla_producto)
adicionales = [('','','','')]*(15-len(detalles))
tabla_detalle = Table([encabezados] + lista_detalles + adicionales,colWidths=[1 * cm, 13.5 * cm, 1.5 * cm, 2* cm])
tabla_detalle.setStyle(TableStyle(
[
('ALIGN',(0,0),(3,0),'CENTER'),
('GRID', (0, 0), (-1, -1), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 7),
('ALIGN',(3,1),(-1,-1),'LEFT'),
]
))
tabla_detalle.wrapOn(pdf, 800, 600)
tabla_detalle.drawOn(pdf, 40,y+80)
def cuadro_observaciones(self,pdf,y,cotizacion):
p = ParagraphStyle('parrafos')
p.alignment = TA_JUSTIFY
p.fontSize = 8
p.fontName="Times-Roman"
obs=Paragraph("OBSERVACIONES: "+cotizacion.observaciones,p)
observaciones = [[obs]]
tabla_observaciones = Table(observaciones,colWidths=[18 * cm], rowHeights=1.8 * cm)
tabla_observaciones.setStyle(TableStyle(
[
('GRID', (0, 0), (0, 2), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
('ALIGN',(0,0),(-1,-1),'LEFT'),
('VALIGN',(0,0),(-1,-1),'TOP'),
]
))
tabla_observaciones.wrapOn(pdf, 800, 600)
tabla_observaciones.drawOn(pdf, 40,y+20)
def tabla_encabezado(self, styles):
sp = ParagraphStyle('parrafos',
alignment=TA_CENTER,
fontSize=14,
fontName="Times-Roman")
requerimiento = self.requerimiento
try:
archivo_imagen = os.path.join(settings.MEDIA_ROOT, str(EMPRESA.logo))
imagen = Image(archivo_imagen, width=90, height=50, hAlign='LEFT')
except:
print u"Ingresa acá "
imagen = Paragraph(u"LOGO", sp)
nro = Paragraph(u"REQUERIMIENTO DE BIENES Y SERVICIOS<br/>N°" + requerimiento.codigo, sp)
encabezado = [[imagen, nro, '']]
tabla_encabezado = Table(encabezado, colWidths=[4 * cm, 11 * cm, 4 * cm])
tabla_encabezado.setStyle(TableStyle(
[
('ALIGN', (0, 0), (1, 0), 'CENTER'),
('VALIGN', (0, 0), (1, 0), 'CENTER'),
]
))
return tabla_encabezado
def tabla_datos(self, styles):
requerimiento = self.requerimiento
izquierda = ParagraphStyle('parrafos',
alignment=TA_LEFT,
fontSize=10,
fontName="Times-Roman")
solicitado = Paragraph(u"SOLICITADO POR: " + requerimiento.solicitante.nombre_completo(), izquierda)
oficina = Paragraph(u"OFICINA: " + requerimiento.oficina.nombre, izquierda)
motivo = Paragraph(u"MOTIVO: " + requerimiento.motivo, izquierda)
fecha = Paragraph(u"FECHA DE REQUERIMIENTO: " + requerimiento.fecha.strftime('%d/%m/%Y'), izquierda)
mes = Paragraph(u"MES EN QUE SE NECESITA: " + requerimiento.get_mes_display(), izquierda)
para_stock = Paragraph(u"AÑO EN QUE SE NECESITA: " + str(requerimiento.annio), izquierda)
if requerimiento.entrega_directa_solicitante:
entrega = Paragraph(u"ENTREGA DIRECTAMENTE AL SOLICITANTE: SI", izquierda)
else:
entrega = Paragraph(u"ENTREGA DIRECTAMENTE AL SOLICITANTE: NO", izquierda)
datos = [[solicitado, oficina], [motivo], [fecha, mes], [para_stock, entrega]]
tabla_datos = Table(datos, colWidths=[11 * cm, 9 * cm])
style = TableStyle(
[
('SPAN', (0, 1), (1, 1)),
]
)
tabla_datos.setStyle(style)
return tabla_datos
def tabla_observaciones(self):
requerimiento = self.requerimiento
p = ParagraphStyle('parrafos')
p.alignment = TA_JUSTIFY
p.fontSize = 8
p.fontName = "Times-Roman"
obs = Paragraph("OBSERVACIONES: " + requerimiento.observaciones, p)
observaciones = [[obs]]
tabla_observaciones = Table(observaciones, colWidths=[20 * cm], rowHeights=1.8 * cm)
tabla_observaciones.setStyle(TableStyle(
[
('GRID', (0, 0), (0, 2), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
('ALIGN', (0, 0), (-1, -1), 'LEFT'),
('VALIGN', (0, 0), (-1, -1), 'TOP'),
]
))
return tabla_observaciones
def tabla_observaciones(self):
movimiento = self.movimiento
p = ParagraphStyle('parrafos',
alignment = TA_JUSTIFY,
fontSize = 8,
fontName="Times-Roman")
obs=Paragraph("OBSERVACIONES: "+movimiento.observaciones,p)
observaciones = [[obs]]
tabla_observaciones = Table(observaciones,colWidths=[20 * cm], rowHeights=1.8 * cm)
tabla_observaciones.setStyle(TableStyle(
[
('GRID', (0, 0), (0, 2), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
('ALIGN',(0,0),(-1,-1),'LEFT'),
('VALIGN',(0,0),(-1,-1),'TOP'),
]
))
return tabla_observaciones
def tabla_encabezado_consolidado(self, grupos):
sp = ParagraphStyle('parrafos',
alignment=TA_CENTER,
fontSize=14,
fontName="Times-Roman")
try:
archivo_imagen = os.path.join(settings.MEDIA_ROOT, str(EMPRESA.logo))
imagen = Image(archivo_imagen, width=90, height=50, hAlign='LEFT')
except:
imagen = Paragraph(u"LOGO", sp)
if grupos:
titulo = Paragraph(u"RESUMEN MENSUAL DE ALMACÉN POR GRUPOS Y CUENTAS", sp)
else:
titulo = Paragraph(u"RESUMEN MENSUAL DE ALMACÉN POR PRODUCTOS", sp)
encabezado = [[imagen,titulo]]
tabla_encabezado = Table(encabezado, colWidths=[2 * cm, 23 * cm])
style = TableStyle(
[
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
]
)
tabla_encabezado.setStyle(style)
return tabla_encabezado
def run(self,open=True):
self.Set_Heading()
self.Set_Heading_Style()
self.SetTable_Style()
self.Format_Title()
#[self.cW1*cm]*2+[self.cW2*cm]+[1*cm]*2+[self.cW3*cm]*56
#[self.cW1*cm]*2+[self.cW2*cm]+[1*cm]*2+[self.cW3*cm]*51+[ self.cW4*cm]*11+[self.cW5*cm]+[self.cW3*cm]*3
self.Heading_Table=Table(self.HEADING,[self.cW1*cm]*2+[self.cW2*cm]+[1*cm]*2+[self.cW3*cm]*41+[ self.cW4*cm]*11+[self.cW5*cm]+[self.cW3*cm]*3,[self.rH2*cm]+[self.rH3*cm]+[self.rH4*cm])
self.Heading_Table.setStyle(TableStyle(self.Heading_Style))
self.Populate()
#self.AddPage()
self.Set_Consolidation()
self.Set_Consolidation_Style()
self.Add_Consolidation()
self.Failed_Report()
self.Save(open)
def add_timeline(self):
ptext = '<b><font size=14>Processing Timeline</font></b>'
self.Story.append(Paragraph(ptext, self.styles['Normal']))
self.Story.append(Spacer(1, 0.1*inch))
data = [
[self.request['stage'][0]['name'], self.time_str(self.request['stage'][0]['time'])],
[self.request['stage'][1]['name'], self.time_str(self.request['stage'][1]['time'])],
[self.request['stage'][2]['name'], self.time_str(self.request['stage'][2]['time'])],
[self.request['stage'][3]['name'], self.time_str(int(time.time()))]
# ['complete', self.time_str(self.request['stage'][3]['time'])]
]
data = [[i[0], pg(i[1], 1)] for i in data]
t = Table(data)
t.setStyle(TableStyle([
('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
('BOX', (0,0), (-1,-1), 0.25, colors.black)
]))
self.Story.append(t)
def gather_elements(self, client, node, style):
if isinstance(node.parent, docutils.nodes.authors):
# Is only one of multiple authors. Return a paragraph
node.elements = [Paragraph(client.gather_pdftext(node),
style=style)]
if client.doc_author:
client.doc_author += client.author_separator(style=style) \
+ node.astext().strip()
else:
client.doc_author = node.astext().strip()
else:
# A single author: works like a field
fb = client.gather_pdftext(node)
t_style=TableStyle(client.styles['field-list'].commands)
colWidths=map(client.styles.adjustUnits,
client.styles['field-list'].colWidths)
node.elements = [Table(
[[Paragraph(client.text_for_label("author", style)+":",
style=client.styles['fieldname']),
Paragraph(fb, style)]],
style=t_style, colWidths=colWidths)]
client.doc_author = node.astext().strip()
return node.elements
def tabla_encabezado(self, styles):
orden_compra = self.orden_compra
sp = ParagraphStyle('parrafos',
alignment = TA_CENTER,
fontSize = 14,
fontName="Times-Roman")
try:
archivo_imagen = os.path.join(settings.MEDIA_ROOT,str(EMPRESA.logo))
imagen = Image(archivo_imagen, width=90, height=50,hAlign='LEFT')
except:
imagen = Paragraph(u"LOGO", sp)
nro = Paragraph(u"ORDEN DE COMPRA", sp)
ruc = Paragraph("R.U.C."+EMPRESA.ruc, sp)
encabezado = [[imagen,nro,ruc],['',u"N°"+orden_compra.codigo,EMPRESA.distrito + " " + orden_compra.fecha.strftime('%d de %b de %Y')]]
tabla_encabezado = Table(encabezado,colWidths=[4 * cm, 9 * cm, 6 * cm])
tabla_encabezado.setStyle(TableStyle(
[
('ALIGN',(0,0),(2,1),'CENTER'),
('VALIGN',(0,0),(2,0),'CENTER'),
('VALIGN',(1,1),(2,1),'TOP'),
('SPAN',(0,0),(0,1)),
]
))
return tabla_encabezado
def tabla_datos(self, styles):
orden = self.orden_compra
izquierda = ParagraphStyle('parrafos',
alignment = TA_LEFT,
fontSize = 10,
fontName="Times-Roman")
cotizacion = orden.cotizacion
if cotizacion is None:
proveedor = orden.proveedor
else:
proveedor = orden.cotizacion.proveedor
razon_social_proveedor = Paragraph(u"SEÑOR(ES): "+proveedor.razon_social, izquierda)
ruc_proveedor = Paragraph(u"R.U.C.: "+proveedor.ruc, izquierda)
direccion = Paragraph(u"DIRECCIÓN: "+proveedor.direccion, izquierda)
try:
telefono = Paragraph(u"TELÉFONO: "+proveedor.telefono, izquierda)
except:
telefono = Paragraph(u"TELÉFONO: -", izquierda)
try:
referencia = Paragraph(u"REFERENCIA: "+orden.cotizacion.requerimiento.codigo+" - "+orden.cotizacion.requerimiento.oficina.nombre, izquierda)
except:
referencia = Paragraph(u"REFERENCIA: ",izquierda)
proceso = Paragraph(u"PROCESO: "+orden.proceso, izquierda)
nota = Paragraph(u"Sírvase remitirnos según especificaciones que detallamos lo siguiente: ", izquierda)
datos = [[razon_social_proveedor,ruc_proveedor],[direccion,telefono],[referencia,''],[proceso,''],[nota,'']]
tabla_detalle = Table(datos,colWidths=[11* cm, 9 * cm])
tabla_detalle.setStyle(TableStyle(
[
('SPAN',(0,2),(1,2)),
]
))
return tabla_detalle
def tabla_detalle(self):
orden = self.orden_compra
encabezados = ['Item', 'Cantidad', 'Unidad', u'Descripción','Precio','Total']
detalles = DetalleOrdenCompra.objects.filter(orden=orden).order_by('pk')
sp = ParagraphStyle('parrafos')
sp.alignment = TA_JUSTIFY
sp.fontSize = 8
sp.fontName="Times-Roman"
lista_detalles = []
for detalle in detalles:
try:
tupla_producto = [Paragraph(str(detalle.nro_detalle),sp),
Paragraph(str(detalle.cantidad), sp),
Paragraph(detalle.detalle_cotizacion.detalle_requerimiento.producto.unidad_medida.descripcion,sp),
Paragraph(detalle.detalle_cotizacion.detalle_requerimiento.producto.descripcion, sp),
Paragraph(str(detalle.precio),sp),
Paragraph(str(detalle.valor),sp)]
except:
tupla_producto = [Paragraph(str(detalle.nro_detalle),sp),
Paragraph(str(detalle.cantidad), sp),
Paragraph(detalle.producto.unidad_medida.descripcion,sp),
Paragraph(detalle.producto.descripcion, sp),
Paragraph(str(detalle.precio),sp),
Paragraph(str(detalle.valor),sp)]
lista_detalles.append(tupla_producto)
adicionales = [('','','','','')] * (15-len(lista_detalles))
tabla_detalle = Table([encabezados] + lista_detalles + adicionales,colWidths=[0.8 * cm, 2 * cm, 2.5 * cm,10.2* cm, 2 * cm, 2.5 * cm])
style = TableStyle(
[
('ALIGN',(0,0),(4,0),'CENTER'),
('GRID', (0, 0), (-1, -1), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 7),
('ALIGN',(4,1),(-1,-1),'LEFT'),
('VALIGN',(0,0),(-1,-1),'TOP'),
]
)
tabla_detalle.setStyle(style)
return tabla_detalle
def tabla_total_letras(self):
orden = self.orden_compra
total_letras = [("SON: "+orden.total_letras,'')]
tabla_total_letras = Table(total_letras,colWidths=[17.5 * cm, 2.5 * cm])
tabla_total_letras.setStyle(TableStyle(
[
('GRID', (0, 0), (1, 0), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
]
))
return tabla_total_letras
def tabla_afectacion_presupuestal(self):
orden = self.orden_compra
p = ParagraphStyle('parrafos',
alignment = TA_JUSTIFY,
fontSize = 8,
fontName="Times-Roman")
hoja_afectacion = Paragraph(u"HOJA DE AFECTACIÓN PRESUPUESTAL: ",p)
importante = Paragraph(u"IMPORTANTE: ", p)
recibido = Paragraph(u"RECIBIDO POR: ", p)
firma = Paragraph(u"FIRMA: ", p)
nombre = Paragraph(u"NOMBRE: ", p)
dni = Paragraph(u"DNI: ", p)
lista = ListFlowable([
Paragraph("""Consignar el número de la presente Orden de Compra en su Guía de Remisión y Factura.
Facturar a nombre de """ + smart_str(EMPRESA.razon_social),p),
Paragraph("El " + smart_str(EMPRESA.razon_social) + """, se reserva el derecho de devolver
la mercaderia, sino se ajusta a las especificaciones requeridas, asimismo de anular la presente
Orden de Compra.""",p),
Paragraph("""El pago de toda factura se hará de acuerdo a las condiciones establecidas.""",p)
],bulletType='1'
)
datos_otros = [[hoja_afectacion,''],
[importante,recibido],
[lista,''],
['',firma],
['',nombre],
['',dni],
]
tabla_afectacion_presupuestal = Table(datos_otros,colWidths=[10 * cm, 10 * cm])
tabla_afectacion_presupuestal.setStyle(TableStyle(
[
('ALIGN',(0,1),(1,1),'CENTER'),
('SPAN',(0,2),(0,5)),
]
))
return tabla_afectacion_presupuestal
def detalle(self,pdf,y,orden):
encabezados = ('Item', 'Cantidad', 'Unidad', u'Descripción','Precio','Total')
try:
detalles = [(detalle.nro_detalle, detalle.cantidad, detalle.detalle_cotizacion.detalle_requerimiento.producto.unidad_medida.descripcion, detalle.detalle_cotizacion.detalle_requerimiento.producto.descripcion, detalle.precio,round(detalle.valor,5)) for detalle in DetalleOrdenCompra.objects.filter(orden=orden)]
except:
detalles = [(detalle.nro_detalle, detalle.cantidad, detalle.producto.unidad_medida.descripcion, detalle.producto.descripcion, detalle.precio, round(detalle.precio,5)) for detalle in DetalleOrdenCompra.objects.filter(orden=orden)]
adicionales = [('','','','','','')]*(15-len(detalles))
detalle_orden = Table([encabezados] + detalles + adicionales,colWidths=[0.8 * cm, 1.9 * cm, 2 * cm,9.3* cm, 2 * cm, 2.5 * cm])
detalle_orden.setStyle(TableStyle(
[
('ALIGN',(0,0),(5,0),'CENTER'),
('GRID', (0, 0), (-1, -1), 1, colors.black),
#('LINEBELOW', (0,1), (5,-1), 0, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
('ALIGN',(4,1),(-1,-1),'RIGHT'),
]
))
detalle_orden.wrapOn(pdf, 800, 600)
detalle_orden.drawOn(pdf, 40,y+75)
#Letras
total_letras = [("SON: "+orden.total_letras,'')]
tabla_total_letras = Table(total_letras,colWidths=[16 * cm, 2.5 * cm])
tabla_total_letras.setStyle(TableStyle(
[
('GRID', (0, 0), (1, 0), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
]
))
tabla_total_letras.wrapOn(pdf, 800, 600)
tabla_total_letras.drawOn(pdf, 40,y+55)
def otros(self,pdf,y,orden):
encabezados_otros = ('LUGAR DE ENTREGA', 'PLAZO DE ENTREGA', 'FORMA DE PAGO')
otros = [(EMPRESA.direccion(),u"INMEDIATA",orden.forma_pago.descripcion)]
tabla_otros = Table([encabezados_otros] + otros,colWidths=[6 * cm, 3.5 * cm, 4.5 * cm], rowHeights=[0.6 * cm, 1 * cm])
tabla_otros.setStyle(TableStyle(
[
('ALIGN',(0,0),(2,0),'CENTER'),
('GRID', (0, 0), (2, 1), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
]
))
tabla_otros.wrapOn(pdf, 800, 600)
tabla_otros.drawOn(pdf, 40,y+5)
def cuadro_total(self,pdf,y,orden):
pdf.drawString(445, y+40, u"SUB-TOTAL: ")
pdf.drawString(445, y+20, u"IGV: ")
pdf.drawString(445, y, u"TOTAL: S/")
total = [[round(orden.subtotal,2)],[round(orden.impuesto,2)],[round(orden.total,2)]]
tabla_total = Table(total,colWidths=[2.5 * cm])
tabla_total.setStyle(TableStyle(
[
('GRID', (0, 0), (0, 2), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
('ALIGN',(0,0),(-1,-1),'RIGHT'),
]
))
tabla_total.wrapOn(pdf, 800, 600)
tabla_total.drawOn(pdf, 495,y-2)
def cuadro_observaciones(self,pdf,y,orden):
p = ParagraphStyle('parrafos')
p.alignment = TA_JUSTIFY
p.fontSize = 10
p.fontName="Times-Roman"
obs=Paragraph("Observaciones: "+orden.observaciones,p)
observaciones = [[obs]]
tabla_observaciones = Table(observaciones,colWidths=[18.50 * cm], rowHeights=1.8 * cm)
tabla_observaciones.setStyle(TableStyle(
[
('GRID', (0, 0), (0, 2), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
('ALIGN',(0,0),(-1,-1),'LEFT'),
('VALIGN',(0,0),(-1,-1),'TOP'),
]
))
tabla_observaciones.wrapOn(pdf, 800, 600)
tabla_observaciones.drawOn(pdf, 40,y-58)
def otros(self,pdf,y,orden):
encabezados_otros = ('LUGAR DE ENTREGA', 'PLAZO DE ENTREGA', 'FORMA DE PAGO')
otros = [('',u" DÍAS","")]
tabla_otros = Table([encabezados_otros] + otros,colWidths=[6 * cm, 3.5 * cm, 4.5 * cm], rowHeights=[0.6 * cm, 1 * cm])
tabla_otros.setStyle(TableStyle(
[
('GRID', (0, 0), (2, 1), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
]
))
tabla_otros.wrapOn(pdf, 800, 600)
tabla_otros.drawOn(pdf, 40,y+5)
def cuadro_total(self,pdf,y,orden):
pdf.drawString(445, y+40, u"SUB-TOTAL: ")
pdf.drawString(445, y+20, u"IGV: ")
pdf.drawString(445, y, u"TOTAL: ")
total = [[orden.subtotal],[str(orden.impuesto)],[str(orden.total)]]
tabla_total = Table(total,colWidths=[2.5 * cm])
tabla_total.setStyle(TableStyle(
[
('GRID', (0, 0), (0, 2), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
('ALIGN',(0,0),(-1,-1),'RIGHT'),
]
))
tabla_total.wrapOn(pdf, 800, 600)
tabla_total.drawOn(pdf, 495,y-2)
def cabecera(self,pdf,cotizacion):
archivo_imagen = os.path.join(settings.MEDIA_ROOT,str(EMPRESA.logo))
pdf.drawImage(archivo_imagen, 20, 750, 120, 90,preserveAspectRatio=True)
pdf.setFont("Times-Roman", 14)
encabezado = [[u"SOLICITUD DE COTIZACIÓN"]]
tabla_encabezado = Table(encabezado,colWidths=[8 * cm])
tabla_encabezado.setStyle(TableStyle(
[
('ALIGN',(0,0),(0,0),'CENTER'),
('GRID', (0, 0), (1, 0), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 10),
]
))
tabla_encabezado.wrapOn(pdf, 800, 600)
tabla_encabezado.drawOn(pdf, 200,800)
pdf.drawString(270, 780, u"N°"+cotizacion.codigo)
pdf.setFont("Times-Roman", 10)
pdf.drawString(40, 750, u"SEÑOR(ES): "+cotizacion.proveedor.razon_social)
pdf.drawString(440, 750, u"R.U.C.: "+cotizacion.proveedor.ruc)
direccion = cotizacion.proveedor.direccion
if len(direccion)>60:
pdf.drawString(40,730,u"DIRECCIÓN: "+direccion[0:60])
pdf.drawString(105, 720,direccion[60:])
else:
pdf.drawString(40,730,u"DIRECCIÓN: "+direccion)
try:
pdf.drawString(440, 730, u"TELÉFONO: "+cotizacion.proveedor.telefono)
except:
pdf.drawString(440, 730, u"TELÉFONO: -")
pdf.drawString(40, 710, u"FECHA: "+cotizacion.fecha.strftime('%d/%m/%Y'))
def tabla_encabezado(self, styles):
movimiento = self.movimiento
sp = ParagraphStyle('parrafos',
alignment = TA_CENTER,
fontSize = 14,
fontName="Times-Roman")
try:
archivo_imagen = os.path.join(settings.MEDIA_ROOT,str(EMPRESA.logo))
imagen = Image(archivo_imagen, width=90, height=50,hAlign='LEFT')
except:
imagen = Paragraph(u"LOGO", sp)
if movimiento.tipo_movimiento.incrementa:
nota = Paragraph(u"NOTA DE INGRESO N°", sp)
else:
nota = Paragraph(u"NOTA DE SALIDA N°", sp)
id_movimiento = Paragraph(movimiento.id_movimiento, sp)
fecha = Paragraph("FECHA: "+movimiento.fecha_operacion.strftime('%d/%m/%y'), sp)
encabezado = [[imagen,nota,fecha],
['',id_movimiento,'']
]
tabla_encabezado = Table(encabezado,colWidths=[4 * cm, 9 * cm, 6 * cm])
tabla_encabezado.setStyle(TableStyle(
[
('VALIGN',(0,0),(2,0),'CENTER'),
('VALIGN',(1,1),(2,1),'TOP'),
('SPAN',(0,0),(0,1)),
]
))
return tabla_encabezado
def tabla_datos(self, styles):
movimiento = self.movimiento
izquierda = ParagraphStyle('parrafos',
alignment = TA_LEFT,
fontSize = 10,
fontName="Times-Roman")
try:
if movimiento.referencia.cotizacion is not None:
proveedor = Paragraph(u"PROVEEDOR: "+movimiento.referencia.cotizacion.proveedor.razon_social,izquierda)
else:
proveedor = Paragraph(u"PROVEEDOR: "+movimiento.referencia.proveedor.razon_social,izquierda)
except:
proveedor = Paragraph(u"PROVEEDOR:",izquierda)
operacion = Paragraph(u"OPERACIÓN: "+movimiento.tipo_movimiento.descripcion,izquierda)
almacen = Paragraph(u"ALMACÉN: "+movimiento.almacen.codigo+"-"+movimiento.almacen.descripcion,izquierda)
try:
orden_compra = Paragraph(u"ORDEN DE COMPRA: "+movimiento.referencia.codigo,izquierda)
except:
orden_compra = Paragraph(u"REFERENCIA: -",izquierda)
try:
documento = Paragraph(u"DOCUMENTO: "+movimiento.tipo_documento.descripcion + " SERIE:" + movimiento.serie + u" NÚMERO:" + movimiento.numero,
izquierda)
except:
documento = ""
try:
pedido = Paragraph(u"PEDIDO: "+movimiento.pedido.codigo, izquierda)
except:
pedido = ""
encabezado = [[operacion,''],
[almacen,''],
[proveedor,''],
[orden_compra,''],
[documento,''],
[pedido,'']]
tabla_datos = Table(encabezado,colWidths=[11 * cm, 9 * cm])
tabla_datos.setStyle(TableStyle(
[
]
))
return tabla_datos
def tabla_detalle(self):
movimiento = self.movimiento
encabezados = ['Item', 'Cantidad', 'Unidad', u'Descripción','Precio','Total']
detalles = DetalleMovimiento.objects.filter(movimiento=movimiento).order_by('pk')
sp = ParagraphStyle('parrafos')
sp.alignment = TA_JUSTIFY
sp.fontSize = 8
sp.fontName="Times-Roman"
lista_detalles = []
for detalle in detalles:
tupla_producto = [str(detalle.nro_detalle),
format(detalle.cantidad,'.5f'),
str(detalle.producto.unidad_medida.codigo),
detalle.producto.descripcion,
format(detalle.precio,'.5f'),
format(detalle.valor,'.5f')]
lista_detalles.append(tupla_producto)
adicionales = [('','','','','')] * (15-len(lista_detalles))
tabla_detalle = Table([encabezados] + lista_detalles,colWidths=[1.5 * cm, 2.5 * cm, 1.5 * cm,10* cm, 2 * cm, 2.5 * cm])
style = TableStyle(
[
('GRID', (0, 0), (-1, -1), 1, colors.black),
('FONTSIZE', (0, 0), (-1, -1), 8),
('ALIGN',(4,0),(-1,-1),'RIGHT'),
]
)
tabla_detalle.setStyle(style)
return tabla_detalle
def tabla_firmas(self):
movimiento = self.movimiento
izquierda = ParagraphStyle('parrafos',
alignment = TA_CENTER,
fontSize = 8,
fontName="Times-Roman")
nombre_oficina_administracion = Paragraph(OFICINA_ADMINISTRACION.nombre,izquierda)
nombre_oficina_logistica = Paragraph(LOGISTICA.nombre,izquierda)
if movimiento.tipo_movimiento.incrementa:
total = [[nombre_oficina_administracion,'', nombre_oficina_logistica]]
tabla_firmas = Table(total,colWidths=[7 * cm,4 * cm,7 * cm])
tabla_firmas.setStyle(TableStyle(
[
("LINEABOVE", (0,0), (0,0), 1, colors.black),
("LINEABOVE", (2,0), (2,0), 1, colors.black),
('VALIGN',(0,0),(-1,-1),'TOP'),
]
))
else:
solicitante = Paragraph('SOLICITANTE',izquierda)
total = [[nombre_oficina_administracion,'',nombre_oficina_logistica,'',solicitante]]
tabla_firmas = Table(total,colWidths=[5 * cm, 1 * cm, 5 * cm, 1 * cm, 5 * cm])
tabla_firmas.setStyle(TableStyle(
[
("LINEABOVE", (0,0), (0,0), 1, colors.black),
("LINEABOVE", (2,0), (2,0), 1, colors.black),
("LINEABOVE", (4,0), (4,0), 1, colors.black),
#("LINEABOVE", (2,0), (2,0), 1, colors.black),
('VALIGN',(0,0),(-1,-1),'TOP'),
]
))
return tabla_firmas
def _header_footer(self, canvas, doc):
canvas.saveState()
sp = ParagraphStyle('parrafos',
alignment=TA_CENTER,
fontSize=14,
fontName="Times-Roman")
try:
archivo_imagen = os.path.join(settings.MEDIA_ROOT, str(EMPRESA.logo))
imagen = Image(archivo_imagen, width=90, height=50, hAlign='LEFT')
except:
imagen = Paragraph(u"LOGO", sp)
ruc_empresa = "RUC: " + EMPRESA.ruc
if self.grupos:
titulo = Paragraph(u"RESUMEN MENSUAL DE ALMACÉN POR GRUPOS Y CUENTAS", sp)
else:
titulo = Paragraph(u"RESUMEN MENSUAL DE ALMACÉN", sp)
periodo = "PERIODO: " + self.desde.strftime('%d/%m/%Y') + ' - ' + self.hasta.strftime('%d/%m/%Y')
pagina = u"Página " + str(doc.page) + " de " + str(self.total_paginas)
encabezado = [[imagen, titulo, pagina],[ruc_empresa,periodo,""]]
tabla_encabezado = Table(encabezado, colWidths=[3 * cm, 20 * cm, 3 * cm])
style = TableStyle(
[
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
]
)
tabla_encabezado.setStyle(style)
tabla_encabezado.wrapOn(canvas, 50, 510)
tabla_encabezado.drawOn(canvas, 50, 510)
canvas.restoreState()
def _header(self, canvas, doc):
canvas.saveState()
sp = ParagraphStyle('parrafos',
alignment=TA_CENTER,
fontSize=14,
fontName="Times-Roman")
try:
archivo_imagen = os.path.join(settings.MEDIA_ROOT, str(EMPRESA.logo))
imagen = Image(archivo_imagen, width=90, height=50, hAlign='LEFT')
except:
imagen = Paragraph(u"LOGO", sp)
ruc_empresa = "RUC: " + EMPRESA.ruc
if self.valorizado:
titulo = Paragraph(u"REGISTRO DEL INVENTARIO PERMANENTE VALORIZADO", sp)
else:
titulo = Paragraph(u"REGISTRO DEL INVENTARIO PERMANENTE EN UNIDADES FÍSICAS",sp)
pagina = u"Página " + str(doc.page) + " de " + str(self.total_paginas)
encabezado = [[imagen, titulo, pagina], [ruc_empresa, "", ""]]
tabla_encabezado = Table(encabezado, colWidths=[3 * cm, 20 * cm, 3 * cm])
style = TableStyle(
[
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
]
)
tabla_encabezado.setStyle(style)
tabla_encabezado.wrapOn(canvas, 50, 510)
tabla_encabezado.drawOn(canvas, 50, 510)
canvas.restoreState()