Ejemplo n.º 1
0
    def resumir(self):
	vs=Ventas(self.parent,self.periodo)
	(lista,resumen)=vs.resumir(self.periodo,self.parent.caja)
	self.efectivo=resumen['efectivo']
	movimientos=libutil.listaHtml(lista,'Tabla de movimientos',['Concepto','Monto'],'#fff','#1162A7',14,anchos=[70,30])
	head="id_movimiento,usuarios.nombre,cajas.nombre,detalle,tipo, monto,fecha"
	lista=Movimiento(self.parent.conexion).buscar(head,self.periodo+" order by tipo")
	movs=libutil.listaHtml(lista,'Tabla de movimientos de efectivo',
	"#,Usuario,Caja,Detalle,Tipo, Monto,Fecha".split(','),'#fff','#1162A7',10,opc="110",anchos=[5,15,15,22,13,15,15])
	ventas=vs.detallarVentas(caja=self.parent.caja,color='#fff',fondo='#1162A7')
	#dns=vs.detalleNotas(periodo=self.periodo,caja=self.parent.caja)
	#ventas=libutil.listaHtml(dns,'Detalle de ventas',['Tipo','Estado','Valor'],'#fff','#1162A7',12,anchos=[40,30,30])
	tabla=libutil.listaHtml([[movimientos+ventas,movs]],color='#fff',fondo='#1162A7',opc="000",anchos=[40,60])
	self.resumen=tabla
	self.teResumen.setHtml(tabla)
Ejemplo n.º 2
0
    def detallar(self):
      	self.setCursor(QtGui.QCursor(3))
	ventas=RVentas(self.parent,self.periodo)
	(lista,resumen)=ventas.resumir(self.periodo,self.caja)
	movimientos=libutil.listaHtml(lista,'Entradas y salidas',['Concepto','Monto'],'#fff','#1162A7',14,anchos=[70,30])
	tventas=ventas.detallarVentas(caja=self.caja)+"<br/>"
	tcajas=ventas.detallarCajas(caja=self.caja)
	tusuarios=ventas.detallarUsuarios(caja=self.caja)
	tdeptos=ventas.detallarDeptos(caja=self.caja)
	tprods=ventas.detallarProds(caja=self.caja)
	tabla2=libutil.listaHtml([[tventas+tusuarios+tcajas,movimientos+tdeptos]],titulo="Resumen de movimientos",color='#fff',fondo='#1162A7',opc="000",anchos=[50,50])
	self.html=tabla2+tprods
	self.teResumen.setHtml(tabla2+tprods)	
	self.stackReportes.setCurrentIndex(2)
	self.setCursor(QtGui.QCursor(0))
Ejemplo n.º 3
0
 def imprimir(self):
     titulo = "Lista completa de faltantes del dia %s" % self.ui.deFFecha.date().toString("dd-MM-yyyy")
     html = libutil.listaHtml(
         self.modelo.getVector(),
         titulo,
         [[5, "Ref"], [5, "Cantidad"], [30, "Producto"], [15, "Prioridad"], [15, "Usuario"], [20, "Fecha"]],
         "#FFF",
         "#639639",
         10,
     )
     libutil.printa(html, titulo, self.ui)
Ejemplo n.º 4
0
  def aplicar(self):
    nuevos=int(float(self.dsbCant.value())*float(self.sub['prop']))
    tmp=float(self.dsbCant.value())*float(self.sub['prop'])
    viejos=int(self.dsbCant.value())-((tmp-int(tmp))*float(self.sub['cantidad']))
    if float(self.producto['stock_logico'])>=viejos:
	antes=libutil.listaHtml([
	[self.prod['descripcion'],self.prod['stock_logico']],
	[self.sub['descripcion'],self.sub['stock_logico']]
	], "Existencias antes.",[[80,"Producto"],[20,"Existencias"]])

	despues=libutil.listaHtml([
	  [self.prod['descripcion'],self.prod['stock_logico']-viejos],
	  [self.sub['descripcion'],float(self.sub['stock_logico'])+(nuevos)]
	  ], "Existencias despues.",[[80,"Producto"],[20,"Existencias"]])
	  
	tabla=libutil.listaHtml([antes,despues],"Tabla comparativa",[],'#fff',"#239AB1", tfuente=10,opc="100")
	self.lbResulta.setText(str(self.lbResulta.text())%(viejos,self.prod['descripcion'],nuevos,self.sub['descripcion'],antes,despues))
	self.stack.setCurrentIndex(1)
    else:
      em=QtGui.QErrorMessage(self)
      em.showMessage( "No hay suficientes unidades, hay %s unidades se requieren %s"%(float(self.producto['stock_logico']),viejos))
      print "No hay suficientes unidades ",float(self.producto['stock_logico']),viejos
Ejemplo n.º 5
0
    def detallarEntradas(self):
	self.setCursor(QtGui.QCursor(3))
	ventas=Ventas(self.parent,self.periodo)
	tventas=ventas.detallarVentas(caja=self.parent.caja)+"<br/>"
	tcajas=ventas.detallarCajas()
	tusuarios=ventas.detallarUsuarios()
	tdeptos=ventas.detallarDeptos()
	tprods=ventas.detallarProds()
	tabla2=libutil.listaHtml([[tventas+tusuarios+tcajas,tdeptos]],titulo="Resumen de movimientos",opc="000",anchos=[40,60])
	self.teEntradasDetalle.setText(tabla2+tprods)	
	self.detalle=tabla2+tprods
	self.stack.setCurrentIndex(1)
	self.setCursor(QtGui.QCursor(0))
Ejemplo n.º 6
0
    def resumir(self,fecha='curdate()'):
	resumen={'ventas':0,'gastos':0,'compras':0, 'inicial':0.0}
	self.cursor.execute("select  IFNULL(ROUND(sum(total),2),0) from notas where date(fecha)="+fecha)
	resumen['ventas']=self.cursor.fetchone()[0]
	self.cursor.execute("select  IFNULL(ROUND(sum(cantidad),2),0) from gastos where date(fecha)="+fecha)
	resumen['gastos']=self.cursor.fetchone()[0]
	self.cursor.execute("select  IFNULL(ROUND(sum(total),2),0) from compras where date(fecha)="+fecha)
	resumen['compras']=self.cursor.fetchone()[0]
	self.cursor.execute("SELECT saldo_inicial from cajas where num_caja=%s and estado=curdate();"%self.parent.caja)
	res=self.cursor.fetchone()
	if res!=None:
	  resumen['inicial']=res[0]	
	#self.cursor.execute("select  IFNULL(inicial,0) from ventas where fecha=curdate() ")
	#row=self.cursor.fetchone()
	#if row!=None:
	  #resumen['inicial']=row[0]
	#else:
	  #resumen['inicial']=0  
	#tabla='<H2>Tabla de movimientos de dinero </H2>\
#<table cellspacing="6px" width="100%%">\
#<TR> <Th align=\"left\">Concepto</Th><TH>Cantidad</TH></TR>\
#<tr> <TD >Ventas:</TD><TD  align=\"right\" >%s		</TD></tr>\
#<tr> <TD>Compras:</TD><TD  align=\"right\" style="color:#F00">%s		</TD></tr>\
#<tr> <TD>Gastos:</TD><TD  align=\"right\" style="color:#F00">%s		</TD></tr>\
#<tr> <TD>Efectivo inicial:</TD><TD  align=\"right\">%s		</TD></tr>\
#<tr> <TD>Efectivo final:</TD><TD  align=\"right\" style="color:#000;font-weight:800;font-size:16px">%s		</TD></tr>\
#</table>'%(resumen['ventas'],resumen['compras'],resumen['gastos'],resumen['inicial'],(resumen['ventas']-resumen['compras']-resumen['gastos']+resumen['inicial']))
	self.efectivo=(resumen['ventas']-resumen['compras']-resumen['gastos']+resumen['inicial'])

	lista=[
	  ['Ventas:',resumen['ventas']],
	  ['Compras:',resumen['compras']],
	  ['Gastos:',resumen['gastos']],
	  ['Efectivo inicial:',resumen['inicial']],
	  ['Efectivo final:',self.efectivo]
	  ]
	tabla=libutil.listaHtml(lista,'Tabla de movimientos de dinero',[[48,'Concepto'],[48,'Monto']],'#333','#E2E6E7',14)
	return tabla
Ejemplo n.º 7
0
    def iniciar(self):
      if self.cargarPlantilla():
	iva=0
	subtotal=0
	total=0
	alto=int(self.cfg.get("documento", "alto"))
	ancho=int(self.cfg.get("documento", "ancho"))
	cfont=QFont("Droid Sans", int(self.cfg.get("cliente", "fuente")), int(self.cfg.get("cliente", "peso") ))
	pfont=QFont("Droid Sans", int(self.cfg.get("productos", "fuente")), int(self.cfg.get("productos", "peso") ))
	ffont=QFont("Droid Sans", int(self.cfg.get("fecha", "fuente")), int(self.cfg.get("fecha", "peso") ))
	tfont=QFont("Droid Sans", int(self.cfg.get("totales", "fuente")), int(self.cfg.get("totales", "peso") ))
	self.escena.setSceneRect(-int(self.cfg.get("documento", "x")),-int(self.cfg.get("documento", "y")),ancho,alto)
	fuente=QFont("Droid Sans", int(self.cfg.get("documento", "fuente")), int(self.cfg.get("documento", "peso") ))
	smallDroid=QFont("Droid Sans", 9)
	sql="""SELECT * FROM clientes as C, notas WHERE notas.id=%s and notas.cliente=C.id;"""%self.num
	self.curser.execute(sql)
	cliente=self.curser.fetchone()
	if cliente!=None:
	  cliente=dicursor(self.curser,cliente)
	datos=self.escena.addText("",cfont)
	datos.setHtml("<p><b>Nombre:</b> %s<br><b>Direccion:</b>  %s, C.P %s %s, %s.<br><b>RFC:</b>  %s</p>"%(cliente['nombre'],cliente['direccion'],cliente['correo'],cliente['poblacion'],cliente['estado'],cliente['rfc']))
	datos.setPos(int(self.cfg.get("cliente", "x")) ,int(self.cfg.get("cliente", "y")))
	datos.setTextWidth(int(self.cfg.get("cliente", "ancho")))
	self.curser.execute("SELECT cantidad, `descripcion`,total/cantidad as precio,total,porcentaje as imp,unidades.nombre as unidad, ' ' as espacio  from productos,vendidos, impuestos , unidades where ref=producto and venta="+str(self.num)+" and impuestos.id=impuesto and unidades.id=unidad group by ref")
	fecha=self.escena.addText("",ffont)
	if isinstance(cliente['fecha'],datetime.datetime):
	  fecha.setHtml(cliente['fecha'].strftime(self.cfg.get("fecha", "formato")))
	else:
	  fecha.setHtml(datetime.datetime.strptime(cliente['fecha'],'%Y-%m-%d %H:%M:%S').strftime(self.cfg.get("fecha", "formato")))
	fecha.setPos(int(self.cfg.get("fecha", "x")),int(self.cfg.get("fecha", "y")))
	fecha.setTextWidth(int(self.cfg.get("fecha", "ancho")))
	#print "SELECT cantidad, `descripcion`,precio,total from productos,vendidos where ref=producto and venta="+str(self.num)+" group by ref"
	arts=self.curser.fetchall()
	if arts!=None:
	  arts=dicursor(self.curser,arts)
	  col=[[],[],[],[],[]]
	  #dict(arts)
	  for item in arts:
	    imp=0;porc=0
	    imp=item['total']/float("1.%d"%item['imp'])
	    porc=imp*(int(item['imp'])*.01)
	    #imp=round(imp,2)
	    #porc=round(porc,2)
	    #porc+=item['total']-(imp+porc)
	    total+=item['total']
	    item['precio']=round(imp/item['cantidad'],2)
	    item['total']=round(imp,2) 
	    iva+=porc
	    subtotal+=imp
	  subtotal=round(subtotal,2)
	  iva=round(iva,2)
	  filas=[]
	  campos=self.cfg.get("productos", "campos").replace(" ","").split(",")
	  heads="{%s}"%"},{".join(campos)
	  anchos=self.cfg.get("productos", "anchos").replace(" ","").split(",")
	  #cabezas=heads.replace("{","").replace("}","").split(",")
	  for item in arts:
	      row=heads.format(**item)
	      filas.append(row.split(','))

	  heads=heads.replace("{","").replace("}","") 
	  tabla=self.escena.addText("",pfont)
	  tabla.setHtml(listaHtml(filas,cabezas=campos,color='#fff',fondo="#FFF", tfuente=11,opc="101",css="th{color:#FFF} .celda{margin:10px;padding:5px;}",anchos=anchos))
	  tabla.setPos(int(self.cfg.get("productos", "x")),int(self.cfg.get("productos", "y")))
	  tabla.setTextWidth(int(self.cfg.get("productos", "ancho")))

	cantidad=self.escena.addText("",pfont)
	cantidad.setHtml("<center>%s</center>"%nletra(total))
	cantidad.setPos(int(self.cfg.get("nletra", "x")),int(self.cfg.get("nletra", "y")))
	cantidad.setTextWidth(int(self.cfg.get("nletra", "ancho")))
	totales=self.escena.addText("",tfont)
	totales.setHtml("<p ALIGN=right>%.2f</p><p ALIGN=right>%.2f</p><p ALIGN=right>%.2f</p>"%(float(subtotal),float(iva),float(total)))
	totales.setPos(int(self.cfg.get("totales", "x")),int(self.cfg.get("totales", "y")))
	totales.setTextWidth(int(self.cfg.get("totales", "ancho")))
	#self.curser.execute("SELECT cantidad, `descripcion`,precio,total from productos,vendidos where ref=producto and venta="+str(self.num)+" group by ref")
	
	self.gvDocumento.setScene(self.escena)
      else:
	print "Error al cargar plantilla"
Ejemplo n.º 8
0
    def detallarEntradas(self):
        self.setCursor(QtGui.QCursor(3))

        # ventas={'realizadas':[],'cobradas':[],'facturas':[],'notas':[],'efectivo':[],'credito':[]}
        # self.cursor.execute("select count(id), ROUND(sum(total),2) from notas where "+self.periodo+" ")
        # row=self.cursor.fetchone()
        # ventas['realizadas']=row
        # self.cursor.execute("select count(id), ROUND(sum(total),2) from notas where "+self.periodo+"  and status>0 ")
        # row=self.cursor.fetchone()
        # ventas['cobradas']=row
        # self.cursor.execute("select count(id), ROUND(sum(total),2) from notas where "+self.periodo+"  and tipo=1 ")
        # row=self.cursor.fetchone()
        # ventas['facturas']=row
        # self.cursor.execute("select count(id), ROUND(sum(total),2) from notas where "+self.periodo+"  and tipo=0 ")
        # row=self.cursor.fetchone()
        # ventas['notas']=row
        # self.cursor.execute("select count(id), ROUND(sum(total),2) from notas where "+self.periodo+"  and status=1 ")
        # row=self.cursor.fetchone()
        # ventas['efectivo']=row
        # self.cursor.execute("select count(id), ROUND(sum(total),2) from notas where "+self.periodo+" and status=2 ")
        # row=self.cursor.fetchone()
        # ventas['credito']=row
        # tabla='<h2>Tabla general de ventas</h2>\
        # <table cellspacing="6px" width="100%%">\
        # <TR> <Th>Concepto</Th><TH>Cantidad</TH><th>Valor</th>	</TR>\
        # <tr> <TD>Ventas realizadas</TD>	<TD >%s		</TD>       <TD >		%s</TD>      </tr>\
        # <tr> <TD>Ventas cobradas</TD>	<TD >%s		</TD>       <TD	>		%s</TD>      </tr>\
        # <tr> <TD>En efectivo</TD>	<TD >%s		</TD>       <TD >		%s</TD>      </tr>\
        # <tr> <TD>En credito</TD>	<TD >%s		</TD>       <TD >		%s</TD>      </tr>\
        # </table>'%(ventas['realizadas'][0],ventas['realizadas'][1],ventas['cobradas'][0],ventas['cobradas'][1],ventas['efectivo'][0],ventas['efectivo'][1],ventas['credito'][0],ventas['credito'][1])
        # self.teDetalles.setText(tabla)
        # rows=""
        # 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;")
        # ventas=self.cursor.fetchall()

        # for v in ventas:
        # rows+='<tr> <TD>%s</TD>	<TD >%s	</TD>       <TD >	%s</TD>      </tr>'%v;
        # tabla+='<h2>Tabla de ventas por usuario</h2><table cellspacing="6px" width="100%%"><TR> <Th>Usuario</Th><TH>Num. ventas</TH><th>Cantidad cobrada</th></TR>%s</table>'%rows;
        # self.teDetalles.setText(tabla)
        ##TABLA DE VENTAS POR DEP
        # 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;")
        # ventas=self.cursor.fetchall()
        # rows=""
        # for v in ventas:
        # rows+='<tr> <TD>%s</TD>	<TD >%s	</TD>       <TD >	%s</TD>      </tr>'%v;
        # tabla+='<H2>Tabla de ventas por departamento</H2><table cellspacing="6px" width="100%%"><TR> <Th>Departamento</Th><TH>Num. ventas</TH><th>Cantidad cobrada</th></TR>%s</table>'%rows;
        ventas = Ventas(self.parent, self.periodo)
        tab = ventas.detallarVentas()
        tab += "<br/>%s" % ventas.detallarCajas()
        tabu = ventas.detallarUsuarios()
        tab += "<br/>%s" % ventas.detallarDeptos()
        tabu += "<br/>%s" % ventas.detallarProds()
        # tabla=tab
        tabla2 = libutil.listaHtml(
            [[tab, tabu]],
            "Detalle de ventas </span><br/><span>En el periodo del %s al %s <br/> "
            % (
                self.deDesde.date().toString("(dd 'de' MMM 'del' yyyy)"),
                self.deHasta.date().toString("(dd 'de' MMM 'del' yyyy)"),
            ),
            [[50, "Departamento"], [50, "Ventas realizadas"]],
            "#1A4F67",
            "#eee",
            14,
            "100",
            "#totaldeventas > tr.odd{ background:rgba(0,0,0,0); }",
        )
        # print tabu

        # tabla2+="<br/><img src='/tmp/grafica.png'/>"
        self.teEntradasDetalle.setText(tabla2)
        self.stack.setCurrentIndex(2)
        self.setCursor(QtGui.QCursor(0))
Ejemplo n.º 9
0
 def imprimir(self):
   titulo="Lista completa de faltantes %s"%self.ui.deFFecha.date().toString('MMM dd')
   html=libutil.listaHtml(self.modelo.getVector(),titulo, ['Ref','Cantidad','Producto','Prioridad','Usuario','Fecha'],'#FFF',"#639639",10,anchos=[5,5,30,15,15,25,20])
   libutil.printa(html,titulo,self.ui)
Ejemplo n.º 10
0
 def printInc(self):
   html=libutil.listaHtml(self.incos,"Inconsistencias", ['Ref','Descripcion','Falte/Sobrante','Costo','Monto'],anchos=[10,40,15,15,20])
   libutil.printa(html,"Inconsistencias",self)
Ejemplo n.º 11
0
 def printInc(self):
   titulo="Inconsistencias del inventario %s"%libutil.seleccionar(self.ui.tblInventario, self.modelo)[0]
   html=libutil.listaHtml(self.incos,titulo, cabezas=['Ref','Descripcion','Falte/Sobrante','Costo','Monto'],anchos=[10,40,15,15,20])
   libutil.printa(html,titulo,self.ui)
Ejemplo n.º 12
0
    def resumir(self,fecha='CURDATE()'):
	rvs=RVentas(self.parent,fecha)
	(lista,resumen)=rvs.resumir("date(fecha)={0}".format(fecha),self.caja)
	self.efectivo=resumen['efectivo']
	tabla=libutil.listaHtml(lista,'Tabla de movimientos de dinero',['Concepto','Monto'],'#333','#E2E6E7',14,anchos=[70,30])
	return tabla