Files
MBS/PROYECTO/cgdir/cgprmt004.4gl
T

1932 lines
66 KiB
Plaintext

{
-----------------------------------------------------------------------------
PROGRAMA : CGPRMT04
OBJETIVO : Mantenimiento Transacciones Entradas de diario
REALIZADO POR : Ing. Juan F. Soto
FECHA : Octubre 15, 1993.
-----------------------------------------------------------------------------
}
GLOBALS "cgprgb000.4gl"
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
dias, registros, pcod_sp, numero_entrada SMALLINT,
secuencia_entrada INT,
xentrada VARCHAR(25),
nom1_emp, nom2_Emp, apell1_Emp, apell2_emp VARCHAR(30),
num_doccxp, num_doccxc VARCHAR(25)
#DEFINE hoy DATE
DEFINE blanco, p_dpto CHAR(1)
DEFINE u_mes SMALLINT
DEFINE
cuadre DECIMAL(12, 2),
cuadrada BOOLEAN
DEFINE nombre_aux CHAR(30)
DEFINE nivel SMALLINT
DEFINE
t_debito, t_credito DECIMAL(12, 2),
tiempo CHAR(4),
ultimo SMALLINT,
numero_ent CHAR(2),
container INT
DEFINE p_ano CHAR(4)
DEFINE p_entrada RECORD
fecha DATE,
entrada_no VARCHAR(25),
tipo LIKE cgtb00004.tipo,
detalles LIKE cgtb00004.detalles,
detalle_1 LIKE cgtb00004.detalles
END RECORD
DEFINE transac DYNAMIC ARRAY OF RECORD
cuenta CHAR(8),
departamento LIKE adtb00001.departamento,
cod_aux LIKE cgtb00004.cod_aux,
cod_sec LIKE cgtb00004.cod_sec,
num_doc LIKE cgtb00004.num_doc,
debito DECIMAL(12, 2),
credito DECIMAL(12, 2)
END RECORD
DEFINE
cuentas1 DYNAMIC ARRAY OF RECORD
cuenta_no LIKE cgtb00001.cuenta_no,
descripcion LIKE cgtb00001.descripcion,
nivel LIKE cgtb00001.nivel
END RECORD,
str_detalles VARCHAR(100),
cheques CHAR(2),
pcuenta_no CHAR(10)
MAIN
DEFER INTERRUPT
CALL ARG_VAL(1) RETURNING usuarios
CALL ARG_VAL(2) RETURNING clave
CALL ARG_VAL(3) RETURNING impresor
# LET usuarios = "jsoto"
# LET clave = "1234"
CONNECT TO "marmotech" AS "IFMX" USER usuarios USING clave
CONNECT TO "smarmotech" AS "MSSQL" USER usuarios USING clave
SELECT a.* INTO p_compania.* FROM companias a
CALL cgprmt004()
END MAIN
FUNCTION cgprmt004()
OPTIONS FORM LINE 8, ERROR LINE 24, COMMENT LINE 22, PROMPT LINE 23
#CALL pantalla()
OPEN FORM cgfmmt004 FROM "cgfmmt004"
DISPLAY FORM cgfmmt004
DISPLAY "cgprmt004" AT 4, 3
DISPLAY "Entradas de diario" AT 6, 31
MENU "OPCION"
ON ACTION nuevo
CALL cgpcad004()
ON ACTION buscar
CALL cgpcmf004()
# ON ACTION entradas
# LET INT_FLAG = FALSE
# CALL cheques1()
ON ACTION salir
EXIT MENU
END MENU
END FUNCTION
####### Funcion para agregar una entrada de diario
FUNCTION cgpcad004()
DEFINE x RECORD
id INTEGER,
ref VARCHAR(25),
cuenta_no LIKE cgtb00004.cuenta_no,
departamento LIKE cgtb00004.departamento,
cod_aux LIKE cgtb00004.cod_aux,
cod_sec LIKE cgtb00004.cod_sec,
num_doc LIKE cgtb00004.num_doc,
debito LIKE cgtb00004.debito,
credito LIKE cgtb00004.credito
END RECORD
DEFINE
fecha1, fecha2 DATE,
pdescripcion CHAR(30)
LET hoy = TODAY
LABEL vuelve:
IF opt IS NULL OR opt = "S" THEN
LET p_entrada.entrada_no = NULL
END IF
INPUT BY NAME p_entrada.*, preview, cheques WITHOUT DEFAULTS
BEFORE INPUT
LET preview = 0
LET p_entrada.tipo = 1
DISPLAY BY NAME p_entrada.tipo
BEFORE FIELD fecha
LET p_entrada.fecha = hoy
LET p_ano = YEAR(TODAY) USING "&&&&"
LET p_entrada.entrada_no = 'ED. - /'
LET p_entrada.entrada_no[13, 14] = MONTH(TODAY) USING "&&"
LET p_entrada.entrada_no[15, 16] = p_ano[3, 4]
DISPLAY BY NAME p_entrada.fecha, p_entrada.entrada_no
AFTER FIELD fecha
IF p_entrada.fecha IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha
END IF
IF p_entrada.fecha > TODAY THEN
CALL msg(57)
NEXT FIELD fecha
END IF
LET hoy = p_entrada.fecha
#------------------------------------------------------------------------
LET p_fechas = p_entrada.fecha #USING "dd/mm/yyyy"
CALL prd(p_fechas, usuarios) RETURNING bandera
IF bandera = 1 THEN
LET bandera = 0
NEXT FIELD fecha
END IF
LET p_entrada.fecha = hoy
LET p_ano = YEAR(p_entrada.fecha) USING "&&&&"
LET p_entrada.entrada_no = 'ED. - /'
LET p_entrada.entrada_no[13, 14] = MONTH(p_entrada.fecha) USING "&&"
LET p_entrada.entrada_no[15, 16] = p_ano[3, 4]
DISPLAY BY NAME p_entrada.fecha, p_entrada.entrada_no
#------------------------------------------------------------------------
AFTER FIELD entrada_no
DISPLAY "ANTES DEL CONTAINER: ",p_entrada.entrada_no
-- NUEVA FUNCION
LET container = p_entrada.entrada_no[4, 5]
CALL controlNumericoED(
container, p_entrada.fecha, NULL)
RETURNING p_entrada.entrada_no
LET container = numero_ent
DISPLAY BY NAME p_entrada.entrada_no
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
LET dias = TODAY - p_entrada.fecha
END INPUT
IF opt = "YES" OR opt IS NULL THEN
CALL transac.clear()
END IF
IF cheques = "ED" THEN
SET CONNECTION "IFMX"
INPUT BY NAME xentrada
AFTER FIELD xentrada
IF xentrada IS NULL THEN
CALL msg(16)
NEXT FIELD xentrada
END IF
SELECT DISTINCT a.ref
FROM cgtb00004 a
WHERE a.ref = xentrada AND a.status_t IS NULL
IF STATUS = NOTFOUND THEN
CALL msg(3)
NEXT FIELD xentrada
END IF
AFTER INPUT
IF INT_FLAG THEN
CALL msg(2)
LET INT_FLAG = FALSE
EXIT INPUT
ELSE
DECLARE busca_entrada1 CURSOR FOR
SELECT A.CUENTA_NO,
c.DEPARTAMENTO,
SUM(c.DEBITO),
SUM(c.CREDITO)
FROM cgtb00001 a, cgtb00004 c
WHERE a.cuenta_no = c.cuenta_no
AND c.status_t IS NULL
AND c.ref = xentrada
GROUP BY A.CUENTA_NO, c.DEPARTAMENTO
LET idx = 1
FOREACH busca_entrada1
INTO transac[idx].cuenta,
transac[idx].departamento,
transac[idx].debito,
transac[idx].credito
LET idx = idx + 1
END FOREACH
END IF
END INPUT
END IF
IF cheques = "CK" THEN
SET CONNECTION "IFMX"
INPUT BY NAME fecha1, fecha2, pcuenta_no
AFTER FIELD pcuenta_no
SELECT a.descripcion
INTO pdescripcion
FROM cgtb00001 a
WHERE a.cuenta_no = pcuenta_no AND a.status_t IS NULL
IF STATUS = NOTFOUND THEN
CALL msg(3)
NEXT FIELD pcuenta_no
END IF
DISPLAY BY NAME pdescripcion
AFTER INPUT
EXIT INPUT
END INPUT
DECLARE busca_cheques CURSOR FOR
SELECT A.CUENTA_NO, c.DEPARTAMENTO, SUM(c.DEBITO), SUM(c.CREDITO)
FROM cgtb00001 a, cgtb00004 c
WHERE a.cuenta_no = c.cuenta_no
AND c.status_t IS NULL
AND c.fecha BETWEEN fecha1 AND fecha2
AND detalles = pcuenta_no
GROUP BY A.CUENTA_NO, c.DEPARTAMENTO
ORDER BY a.cuenta_no
LET idx = 1
FOREACH busca_cheques
INTO transac[idx].cuenta,
transac[idx].departamento,
transac[idx].debito,
transac[idx].credito
LET idx = idx + 1
END FOREACH
END IF
IF cheques = "CP" THEN
SET CONNECTION "IFMX"
INPUT BY NAME pcod_sp, fecha1, fecha2
AFTER FIELD pcod_sp
IF pcod_sp IS NULL THEN
CALL msg(16)
NEXT FIELD pcod_sp
END IF
AFTER FIELD fecha2
SELECT COUNT(*)
INTO registros
FROM cptb00003 a
WHERE a.fecha BETWEEN fecha1 AND fecha2
AND a.cod_sp = pcod_sp
AND a.status_t IS NULL
IF registros < 0 OR registros IS NULL THEN
CALL msg(3)
NEXT FIELD fecha1
END IF
AFTER INPUT
EXIT INPUT
END INPUT
DECLARE busca_cxp CURSOR FOR
SELECT A.CUENTA_NO,
a.DEPARTAMENTO,
a.cod_aux,
a.cod_sec,
a.num_doc,
SUM(a.DEBITO),
SUM(a.CREDITO)
FROM cptb00003 a
WHERE a.status_t IS NULL
AND a.cod_sp = pcod_sp
AND a.fecha BETWEEN fecha1 AND fecha2
GROUP BY A.CUENTA_NO,
a.DEPARTAMENTO,
a.cod_aux,
a.cod_Sec,
a.num_doc
ORDER BY a.num_doc DESC, 6 DESC, 2
LET idx = 1
FOREACH busca_cxp
INTO transac[idx].cuenta,
transac[idx].departamento,
transac[idx].cod_aux,
transac[idx].cod_sec,
transac[idx].num_doc,
transac[idx].debito,
transac[idx].credito
LET idx = idx + 1
END FOREACH
END IF
SET CONNECTION "MSSQL"
## AQUI SE INTRODUCEN LOS DATOS DEL ARREGLO
LABEL volver:
INPUT ARRAY transac WITHOUT DEFAULTS FROM s_trx.*
# Para moverse dentro del arreglo
ON KEY(CONTROL-P)
NEXT FIELD cuenta
## VENTANA PARA BUSCAR LAS CUENTAS CONTABLES
ON ACTION bcuenta
LET curr = arr_curr()
LET scr_l = scr_line()
CALL busca_cuenta()
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
NEXT FIELD cuenta
END IF
IF existe = "N" THEN
LET existe = "S"
NEXT FIELD cuenta
END IF
LET descrip = cuentas1[curr1].descripcion
LET transac[curr].cuenta = cuentas1[curr1].cuenta_no
DISPLAY transac[curr].cuenta TO s_trx[scr_l].cuenta
DISPLAY BY NAME descrip
LET verdad = "N"
#CALL otravez()
IF verdad = "S" THEN
NEXT FIELD cuenta
END IF
NEXT FIELD cuenta
ON ACTION empleados
LET scr_l = scr_line()
IF transac[curr].cod_aux = '01' THEN
CALL busca_empleado1()
RETURNING transac[curr].cod_sec,
nom1_emp,
nom2_emp,
apell1_emp,
apell2_emp
LET nombre_aux = nom1_emp CLIPPED, ' ', apell1_emp CLIPPED
DISPLAY BY NAME nombre_aux
DISPLAY transac[curr].cod_sec TO s_trx[scr_l].cod_Sec
DISPLAY transac[curr].cod_sec TO s_trx[scr_l].cod_Sec
END IF
BEFORE ROW
LET curr = arr_curr()
LET scr_l = scr_line()
AFTER FIELD cuenta
IF transac[curr].cuenta IS NOT NULL THEN
LET verdad = "N"
#CALL otravez()
IF verdad = "S" THEN
NEXT FIELD cuenta
END IF
SELECT UNIQUE a.descripcion, a.depto, a.nivel, a.ref, a.cata
INTO descrip, p_dpto, nivel, p_ref, p_cata
FROM cgtb00001 a
WHERE a.cuenta_no = transac[curr].cuenta
AND a.status_t IS NULL
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cuenta
END IF
IF nivel < 3 THEN
LET numero_msg = 175
CALL msg(numero_msg)
NEXT FIELD cuenta
END IF
DISPLAY BY NAME descrip
IF p_dpto = "S" THEN
NEXT FIELD departamento
ELSE
LET transac[curr].departamento = NULL
LET nombre = NULL
END IF
IF p_cata = "S" THEN
NEXT FIELD cod_aux
ELSE
LET transac[curr].cod_aux = NULL
LET transac[curr].cod_sec = NULL
END IF
IF p_ref = "S" THEN
NEXT FIELD num_doc
ELSE
LET transac[curr].num_doc = NULL
END IF
NEXT FIELD debito
END IF
AFTER FIELD departamento
IF transac[curr].cuenta IS NOT NULL THEN
IF p_dpto = "S" THEN
IF transac[curr].departamento IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD departamento
END IF
SELECT a.nom_dpto
INTO nombre
FROM adtb00001 a
WHERE a.departamento = transac[curr].departamento
AND a.status_t IS NULL
IF status = NOTFOUND THEN
LET numero_msg = 134
CALL msg(numero_msg)
NEXT FIELD departamento
END IF
DISPLAY BY NAME nombre
END IF
DISPLAY BY NAME nombre
IF p_cata = "S" THEN
NEXT FIELD cod_aux
ELSE
IF p_ref = "S" THEN
NEXT FIELD num_doc
ELSE
NEXT FIELD debito
END IF
END IF
NEXT FIELD debito
END IF
AFTER FIELD cod_aux
IF transac[curr].cuenta IS NOT NULL THEN
IF p_cata = "S" THEN
IF transac[curr].cod_aux IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
ELSE
DISPLAY transac[curr].cod_sec TO s_trx[scr_l].cod_sec
IF p_ref = "S" THEN
NEXT FIELD num_doc
ELSE
NEXT FIELD debito
END IF
END IF
END IF
AFTER FIELD num_doc
IF transac[curr].cuenta IS NOT NULL THEN
IF p_ref = "S" THEN
IF transac[curr].num_doc IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD num_doc
END IF
END IF
END IF
AFTER FIELD cod_sec
IF transac[curr].cuenta IS NOT NULL THEN
IF p_cata = "S" THEN
IF transac[curr].cod_sec IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_sec
END IF
LET existe = "S"
IF transac[curr].cod_aux != 1 THEN
# Busqueda de suplidores
SELECT a.nom_sp
INTO nombre_aux
FROM cotb00001 a
WHERE a.cod_sp = transac[curr].cod_aux
AND a.cod_sp_sec = transac[curr].cod_sec
AND a.status_t IS NULL
IF status = NOTFOUND THEN
LET existe = "N"
END IF
# Busqueda de clientes
IF existe = "N" THEN
SELECT a.nombre
INTO nombre_aux
FROM vetb00004 a
WHERE a.tipo_cliente = transac[curr].cod_aux
AND a.sec_cliente = transac[curr].cod_sec
AND a.status_t IS NULL
IF status = NOTFOUND THEN
LET numero_msg = 200
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
END IF
# Busqueda de nombre del empleado
IF transac[curr].cod_aux = 1 THEN
SELECT a.nom1_emp
INTO nombre_aux
FROM adtb00003 a
WHERE a.num_emp = transac[curr].cod_sec
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
END IF
END IF
END IF
DISPLAY BY NAME nombre_aux
IF p_ref = "S" THEN
NEXT FIELD num_doc
ELSE
NEXT FIELD debito
END IF
END IF
AFTER FIELD debito
LET t_debito = 0
FOR idx = 1 TO arr_count()
IF transac[idx].debito IS NULL THEN
LET transac[idx].debito = 0
END IF
LET t_debito = transac[idx].debito + t_debito
END FOR
DISPLAY BY NAME t_debito
IF p_dpto = "N" THEN
LET transac[curr].departamento = NULL
END IF
IF p_ref = "N" THEN
LET transac[curr].num_doc = NULL
END IF
NEXT FIELD credito
AFTER FIELD credito
LET t_credito = 0
IF transac[curr].credito IS NOT NULL THEN
FOR idx = 1 TO arr_count()
IF transac[idx].credito IS NULL THEN
LET transac[idx].credito = 0
END IF
LET t_credito = transac[idx].credito + t_credito
END FOR
END IF
DISPLAY BY NAME t_credito
IF transac[curr].cuenta IS NOT NULL THEN
IF transac[curr].debito IS NULL OR transac[curr].debito = 0 THEN
IF transac[curr].credito IS NULL
OR transac[curr].credito = 0 THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta
END IF
END IF
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
CLEAR FORM
RETURN
END IF
FOR idx = 1 TO transac.getLength()
IF transac[idx].cuenta IS NOT NULL THEN
SELECT UNIQUE a.descripcion, a.depto, a.nivel, a.ref, a.cata
INTO descrip, p_dpto, nivel, p_ref, p_cata
FROM cgtb00001 a
WHERE a.cuenta_no = transac[idx].cuenta
AND a.status_t IS NULL
IF status = NOTFOUND THEN
LET scr_l = scr_line()
LET numero_msg = 3
CALL msg(numero_msg)
DISPLAY transac[idx].cuenta
TO s_trx[scr_l].cuenta
ATTRIBUTE(RED)
DISPLAY BY NAME descrip ATTRIBUTE(RED)
NEXT FIELD cuenta
END IF
IF nivel < 3 THEN
LET numero_msg = 175
CALL msg(numero_msg)
NEXT FIELD cuenta
END IF
END IF
END FOR
IF transac[curr].cuenta IS NOT NULL THEN
IF transac[curr].debito IS NULL OR transac[curr].debito = 0 THEN
IF transac[curr].credito IS NULL
OR transac[curr].credito = 0 THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta
END IF
END IF
END IF
CALL verificada()
IF NOT cuadrada THEN
CONTINUE INPUT
LET numero_msg = 174
CALL msg(numero_msg)
END IF
EXIT INPUT
END INPUT
LET opt =
fgl_winquestion(
"Impresion",
"Toda la Informacion esta correcta?",
"YES",
"YES|No",
"question",
1)
IF opt = "YES" THEN
LET cuadre = 0
LET t_debito = 0
LET t_credito = 0
FOR idx = 1 TO transac.getLength()
IF transac[idx].debito IS NULL THEN
LET transac[idx].debito = 0
END IF
IF transac[idx].credito IS NULL THEN
LET transac[idx].credito = 0
END IF
LET t_debito = transac[idx].debito + t_debito
LET t_credito = transac[idx].credito + t_credito
LET cuadre = cuadre + (transac[idx].debito - transac[idx].credito)
END FOR
DISPLAY BY NAME t_credito
DISPLAY BY NAME t_debito
# Control para que el usuario no digite las cuentas1 en blanco
LET blanco = "S"
FOR idx = 1 TO arr_count()
IF transac[idx].cuenta IS NOT NULL THEN
LET blanco = "N"
END IF
END FOR
IF blanco = "S" THEN
LET numero_msg = 84
CALL msg(numero_msg)
RETURN
END IF
#------------------------------------------------------------------------------
IF cuadre != 0 THEN
LET numero_msg = 174
CALL msg(numero_msg)
GOTO volver
END IF
LET r_filename = "cgprmt004.4rp"
LET r_output = "SVG"
#LET preview = 1
-- configure report engine; the functions prefixed fgl that are called here are part of the GRW API
IF fgl_report_loadCurrentSettings(r_filename) THEN -- load the .4rp file
CALL fgl_report_selectDevice(r_output) -- changing default
IF preview = 0 THEN
CALL fgl_report_selectPreview(1) -- changing default
CALL fgl_report_configureSVGPreview("PrintOnDefaultPrinter")
ELSE
CALL fgl_report_selectPreview(preview)
END IF
LET handler = fgl_report_commitCurrentSettings() -- commit changes
ELSE
EXIT PROGRAM
END IF
--run the report
IF handler IS NOT NULL THEN -- report engine was configured ok
START REPORT imp_entrada4 TO XML HANDLER HANDLER
BEGIN WORK
INITIALIZE container TO NULL
DISPLAY "ANTES DEL INSERT: ",p_entrada.entrada_no[4,5]
LET container = p_entrada.entrada_no[4, 5]
CALL controlNumericoED(
container, p_entrada.fecha, usuarios)
RETURNING p_entrada.entrada_no
LET container = numero_ent
DISPLAY BY NAME p_entrada.entrada_no
CALL validarFormatoEntrada(p_entrada.entrada_no) RETURNING bandera
IF bandera = 1 THEN
ROLLBACK WORK
RETURN
END IF
# INFORMACIONES GENERALES DE LA ENTRADA AL DIARIO
INSERT INTO cgtb00006(
fecha,
numero_entrada,
secuencia_entrada,
mes,
periodo,
ref,
detalle,
informacion,
cod_sp,
fecha_inicial,
fecha_final,
cuenta_no,
us_crea,
fech_crea)
VALUES(p_entrada.fecha,
numero_entrada,
ultimo,
u_mes,
tiempo,
p_entrada.entrada_no,
str_detalles,
cheques,
pcod_sp,
fecha1,
fecha2,
pcuenta_no,
usuarios,
getdate())
FOR idx = 1 TO arr_count()
IF transac[idx].cuenta IS NOT NULL THEN
IF transac[idx].debito IS NULL THEN
LET transac[idx].debito = 0
END IF
IF transac[idx].credito IS NULL THEN
LET transac[idx].credito = 0
END IF
INSERT INTO cgtb00004(
fecha,
tipo,
ref,
cuenta_no,
departamento,
num_doc,
cod_aux,
cod_Sec,
detalle_1,
detalle_2,
debito,
credito,
us_crea,
fech_crea)
VALUES(p_entrada.fecha,
p_entrada.tipo,
p_entrada.entrada_no,
transac[idx].cuenta,
transac[idx].departamento,
transac[idx].num_doc,
transac[idx].cod_aux,
transac[idx].cod_sec,
p_entrada.detalles,
p_entrada.detalle_1,
transac[idx].debito,
transac[idx].credito,
usuarios,
GETDATE())
IF STATUS < 0 THEN
ROLLBACK WORK
CALL msg(1663)
RETURN
END IF
LET x.id = idx
LET x.ref = p_entrada.entrada_no
LET x.cuenta_no = transac[idx].cuenta
LET x.departamento = transac[idx].departamento
LET x.cod_aux = transac[idx].cod_aux
LET x.cod_sec = transac[idx].cod_sec
LET x.num_doc = transac[idx].num_doc
LET x.debito = transac[idx].debito
LET x.credito = transac[idx].credito
OUTPUT TO REPORT imp_entrada4(x.*)
END IF
END FOR
{ UPDATE cgtb00011
SET referencia = referencia + 1,
us_mod = usuarios,
fech_mod = getdate()
WHERE entrada_no = container}
COMMIT WORK
FINISH REPORT imp_entrada4
END IF
CALL integridad()
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
LET numero_msg = 1
CALL msg(numero_msg)
CLEAR FORM
END IF
CLEAR FORM
CALL transac.clear()
GOTO vuelve
END FUNCTION
## Funcion para consultar/modificar una entrada de diario
FUNCTION cgpcmf004()
DEFINE x RECORD
id INTEGER,
ref VARCHAR(25),
cuenta_no LIKE cgtb00004.cuenta_no,
departamento LIKE cgtb00004.departamento,
cod_aux LIKE cgtb00004.cod_aux,
cod_sec LIKE cgtb00004.cod_sec,
num_doc LIKE cgtb00004.num_doc,
debito LIKE cgtb00004.debito,
credito LIKE cgtb00004.credito
END RECORD
DEFINE usuario RECORD
us_crea CHAR(9),
fech_crea LIKE cgtb00004.fech_crea
END RECORD
# WHENEVER ERROR CONTINUE
## SE PREPARA EL CRITERIO PARA CONSULTAR/MODIFICAR UN REGISTRO
CONSTRUCT CRITERIO ON a.fecha, a.ref FROM fecha, entrada_no
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
CLEAR FORM
RETURN
END IF
LET selec =
"SELECT DISTINCT CONVERT(char(10),a.fecha,103),a.ref,a.tipo,a.detalle_1,a.detalle_2 ",
"FROM cgtb00004 a ",
"WHERE ",
criterio CLIPPED,
" AND a.tipo IN(1,3) ORDER BY CONVERT(char(10),a.fecha,103),a.ref"
DISPLAY "seleccion: ", selec
PREPARE busca FROM selec
DECLARE datos SCROLL CURSOR FOR busca
OPEN datos
FETCH FIRST datos INTO p_entrada.*
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
RETURN
END IF
CALL informacionAux()
DISPLAY BY NAME p_entrada.*
MENU "OPCION"
COMMAND "Siguiente"
"Presenta en pantalla el proximo registro encontrado"
FETCH NEXT datos INTO p_entrada.*
IF status = NOTFOUND THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
CALL informacionAux()
DISPLAY BY NAME p_entrada.*
COMMAND "Anterior"
"Presenta en pantalla el registro anterior encontrado"
FETCH PREVIOUS datos INTO p_entrada.*
IF status = NOTFOUND THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
CALL informacionAux()
DISPLAY BY NAME p_entrada.*
COMMAND "Primero" "Presenta en pantalla el primer registro encontrado"
FETCH FIRST datos INTO p_entrada.*
IF status = NOTFOUND THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
CALL informacionAux()
DISPLAY BY NAME p_entrada.*
COMMAND "Ultimo" "Presenta en pantalla el ultimo registro encontrado"
FETCH LAST datos INTO p_entrada.*
IF status = NOTFOUND THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
CALL informacionAux()
DISPLAY BY NAME p_entrada.*
COMMAND "Escoger"
"<Esc> Actualiza Registro <Ctrl-C> Cancela Operacion"
# IF num_doccxp IS NOT NULL THEN
# CALL msg(383)
# CONTINUE MENU
# END IF
# IF num_doccxc IS NOT NULL THEN
# CALL msg(383)
# CONTINUE MENU
# END IF
## AQUI SE MODIFICAN/ACTUALIZAN LOS DATOS DEL REGISTRO
LET p_fechas = p_entrada.fecha
CALL prd(p_fechas, usuarios) RETURNING bandera
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
INPUT BY NAME p_entrada.fecha,
p_entrada.tipo,
p_entrada.detalles,
p_entrada.detalle_1,
preview
WITHOUT DEFAULTS
BEFORE INPUT
LET preview = 0
AFTER FIELD fecha
IF p_entrada.fecha IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha
END IF
LET hoy = p_entrada.fecha
LET p_fechas = p_entrada.fecha
CALL prd(p_fechas, usuarios) RETURNING bandera
{IF year(p_fechas) <> year(TODAY) THEN
LET numero_msg = 59
CALL msg(numero_msg)
NEXT FIELD fecha
END IF}
IF bandera = 1 THEN
LET bandera = 0
#NEXT FIELD fecha
END IF
AFTER INPUT
EXIT INPUT
END INPUT
CALL transac.clear()
DECLARE buscar1 CURSOR FOR
SELECT a.cuenta_no,
a.departamento,
a.cod_aux,
a.cod_sec,
a.num_doc,
a.debito,
a.credito
FROM cgtb00004 a
WHERE a.ref = p_entrada.entrada_no AND a.status_t IS NULL
LET idx = 1
FOREACH buscar1 INTO transac[idx].*
LET idx = idx + 1
END FOREACH
CALL set_count(idx - 1)
## AQUI SE MODIFICAN/ACTUALIZAN LOS CAMPOS DEL ARREGLO
LABEL volver1:
INPUT ARRAY transac WITHOUT DEFAULTS FROM s_trx.*
ON KEY(CONTROL-P)
NEXT FIELD cuenta
## VENTANA PARA BUSCAR LAS CUENTAS CONTABLES
ON ACTION bcuenta
LET curr = arr_curr()
LET scr_l = scr_line()
CALL busca_cuenta()
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
NEXT FIELD cuenta
END IF
IF existe = "N" THEN
LET existe = "S"
NEXT FIELD cuenta
END IF
LET descrip = cuentas1[curr1].descripcion
LET transac[curr].cuenta = cuentas1[curr1].cuenta_no
DISPLAY transac[curr].cuenta TO s_trx[scr_l].cuenta
DISPLAY BY NAME descrip
LET verdad = "N"
#CALL otravez()
IF verdad = "S" THEN
NEXT FIELD cuenta
END IF
NEXT FIELD cuenta
ON ACTION empleados
IF transac[curr].cod_aux = '01' THEN
CALL busca_empleado1()
RETURNING transac[curr].cod_sec,
nom1_emp,
nom2_emp,
apell1_emp,
apell2_emp
LET nombre_aux =
nom1_emp CLIPPED, ' ', apell1_emp CLIPPED
DISPLAY BY NAME nombre_aux
END IF
BEFORE ROW
LET curr = arr_curr()
LET scr_l = scr_line()
AFTER FIELD cuenta
IF transac[curr].cuenta IS NOT NULL THEN
LET verdad = "N"
#CALL otravez()
IF verdad = "S" THEN
NEXT FIELD cuenta
END IF
SELECT UNIQUE a.descripcion,
a.depto,
a.nivel,
a.ref,
a.cata
INTO descrip, p_dpto, nivel, p_ref, p_cata
FROM cgtb00001 a
WHERE a.cuenta_no = transac[curr].cuenta
AND a.status_t IS NULL
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cuenta
END IF
IF nivel < 3 THEN
LET numero_msg = 175
CALL msg(numero_msg)
NEXT FIELD cuenta
END IF
DISPLAY BY NAME descrip
IF p_dpto = "S" THEN
NEXT FIELD departamento
ELSE
LET transac[curr].departamento = NULL
LET nombre = NULL
END IF
IF p_cata = "S" THEN
NEXT FIELD cod_aux
ELSE
LET transac[curr].cod_aux = NULL
LET transac[curr].cod_sec = NULL
END IF
IF p_ref = "S" THEN
NEXT FIELD num_doc
ELSE
LET transac[curr].num_doc = NULL
END IF
NEXT FIELD debito
END IF
AFTER FIELD departamento
IF transac[curr].cuenta IS NOT NULL THEN
IF p_dpto = "S" THEN
IF transac[curr].departamento IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD departamento
END IF
SELECT a.nom_dpto
INTO nombre
FROM adtb00001 a
WHERE a.departamento
=
transac[curr].departamento
AND a.status_t IS NULL
IF status = NOTFOUND THEN
LET numero_msg = 134
CALL msg(numero_msg)
NEXT FIELD departamento
END IF
DISPLAY BY NAME nombre
END IF
IF p_cata = "S" THEN
NEXT FIELD cod_aux
ELSE
IF p_ref = "S" THEN
NEXT FIELD num_doc
END IF
END IF
END IF
NEXT FIELD debito
AFTER FIELD cod_aux
IF transac[curr].cuenta IS NOT NULL THEN
IF p_cata = "S" THEN
IF transac[curr].cod_aux IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
ELSE
LET transac[curr].cod_aux = NULL
DISPLAY transac[curr].cod_aux
TO s_trx[scr_l].cod_aux
IF p_ref = "S" THEN
NEXT FIELD num_doc
ELSE
NEXT FIELD debito
END IF
END IF
END IF
AFTER FIELD num_doc
IF transac[curr].cuenta IS NOT NULL THEN
IF p_ref = "S" THEN
IF transac[curr].num_doc IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD num_doc
END IF
END IF
NEXT FIELD debito
END IF
AFTER FIELD cod_sec
IF transac[curr].cuenta IS NOT NULL THEN
IF p_cata = "S" THEN
IF transac[curr].cod_sec IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_sec
END IF
LET existe = "S"
IF transac[curr].cod_aux != 1 THEN
# Busqueda de suplidores
SELECT a.nom_sp
INTO nombre_aux
FROM cotb00001 a
WHERE a.cod_sp = transac[curr].cod_aux
AND a.cod_sp_sec = transac[curr].cod_sec
AND a.status_t IS NULL
IF status = NOTFOUND THEN
LET existe = "N"
END IF
# Busqueda de clientes
IF existe = "N" THEN
SELECT a.nombre
INTO nombre_aux
FROM vetb00004 a
WHERE a.tipo_cliente
=
transac[curr].cod_aux
AND a.sec_cliente
=
transac[curr].cod_sec
AND a.status_t IS NULL
IF status = NOTFOUND THEN
LET numero_msg = 200
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
END IF
# Busqueda de nombre del empleado
IF transac[curr].cod_aux = 1 THEN
SELECT a.nom1_emp
INTO nombre_aux
FROM adtb00003 a
WHERE a.num_emp = transac[curr].cod_sec
IF status = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
END IF
END IF
END IF
IF p_ref = "S" THEN
NEXT FIELD num_doc
ELSE
NEXT FIELD debito
END IF
DISPLAY BY NAME nombre_aux
NEXT FIELD debito
END IF
AFTER FIELD debito
LET t_debito = 0
IF transac[curr].debito IS NOT NULL THEN
FOR idx = 1 TO arr_count()
IF transac[idx].debito IS NULL THEN
LET transac[idx].debito = 0
END IF
LET t_debito = transac[idx].debito + t_debito
END FOR
END IF
DISPLAY BY NAME t_debito
AFTER FIELD credito
LET t_credito = 0
IF transac[curr].credito IS NOT NULL THEN
FOR idx = 1 TO arr_count()
IF transac[idx].credito IS NULL THEN
LET transac[idx].credito = 0
END IF
LET t_credito = transac[idx].credito + t_credito
END FOR
END IF
DISPLAY BY NAME t_credito
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
CLEAR FORM
RETURN
END IF
IF transac[curr].cuenta IS NOT NULL THEN
IF transac[curr].debito IS NULL
OR transac[curr].debito = 0 THEN
IF transac[curr].credito IS NULL
OR transac[curr].credito = 0 THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta
END IF
END IF
END IF
CALL verificada()
IF NOT cuadrada THEN
CONTINUE INPUT
LET numero_msg = 174
CALL msg(numero_msg)
END IF
EXIT INPUT
END INPUT
# Control para que el usuario no digite las cuentas1 en blanco
LET blanco = "S"
FOR idx = 1 TO arr_count()
IF transac[idx].cuenta IS NOT NULL THEN
LET blanco = "N"
END IF
END FOR
IF blanco = "S" THEN
LET numero_msg = 84
CALL msg(numero_msg)
RETURN
END IF
#------------------------------------------------------------------------------
## AQUI SE REALIZA LA MODIFICACION DEL REGISTRO
{
DELETE FROM cgtb00004 WHERE
cgtb00004.ref = p_entrada.entrada_no
}
#CALL defecto(usuarios,clave,impresor) RETURNING imprime,negrilla_on,negrillas_of,
# doble_on,doble_off,comp_on,comp_off,
# doce,normal,archivo
#CALL seleccionarSalida() RETURNING r_output
LET r_filename = "cgprmt004.4rp"
# LET preview = 1
LET r_output = "SVG"
-- configure report engine; the functions prefixed fgl that are called here are part of the GRW API
IF fgl_report_loadCurrentSettings(
r_filename) THEN -- load the .4rp file
CALL fgl_report_selectDevice(r_output) -- changing default
IF preview = 0 THEN
CALL fgl_report_selectPreview(1) -- changing default
CALL fgl_report_configureSVGPreview("PrintOnDefaultPrinter")
ELSE
CALL fgl_report_selectPreview(preview)
END IF
LET handler =
fgl_report_commitCurrentSettings() -- commit changes
ELSE
EXIT PROGRAM
END IF
--run the report
IF handler IS NOT NULL THEN -- report engine was configured ok
START REPORT imp_entrada4 TO XML HANDLER HANDLER
BEGIN WORK
DELETE FROM cgtb00004 WHERE cgtb00004.ref = p_entrada.entrada_no
IF STATUS < 0 THEN
ROLLBACK WORK
CALL msg(1663)
RETURN
END IF
FOR idx = 1 TO arr_count()
IF transac[idx].cuenta IS NOT NULL THEN
IF transac[idx].debito IS NULL THEN
LET transac[idx].debito = 0
END IF
IF transac[idx].credito IS NULL THEN
LET transac[idx].credito = 0
END IF
INSERT INTO cgtb00004(
fecha,
tipo,
ref,
cuenta_no,
departamento,
num_doc,
cod_aux,
cod_Sec,
detalle_1,
detalle_2,
debito,
credito,
us_crea,
fech_crea)
VALUES(p_entrada.fecha,
p_entrada.tipo,
p_entrada.entrada_no,
transac[idx].cuenta,
transac[idx].departamento,
transac[idx].num_doc,
transac[idx].cod_aux,
transac[idx].cod_sec,
p_entrada.detalles,
p_entrada.detalle_1,
transac[idx].debito,
transac[idx].credito,
usuarios,
GETDATE())
IF STATUS < 0 THEN
ROLLBACK WORK
CALL msg(1663)
RETURN
END IF
LET x.id = idx
LET x.ref = p_entrada.entrada_no
LET x.cuenta_no = transac[idx].cuenta
LET x.departamento = transac[idx].departamento
LET x.cod_aux = transac[idx].cod_aux
LET x.cod_sec = transac[idx].cod_sec
LET x.num_doc = transac[idx].num_doc
LET x.debito = transac[idx].debito
LET x.credito = transac[idx].credito
OUTPUT TO REPORT imp_entrada4(x.*)
END IF
END FOR
COMMIT WORK
FINISH REPORT imp_entrada4
END IF
DISPLAY BY NAME p_entrada.fecha, p_entrada.entrada_no
LET numero_msg = 13
CALL msg(numero_msg)
## AQUI SE REALIZA LA ANULACION DE UN REGISTRO
COMMAND KEY("N") "aNular"
SET CONNECTION "MSSQL"
SELECT UNIQUE a.fecha
INTO p_fechas
FROM cgtb00004 a
WHERE a.ref = p_entrada.entrada_no
CALL prd(p_fechas, usuarios) RETURNING bandera
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
LET opt3 =
fgl_winquestion(
"ANULAR",
"ESTA SEGURO DE ANULAR ESTA ENTRADA?",
"NO",
"NO|YES",
"QUESTION",
0)
IF opt3 = "YES" THEN
UPDATE cgtb00004
SET status_t = "E", us_mod = usuarios, fech_mod = getdate()
WHERE cgtb00004.ref = p_entrada.entrada_no
LET numero_msg = 82
CALL msg(numero_msg)
END IF
ON ACTION imprimir ATTRIBUTE(TEXT = "Imprime", IMAGE = 'print')
CALL impresion()
COMMAND "Retornar"
CLOSE datos
CLEAR FORM
FOR idx = 1 TO 3
LET transac[idx].cuenta = NULL
LET transac[idx].departamento = NULL
LET transac[idx].cod_aux = NULL
LET transac[idx].cod_sec = NULL
LET transac[idx].num_doc = NULL
LET transac[idx].debito = NULL
LET transac[idx].credito = NULL
DISPLAY transac[idx].cuenta TO s_trx[idx].cuenta
DISPLAY transac[idx].departamento TO s_trx[idx].departamento
DISPLAY transac[idx].cod_aux TO s_trx[idx].cod_aux
DISPLAY transac[idx].cod_sec TO s_trx[idx].cod_sec
DISPLAY transac[idx].num_doc TO s_trx[idx].num_doc
DISPLAY transac[idx].debito TO s_trx[idx].debito
DISPLAY transac[idx].credito TO s_trx[idx].credito
END FOR
EXIT MENU
END MENU
END FUNCTION
FUNCTION otravez()
DEFINE contar RECORD
cuenta CHAR(8)
END RECORD
LET contar.cuenta = transac[curr].cuenta
FOR idx = 1 TO arr_count()
IF idx != curr THEN
IF transac[idx].cuenta IS NOT NULL THEN
IF transac[idx].cuenta = contar.cuenta THEN
LET numero_msg = 172
CALL msg(numero_msg)
LET verdad = "S"
ELSE
IF verdad != "S" THEN
LET verdad = "N"
END IF
END IF
END IF
END IF
END FOR
END FUNCTION
FUNCTION busca_cuenta()
OPEN WINDOW cons_cuenta
AT 10, 5
WITH FORM "cgfmwd004"
ATTRIBUTE(BORDER, FORM LINE FIRST + 1, COMMENT LINE LAST)
CONSTRUCT BY NAME criterio ON descripcion
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
RETURN
END IF
LET selec =
"SELECT cuenta_no,descripcion,nivel FROM cgtb00001 ",
"WHERE ",
criterio CLIPPED,
" AND status_t is null ORDER BY 1"
PREPARE comando FROM selec
DECLARE busca2 CURSOR FOR comando
OPEN busca2
LET idx = 1
WHILE STATUS != NOTFOUND
FETCH busca2 INTO cuentas1[idx].*
IF status = NOTFOUND THEN
EXIT WHILE
END IF
LET idx = idx + 1
END WHILE
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
RETURN
END IF
CALL set_count(idx - 1)
DISPLAY ARRAY cuentas1 TO s_cuentas.*
LET curr1 = arr_curr()
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
RETURN
END IF
CLOSE WINDOW cons_cuenta
END FUNCTION
#### Funcion para dar salida ordenada a la informacion requerida de
#### una entrada de diario de nominas local
REPORT imp_entrada4(x)
DEFINE x RECORD
id INTEGER,
ref VARCHAR(25),
cuenta_no LIKE cgtb00004.cuenta_no,
departamento LIKE cgtb00004.departamento,
cod_aux LIKE cgtb00004.cod_aux,
cod_sec LIKE cgtb00004.cod_sec,
num_doc LIKE cgtb00004.num_doc,
debito LIKE cgtb00004.debito,
credito LIKE cgtb00004.credito
END RECORD
DEFINE fecha1, fecha2 DATE
DEFINE t_debito, t_credito DECIMAL(12, 2)
DEFINE descripcion CHAR(30)
DEFINE doble_on CHAR(2)
DEFINE doble_off CHAR(2)
DEFINE negrillas_on CHAR(6)
DEFINE negrillas_off CHAR(6)
DEFINE comp_on CHAR(2)
DEFINE comp_off CHAR(2)
DEFINE doce CHAR(2)
DEFINE normal CHAR(2)
DEFINE hora CHAR(5)
DEFINE dpto INTEGER
DEFINE nomina1 CHAR(24)
DEFINE
detalle1 CHAR(30),
total_registro SMALLINT,
fecha CHAR(40)
OUTPUT
LEFT MARGIN 0
TOP MARGIN 0
ORDER BY x.id
FORMAT
FIRST PAGE HEADER
LET total_registro = 0
LET t_debito = 0
LET t_credito = 0
LET fecha = TODAY USING "dd/mm/yyyy", ":", TIME
ON EVERY ROW
LET t_credito = t_credito + x.credito
LET t_debito = t_debito + x.debito
LET total_registro = total_registro + 1
SELECT a.descripcion
INTO descripcion
FROM cgtb00001 a
WHERE a.cuenta_no = x.cuenta_no AND a.status_t IS NULL
PRINTX x.*,
descripcion,
p_compania.*,
p_entrada.*,
fecha,
total_registro,
t_credito,
t_debito
END REPORT
FUNCTION entradas()
DEFINE des_entra DYNAMIC ARRAY OF RECORD
procesa CHAR(2),
descripcion VARCHAR(60),
estado VARCHAR(30)
END RECORD
OPEN WINDOW win_entradas
AT 10, 10
WITH FORM "cgfmwd010"
ATTRIBUTE(BORDER, FORM LINE FIRST + 1, COMMENT LINE LAST)
DECLARE busca_Entrada CURSOR FOR
SELECT 'N', a.descripcion, a.prog_4gl
FROM cgtb00011 a
WHERE referencia IS NULL
ORDER BY a.descripcion
LET idx = 1
FOREACH busca_entrada INTO des_entra[idx].*
LET des_Entra[idx].procesa = "N"
LET idx = idx + 1
END FOREACH
CALL set_count(idx - 1)
INPUT ARRAY des_entra WITHOUT DEFAULTS FROM s_entradas.*
AFTER INPUT
LET idx = arr_curr()
# IF des_entra[idx].estado = 'funcion1' THEN
CALL cheques1()
SET CONNECTION "MSSQL"
# END IF
END INPUT
CLOSE WINDOW win_entradas
END FUNCTION
FUNCTION cheques1()
DEFINE
kfecha1, kfecha2 DATE,
kcuenta_no CHAR(10),
kdescripcion VARCHAR(60),
kdetalle DYNAMIC ARRAY OF RECORD
cuenta_no CHAR(10),
descripcion CHAR(60),
departamento INT,
debito DEC(12, 2),
credito DEC(12, 2)
END RECORD
OPEN WINDOW cgfmwd011
AT 15, 10
WITH FORM "cgfmwd011"
ATTRIBUTE(BORDER, FORM LINE FIRST + 1, COMMENT LINE LAST)
SET CONNECTION "IFMX"
INPUT BY NAME kfecha1, kfecha2, kcuenta_no
AFTER FIELD kcuenta_no
IF kcuenta_no IS NOT NULL THEN
SELECT a.descripcion
INTO kdescripcion
FROM cgtb00001 a
WHERE a.cuenta_no = kcuenta_no
IF STATUS = NOTFOUND THEN
CALL msg(3)
NEXT FIELD kcuenta_no
END IF
DISPLAY BY NAME kdescripcion
END IF
# ON ACTION pcuentas
# CALL busca_cuenta()
# DISPLAY BY NAME descripcion
AFTER INPUT
IF kfecha2 > kfecha1 THEN
CALL msg(64)
NEXT FIELD fecha1
END IF
END INPUT
DECLARE busca_ex CURSOR FOR
SELECT A.CUENTA_NO,
A.DESCRIPCION,
c.DEPARTAMENTO,
SUM(c.DEBITO),
SUM(c.CREDITO)
FROM cgtb00001 a, cgtb00004 c
WHERE a.cuenta_no = c.cuenta_no
AND c.status_t IS NULL
AND c.fecha BETWEEN kfecha1 AND kfecha2
AND detalles = kcuenta_no
GROUP BY A.CUENTA_NO, A.DESCRIPCION, c.DEPARTAMENTO
ORDER BY a.cuenta_no
LET idx = 1
FOREACH busca_ex INTO kdetalle[idx].*
LET transac[idx].cuenta = kdetalle[idx].cuenta_no
LET transac[idx].departamento = kdetalle[idx].departamento
LET transac[idx].debito = kdetalle[idx].debito
LET transac[idx].credito = kdetalle[idx].credito
LET idx = idx + 1
END FOREACH
CALL set_count(idx - 1)
CLOSE WINDOW cgfmwd011
END FUNCTION
FUNCTION verificada()
LET cuadrada = FALSE
LET cuadre = 0
FOR idx = 1 TO transac.getLength()
IF transac[idx].debito IS NULL THEN
LET transac[idx].debito = 0
END IF
IF transac[idx].credito IS NULL THEN
LET transac[idx].credito = 0
END IF
LET cuadre = cuadre + (transac[idx].debito - transac[idx].credito)
END FOR
IF cuadre = 0 THEN
LET cuadrada = TRUE
END IF
END FUNCTION
FUNCTION impresion()
DEFINE
x RECORD
id INTEGER,
ref LIKE cgtb00004.ref,
cuenta_no LIKE cgtb00004.cuenta_no,
departamento LIKE cgtb00004.departamento,
cod_aux LIKE cgtb00004.cod_aux,
cod_sec LIKE cgtb00004.cod_sec,
num_doc LIKE cgtb00004.num_doc,
debito LIKE cgtb00004.debito,
credito LIKE cgtb00004.credito
END RECORD,
i INT
INPUT BY NAME preview
AFTER INPUT
IF preview IS NULL THEN
CALL msg(16)
NEXT FIELD preview
END IF
EXIT INPUT
END INPUT
DECLARE buscar2 CURSOR FOR
SELECT a.cuenta_no,
a.departamento,
a.cod_aux,
a.cod_sec,
a.num_doc,
a.debito,
a.credito
FROM cgtb00004 a
WHERE a.ref = p_entrada.entrada_no AND a.status_t IS NULL
LET idx = 1
FOREACH buscar2 INTO transac[idx].*
LET idx = idx + 1
END FOREACH
LET r_filename = "cgprmt004.4rp"
# LET preview = 1
LET r_output = "SVG"
-- configure report engine; the functions prefixed fgl that are called here are part of the GRW API
IF fgl_report_loadCurrentSettings(r_filename) THEN -- load the .4rp file
CALL fgl_report_selectDevice(r_output) -- changing default
IF preview = 0 THEN
CALL fgl_report_selectPreview(1) -- changing default
CALL fgl_report_configureSVGPreview("PrintOnDefaultPrinter")
ELSE
CALL fgl_report_selectPreview(preview)
END IF
LET handler = fgl_report_commitCurrentSettings() -- commit changes
ELSE
EXIT PROGRAM
END IF
--run the report
IF handler IS NOT NULL THEN -- report engine was configured ok
START REPORT imp_entrada4 TO XML HANDLER HANDLER
END IF
FOR i = 1 TO idx
IF transac[i].cuenta IS NOT NULL THEN
LET x.id = i
LET x.ref = p_entrada.entrada_no
LET x.cuenta_no = transac[i].cuenta
LET x.departamento = transac[i].departamento
LET x.cod_aux = transac[i].cod_aux
LET x.cod_sec = transac[i].cod_sec
LET x.num_doc = transac[i].num_doc
LET x.debito = transac[i].debito
LET x.credito = transac[i].credito
OUTPUT TO REPORT imp_entrada4(x.*)
END IF
END FOR
FINISH REPORT imp_entrada4
END FUNCTION
FUNCTION informacionAux()
LET num_doccxp = NULL
LET num_doccxc = NULL
SELECT DISTINCT a.factura_proveedor, a.num_doc_cxc
INTO num_doccxp, num_doccxc
FROM cgtb00004 a
WHERE a.ref = p_entrada.entrada_no
AND (a.factura_proveedor IS NOT NULL OR a.num_doc_cxc IS NOT NULL)
AND a.status_t IS NULL
END FUNCTION
FUNCTION validarFormatoEntrada(entrada VARCHAR(25))
DEFINE
entrada_str STRING,
longitud SMALLINT,
tipo_doc CHAR(2),
separador_punto CHAR(1),
num_tipo CHAR(2),
separador_guion CHAR(1),
secuencia CHAR(5),
separador_barra CHAR(1),
mes CHAR(2),
anio CHAR(2)
-- Convertir a STRING y quitar espacios extremos
LET entrada_str = entrada CLIPPED
LET longitud = entrada_str.getLength()
-- Validacion de longitud exacta
IF longitud != 16 THEN
CALL msg(77)
RETURN 1
END IF
-- Extraccion de cada segmento por posicion
LET tipo_doc = entrada_str.subString(1, 2)
LET separador_punto = entrada_str.subString(3, 3)
LET num_tipo = entrada_str.subString(4, 5)
LET separador_guion = entrada_str.subString(6, 6)
LET secuencia = entrada_str.subString(7, 11)
LET separador_barra = entrada_str.subString(12, 12)
LET mes = entrada_str.subString(13, 14)
LET anio = entrada_str.subString(15, 16)
-- Validacion de tipo de documento
IF tipo_doc != "ED" THEN
CALL msg(77)
RETURN 1
END IF
-- Validacion de separadores fijos
IF separador_punto != "." THEN
CALL msg(77)
RETURN 1
END IF
IF separador_guion != "-" THEN
CALL msg(77)
RETURN 1
END IF
IF separador_barra != "/" THEN
CALL msg(77)
RETURN 1
END IF
-- Validacion de que num_tipo sean digitos y no espacios
IF num_tipo IS NULL OR num_tipo = " " THEN
CALL msg(77)
RETURN 1
END IF
-- Validacion de que la secuencia sean digitos
IF secuencia IS NULL OR secuencia = " " THEN
CALL msg(77)
RETURN 1
END IF
-- Validacion de mes (01-12)
IF mes < "01" OR mes > "12" THEN
CALL msg(77)
RETURN 1
END IF
RETURN 0 -- formato correcto
END FUNCTION