FoxPro/Visual FoxPro - MOSTRAR ULTIMO MOVIMIENTO DE PRODUCTO EN INVENTARIO

 
Vista:
Imágen de perfil de Helder

MOSTRAR ULTIMO MOVIMIENTO DE PRODUCTO EN INVENTARIO

Publicado por Helder (37 intervenciones) el 24/09/2016 18:05:13
HOLA A TODOS.

EN UN REPORTE DE INVENTARIO, QUIERO MOSTRAR EL ULTIMO MOVIMIENTO DE UN PRODUCTO, SI SE FIJAN EN LA IMAGEN HAY DOS PRODUCTOS LLAMADOS NEODIP y COMPU01, ESOS PRODUCTO TIENEN VARIOS MOVIMIENTOS CON FECHAS DISTINTAS, EL REPORTE LO ESTOY HACIENDO CON FECHAS DE JUNIO A SEPTIEMBRE.


QUE ES LO QUE DESEO?

QUIERO SOLAMENTE VER EL ULTIMO MOVIMIENTO DE ESOS PRODUCTOS LLAMADOS NEODIP Y COMPU01, EL ULTIMO MOVIMIENTO SERIA EL QUE ESTA EN COLOR VERDE DE LA IMAGEN, YA QUE ESE ULTIMO TIENE LA CANTIDAD EXISTENTE ACTUAL PARA CADA UNO. LO IDEAL QUE NO ME MUESTRE LOS MOVIMIENTOS QUE ESTAN EN ROJO, SOLO EL VERDE.

***NOTA**
ESTO SERIA PARA MUCHOS PRODUCTOS QUE PUEDEN TENER VARIOS MOVIMIENTOS EN LA TABLA, PERO SOLO LES MUESTRO ESTOS 2 COMO EJEMPLO.

************ESTE ES EL CODIGO:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
SELECT inventario_mov.fecha_inv,;
	inventario_mov.id,;
	inventario_mov.codigo,;
	inventario_mov.producto,;
	inventario_mov.precio_costo,;
	precio_costo * existencia as _total_precio_costo,;
	inventario_mov.precio_venta,;
	precio_venta * existencia as _total_precio_venta,;
	inventario_mov.existencia,;
	inventario_mov.impuesto,;
	inventario_mov.fecha_venc,;
	inventario_mov.categoria,;
	inventario_mov.usuario_agr,;
	inventario_mov.usuario_mod,;
	inventario_mov.fecha_mod;
FROM inventario_mov;
WHERE TTOD(inventario_mov.fecha_inv) >= dFecIni AND;
	  TTOD(inventario_mov.fecha_inv) <= dFecFin;
GROUP BY inventario_mov.fecha_inv,;
			inventario_mov.id,;
	inventario_mov.codigo,;
	inventario_mov.producto,;
	inventario_mov.precio_costo,;
	inventario_mov.precio_venta,;
	inventario_mov.existencia,;
	inventario_mov.impuesto,;
	inventario_mov.fecha_venc,;
	inventario_mov.categoria,;
	inventario_mov.usuario_agr,;
	inventario_mov.usuario_mod,;
	inventario_mov.fecha_mod;
INTO CURSOR _inventario_geneneral




***SALUDOS CORDIALES Y GRACIAS.
reporte_inventario
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Mauricio Antonio
Val: 471
Plata
Ha mantenido su posición en FoxPro/Visual FoxPro (en relación al último mes)
Gráfica de FoxPro/Visual FoxPro

MOSTRAR ULTIMO MOVIMIENTO DE PRODUCTO EN INVENTARIO

Publicado por Mauricio Antonio (1541 intervenciones) el 24/09/2016 19:20:37
Helder, solo agrega en el SELECT un campo: MAX(inventario_mov.fecha_inv) AS fecha.
Con esto, te saldran los ultimos movimientos. Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Helder

MOSTRAR ULTIMO MOVIMIENTO DE PRODUCTO EN INVENTARIO

Publicado por Helder (37 intervenciones) el 24/09/2016 19:56:38
SI MAURICIO, LO QUE QUIERO ES QUE SOLO ME APAREZCA UN SOLO MOVIMIENTO POR PRODUCTO. NO SE SI ME ENTIENES.

SALUDOS,
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Helder

MOSTRAR ULTIMO MOVIMIENTO DE PRODUCTO EN INVENTARIO

Publicado por Helder (37 intervenciones) el 24/09/2016 20:53:03
MAURICIO SI TE FIJAS HAGO LO QUE ME DECIS PERO ME MUESTRA LOS MISMOS RESULTADOS;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
SELECT MAX(inventario_mov.fecha_inv) as fecha_inv,;
   inventario_mov.id,;
   inventario_mov.codigo,;
	inventario_mov.producto,;
	inventario_mov.precio_costo,;
	precio_costo * existencia as _total_precio_costo,;
	inventario_mov.precio_venta,;
	precio_venta * existencia as _total_precio_venta,;
	inventario_mov.existencia,;
	inventario_mov.impuesto,;
	inventario_mov.fecha_venc,;
	inventario_mov.categoria,;
	inventario_mov.usuario_agr,;
	inventario_mov.usuario_mod,;
	inventario_mov.fecha_mod;
FROM inventario_mov;
WHERE TTOD(inventario_mov.fecha_inv) >= dFecIni AND;
	  TTOD(inventario_mov.fecha_inv) <= dFecFin;
GROUP BY inventario_mov.fecha_inv,;
	inventario_mov.id,;
	inventario_mov.codigo,;
	inventario_mov.producto,;
	inventario_mov.precio_costo,;
	inventario_mov.precio_venta,;
	inventario_mov.existencia,;
	inventario_mov.impuesto,;
	inventario_mov.fecha_venc,;
	inventario_mov.categoria,;
	inventario_mov.usuario_agr,;
	inventario_mov.usuario_mod,;
	inventario_mov.fecha_mod;
INTO CURSOR _inventario_geneneral
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 59
Ha disminuido 1 puesto en FoxPro/Visual FoxPro (en relación al último mes)
Gráfica de FoxPro/Visual FoxPro

MOSTRAR ULTIMO MOVIMIENTO DE PRODUCTO EN INVENTARIO

Publicado por Juan R. (114 intervenciones) el 25/09/2016 00:59:29
Buenas Helder

Que me corrija alguien si me equivoco, pero el problema lo tienes en el GROUP BY, estás agrupando por todos los campos, tendrías que agrupar únicamente por el campo mov.id. Has probado a sólo agrupar por este campo?

Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de HelderC

MOSTRAR ULTIMO MOVIMIENTO DE PRODUCTO EN INVENTARIO

Publicado por HelderC (37 intervenciones) el 25/09/2016 01:46:55
Gracias Juan voy a probar. Te aviso.

Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Helder

MOSTRAR ULTIMO MOVIMIENTO DE PRODUCTO EN INVENTARIO

Publicado por Helder (37 intervenciones) el 26/09/2016 21:13:13
Hola a todos, lo logres hacer, Pero tengo otra consulta, esta consulta me muestra los productos que han tenido movimientos en el mes, ahora quiero mostrar en otra consulta los productos que no tuvieron movimiento, osea que no me muestre los productos capturados en la consulta anterior, que sean lo contrario, sin importar la fecha, lo estoy haciendo de esta forma pero siempre aparecen registros productos de la consulta anterior, LES DETALLO LAS DOS CONSULTAS, LA CONSULTA 1 ESTA CORRECTA;


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
**CONSULTA 1
SELECT 	inventario_mov.codigo,;
		inventario_mov.producto,;
		inventario_mov.fecha_inv,;
		inventario_mov.id,;
		inventario_mov.precio_costo,;
		precio_costo * existencia as _total_precio_costo,;
		inventario_mov.precio_venta,;
		precio_venta * existencia as _total_precio_venta,;
		inventario_mov.existencia,;
		inventario_mov.impuesto,;
		inventario_mov.fecha_venc,;
		inventario_mov.categoria,;
		inventario_mov.usuario_agr,;
		inventario_mov.usuario_mod,;
		inventario_mov.fecha_mod;
FROM inventario_mov;
INNER JOIN (select codigo as codigo1, MAX(id) as id1 FROM inventario_mov;
WHERE BETWEEN(TTOD(fecha_inv), dFecIni, dFecFin) GROUP BY codigo);
um ON inventario_mov.codigo = um.codigo1 AND inventario_mov.id = um.id1 ;
GROUP BY inventario_mov.fecha_inv,;
		inventario_mov.id,;
		inventario_mov.codigo,;
		inventario_mov.producto,;
		inventario_mov.precio_costo,;
		inventario_mov.precio_venta,;
		inventario_mov.existencia,;
		inventario_mov.impuesto,;
		inventario_mov.fecha_venc,;
		inventario_mov.categoria,;
		inventario_mov.usuario_agr,;
		inventario_mov.usuario_mod,;
		inventario_mov.fecha_mod;
HAVING fecha_inv = MAX(fecha_inv)	;
INTO CURSOR _inventario_geneneral
SELECT _inventario_geneneral
BROWSE
 
*CONSULTA 2
SELECT _inventario_geneneral
GO TOP
SCAN
	SELECT *;
	FROM inventario_mov;
	WHERE inventario_mov.id <> _inventario_geneneral.id;
	INTO CURSOR _inventario_geneneral1
ENDSCAN
SELECT _inventario_geneneral1
BROWSE
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar