328 lines
12 KiB
Plaintext
328 lines
12 KiB
Plaintext
{
|
|
------------------------------------------------------------------------------
|
|
PROGRAMA : IRPRRP009
|
|
OBJETIVO : Operacion por Tipo de Movimiento 45
|
|
PROGRAMADOR : VALENTIN RODRIGUEZ
|
|
FECHA REALIZACION : MARZO, 13 2020
|
|
---------------------------------------------------------------------------------}
|
|
|
|
GLOBALS "idprgb000.4gl"
|
|
DEFINE p_fecha DATE
|
|
DEFINE afecta CHAR(3)
|
|
|
|
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),
|
|
gasto_ind LIKE irtb00013.costo_st,
|
|
consumo_cuenta DECIMAL(12,2)
|
|
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(30),
|
|
consumo_cuenta DECIMAL(12,2)
|
|
END RECORD
|
|
|
|
OPEN FORM edfmrp125 FROM "edfmrp125"
|
|
DISPLAY FORM edfmrp125
|
|
|
|
INPUT BY NAME datos_cons.fech_in,datos_cons.fech_fi,entra
|
|
|
|
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
|
|
|
|
IF datos_cons.fech_in <= p_fecha THEN
|
|
ERROR "(179) EXISTE ENTRADA DE DIARIO CON ESA FECHA"
|
|
NEXT FIELD fech_in
|
|
END IF
|
|
|
|
LET numero_ent = 05
|
|
LET p_ano = YEAR(datos_cons.fech_in)
|
|
|
|
LET tiempo = MONTH(datos_cons.fech_in) using "&&",p_ano[3,4]
|
|
|
|
LET entra = "ED.05-011","/",tiempo
|
|
LET entra1 = entra
|
|
|
|
DISPLAY BY NAME entra
|
|
|
|
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)
|
|
|
|
SELECT descrip_mov INTO acumulado.descrip_mov FROM iptb00005
|
|
WHERE cod_mov = 45
|
|
|
|
SELECT a.descrip INTO nombre_mes
|
|
FROM mestable a
|
|
WHERE a.mes = MONTH(datos_cons.fech_fi)
|
|
|
|
LET detalle = 'PARA REGISTRAR (45)',acumulado.descrip_mov CLIPPED,
|
|
'DEL MES DE ',nombre_mes CLIPPED, 'DEL ',YEAR(datos_cons.fech_fi)
|
|
|
|
{ AFTER FIELD entra
|
|
SELECT UNIQUE a.ref FROM cgtb00004 a WHERE a.ref = entra
|
|
|
|
IF STATUS != NOTFOUND THEN
|
|
ERROR "(12) REGISTRO EXISTE"
|
|
NEXT FIELD entra
|
|
END IF
|
|
|
|
LET entra1 = entra}
|
|
|
|
AFTER INPUT
|
|
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
RETURN
|
|
END IF
|
|
|
|
END INPUT
|
|
|
|
CONSTRUCT criterio ON b.cod_n,b.cod_grupo,b.cod_tipo,
|
|
b.cod_sec,b.sec_a
|
|
FROM cod_n,cod_grupo,cod_tipo,cod_sec,departamento
|
|
|
|
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_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 ",
|
|
"b.cod_mov = 45 and ",
|
|
"a.cod_sec = b.cod_sec 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 ",
|
|
criterio CLIPPED, " AND 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_no ",
|
|
" ORDER BY b.cod_mov,b.sec_a,b.cod_n,b.cod_grupo,b.cod_tipo,b.cod_sec"
|
|
DISPLAY select_ac
|
|
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 ="edprrp125.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.mes_ini <= p_mes) and a.mes_fin >= p_mes and a.ano = c_ano 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 descripcion INTO acumulado_arr[idz].descripcion
|
|
FROM cgtb00001
|
|
WHERE cgtb00001.cuenta_no = acumulado.cuenta
|
|
|
|
IF acumulado.consumo < 0 THEN
|
|
LET acumulado.consumo = acumulado.consumo * -1
|
|
END IF
|
|
|
|
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.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 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
|
|
|
|
LET opt = FGL_WINQUESTION("PREGUNTA","Desea afectar al mayor?","yes","Yes|no","question",0)
|
|
|
|
LET afecta = UPSHIFT(opt)
|
|
CALL edprrp125(datos_cons.fech_in,datos_cons.fech_fi,detalle,entra,afecta, p_companias.nombre, acumulado_arr)
|
|
|
|
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),
|
|
gasto_ind LIKE irtb00013.costo_st,
|
|
consumo_cuenta DECIMAL(12,2)
|
|
END RECORD
|
|
|
|
DEFINE rango_fecha CHAR(30)
|
|
DEFINE movimiento CHAR(50)
|
|
DEFINE codigo_producto CHAR(100)
|
|
DEFINE hora CHAR(5)
|
|
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
|
|
|
|
BEFORE GROUP OF x.cuenta
|
|
LET total_cuenta = 0
|
|
PRINTX x.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 |