lsoto
This commit is contained in:
@@ -0,0 +1,298 @@
|
||||
{------------------------------------------------------------------------------
|
||||
PROGRAMA : IRPRRP009
|
||||
OBJETIVO : Operacion por Tipo de Movimiento Repuestos
|
||||
PROGRAMADOR : VALENTIN RODRIGUEZ
|
||||
FECHA REALIZACION : MARZO, 13 2020
|
||||
---------------------------------------------------------------------------------}
|
||||
|
||||
GLOBALS "irprgb000.4gl"
|
||||
DEFINE p_fecha DATE
|
||||
DEFINE afecta CHAR(1)
|
||||
|
||||
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
|
||||
criterio STRING
|
||||
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 irprrp009()
|
||||
END MAIN
|
||||
|
||||
FUNCTION irprrp009()
|
||||
|
||||
DEFINE select_ac CHAR(1000)
|
||||
DEFINE c_ano CHAR(4)
|
||||
DEFINE entra,nombre_mes CHAR(14)
|
||||
DEFINE entra1 CHAR(5)
|
||||
DEFINE detalle CHAR(100)
|
||||
DEFINE numero_ent CHAR(2)
|
||||
DEFINE p_ano, ano_act CHAR(4)
|
||||
DEFINE tiempo CHAR(4)
|
||||
DEFINE idz INT
|
||||
|
||||
DEFINE acumulado RECORD
|
||||
cod_n LIKE irtb00002.cod_n,
|
||||
cod_grupo LIKE irtb00002.cod_grupo,
|
||||
cod_tipo LIKE irtb00002.cod_tipo,
|
||||
cod_sec LIKE irtb00002.cod_sec,
|
||||
descrip_esp LIKE irtb00002.descrip_esp,
|
||||
unidad_med LIKE irtb00002.unidad_med,
|
||||
cod_mov LIKE irtb00006.cod_mov,
|
||||
descrip_mov LIKE intb00005.descrip_mov,
|
||||
departamento SMALLINT,
|
||||
nombre CHAR(30),
|
||||
consumo decimal(12,2),
|
||||
cuenta CHAR(10),
|
||||
cuenta_inv CHAR(10),
|
||||
gasto_ind LIKE irtb00013.costo_st,
|
||||
consumo_cuenta DECIMAL(12,2),
|
||||
nombre_cuenta VARCHAR(50)
|
||||
END RECORD
|
||||
|
||||
DEFINE acumulado_arr DYNAMIC ARRAY OF RECORD
|
||||
cod_mov LIKE irtb00006.cod_mov,
|
||||
descrip_mov LIKE intb00005.descrip_mov,
|
||||
departamento SMALLINT,
|
||||
nombre CHAR(30),
|
||||
consumo decimal(12,2),
|
||||
cuenta CHAR(10),
|
||||
gasto_ind LIKE irtb00013.costo_st,
|
||||
descripcion CHAR(50),
|
||||
consumo_cuenta DECIMAL(12,2),
|
||||
cuenta_inv CHAR(10)
|
||||
END RECORD
|
||||
|
||||
OPEN FORM edfmrp118 FROM "irfmrp009"
|
||||
DISPLAY FORM edfmrp118
|
||||
-- columnas calificadas con b. (irtb00006): sin prefijo, cod_n/cod_grupo/cod_tipo/cod_sec
|
||||
-- son ambiguas en el JOIN con irtb00002 y cualquier filtro por codigo fallaba
|
||||
CONSTRUCT criterio ON b.cod_mov,b.cod_n,b.cod_grupo,b.cod_tipo,b.cod_sec
|
||||
FROM cod_mov,cod_n,cod_grupo,cod_tipo,cod_sec
|
||||
BEFORE CONSTRUCT
|
||||
CALL ircmovimientos()
|
||||
AFTER CONSTRUCT
|
||||
IF int_flag THEN
|
||||
CALL msg(2)
|
||||
LET int_flag = FALSE
|
||||
RETURN
|
||||
END IF
|
||||
EXIT CONSTRUCT
|
||||
END CONSTRUCT
|
||||
INPUT BY NAME datos_cons.fech_in,datos_cons.fech_fi
|
||||
|
||||
|
||||
BEFORE FIELD fech_in
|
||||
SELECT MAX(a.fecha) INTO p_fecha FROM cgtb00004 a
|
||||
WHERE a.ref[1,9] = entra1
|
||||
LET datos_cons.fech_in = p_fecha + 1
|
||||
DISPLAY BY NAME datos_cons.fech_in
|
||||
|
||||
AFTER FIELD fech_in
|
||||
IF datos_cons.fech_in IS NULL THEN
|
||||
ERROR "(16) CAMPO EN BLANCO"
|
||||
NEXT FIELD fech_in
|
||||
END IF
|
||||
|
||||
|
||||
LET p_ano = YEAR(datos_cons.fech_in)
|
||||
|
||||
AFTER FIELD fech_fi
|
||||
IF datos_cons.fech_fi IS NULL THEN
|
||||
LET numero_msg = 16
|
||||
CALL msg(numero_msg)
|
||||
NEXT FIELD fech_final
|
||||
END IF
|
||||
|
||||
LET ano_act = year(datos_cons.fech_fi)
|
||||
|
||||
AFTER INPUT
|
||||
|
||||
IF int_flag THEN
|
||||
LET numero_msg = 2
|
||||
CALL msg(numero_msg)
|
||||
LET int_flag = false
|
||||
RETURN
|
||||
END IF
|
||||
|
||||
LET select_ac =
|
||||
|
||||
"SELECT b.cod_n,b.cod_grupo,b.cod_tipo,b.cod_sec,a.descrip_esp, ",
|
||||
"a.unidad_med,b.cod_mov,c.descrip_mov,b.sec_a,d.nom_dpto,SUM(b.cantidad_2), a.cuenta,e.cuenta_no ",
|
||||
"FROM irtb00002 AS a INNER JOIN ",
|
||||
"irtb00006 AS b ON a.cod_n = b.cod_n AND a.cod_grupo = b.cod_grupo AND a.cod_tipo = b.cod_tipo AND ",
|
||||
criterio CLIPPED," and ",
|
||||
"a.cod_sec = b.cod_sec and b.status_t IS NULL INNER JOIN ",
|
||||
" iptb00022 e ON e.cod_cia = a.cod_n INNER JOIN ",
|
||||
"irtb00005 AS c ON b.cod_mov = c.cod_mov LEFT OUTER JOIN ",
|
||||
"adtb00001 AS d ON b.sec_a = d.departamento ",
|
||||
"WHERE ",
|
||||
" b.fecha BETWEEN ? AND ? AND b.status_t IS NULL ",
|
||||
" GROUP BY b.cod_n,b.cod_grupo,b.cod_tipo,b.cod_sec,a.descrip_esp,a.unidad_med,b.cod_mov,c.descrip_mov,b.sec_a,d.nom_dpto, a.cuenta,e.cuenta_no ",
|
||||
" ORDER BY b.cod_mov,b.sec_a,b.cod_n,b.cod_grupo,b.cod_tipo,b.cod_sec"
|
||||
|
||||
DISPLAY "<< Estoy Buscando Acumulado Del Periodo Dado >>"
|
||||
AT 17,14 ATTRIBUTE (REVERSE,BOLD)
|
||||
|
||||
PREPARE busca_ant FROM select_ac
|
||||
DECLARE actual SCROLL CURSOR FOR busca_ant
|
||||
OPEN actual USING datos_cons.fech_in,datos_cons.fech_fi
|
||||
|
||||
LET r_filename ="irprrp009.4rp"
|
||||
LET idx = 1
|
||||
LET idz = 1
|
||||
|
||||
FOREACH actual INTO acumulado.*
|
||||
|
||||
IF idx = 1 THEN
|
||||
IF fgl_report_loadCurrentSettings(r_filename) THEN
|
||||
|
||||
LET preview=1
|
||||
CALL seleccionarsalida() RETURNING r_output -- load the .4rp file
|
||||
CALL fgl_report_selectDevice(r_output) -- changing default
|
||||
CALL fgl_report_selectPreview(preview) -- changing default
|
||||
LET handler = fgl_report_commitCurrentSettings() -- commit changes
|
||||
|
||||
END IF
|
||||
|
||||
LET idx = 2
|
||||
|
||||
START REPORT opera TO XML HANDLER HANDLER
|
||||
|
||||
END IF
|
||||
|
||||
LET c_ano = YEAR(datos_cons.fech_fi)
|
||||
LET acumulado.gasto_ind = 0
|
||||
|
||||
SELECT a.costo_st INTO acumulado.gasto_ind FROM irtb00013 a
|
||||
WHERE (a.cod_n = acumulado.cod_n and a.cod_grupo = acumulado.cod_grupo and
|
||||
a.cod_tipo = acumulado.cod_tipo and a.cod_sec=acumulado.cod_sec) and
|
||||
a.ano = c_ano and
|
||||
a.status_t is NULL
|
||||
|
||||
IF acumulado.gasto_ind IS NULL THEN
|
||||
LET acumulado.gasto_ind = 0
|
||||
END IF
|
||||
|
||||
SELECT ISNULL(descripcion,'NO EXISTE CUENTA')
|
||||
INTO acumulado_arr[idz].descripcion
|
||||
FROM cgtb00001
|
||||
WHERE cgtb00001.cuenta_no = acumulado.cuenta
|
||||
|
||||
|
||||
IF acumulado.consumo is null THEN
|
||||
LET acumulado.consumo = 0
|
||||
END IF
|
||||
|
||||
IF acumulado.nombre IS NULL THEN
|
||||
LET acumulado.nombre = 'NO ESPECIFICADO'
|
||||
END IF
|
||||
LET acumulado.nombre_cuenta = acumulado_arr[idz].descripcion
|
||||
LET acumulado.consumo_cuenta = acumulado.consumo * acumulado.gasto_ind
|
||||
|
||||
LET acumulado_arr[idz].cod_mov = acumulado.cod_mov
|
||||
LET acumulado_arr[idz].descrip_mov = acumulado.descrip_mov
|
||||
LET acumulado_arr[idz].departamento = acumulado.departamento
|
||||
LET acumulado_arr[idz].nombre = acumulado.nombre
|
||||
LET acumulado_arr[idz].consumo = acumulado.consumo
|
||||
LET acumulado_arr[idz].cuenta = acumulado.cuenta
|
||||
LET acumulado_arr[idz].gasto_ind = acumulado.gasto_ind
|
||||
LET acumulado_arr[idz].consumo_cuenta = acumulado.consumo_cuenta
|
||||
LET acumulado_arr[idz].cuenta_inv = acumulado.cuenta_inv
|
||||
|
||||
LET idz = idz + 1
|
||||
OUTPUT TO REPORT opera(acumulado.*)
|
||||
|
||||
END FOREACH
|
||||
|
||||
IF idx > 1 THEN
|
||||
FINISH REPORT opera
|
||||
ELSE
|
||||
CALL fgl_winmessage("INFO", "NO HAY REGISTROS EN ESTE RANGO DE FECHA Y CON LOS PARAMETROS INDICADOS", "INFO")
|
||||
END IF
|
||||
|
||||
END INPUT
|
||||
|
||||
END FUNCTION
|
||||
|
||||
REPORT opera(x)
|
||||
DEFINE x RECORD
|
||||
cod_n LIKE irtb00002.cod_n,
|
||||
cod_grupo LIKE irtb00002.cod_grupo,
|
||||
cod_tipo LIKE irtb00002.cod_tipo,
|
||||
cod_sec LIKE irtb00002.cod_sec,
|
||||
descrip_esp LIKE irtb00002.descrip_esp,
|
||||
unidad_med LIKE irtb00002.unidad_med,
|
||||
cod_mov LIKE irtb00006.cod_mov,
|
||||
descrip_mov LIKE intb00005.descrip_mov,
|
||||
departamento SMALLINT,
|
||||
nombre CHAR(30),
|
||||
consumo decimal(12,2),
|
||||
cuenta CHAR(10),
|
||||
cuenta_inv CHAR(10),
|
||||
gasto_ind LIKE irtb00013.costo_st,
|
||||
consumo_cuenta DECIMAL(12,2),
|
||||
nombre_cuenta VARCHAR(50)
|
||||
END RECORD
|
||||
|
||||
DEFINE rango_fecha CHAR(30)
|
||||
DEFINE movimiento CHAR(50)
|
||||
DEFINE codigo_producto CHAR(100)
|
||||
DEFINE hora CHAR(5),
|
||||
actual VARCHAR(20)
|
||||
DEFINE total_material, total_movimiento,total_cuenta, total_departamento,
|
||||
total_general DECIMAL (12,2)
|
||||
|
||||
FORMAT
|
||||
|
||||
PAGE HEADER
|
||||
LET hora = TIME
|
||||
LET actual = today using "dd/mm/yy"
|
||||
LET rango_fecha = datos_cons.fech_in ,"--",datos_cons.fech_fi
|
||||
|
||||
BEFORE GROUP OF x.cod_mov
|
||||
LET movimiento = x.cod_mov,"--",x.descrip_mov
|
||||
LET total_movimiento = 0
|
||||
PRINTX movimiento
|
||||
|
||||
BEFORE GROUP OF x.departamento
|
||||
LET total_departamento = 0
|
||||
PRINTX x.nombre,x.departamento
|
||||
|
||||
BEFORE GROUP OF x.cuenta
|
||||
LET total_cuenta = 0
|
||||
PRINTX x.cuenta,x.nombre_cuenta
|
||||
|
||||
ON EVERY ROW
|
||||
|
||||
LET codigo_producto = '(',x.cod_n,'-',x.cod_grupo,'-',x.cod_tipo,'-',x.cod_sec,')',x.descrip_esp
|
||||
|
||||
LET total_movimiento = total_movimiento + x.consumo_cuenta
|
||||
LET total_departamento = total_departamento + x.consumo_cuenta
|
||||
LET total_cuenta = total_cuenta + x.consumo_cuenta
|
||||
LET total_general = total_general + x.consumo_cuenta
|
||||
|
||||
PRINTX codigo_producto,x.unidad_med,x.consumo,x.gasto_ind,
|
||||
rango_fecha,p_companias.nombre, x.consumo_cuenta,
|
||||
hora,actual,x.cuenta
|
||||
|
||||
AFTER GROUP OF x.departamento
|
||||
PRINTX x.nombre,total_departamento
|
||||
|
||||
AFTER GROUP OF x.cod_mov
|
||||
PRINTX total_movimiento
|
||||
|
||||
AFTER GROUP OF x.cuenta
|
||||
PRINTX total_cuenta
|
||||
|
||||
ON LAST ROW
|
||||
LET total_general = SUM(x.consumo_cuenta)
|
||||
PRINTX total_general
|
||||
LET total_material = 0
|
||||
END REPORT
|
||||
Reference in New Issue
Block a user