Exemple #1
0
    def detallarVentas(self,caja='1',color="#fff",fondo="#1162A7"):
      self.cursor.execute("SELECT ROUND(sum(total),2) from notas where {periodo} and {caja}  ".format(periodo=self.periodo,caja=caja))
      rows=self.cursor.fetchone()
      total=rows[0]
      if total==None:
	  total=0
      dns=self.detalleNotas(periodo=self.periodo,caja=caja)
      ventas=libutil.listaHtml(dns,'Detalle de ventas',['Tipo','Estado','Valor'],color,fondo,12,anchos=[40,30,30])	
      tabla=libutil.listaHtml([],"",['SUMA TOTAL:','$ {0:,.2f}'.format(total)],opc="010",anchos=[70,30])
      return ventas+"\n\n"+tabla
Exemple #2
0
 def detallarProdsVendidos(self,limit=20):
   periodo=self.periodo.replace("fecha", "n.fecha")
   self.cursor.execute("select DISTINCT descripcion,count(n.id),ROUND(sum(v.cantidad),2),u.nombre, ROUND(sum(v.total),2), stock_logico, ROUND(stock_logico-sum(v.cantidad),2)  from productos as p, notas as n, vendidos as v, existencia as e, unidades as u where %s  and v.venta=n.id and p.ref=v.producto and e.producto=ref and u.id=unidad group by ref order by count(n.id) desc limit %s;"%(periodo,limit))
   rows=self.cursor.fetchall()
   self.ventas['prods']=list([list(a) for a in rows])
   tabla=libutil.listaHtml(self.ventas['prods'],"Total de ventas por mejores productos",[[40,'Producto'],[10,'Ventas realizadas'],[10,'U. Vendidas'],[10,'Unidad'], [10,'Monto total'],[10,'Stock <br/>actual'],[10,'Requeridas']],'#fff',"#239AB1", 12) 
   return tabla      
Exemple #3
0
 def detallarDeptos(self):
   periodo=self.periodo.replace("fecha", "n.fecha")
   self.cursor.execute("select DISTINCT d.nombre,count(n.id),ROUND(sum(v.total),2) from productos as p, notas as n, vendidos as v, familias as f, departamentos as d where "+periodo+"  and v.venta=n.id and p.ref=v.producto and f.id=p.familia  and d.id=f.departamento  group by d.id order by ROUND(sum(v.total),2) desc;")
   rows=self.cursor.fetchall()
   self.ventas['deptos']=list([list(a) for a in rows])
   tabla=libutil.listaHtml(self.ventas['deptos'],"Total de ventas por departamento",[[50,'Departamento'],[20,'Ventas realizadas'], [30,'Monto total']]) 
   return tabla
Exemple #4
0
 def detallarProdsVendidos(self,caja='1',limit=20):
   periodo=self.periodo.replace("fecha", "n.fecha")
   self.cursor.execute("select DISTINCT descripcion,count(n.id), ROUND(sum(v.total),2),ROUND(sum(v.cantidad),2),u.nombre, stock_logico, ROUND(stock_logico-sum(v.cantidad),2)  from productos as p, notas as n, vendidos as v, existencia as e, unidades as u where {periodo} and {caja}  and v.venta=n.id and p.ref=v.producto and e.producto=ref and u.id=unidad group by ref order by count(n.id) desc limit {limit};".format(periodo=periodo,caja=caja,limit=limit))
   rows=self.cursor.fetchall()
   self.ventas['prods']=list([list(a) for a in rows])
   tabla=libutil.listaHtml(self.ventas['prods'],"Mejores productos vendidos",['Producto','# Ventas','Monto total','U. Vendidas','Unidad','Stock <br/>actual','Requeridas'],'#fff',"#239AB1", 12,anchos=[35,10,15,10,10,10,10]) 
   return tabla      
Exemple #5
0
 def detallarDeptos(self,caja='1'):
   periodo=self.periodo.replace("fecha", "n.fecha")
   self.cursor.execute("select DISTINCT d.nombre,count(n.id),ROUND(sum(v.total),2) from productos as p, notas as n, vendidos as v, familias as f, departamentos as d where {periodo}  and v.venta=n.id and p.ref=v.producto and f.id=p.familia  and d.id=f.departamento and {caja} group by d.id order by ROUND(sum(v.total),2) desc;".format(periodo=periodo,caja=caja))
   rows=self.cursor.fetchall()
   self.ventas['deptos']=list([list(a) for a in rows])
   tabla=libutil.listaHtml(self.ventas['deptos'],"Total de ventas por departamento",['Departamento','#','Valor total'],anchos=[50,50]) 
   return tabla
Exemple #6
0
 def detallarVentas(self):
   self.cursor.execute("SELECT ELT(tipo+1,'Notas','Facturas'), count(id), ROUND(sum(total),2) from notas where "+self.periodo+" and status>0  group by tipo ")
   rows=self.cursor.fetchall()
   self.ventas['general']=list([list(a) for a in rows])
   tabla=libutil.listaHtml(self.ventas['general'],"Ventas cobradas",[[50,'Tipo'],[20,'Ventas realizadas'], [30,'Monto']])
   return tabla
Exemple #7
0
 def detallarUsuarios(self):
   self.cursor.execute("select nombre,count(N.id), ROUND(sum(total),2) from notas as N, usuarios as U where "+self.periodo+" and status=1 and N.usuario=U.id_usuario group by N.usuario order by ROUND(sum(total),2) desc;")
   rows=self.cursor.fetchall()
   self.ventas['usuarios']=list([list(a) for a in rows])
   tabla=libutil.listaHtml(self.ventas['usuarios'],"Total de ventas por usuarios",[[50,'Usuario'],[20,'Ventas realizadas'], [30,'Monto total']]) 
   return tabla
Exemple #8
0
 def detallarCajas(self):
   self.cursor.execute("SELECT nombre,ELT(tipo+1,'Notas','Facturas'), count(id), ROUND(sum(total),2) from notas,cajas where %s and num_caja=caja group by tipo,caja order by caja;"%self.periodo)
   rows=self.cursor.fetchall()
   self.ventas['general']=list([list(a) for a in rows])
   tabla=libutil.listaHtml(self.ventas['general'],"Ventas cobradas por cajas",[[40,'Caja'],[20,'Tipo'],[20,'Ventas realizadas'], [20,'Monto']])
   return tabla
Exemple #9
0
 def detallarUsuarios(self,caja='1'):
   self.cursor.execute("select nombre,count(N.id), ROUND(sum(total),2) from notas as N, usuarios as U where {periodo} and status=1 and N.usuario=U.id_usuario and {caja} group by N.usuario order by ROUND(sum(total),2) desc;".format(periodo=self.periodo,caja=caja))
   rows=self.cursor.fetchall()
   self.ventas['usuarios']=list([list(a) for a in rows])
   tabla=libutil.listaHtml(self.ventas['usuarios'],"Total de ventas por usuarios",['Usuario','#','Valor total'],anchos=[60,10,30]) 
   return tabla
Exemple #10
0
 def detallarCajas(self,caja='1'):
   self.cursor.execute("SELECT nombre, ELT(tipo+1,'Nota','Factura') , count(id), ROUND(sum(total),2) from notas,cajas where {periodo} and {caja} and status>0 and num_caja=caja group by tipo,caja order by caja;".format(periodo=self.periodo,caja=caja))
   rows=self.cursor.fetchall()
   self.ventas['general']=list([list(a) for a in rows])
   tabla=libutil.listaHtml(self.ventas['general'],"Ventas cobradas por cajas",['Caja','Tipo','#','Valor'],anchos=[40,20,20,20])
   return tabla
Exemple #11
0
 def imprimir(self):
     vector=self.modelo.getVector()
     #head=[[len(row),row] for row in self.header]
     tabla=libutil.listaHtml(vector,self.consulta['descripcion'],self.header,'#001931',"#eee", 10) 
     libutil.printa(tabla,"%s %s-%s"%(self.consulta['titulo'],self.deDesde.date().toString('dd.MMM.yy'),self.deHasta.date().toString('dd.MMM.yy')))