789 lines
29 KiB
Plaintext
789 lines
29 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 ,
|
|
ptasa DEC(12,2),
|
|
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 "smarmotech" 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(80),
|
|
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,2),
|
|
valor_acum DECIMAL(12,2),
|
|
codigo CHAR(30),
|
|
grupo_venta CHAR(1),
|
|
descripcion_v CHAR(30),
|
|
descripcion_p CHAR(30),
|
|
vendedor CHAR(60),
|
|
descuento DEC(12,2),
|
|
sec_vend SMALLINT,
|
|
origen VARCHAR(60)
|
|
END RECORD,
|
|
salida string
|
|
|
|
|
|
#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,historico,salida WITHOUT DEFAULTS
|
|
|
|
AFTER FIELD historico
|
|
IF historico IS NULL THEN
|
|
CALL msg(16)
|
|
NEXT FIELD historico
|
|
END IF
|
|
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
|
|
IF historico IS NULL THEN
|
|
CALL msg(16)
|
|
NEXT FIELD historico
|
|
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("ALL")
|
|
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 historico = "NO" THEN
|
|
|
|
IF salida = "veprrp015a.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),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 ",
|
|
" b.sucid = a.sucid 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,k.tasa ",
|
|
|
|
" 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',k.tasa ",
|
|
"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.factura = b.factura 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 ",
|
|
"b.sucid = a.sucid 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,b.sec_vend,x1.nom1_emp,x1.apell1_emp,k.tasa",
|
|
" ORDER BY f.producto,CAST(b.sec_vend AS CHAR(6))+ISNULL(RTRIM(x1.nom1_emp),'')+' '+ISNULL(x1.apell1_emp,' ') "
|
|
|
|
END IF
|
|
IF salida = "veprrp015b.4rp" THEN
|
|
|
|
LET selec =
|
|
"SELECT x1.descripcion,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),k.tasa ",
|
|
"FROM vetb00003 a,vetb00002 b,vetb00061 c,iptb00002 d,iptb00020 f,cgtb00084 k,prdtable l,iptb00022 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 d.cod_cia = x1.cod_cia AND ",criterio CLIPPED," AND ",
|
|
" b.ventas = k.ventas and b.tipo_cliente = k.tipo_cliente and ",
|
|
" b.sucid = a.sucid 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,x1.descripcion,k.tasa ",
|
|
|
|
" UNION ",
|
|
|
|
"SELECT x1.descripcion,",
|
|
"'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',k.tasa ",
|
|
"from iptb00006 q,vetb00003 a,cctb00001 p, vetb00002 b,cgtb00084 k,prdtable l,iptb00020 f,iptb00002 d,vetb00061 c,iptb00022 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 ",
|
|
" 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.factura = b.factura 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 ",
|
|
"b.sucid = a.sucid AND ",
|
|
"f.cod_n = a.cod_n and ",criterio CLIPPED," AND ",
|
|
" d.cod_cia = x1.cod_cia and ",
|
|
"b.ventas = k.ventas and ",
|
|
" b.ventas = c.ventas and ",
|
|
"q.status_t is null and p.status_t is null ",
|
|
"group by x1.descripcion, f.producto,k.tasa ",
|
|
|
|
" ORDER BY x1.descripcion,f.producto "
|
|
|
|
END IF
|
|
IF salida ="veprrp015.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,k.tasa ",
|
|
"FROM vetb00003 a,vetb00002 b,vetb00061 c,iptb00002 d,iptb00020 f,adtb00003 g,cgtb00084 k,prdtable l ",
|
|
"WHERE b.fecha_factura between ? AND ? AND a.factura = b.factura and ",
|
|
" a.sucid = b.sucid 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 ",
|
|
" l.mes = k.mes and l.ano = k.ano and ",
|
|
criterio CLIPPED,
|
|
" AND b.sec_vend = g.num_emp ",
|
|
" AND b.status_t is null ",
|
|
"GROUP BY 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,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,k.tasa ",
|
|
"from iptb00006 q,vetb00003 a,cctb00001 p, vetb00002 b,cgtb00084 k,prdtable l,iptb00020 f,adtb00003 i,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 ",
|
|
" 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.factura = b.factura 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 ",
|
|
" b.sucid = a.sucid and ",
|
|
"f.cod_n = a.cod_n and p.cod_emp_Sec = i.num_emp and ",
|
|
"b.ventas = k.ventas and ", criterio CLIPPED,
|
|
" and b.ventas = c.ventas and ",
|
|
"q.status_t is null and p.status_t is null ",
|
|
"group by b.ventas,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,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), ",
|
|
"b.sec_vend ",
|
|
"ORDER BY b.sec_vend,b.ventas,c.descripcion,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_Sec"
|
|
DISPLAY "DAATA: ",selec
|
|
END IF
|
|
END IF
|
|
|
|
IF salida = "veprrp015b_4.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),k.tasa ",
|
|
"FROM vetb00003 a,vetb00002 b,vetb00061 c,iptb00020 f,cgtb00084 k,prdtable l ",
|
|
"WHERE b.fecha_factura between ? AND ? AND (a.factura = b.factura) and ",
|
|
" b.ventas = c.ventas AND ",
|
|
" b.sucid = a.sucid 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',k.tasa ",
|
|
"from iptb00006 q,vetb00003 a,cctb00001 p, vetb00002 b,cgtb00084 k,prdtable l,iptb00020 f,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 = f.cod_n and b.ventas = k.ventas and ",
|
|
"q.cod_mov in (12,13) and q.factura = b.factura 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 ",
|
|
" a.sucid = b.sucid 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,k.tasa",
|
|
|
|
" ORDER BY f.producto "
|
|
|
|
END IF
|
|
|
|
PREPARE busca_act FROM selec
|
|
DECLARE act2 SCROLL CURSOR FOR busca_act
|
|
OPEN act2 USING fecha_inicial,fecha_final,fecha_inicial,fecha_final
|
|
|
|
LET idx = 1
|
|
-- configure report engine; the functions prefixed fgl that are called here are part of the GRW API
|
|
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 = "veprrp015.4rp" THEN
|
|
START REPORT plan TO XML HANDLER handler
|
|
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,ptasa
|
|
|
|
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" OR salida = "veprrp015b_4.4rp" THEN
|
|
|
|
FOREACH act2 INTO ventas.origen,
|
|
ventas.unidad_acum,ventas.valor_acum,
|
|
ventas.cantidad_dev,ventas.valor_dev,
|
|
ventas.descripcion_v,
|
|
ventas.descuento,ptasa
|
|
|
|
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,ventas.origen,ventas.vendedor)
|
|
END FOREACH
|
|
|
|
FINISH REPORT grupo
|
|
END IF # REPORTE POR GRUPO
|
|
IF salida = "veprrp015a.4rp" THEN
|
|
|
|
FOREACH act2 INTO ventas.vendedor,
|
|
ventas.unidad_acum,ventas.valor_acum,
|
|
ventas.cantidad_dev,ventas.valor_dev,
|
|
ventas.descripcion_v,
|
|
ventas.descuento,ptasa
|
|
|
|
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,ventas.origen,
|
|
ventas.vendedor)
|
|
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(80),
|
|
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,2),
|
|
valor_acum DECIMAL(12,2),
|
|
codigo CHAR(30),
|
|
grupo_venta CHAR(1),
|
|
descripcion_v CHAR(30),
|
|
descripcion_p CHAR(30),
|
|
vendedor CHAR(60),
|
|
descuento DEC(12,2),
|
|
sec_vend SMALLINT,
|
|
origen VARCHAR(60)
|
|
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.vendedor,x.descripcion_v,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.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.origen,
|
|
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,ptasa
|
|
|
|
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),
|
|
origen VARCHAR(60),
|
|
vendedor VARCHAR(60)
|
|
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,
|
|
o_t_t_cantidad_dev, o_t_t_valor_dev,
|
|
o_g_g_cantidad_vend,o_g_g_valor_vend,
|
|
o_g_g_unidad_acum,o_g_g_valor_acum,
|
|
o_t1_cantidad_dev,o_t1_valor_dev,
|
|
g_neto
|
|
DECIMAL(12,2)
|
|
|
|
|
|
#### Especifica Formato de salida
|
|
OUTPUT
|
|
TOP MARGIN 0
|
|
LEFT MARGIN 0
|
|
BOTTOM MARGIN 4
|
|
|
|
|
|
ORDER BY x.origen,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
|
|
|
|
BEFORE GROUP OF x.origen
|
|
LET o_t1_cantidad_dev=0
|
|
LET o_t1_valor_dev=0
|
|
LET o_g_g_cantidad_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 = GROUP SUM(x.unidad_acum)
|
|
LET g_g_g_valor_acum = GROUP SUM(x.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.origen,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,x.vendedor,ptasa
|
|
|
|
|
|
ON LAST ROW
|
|
LET o_g_g_valor_acum = SUM(x.valor_acum)
|
|
LET o_t1_cantidad_dev = SUM(x.cantidad_dev)
|
|
LET g_neto = o_g_g_valor_acum - o_t1_cantidad_dev
|
|
|
|
PRINTX o_g_g_valor_acum,o_t1_cantidad_dev,g_neto
|
|
|
|
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
|
|
|