727 lines
26 KiB
Plaintext
727 lines
26 KiB
Plaintext
{
|
|
-------------------------------------------------------------------------------
|
|
PROGRAMA : VEPRRP015
|
|
OBJETIVO : Relacion de Ventas Brutas y Reales.
|
|
PROGRAMADOR : Ing. Juan Soto (Johnny)
|
|
FECHA REALIZACION : Agosto 28, 1997
|
|
-------------------------------------------------------------------------------
|
|
}
|
|
GLOBALS "veprgb000.4gl"
|
|
DEFINE act,mes_ini INTEGER ,
|
|
fecha_inicial,fecha_final DATE
|
|
MAIN
|
|
DEFER INTERRUPT
|
|
CALL ARG_VAL(1) RETURNING usuarios
|
|
CALL ARG_VAL(2) RETURNING clave
|
|
CALL ARG_VAL(3) RETURNING impresor
|
|
|
|
CONNECT TO "decomarmol" USER usuarios USING clave
|
|
SELECT * INTO p_companias.* FROM companias
|
|
CALL veprrp015()
|
|
|
|
END MAIN
|
|
|
|
FUNCTION veprrp015()
|
|
|
|
DEFINE handler om.SaxDocumentHandler, -- return value from fgl_report_commitCurrentSettings()
|
|
r_filename STRING, -- filename of Report Design Document including .4rp extension
|
|
r_output STRING, -- output format option
|
|
preview INTEGER -- TRUE/FALSE, to set preview option
|
|
DEFINE historico CHAR(2)
|
|
|
|
|
|
### Definicion del registro a exportar al reporte
|
|
DEFINE ventas RECORD
|
|
cod_n SMALLINT,
|
|
cod_grupo SMALLINT,
|
|
cod_tipo SMALLINT,
|
|
cod_sec SMALLINT,
|
|
descrip_esp CHAR(30),
|
|
unidad_med CHAR(4) ,
|
|
marca CHAR(1),
|
|
ventas CHAR(1),
|
|
cantidad_vend DECIMAL(12,2),
|
|
valor DECIMAL(12,2),
|
|
cantidad_dev DECIMAL(12,2),
|
|
valor_dev DECIMAL(12,2),
|
|
unidad_acum DECIMAL(12,5),
|
|
valor_acum DECIMAL(12,2),
|
|
codigo CHAR(17),
|
|
grupo_venta CHAR(1),
|
|
descripcion_v CHAR(30),
|
|
descripcion_p CHAR(30),
|
|
vendedor CHAR(60),
|
|
descuento DEC(12,2),
|
|
sec_vend SMALLINT,
|
|
nombre char(100),
|
|
tasa decimal(12,3),
|
|
categoria CHAR(100)
|
|
END RECORD,
|
|
salida CHAR(50)
|
|
|
|
|
|
#WHENEVER ERROR CONTINUE
|
|
|
|
OPTIONS
|
|
FORM LINE 8,
|
|
ERROR LINE 23,
|
|
COMMENT LINE 21
|
|
|
|
OPEN FORM vefmrp015 FROM "vefmrp015"
|
|
DISPLAY FORM vefmrp015
|
|
|
|
#### Pide los parametros para busqueda de informacion
|
|
|
|
SELECT a.fecha_inicio INTO fecha_inicial FROM prdtable a
|
|
WHERE a.ano =YEAR(today) AND a.mes = MONTH(today)
|
|
|
|
#LET fecha_inicial = today-29
|
|
LET fecha_final = today
|
|
INPUT BY NAME fecha_inicial,fecha_final,salida WITHOUT DEFAULTS
|
|
|
|
|
|
AFTER FIELD salida
|
|
IF salida IS NULL THEN
|
|
CALL msg(16)
|
|
NEXT FIELD salida
|
|
END IF
|
|
AFTER INPUT
|
|
IF INT_FLAG THEN
|
|
LET INT_FLAG = FALSE
|
|
CALL msg(2)
|
|
RETURN
|
|
END IF
|
|
IF salida IS NULL THEN
|
|
CALL msg(16)
|
|
NEXT FIELD salida
|
|
END IF
|
|
|
|
EXIT INPUT
|
|
END INPUT
|
|
|
|
|
|
#### Permite Cancelar reporte mediante el uso de CONTROL-C
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
RETURN
|
|
END IF
|
|
CALL seleccionarSalida() RETURNING r_output
|
|
IF salida <> "veprrp015b.4rp" THEN
|
|
CONSTRUCT criterio ON b.ventas,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,b.sec_vend
|
|
FROM pventas,cod_n,cod_grupo,cod_tipo,cod_Sec,kvendedor
|
|
BEFORE CONSTRUCT
|
|
CALL cventas1()
|
|
CALL cvendedor()
|
|
CALL cbclase()
|
|
|
|
AFTER CONSTRUCT
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
RETURN
|
|
END IF
|
|
EXIT CONSTRUCT
|
|
END CONSTRUCT
|
|
ELSE
|
|
CONSTRUCT criterio ON b.ventas,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,b.sec_vend,b.tipo_cliente,b.sec_cliente
|
|
FROM pventas,cod_n,cod_grupo,cod_tipo,cod_Sec,kvendedor,tipo_cliente,sec_cliente
|
|
BEFORE CONSTRUCT
|
|
CALL cventas1()
|
|
CALL cvendedor()
|
|
CALL cbclase()
|
|
|
|
AFTER CONSTRUCT
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
RETURN
|
|
END IF
|
|
EXIT CONSTRUCT
|
|
END CONSTRUCT
|
|
|
|
END IF
|
|
# Buscando Pilas vendidas del ano actual
|
|
|
|
|
|
IF salida = "veprrp015b_3.4rp" THEN
|
|
|
|
LET selec =
|
|
"SELECT CAST(b.sec_vend AS CHAR(6))+ISNULL(RTRIM(x1.nom1_emp),'')+' '+ISNULL(x1.apell1_emp,' '),sum(a.cantidad),sum((a.cantidad * a.precio)*k.tasa),'0','0', ",
|
|
" f.producto, ",
|
|
" SUM((a.cantidad * a.precio) * (a.cantidad_2 / 100)*k.tasa) ",
|
|
"FROM vetb00003 a,vetb00002 b,vetb00061 c,iptb00002 d,iptb00020 f,cgtb00084 k,prdtable l, ",
|
|
" adtb00003 x1 ",
|
|
"WHERE b.fecha_factura between ? AND ? AND a.factura = b.factura and ",
|
|
" a.cod_n = d.cod_n AND a.cod_grupo = d.cod_grupo AND a.cod_tipo = d.cod_tipo AND ",
|
|
" a.cod_Sec = d.cod_sec AND b.ventas = c.ventas AND ",
|
|
" a.cod_n = f.cod_n and ",criterio CLIPPED," AND ",
|
|
" b.ventas = k.ventas and b.tipo_cliente = k.tipo_cliente and ",
|
|
" b.fecha_factura between l.fecha_inicio and l.fecha_corte and ",
|
|
" l.mes = k.mes and l.ano = k.ano AND ",
|
|
" b.sec_vend = x1.num_emp ",
|
|
" AND b.status_t is null ",
|
|
"GROUP BY f.producto,b.sec_vend,x1.nom1_emp,x1.apell1_emp ",
|
|
|
|
" UNION ",
|
|
|
|
"SELECT ",
|
|
"CAST(b.sec_vend AS CHAR(6))+ISNULL(RTRIM(x1.nom1_emp),'')+' '+ISNULL(x1.apell1_emp,' '),'0','0',sum(q.cantidad_2),sum(((q.cantidad_2 * a.precio)*k.tasa)-((q.cantidad_2 * a.precio) * (a.cantidad_2 / 100)*k.tasa)), ",
|
|
"f.producto, ",
|
|
"'0' ",
|
|
"from iptb00006 q,vetb00003 a,cctb00001 p, vetb00002 b,cgtb00084 k,prdtable l,iptb00020 f,iptb00002 d,vetb00061 c, ",
|
|
" adtb00003 x1 ",
|
|
"where a.cod_n = q.cod_n and a.cod_grupo = q.cod_grupo and a.cod_tipo = q.cod_tipo and a.cod_Sec = q.cod_Sec and ",
|
|
"a.cod_n = d.cod_n and a.cod_grupo = d.cod_grupo and a.cod_tipo = d.cod_tipo and a.cod_Sec = d.cod_Sec and ",
|
|
" q.area = a.area AND ",
|
|
"a.cod_n = f.cod_n and b.ventas = k.ventas and ",
|
|
"q.cod_mov in (12,13) and q.fact_no = cast(b.factura as char(7)) and ",
|
|
" q.fecha between ? AND ? and ",
|
|
"p.banco = q.cod_mov and p.num_cheque = q.num_doc and p.tipo_doc = 'NC' AND ",
|
|
"b.tipo_cliente = p.tipo_cliente and b.sec_cliente = p.sec_cliente and ",
|
|
"p.aplica_a = b.factura and b.factura = a.factura and ",
|
|
"p.fecha_orig between l.fecha_inicio and l.fecha_corte and ",
|
|
"k.mes = l.mes and k.ano = l.ano and k.tipo_cliente = b.tipo_cliente and ",
|
|
"f.cod_n = a.cod_n and ",criterio CLIPPED," AND ",
|
|
"b.ventas = k.ventas and ",
|
|
" b.ventas = c.ventas and ",
|
|
" b.sec_vend = x1.num_emp AND ",
|
|
"q.status_t is null and p.status_t is null ",
|
|
"group by f.producto",
|
|
" ORDER BY f.producto,b.sec_vend,x1.nom1_emp,x1.apell1_emp "
|
|
|
|
END IF
|
|
IF salida = "veprrp015b.4rp" THEN
|
|
|
|
|
|
LET selec =
|
|
"SELECT sum(a.cantidad),sum((a.cantidad * a.precio)*k.tasa),'0','0', ",
|
|
" f.producto, ",
|
|
" SUM((a.cantidad * a.precio) * (a.cantidad_2 / 100)*k.tasa) ",
|
|
"FROM vetb00003 a,vetb00002 b,vetb00061 c,iptb00002 d,iptb00020 f,cgtb00084 k,prdtable l ",
|
|
"WHERE b.fecha_factura between ? AND ? AND a.factura = b.factura and ",
|
|
" a.cod_n = d.cod_n AND a.cod_grupo = d.cod_grupo AND a.cod_tipo = d.cod_tipo AND ",
|
|
" a.cod_Sec = d.cod_sec AND b.ventas = c.ventas AND ",
|
|
" a.cod_n = f.cod_n and ",criterio CLIPPED," AND ",
|
|
" b.ventas = k.ventas and b.tipo_cliente = k.tipo_cliente and ",
|
|
" b.fecha_factura between l.fecha_inicio and l.fecha_corte and ",
|
|
" l.mes = k.mes and l.ano = k.ano ",
|
|
|
|
" AND b.status_t is null ",
|
|
"GROUP BY f.producto,k.tasa ",
|
|
|
|
" UNION ",
|
|
|
|
"SELECT ",
|
|
"'0','0',sum(q.cantidad_2),sum(((q.cantidad_2 * a.precio)*k.tasa)-((q.cantidad_2 * a.precio) * (a.cantidad_2 / 100)*k.tasa)), ",
|
|
"f.producto, ",
|
|
"'0' ",
|
|
"from iptb00006 q,vetb00003 a,cctb00001 p, vetb00002 b,cgtb00084 k,prdtable l,iptb00020 f,iptb00002 d,vetb00061 c ",
|
|
"where a.cod_n = q.cod_n and a.cod_grupo = q.cod_grupo and a.cod_tipo = q.cod_tipo and a.cod_Sec = q.cod_Sec and ",
|
|
" q.area = a.area AND ",
|
|
"a.cod_n = d.cod_n and a.cod_grupo = d.cod_grupo and a.cod_tipo = d.cod_tipo and a.cod_Sec = d.cod_Sec and ",
|
|
"a.cod_n = f.cod_n and b.ventas = k.ventas and ",
|
|
"q.cod_mov in (12,13) and q.fact_no = cast(b.factura as char(7)) and ",
|
|
" q.fecha between ? AND ? and ",
|
|
"p.banco = q.cod_mov and p.num_cheque = q.num_doc and p.tipo_doc = 'NC' AND ",
|
|
"b.tipo_cliente = p.tipo_cliente and b.sec_cliente = p.sec_cliente and ",
|
|
"p.aplica_a = b.factura and b.factura = a.factura and ",
|
|
"p.fecha_orig between l.fecha_inicio and l.fecha_corte and ",
|
|
"k.mes = l.mes and k.ano = l.ano and k.tipo_cliente = b.tipo_cliente and ",
|
|
"f.cod_n = a.cod_n and ",criterio CLIPPED," AND ",
|
|
"b.ventas = k.ventas and ",
|
|
" b.ventas = c.ventas and ",
|
|
"q.status_t is null and p.status_t is null ",
|
|
"group by f.producto ",
|
|
" ORDER BY f.producto "
|
|
|
|
END IF
|
|
IF salida <> "veprrp015b.4rp" THEN
|
|
LET selec =
|
|
|
|
|
|
" SELECT b.ventas,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec, ",
|
|
" sum(a.cantidad),sum((a.cantidad * a.precio)*k.tasa),'0','0',c.descripcion,d.descrip_esp, ",
|
|
" f.producto,ISNULL(RTRIM(CAST(g.nom1_emp AS CHAR(30))) +' '+ RTRIM(CAST(g.apell1_emp AS CHAR(30))),g.nom1_emp),",
|
|
" SUM((a.cantidad * a.precio) * (a.cantidad_2 / 100)*k.tasa),b.sec_vend,h.nombre,k.tasa,m.descripcion ",
|
|
" FROM vetb00003 a,vetb00002 b,vetb00061 c,iptb00002 d,iptb00020 f,adtb00003 g,cgtb00084 k,prdtable l,vetb00004 h,iptb00034 m,iptb00035 n",
|
|
" WHERE b.fecha_factura between ? AND ? AND a.factura = b.factura and",
|
|
" a.cod_n = d.cod_n AND a.cod_grupo = d.cod_grupo AND a.cod_tipo = d.cod_tipo AND",
|
|
" a.cod_Sec = d.cod_sec AND b.ventas = c.ventas AND",
|
|
" a.cod_n = f.cod_n and ",
|
|
" b.ventas = k.ventas and b.tipo_cliente = k.tipo_cliente and ",
|
|
" b.fecha_factura between l.fecha_inicio and l.fecha_corte and n.cod_n=a.cod_n and m.cod_categoria=n.cod_cat and ",
|
|
" l.mes = k.mes and l.ano = k.ano and b.tipo_cliente=h.tipo_cliente and b.sec_cliente=h.sec_cliente and ",
|
|
criterio CLIPPED,
|
|
" AND b.sec_vend = g.num_emp ",
|
|
" AND b.status_t is null ",
|
|
" GROUP BY m.descripcion,b.sec_vend,b.ventas,c.descripcion,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,d.descrip_esp,f.producto,g.nom1_emp,g.apell1_emp,h.nombre,k.tasa ",
|
|
|
|
" UNION ",
|
|
" SELECT b.ventas,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec, ",
|
|
" '0','0',sum(q.cantidad_2),sum(((q.cantidad_2 * a.precio)*k.tasa)-((q.cantidad_2 * a.precio) * (a.cantidad_2 / 100)*k.tasa)),c.descripcion,d.descrip_esp,",
|
|
" f.producto,ISNULL(RTRIM(CAST(i.nom1_emp AS CHAR(30))) +' '+ RTRIM(CAST(i.apell1_emp AS CHAR(30))),i.nom1_emp),",
|
|
" '0',b.sec_vend ,h.nombre,k.tasa,m.descripcion ",
|
|
" from iptb00006 q,vetb00003 a,cctb00001 p, vetb00002 b,cgtb00084 k,prdtable l,iptb00020 f,adtb00003 i,iptb00002 d,vetb00061 c,vetb00004 h,iptb00034 m,iptb00035 n",
|
|
" where a.cod_n = q.cod_n and a.cod_grupo = q.cod_grupo and a.cod_tipo = q.cod_tipo and a.cod_Sec = q.cod_Sec and",
|
|
" a.area = q.area AND ",
|
|
" a.cod_n = d.cod_n and a.cod_grupo = d.cod_grupo and a.cod_tipo = d.cod_tipo and a.cod_Sec = d.cod_Sec and",
|
|
" a.cod_n = f.cod_n and b.ventas = k.ventas and ",
|
|
" q.cod_mov in (12,13) and q.fact_no = cast(b.factura as char(7)) and",
|
|
" q.fecha between ? AND ? and ",
|
|
" p.banco = q.cod_mov and p.num_cheque = q.num_doc and p.tipo_doc = 'NC' AND ",
|
|
" b.tipo_cliente = p.tipo_cliente and b.sec_cliente = p.sec_cliente and",
|
|
" p.aplica_a = b.factura and b.factura = a.factura and ",
|
|
" p.fecha_orig between l.fecha_inicio and l.fecha_corte and ",
|
|
" k.mes = l.mes and k.ano = l.ano and k.tipo_cliente = b.tipo_cliente and ",
|
|
" f.cod_n = a.cod_n and p.cod_emp_Sec = i.num_emp AND n.cod_n=a.cod_n and m.cod_categoria=n.cod_cat and ",
|
|
" b.ventas = k.ventas ",
|
|
" and b.ventas = c.ventas and b.tipo_cliente=h.tipo_cliente and b.sec_cliente=h.sec_cliente and ",
|
|
criterio CLIPPED,
|
|
" and q.status_t is null and p.status_t is null ",
|
|
" group by m.descripcion,b.ventas,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,",
|
|
" c.descripcion,d.descrip_esp, ",
|
|
" f.producto,i.nom1_emp ,i.apell1_emp ,i.nom1_emp,",
|
|
" b.sec_vend,h.nombre,k.tasa ",
|
|
" ORDER BY b.sec_vend,b.ventas,c.descripcion,h.nombre,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_Sec "
|
|
END IF
|
|
|
|
LET idx=1
|
|
PREPARE busca_act FROM selec
|
|
DECLARE act2 SCROLL CURSOR FOR busca_act
|
|
OPEN act2 USING fecha_inicial,fecha_final,fecha_inicial,fecha_final
|
|
|
|
|
|
-- configure report engine; the functions prefixed fgl that are called here are part of the GRW API
|
|
DISPLAY idx
|
|
IF idx = 1 THEN
|
|
DISPLAY idx
|
|
LET r_filename = salida
|
|
LET preview=1
|
|
IF fgl_report_loadCurrentSettings(r_filename) THEN -- load the .4rp file
|
|
# LET r_output='SVG'
|
|
LET preview=true
|
|
CALL fgl_report_selectDevice(r_output) -- changing default
|
|
CALL fgl_report_selectPreview(preview) -- changing default
|
|
LET handler = fgl_report_commitCurrentSettings() -- commit changes
|
|
END IF
|
|
|
|
### Loop para igualar tipo de venta a la variable ventas.ventas
|
|
IF handler IS NOT NULL THEN -- report engine was configured ok
|
|
IF salida <> "veprrp015b.4rp" THEN
|
|
START REPORT plan TO XML HANDLER HANDLER
|
|
|
|
ELSE
|
|
CALL fgl_winmessage("ERROR","NO EXISTEN ORDENES CON ESA CONDICION","STOP")
|
|
|
|
return
|
|
END IF
|
|
FOREACH act2 INTO ventas.ventas,ventas.cod_n,ventas.cod_grupo,ventas.cod_tipo,
|
|
ventas.cod_sec,ventas.unidad_acum,ventas.valor_acum,
|
|
ventas.cantidad_dev,ventas.valor_dev,
|
|
ventas.descripcion_v,ventas.descrip_esp,ventas.descripcion_p,
|
|
ventas.vendedor,ventas.descuento,ventas.sec_vend,ventas.nombre,ventas.tasa,ventas.categoria
|
|
|
|
IF ventas.descuento IS NULL THEN
|
|
LET ventas.descuento = 0
|
|
END IF
|
|
LET ventas.valor_acum = ventas.valor_acum - ventas.descuento
|
|
IF ventas.cantidad_dev IS NULL THEN
|
|
LET ventas.cantidad_Dev = 0
|
|
END IF
|
|
|
|
IF ventas.valor_dev IS NULL THEN
|
|
LET ventas.valor_Dev = 0
|
|
END IF
|
|
|
|
LET ventas.codigo = ventas.cod_n USING "&&&","-",ventas.cod_grupo USING "&&&&","-",
|
|
ventas.cod_tipo USING "&&&","-",ventas.cod_sec USING "&&&"
|
|
|
|
IF ventas.unidad_acum IS NULL THEN
|
|
LET ventas.unidad_acum = 0
|
|
END IF
|
|
IF ventas.valor_acum IS NULL THEN
|
|
LET ventas.valor_acum = 0
|
|
END IF
|
|
|
|
OUTPUT TO REPORT plan(ventas.*)
|
|
|
|
END FOREACH
|
|
|
|
FINISH REPORT plan
|
|
ELSE
|
|
START REPORT grupo TO XML HANDLER HANDLER
|
|
IF salida = "veprrp015b.4rp" THEN
|
|
|
|
FOREACH act2 INTO
|
|
ventas.unidad_acum,ventas.valor_acum,
|
|
ventas.cantidad_dev,ventas.valor_dev,
|
|
ventas.descripcion_v,
|
|
ventas.descuento
|
|
|
|
IF ventas.descuento IS NULL THEN
|
|
LET ventas.descuento = 0
|
|
END IF
|
|
LET ventas.valor_acum = ventas.valor_acum - ventas.descuento
|
|
IF ventas.cantidad_dev IS NULL THEN
|
|
LET ventas.cantidad_Dev = 0
|
|
END IF
|
|
|
|
IF ventas.valor_dev IS NULL THEN
|
|
LET ventas.valor_Dev = 0
|
|
END IF
|
|
|
|
IF ventas.unidad_acum IS NULL THEN
|
|
LET ventas.unidad_acum = 0
|
|
END IF
|
|
IF ventas.valor_acum IS NULL THEN
|
|
LET ventas.valor_acum = 0
|
|
END IF
|
|
|
|
OUTPUT TO REPORT grupo(ventas.unidad_acum,ventas.valor_acum,
|
|
ventas.cantidad_dev,ventas.valor_dev,
|
|
ventas.descripcion_v,
|
|
ventas.descuento)
|
|
END FOREACH
|
|
|
|
FINISH REPORT grupo
|
|
END IF # REPORTE POR GRUPO
|
|
IF salida = "veprrp015b_3.4rp" THEN
|
|
|
|
FOREACH act2 INTO ventas.vendedor,
|
|
ventas.unidad_acum,ventas.valor_acum,
|
|
ventas.cantidad_dev,ventas.valor_dev,
|
|
ventas.descripcion_v,
|
|
ventas.descuento
|
|
|
|
IF ventas.descuento IS NULL THEN
|
|
LET ventas.descuento = 0
|
|
END IF
|
|
LET ventas.valor_acum = ventas.valor_acum - ventas.descuento
|
|
IF ventas.cantidad_dev IS NULL THEN
|
|
LET ventas.cantidad_Dev = 0
|
|
END IF
|
|
|
|
IF ventas.valor_dev IS NULL THEN
|
|
LET ventas.valor_Dev = 0
|
|
END IF
|
|
|
|
IF ventas.unidad_acum IS NULL THEN
|
|
LET ventas.unidad_acum = 0
|
|
END IF
|
|
IF ventas.valor_acum IS NULL THEN
|
|
LET ventas.valor_acum = 0
|
|
END IF
|
|
|
|
OUTPUT TO REPORT grupo(ventas.unidad_acum,ventas.valor_acum,
|
|
ventas.cantidad_dev,ventas.valor_dev,
|
|
ventas.descripcion_v,
|
|
ventas.descuento)
|
|
END FOREACH
|
|
|
|
FINISH REPORT grupo
|
|
END IF # REPORTE POR GRUPO / VENDEDOR
|
|
|
|
END IF
|
|
|
|
|
|
END IF
|
|
|
|
END FUNCTION
|
|
|
|
REPORT plan(x)
|
|
DEFINE x RECORD
|
|
cod_n SMALLINT,
|
|
cod_grupo SMALLINT,
|
|
cod_tipo SMALLINT,
|
|
cod_sec SMALLINT,
|
|
descrip_esp CHAR(30),
|
|
unidad_med CHAR(4) ,
|
|
marca CHAR(1),
|
|
ventas CHAR(1),
|
|
cantidad_vend DECIMAL(12,2),
|
|
valor DECIMAL(12,2),
|
|
cantidad_dev DECIMAL(12,2),
|
|
valor_dev DECIMAL(12,2),
|
|
unidad_acum DECIMAL(12,5),
|
|
valor_acum DECIMAL(12,2),
|
|
codigo CHAR(17),
|
|
grupo_venta CHAR(1),
|
|
descripcion_v CHAR(30),
|
|
descripcion_p CHAR(30),
|
|
vendedor CHAR(60),
|
|
descuento DEC(12,2),
|
|
sec_vend SMALLINT,
|
|
nombre char(100),
|
|
tasa decimal(12,3),
|
|
categoria CHAR(100)
|
|
END RECORD,
|
|
cantidadReal,valorReal DEC(12,2)
|
|
|
|
DEFINE hora CHAR(5)
|
|
|
|
DEFINE t_cantidad_dev,t_valor_dev,t_t_cantidad_dev,t_t_valor_dev,
|
|
t_t_t_cantidad_dev, t_t_t_valor_dev,g_cantidad_vend,g_valor_vend,
|
|
g_unidad_acum,g_valor_acum,g_g_cantidad_vend,g_g_valor_vend,
|
|
g_g_unidad_acum,g_g_valor_acum,g_g_g_cantidad_vend,g_g_g_valor_vend,
|
|
g_g_g_unidad_acum,g_g_g_valor_acum,
|
|
t1_cantidad_dev,t1_valor_dev,g1_cantidad_vend,g1_valor_vend
|
|
|
|
DECIMAL(12,2)
|
|
|
|
DEFINE gcantidad_v,gvalor,gcantidad_dev,gvalor_Dev,gcantidad_neta,
|
|
gvalor_neto DEC(12,2)
|
|
|
|
#### Especifica Formato de salida
|
|
OUTPUT
|
|
TOP MARGIN 0
|
|
LEFT MARGIN 0
|
|
BOTTOM MARGIN 4
|
|
|
|
ORDER BY x.categoria,x.vendedor,x.descripcion_v,x.nombre,x.descripcion_p,x.codigo
|
|
|
|
FORMAT
|
|
FIRST PAGE HEADER
|
|
|
|
LET g_g_g_unidad_acum = 0
|
|
LET g_g_g_valor_acum = 0
|
|
LET t1_cantidad_dev = 0
|
|
LET t1_valor_dev = 0
|
|
|
|
LET t_t_t_cantidad_dev = 0
|
|
LET t_t_t_valor_dev = 0
|
|
|
|
|
|
LET g_g_g_cantidad_vend = 0
|
|
|
|
LET g_g_g_valor_vend = 0
|
|
|
|
BEFORE GROUP OF x.vendedor
|
|
LET t_t_cantidad_dev = 0
|
|
LET t_t_valor_dev = 0
|
|
LET g_g_unidad_acum = 0
|
|
LET g_g_valor_acum = 0
|
|
|
|
LET g_cantidad_vend = 0
|
|
LET g_valor_vend = 0
|
|
|
|
BEFORE GROUP OF x.descripcion_v
|
|
LET t_cantidad_dev = 0
|
|
LET t_valor_dev = 0
|
|
LET g_unidad_acum = 0
|
|
LET g_valor_acum = 0
|
|
|
|
LET g_g_cantidad_vend = 0
|
|
LET g_g_valor_vend = 0
|
|
|
|
BEFORE GROUP OF x.nombre
|
|
|
|
BEFORE GROUP OF x.descripcion_p
|
|
LET gcantidad_dev = 0
|
|
LET gvalor_dev = 0
|
|
LET gcantidad_v = 0
|
|
LET gvalor = 0
|
|
LET gcantidad_neta = 0
|
|
LET gvalor_neto = 0
|
|
|
|
|
|
|
|
ON EVERY ROW
|
|
|
|
|
|
LET cantidadReal = x.unidad_acum - x.cantidad_dev
|
|
LET valorReal = x.valor_acum - x.valor_dev
|
|
|
|
#TOTAL VENTAS
|
|
|
|
LET t_cantidad_dev = x.cantidad_dev + t_cantidad_Dev
|
|
LET t_valor_dev = x.valor_dev + t_valor_Dev
|
|
LET g_unidad_acum = x.unidad_acum + g_unidad_acum
|
|
LET g_valor_acum = x.valor_acum + g_valor_acum
|
|
|
|
LET g_g_cantidad_vend = (x.unidad_acum - x.cantidad_dev) + g_g_cantidad_vend
|
|
LET g_g_valor_vend = (x.valor_acum - x.valor_dev) + g_g_valor_vend
|
|
|
|
LET g1_cantidad_vend = g_g_cantidad_vend + g1_cantidad_vend
|
|
LET g1_valor_vend = g_g_valor_vend + g1_valor_vend
|
|
|
|
# TOTAL VENDEDOR
|
|
LET t_t_cantidad_dev = x.cantidad_dev + t_t_cantidad_dev
|
|
LET t_t_valor_dev = x.valor_dev + t_t_valor_dev
|
|
LET g_g_unidad_acum = x.unidad_acum + g_g_unidad_acum
|
|
LET g_g_valor_acum = x.valor_acum + g_g_valor_acum
|
|
|
|
LET g_cantidad_vend = (x.unidad_acum - x.cantidad_dev) + g_cantidad_vend
|
|
LET g_valor_vend = (x.valor_acum - x.valor_dev) + g_valor_vend
|
|
# TOTAL GRUPO
|
|
|
|
LET gcantidad_dev = x.cantidad_dev + gcantidad_Dev
|
|
LET gvalor_dev = x.valor_dev + gvalor_Dev
|
|
LET gcantidad_v = x.unidad_acum + gcantidad_v
|
|
LET gvalor = x.valor_acum + gvalor
|
|
|
|
LET gcantidad_neta = (x.unidad_acum - x.cantidad_dev) + gcantidad_neta
|
|
LET gvalor_neto = (x.valor_acum - x.valor_dev) + gvalor_neto
|
|
|
|
# TOTAL GENERAL
|
|
|
|
LET g_g_g_unidad_acum = x.unidad_acum + g_g_g_unidad_acum
|
|
LET g_g_g_valor_acum = x.valor_acum + g_g_g_valor_acum
|
|
LET t1_cantidad_dev = x.cantidad_dev + t1_cantidad_Dev
|
|
LET t1_valor_dev = x.valor_dev + t1_valor_Dev
|
|
|
|
LET g_g_g_cantidad_vend = (x.unidad_acum - x.cantidad_dev) + g_g_g_cantidad_vend
|
|
LET g_g_g_valor_vend = (x.valor_acum - x.valor_dev) + g_g_g_valor_vend
|
|
|
|
# CALL fgl_winmessage("INFO",g_g_g_valor_vend,"stop")
|
|
|
|
PRINTX x.codigo,x.descrip_esp,x.unidad_med,
|
|
x.unidad_acum,
|
|
x.valor_acum ,
|
|
x.cantidad_dev,
|
|
x.valor_dev,
|
|
CantidadReal,
|
|
valorReal,
|
|
x.descripcion_p,
|
|
p_companias.nombre,
|
|
hora,
|
|
fecha_inicial,fecha_final,
|
|
x.descripcion_v,
|
|
x.vendedor,
|
|
g_unidad_acum,
|
|
g_valor_acum,
|
|
t_cantidad_dev,
|
|
t_valor_dev,
|
|
g_g_cantidad_Vend,
|
|
g_g_valor_vend,
|
|
g_g_unidad_acum,
|
|
g_g_valor_acum,
|
|
t_t_cantidad_dev,
|
|
t_t_valor_dev,
|
|
g_cantidad_vend,
|
|
g_valor_vend,
|
|
g_g_g_unidad_acum,g_g_g_valor_acum,
|
|
t1_cantidad_dev,t1_valor_dev,t_t_t_cantidad_dev,
|
|
t_t_t_valor_dev,
|
|
gcantidad_v,
|
|
gvalor,
|
|
gcantidad_dev,
|
|
gvalor_Dev,
|
|
gcantidad_neta,
|
|
gvalor_neto,
|
|
g_g_g_cantidad_vend,
|
|
g_g_g_valor_vend,
|
|
g1_cantidad_Vend,g1_valor_vend,x.nombre,x.tasa,x.categoria
|
|
|
|
END REPORT
|
|
|
|
|
|
REPORT grupo(x)
|
|
DEFINE x RECORD
|
|
unidad_acum DECIMAL(12,2),
|
|
valor_acum DECIMAL(12,2),
|
|
cantidad_dev DECIMAL(12,2),
|
|
valor_dev DECIMAL(12,2),
|
|
descripcion_v CHAR(30),
|
|
descuento DEC(12,2)
|
|
END RECORD,
|
|
cantidadReal,valorReal DEC(12,2)
|
|
|
|
DEFINE hora CHAR(5)
|
|
|
|
DEFINE t_t_t_cantidad_dev, t_t_t_valor_dev,
|
|
g_g_g_cantidad_vend,g_g_g_valor_vend,
|
|
g_g_g_unidad_acum,g_g_g_valor_acum,
|
|
t1_cantidad_dev,t1_valor_dev
|
|
|
|
DECIMAL(12,2)
|
|
|
|
|
|
#### Especifica Formato de salida
|
|
OUTPUT
|
|
TOP MARGIN 0
|
|
LEFT MARGIN 0
|
|
BOTTOM MARGIN 4
|
|
|
|
|
|
ORDER BY x.descripcion_v
|
|
FORMAT
|
|
FIRST PAGE HEADER
|
|
|
|
LET g_g_g_unidad_acum = 0
|
|
LET g_g_g_valor_acum = 0
|
|
|
|
LET t_t_t_cantidad_dev = 0
|
|
LET t_t_t_valor_dev = 0
|
|
LET t1_cantidad_dev = 0
|
|
LET t1_valor_dev =0
|
|
|
|
LET g_g_g_cantidad_vend = 0
|
|
|
|
LET g_g_g_valor_vend = 0
|
|
|
|
|
|
AFTER GROUP OF x.descripcion_v
|
|
LET x.valor_acum = GROUP SUM(x.valor_acum)
|
|
LET x.cantidad_dev = GROUP SUM(x.cantidad_dev)
|
|
LET x.unidad_acum = GROUP SUM(x.unidad_acum)
|
|
LET cantidadReal = x.unidad_acum-x.cantidad_dev
|
|
LET x.valor_dev = GROUP SUM(x.valor_dev)
|
|
LET valorReal = x.valor_acum - x.valor_dev
|
|
# TOTAL GENERAL
|
|
|
|
LET g_g_g_unidad_acum = x.unidad_acum + g_g_g_unidad_acum
|
|
LET g_g_g_valor_acum = x.valor_acum + g_g_g_valor_acum
|
|
|
|
LET t1_cantidad_dev = x.cantidad_dev + t1_cantidad_Dev
|
|
LET t1_valor_dev = x.valor_dev + t1_valor_Dev
|
|
|
|
LET g_g_g_cantidad_vend = (x.unidad_acum - x.cantidad_dev) + g_g_g_cantidad_vend
|
|
LET g_g_g_valor_vend = (x.valor_acum - x.valor_dev) + g_g_g_valor_vend
|
|
|
|
# CALL fgl_winmessage("INFO",g_g_g_valor_vend,"stop")
|
|
|
|
|
|
|
|
|
|
PRINTX x.unidad_acum,
|
|
x.valor_acum ,
|
|
x.cantidad_dev,
|
|
x.valor_dev,
|
|
CantidadReal,
|
|
valorReal,
|
|
p_companias.nombre,
|
|
hora,
|
|
fecha_inicial,fecha_final,
|
|
x.descripcion_v,
|
|
g_g_g_cantidad_vend,
|
|
g_g_g_unidad_acum,
|
|
g_g_g_valor_acum,
|
|
g_g_g_valor_vend,
|
|
t1_cantidad_dev,
|
|
t1_valor_dev
|
|
|
|
|
|
|
|
END REPORT
|
|
|
|
FUNCTION cventas1()
|
|
DEFINE kventas SMALLINT, dventas CHAR(30)
|
|
|
|
LET pventas = ui.combobox.forname("formonly.pventas")
|
|
|
|
DECLARE bventas CURSOR FOR
|
|
SELECT a.ventas,a.descripcion FROM vetb00061 a
|
|
CALL pventas.clear()
|
|
|
|
FOREACH bventas INTO kventas,dventas
|
|
CALL pventas.additem(kventas,dventas)
|
|
END FOREACH
|
|
|
|
END FUNCTION
|
|
|