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

1973 lines
58 KiB
Plaintext

{
-----------------------------------------------------------------------------
PROGRAMA : CGPRMT013
OBJETIVO : Mantenimiento de Cheques de pago en US$
REALIZADO POR : Ing. Juan F. Soto
FECHA : Febrero 17, 1995
-----------------------------------------------------------------------------
}
GLOBALS "cgprgb000.4gl"
DEFINE k_tipo CHAR(3)
###### Funcion que adiciona informacion referente a la aplicacion de un pago
FUNCTION cgprmt013()
OPTIONS
FORM LINE 8,
ERROR LINE 24,
COMMENT LINE 22,
PROMPT LINE 23
CALL pantalla()
OPEN FORM cgfmmt013 FROM "cgfmmt013"
DISPLAY FORM cgfmmt013
DISPLAY "cgprmt013" AT 4,3 ATTRIBUTE(blue)
DISPLAY "Registro De Cheques En US$ " AT 6,26 ATTRIBUTE(blue)
MENU "Mant."
COMMAND "Adicionar"
"Presione ESC Para Grabar Ctrl-C Cancela Ctrl-F Moverse Sobre Pantalla"
LET int_flag = FALSE
CALL cgprad013()
COMMAND "Consultar/Modificar"
"Presione ESC Para Buscar Ctrl-C Cancela Ctrl-F Moverse Sobre Pantalla"
LET int_flag = FALSE
CALL cgprmd013()
COMMAND "Salir"
LET int_flag = FALSE
EXIT MENU
END MENU
END FUNCTION
FUNCTION cgprad013()
LET hoy = today
LET k_tipo = "CK."
LABEL volver1:
INITIALIZE recibo.* TO NULL
#ERROR "Para Anular Un Cheque Presione <Ctrl-B>"
CLEAR FORM
LET recibo.cuenta_p = "1108"
SELECT cheque_no INTO numero FROM cgtb00012
WHERE cuenta_no = recibo.cuenta_p
IF status = notfound THEN
LET numero_msg = 205
CALL msg(numero_msg)
GOTO volver1
END IF
LET numero = numero + 1
LABEL volver:
IF opc = "S" or opc is null THEN
LET recibo.nom_sup = null
LET recibo.monto = null
LET opc = null
END IF
#### Aceptando los valores a insertar referentes al pago
INPUT BY NAME recibo.* WITHOUT DEFAULTS
AFTER FIELD codigo
IF recibo.codigo is not null THEN
SELECT a.descripcion INTO p_descrip
FROM tetb00003 a
WHERE a.codigo = recibo.codigo
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD codigo
END IF
DISPLAY BY NAME p_descrip
END IF
AFTER FIELD monto
IF recibo.monto is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD monto
END IF
AFTER FIELD cod_sp_sec
##### Selecionando datos referentes al suplidor
IF recibo.cod_sp_sec is not null THEN
IF recibo.cod_sp != 1 THEN
SELECT a.nom_sp INTO recibo.nom_sup FROM cotb00001 a
WHERE a.cod_sp = recibo.cod_sp AND
a.cod_sp_sec = recibo.cod_sp_sec
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_sp
END IF
DISPLAY BY NAME recibo.cod_sp,recibo.cod_sp_sec,recibo.nom_sup
NEXT FIELD nom_sup
END IF
END IF
IF recibo.cod_sp = 1 THEN
SELECT nom1_emp,apell1_emp,departamento,nomina
INTO nombre_emp,apellido_emp,depto,tipo_d FROM adtb00003
WHERE num_emp = recibo.cod_sp_sec
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_sp_sec
END IF
LET recibo.nom_sup = nombre_emp clipped," ",apellido_emp clipped
DISPLAY BY NAME recibo.nom_sup
END IF
BEFORE FIELD tipo_doc
LET recibo.tipo_doc = "CK"
AFTER FIELD tipo_doc
IF recibo.tipo_doc IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD tipo_doc
END IF
##### Igualando la descripcion de la operacion dependiendo de la clave
##### digitada en el proceso.
LET tipo_doc1 = recibo.tipo_doc
CASE
WHEN recibo.tipo_doc = "CK"
LET nom_tipo = "CHEQUE"
EXIT CASE
WHEN recibo.tipo_doc = "CP"
LET nom_tipo = "PAGO ADELANTADO"
EXIT CASE
END CASE
LET recibo.numero = numero
DISPLAY BY NAME recibo.numero
SELECT *INTO datos_ck.* FROM cgtb00012
WHERE cuenta_no = recibo.cuenta_p
DISPLAY BY NAME nom_tipo ATTRIBUTE (BOLD)
AFTER FIELD numero
IF recibo.numero IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD numero
ELSE
###### Chequeando que el numero de registro a procesar no exista en la
###### Maestra de pago.
LET referencia = "CK.",recibo.numero using "&&&&&&"
SELECT UNIQUE cheque_no FROM cgtb00005
WHERE cheque_no = recibo.numero and
cuenta_no = recibo.cuenta_p
IF status != NOTFOUND THEN
LET numero_msg = 12
CALL msg(numero_msg)
NEXT FIELD numero
END IF
END IF
IF recibo.tipo_doc[1] != "C" THEN
NEXT FIELD cod_sp
END IF
BEFORE FIELD fecha
LET recibo.fecha = hoy
DISPLAY BY NAME recibo.fecha
AFTER FIELD fecha
LET hoy = recibo.fecha
IF recibo.fecha is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha
END IF
LET p_fechas = recibo.fecha
{
CALL prd()
IF bandera = 1 THEN
LET bandera = 0
NEXT FIELD fecha
END IF
}
AFTER INPUT
####### Creando la facilidad para cancelar proceso mediante DELETE o SUPR
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
CLEAR FORM
RETURN
END IF
IF recibo.monto is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD monto
END IF
EXIT INPUT
END INPUT
# Funcion que captura 5 lineas de detalles
CALL detallado()
IF opc = "S" or opc is null THEN
FOR idx = 1 to 30
LET arr_recibo[idx].aplica_a = null
LET arr_recibo[idx].valor_pen = null
LET arr_recibo[idx].valor_pag = null
END FOR
END IF
IF recibo.cod_sp = 1 THEN
GOTO vuelve
END IF
IF recibo.cod_sp_sec is not null THEN
# Entrada de documentos que se pagaran con este cheque si el usuario
LABEL vuelta:
PROMPT "Afecta Cuentas Por Pagar?(S/N) " FOR CHAR opcion
LET opcion = upshift(opcion)
IF opcion != "S" AND
opcion != "N" THEN
LET numero_msg = -1301
CALL msg(numero_msg)
GOTO vuelta
END IF
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
CLEAR FORM
RETURN
END IF
IF opcion = "N" THEN
FOR idx = 1 to 30
LET arr_recibo[idx].aplica_a = null
LET arr_recibo[idx].valor_pen = null
LET arr_recibo[idx].valor_pag = null
END FOR
END IF
IF opcion = "S" THEN
LET remanente = 0
LABEL arr2:
LET sale_arr = "N"
INPUT ARRAY arr_recibo WITHOUT DEFAULTS FROM s_recibo.*
ON KEY (CONTROL-F)
LET sale_arr = "S"
EXIT INPUT
ON KEY (CONTROL-W)
LET curr = arr_curr()
LET scr_l = scr_line()
###### Proceso para abrir window en caso de desconocer el numero de orden
###### perteneciente a la factura que se aplicara el pago.
CASE
WHEN INFIELD (aplica_a)
CALL busca_aplicacion()
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
NEXT FIELD aplica_a
END IF
IF existe = "N" THEN
LET existe = "S"
NEXT FIELD aplica_a
END IF
DISPLAY arr_recibo[curr].aplica_a to s_recibo[scr_l].aplica_a
DISPLAY arr_recibo[curr].valor_pen to s_recibo[scr_l].valor_pen
LET arr_recibo[curr].valor_pag = arr_recibo[curr].valor_pen
DISPLAY arr_recibo[curr].valor_pag to s_recibo[scr_l].valor_pag
NEXT FIELD valor_pag
LET verdad = "N"
CALL repetir1()
IF verdad = "S" THEN
NEXT FIELD aplica_a
END IF
END CASE
BEFORE ROW
LET curr = arr_curr()
LET scr_l = scr_line()
AFTER FIELD orden_no
IF arr_recibo[curr].orden_no != 999999 THEN #IS NOT NULL THEN
IF recibo.cod_sp IS NULL THEN
##### Chequeando que el numero de orden a digitar exista en la maestra de pago[
SELECT UNIQUE a.tipo,a.orden_no,a.cod_sp,a.cod_sp_sec
INTO p_tipo,p_orden,recibo.cod_sp,recibo.cod_sp_sec
FROM cptb00001 a WHERE a.tipo = arr_recibo[curr].tipo AND
a.orden_no = arr_recibo[curr].orden_no
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD tipo
END IF
ELSE
###### Chequeando que el numero de orden exista en la maestra de orden
SELECT b.num_oc FROM cotb00014 b
WHERE b.tipo=arr_recibo[curr].tipo AND b.num_oc=arr_recibo[curr].orden_no
AND b.cod_sp = recibo.cod_sp AND b.cod_sp_sec = recibo.cod_sp_sec
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD tipo
END IF
END IF
ELSE
IF recibo.tipo_doc = "CP" THEN
LET arr_recibo[curr].tipo = "99"
NEXT FIELD valor_pag
END IF
END IF
AFTER FIELD aplica_a
LET tipo_doc1 = recibo.tipo_doc
IF arr_recibo[curr].orden_no is not null AND
arr_recibo[curr].aplica_a IS NULL THEN
LET tipo_doc1= "CP"
# LET nom_tipo = "PAGO ADELANTADO"
END IF
IF arr_recibo[curr].orden_no is not null and
arr_recibo[curr].aplica_a is not null THEN
LET numero_msg = 212
CALL msg(numero_msg)
NEXT FIELD aplica_a
END IF
IF arr_recibo[curr].aplica_a IS NOT NULL THEN
IF recibo.cod_sp != 1 THEN
IF recibo.tipo_doc = "CP" THEN
IF arr_recibo[curr].orden_no IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD orden_no
ELSE
NEXT FIELD valor_pag
END IF
END IF
IF arr_recibo[curr].aplica_a IS NOT NULL THEN
# LET arr_recibo[curr].orden_no = null
# LET arr_recibo[curr].tipo = null
LET verdad = "N"
CALL repetir1()
IF verdad = "S" THEN
NEXT FIELD aplica_a
END IF
IF arr_recibo[curr].aplica_a IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD aplica_a
END IF
# Controla que la factura pertenezca al suplidor
SELECT a.tipo,a.orden_no,a.valor
INTO arr_recibo[curr].tipo,arr_recibo[curr].orden_no,valor_fac
FROM cptb00001 a
WHERE a.num_doc = arr_recibo[curr].aplica_a
AND a.cod_sp = recibo.cod_sp
AND a.cod_sp_sec = recibo.cod_sp_sec
AND a.tipo_doc = "FT"
AND a.status_t is null
IF status = notfound THEN
LET numero_msg = 126
CALL msg(numero_msg)
NEXT FIELD aplica_a
END IF
# Busca el valor pendiente de la factura
SELECT sum(a.valor*-1) INTO valor_fac1 FROM cptb00001 a
WHERE a.cod_sp = recibo.cod_sp
AND a.cod_sp_sec = recibo.cod_sp_sec
AND a.aplica_a = arr_recibo[curr].aplica_a
AND a.tipo_doc not matches "*FT*"
AND a.status_t IS NULL
IF valor_fac1 IS NULL THEN
LET valor_fac1 = 0
END IF
IF valor_fac IS NULL THEN
LET valor_fac = 0
END IF
####### Calculando el valor pendiente de la factura
LET arr_recibo[curr].valor_pen = valor_fac - valor_fac1
LET arr_recibo[curr].valor_pag = arr_recibo[curr].valor_pen
DISPLAY arr_recibo[curr].valor_pag to s_recibo[scr_l].valor_pag
DISPLAY arr_recibo[curr].valor_pen to s_recibo[scr_l].valor_pen
END IF
END IF
END IF
AFTER FIELD valor_pag
IF recibo.tipo_doc = "CP" THEN
IF arr_recibo[curr].orden_no IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD orden_no
END IF
END IF
IF arr_recibo[curr].aplica_a IS NOT NULL AND
arr_recibo[curr].valor_pen IS NOT NULL THEN
LET verdad = "N"
CALL repetir1()
IF verdad = "S" THEN
NEXT FIELD aplica_a
END IF
END IF
IF arr_recibo[curr].valor_pag IS NULL THEN
LET arr_recibo[curr].valor_pag = 0
END IF
IF arr_recibo[curr].aplica_a is not null or
arr_recibo[curr].orden_no is not null THEN
IF arr_recibo[curr].valor_pag = 0 THEN
LET numero_msg = 207
CALL msg(numero_msg)
NEXT FIELD valor_pag
END IF
END IF
LET valor = 0
FOR idx = 1 TO arr_count()
IF arr_recibo[idx].valor_pag is null THEN
LET arr_recibo[idx].valor_pag = 0
END IF
LET valor = arr_recibo[idx].valor_pag + valor
LET remanente = recibo.monto - valor
DISPLAY BY NAME remanente attribute (bold)
END FOR
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
RETURN
END IF
IF arr_recibo[curr].aplica_a is not null or
arr_recibo[curr].orden_no is not null THEN
IF arr_recibo[curr].valor_pag = 0 THEN
LET numero_msg = 207
CALL msg(numero_msg)
NEXT FIELD valor_pag
END IF
END IF
END INPUT
IF sale_arr = "S" THEN
LET opc = "N"
GOTO volver
END IF
# Sumariza el valor de las facturas para que sean iguales
LET valor_f = 0
LET ins_cp = arr_count()
FOR idx= 1 to arr_count()
IF arr_recibo[idx].aplica_a is null and
arr_recibo[idx].orden_no is null THEN
LET arr_recibo[idx].valor_pag = 0
END IF
IF arr_recibo[idx].valor_pag is null THEN
LET arr_recibo[idx].valor_pag = 0
END IF
LET valor_f = arr_recibo[idx].valor_pag + valor_f
END FOR
#------------------------------------------------------------------------
END IF
END IF
# Estas asignaciones estan en comentario por que los usuarios
# de contabilidad desean meter los numeros de documentos en el arreglo de
# arriba y el arreglo de las cuentas contables
{
FOR idx = 1 TO arr_count()
IF arr_recibo[idx].orden_no is not null THEN
LET arr_cuenta1[idx].num_doc = arr_recibo[idx].tipo,"-",
arr_recibo[idx].orden_no using "&&&&&&"
END IF
IF arr_recibo[idx].aplica_a is not null THEN
LET arr_cuenta1[idx].num_doc = arr_recibo[idx].aplica_a
END IF
END FOR
}
IF opc = "N" THEN
GOTO vuelve
END IF
FOR idx = 1 TO 50
LET arr_cuenta1[idx].cuenta_no = null
LET arr_cuenta1[idx].num_doc = null
LET arr_cuenta1[idx].cod_aux = null
LET arr_cuenta1[idx].cod_sec = null
LET arr_cuenta1[idx].num_doc = null
LET arr_cuenta1[idx].nom_cuenta = null
LET arr_cuenta1[idx].departamento = null
LET arr_cuenta1[idx].debito = null
LET arr_cuenta1[idx].credito = null
END FOR
LET arr_cuenta1[1].cod_aux = recibo.cod_sp
LET arr_cuenta1[1].cod_sec = recibo.cod_sp_sec
LABEL vuelve:
# Captura de la codificacion del cheque para contabilidad
LABEL arr3:
LET sale_arr = "N"
INPUT ARRAY arr_cuenta1 WITHOUT DEFAULTS FROM s_cuenta.*
ON KEY(CONTROL-F)
LET opc = "N"
LET sale_arr = "S"
EXIT INPUT
ON KEY(CONTROL-P)
NEXT FIELD cuenta_no
ON KEY(CONTROL-W)
IF INFIELD(cuenta_no) THEN
# CALL busca_cuenta()
IF int_flag THEN
LET int_flag = false
NEXT FIELD cuenta_no
END IF
LET arr_cuenta1[curr].cuenta_no = cuentas[curr1].cuenta_no
LET arr_cuenta1[curr].nom_cuenta = cuentas[curr1].descripcion
DISPLAY arr_cuenta1[curr].cuenta_no TO s_cuenta[scr_l].cuenta_no
DISPLAY arr_cuenta1[curr].nom_cuenta TO s_cuenta[scr_l].nom_cuenta
IF cuentas[curr1].nivel != 3 THEN
LET numero_msg = 175
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
END IF
BEFORE ROW
LET curr = arr_curr()
LET scr_l = scr_line()
AFTER FIELD cuenta_no
IF arr_cuenta1[curr].cuenta_no is not null THEN
SELECT a.descripcion,a.origen,a.depto,a.nivel,a.ref,a.cata
INTO p_descripcion,p_origen,acept_dpto,p_nivel,p_ref,p_cata
FROM cgtb00001 a
WHERE a.cuenta_no = arr_cuenta1[curr].cuenta_no and
a.status_t is null
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
LET arr_cuenta1[curr].nom_cuenta = p_descripcion
DISPLAY arr_cuenta1[curr].nom_cuenta TO s_cuenta[scr_l].nom_cuenta
# Controla que la cuenta del banco no sea igual a una cuenta digitada
# en el arreglo
LET cuenta_a = arr_cuenta1[curr].cuenta_no clipped
LET cuenta_b = recibo.cuenta_p clipped
IF cuenta_a = cuenta_b THEN
LET numero_msg = 192
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
#-----------------------------------------------------------------------------
IF p_nivel < 3 THEN
LET numero_msg = 175
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
IF acept_dpto = "S" THEN
NEXT FIELD departamento
ELSE
LET arr_cuenta1[curr].departamento = null
DISPLAY arr_cuenta1[curr].departamento TO s_cuenta[scr_l].departamento
END IF
IF p_cata = "S" THEN
NEXT FIELD cod_aux
ELSE
LET arr_cuenta1[curr].cod_aux = null
LET arr_cuenta1[curr].cod_sec = null
DISPLAY arr_cuenta1[curr].cod_aux TO s_cuenta[scr_l].cod_aux
DISPLAY arr_cuenta1[curr].cod_sec TO s_cuenta[scr_l].cod_sec
IF p_ref = "S" THEN
NEXT FIELD num_doc
ELSE
LET arr_cuenta1[curr].num_doc = null
DISPLAY arr_cuenta1[curr].num_doc TO s_cuenta[scr_l].num_doc
END IF
NEXT FIELD debito
END IF
END IF
AFTER FIELD departamento
IF arr_cuenta1[curr].cuenta_no is not null THEN
IF acept_dpto = "S" THEN
IF arr_cuenta1[curr].departamento is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD departamento
END IF
SELECT a.nom_dpto INTO nombre_dpto FROM adtb00001 a
WHERE a.departamento = arr_cuenta1[curr].departamento and
a.status_t is null
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD departamento
END IF
DISPLAY BY NAME nombre_dpto ATTRIBUTE(blue)
ELSE
LET arr_cuenta1[curr].departamento = null
DISPLAY arr_cuenta1[curr].departamento TO s_cuenta[scr_l].departamento
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
END IF
NEXT FIELD debito
BEFORE FIELD cod_aux
IF p_cata != "S" THEN
LET arr_cuenta1[curr].cod_aux = null
LET arr_cuenta1[curr].cod_sec = null
DISPLAY arr_cuenta1[curr].cod_aux TO s_cuenta[scr_l].cod_aux
DISPLAY arr_cuenta1[curr].cod_sec TO s_cuenta[scr_l].cod_sec
NEXT FIELD num_doc
END IF
AFTER FIELD cod_aux
IF arr_cuenta1[curr].cuenta_no is not null THEN
IF p_cata = "S" THEN
IF arr_cuenta1[curr].cod_aux is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
ELSE
LET arr_cuenta1[curr].cod_aux = null
LET arr_cuenta1[curr].cod_sec = null
DISPLAY arr_cuenta1[curr].cod_aux TO s_cuenta[scr_l].cod_aux
DISPLAY arr_cuenta1[curr].cod_sec TO s_cuenta[scr_l].cod_sec
NEXT FIELD num_doc
END IF
END IF
AFTER FIELD cod_sec
IF arr_cuenta1[curr].cuenta_no is not null THEN
IF p_cata = "S" THEN
IF arr_cuenta1[curr].cod_sec is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
IF arr_cuenta1[curr].cod_aux != 1 THEN
SELECT a.nom_sp INTO nombre_cata FROM cotb00001 a
WHERE a.cod_sp = arr_cuenta1[curr].cod_aux AND
a.cod_sp_sec = arr_cuenta1[curr].cod_sec
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
DISPLAY BY NAME nombre_cata ATTRIBUTE(blue)
END IF
IF arr_cuenta1[curr].cod_aux = 1 THEN
SELECT nom1_emp,apell1_emp,departamento,nomina INTO nombre_cata
FROM adtb00003
WHERE num_emp = arr_cuenta1[curr].cod_sec
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
DISPLAY BY NAME nombre_cata
IF p_ref = "S" THEN
NEXT FIELD num_doc
ELSE
LET arr_cuenta1[curr].num_doc = null
DISPLAY arr_cuenta1[curr].num_doc TO s_cuenta[scr_l].num_doc
NEXT FIELD debito
END IF
END IF
END IF
END IF
BEFORE FIELD num_doc
IF p_ref != "S" THEN
NEXT FIELD debito
END IF
AFTER FIELD num_doc
IF arr_cuenta1[curr].cuenta_no is not null THEN
IF p_ref = "S" THEN
IF arr_cuenta1[curr].num_doc IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD num_doc
END IF
ELSE
LET arr_cuenta1[curr].num_doc = null
DISPLAY arr_cuenta1[curr].num_doc TO s_cuenta[scr_l].num_doc
END IF
END IF
AFTER FIELD debito
IF arr_cuenta1[curr].debito is not null or
arr_cuenta1[curr].debito != 0 THEN
IF arr_cuenta1[curr].debito != 0 THEN
IF arr_cuenta1[curr].cuenta_no is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
END IF
END IF
AFTER ROW
IF arr_cuenta1[curr].cuenta_no is not null THEN
IF arr_cuenta1[curr].debito = 0 and
arr_cuenta1[curr].credito = 0 THEN
LET numero_msg = 207
CALL msg(numero_msg)
NEXT FIELD cuenta_no
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
IF valor_f is null THEN
LET valor_f = 0
END IF
IF arr_cuenta1[curr].debito is not null THEN
IF arr_cuenta1[curr].cuenta_no is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
END IF
IF arr_cuenta1[curr].credito is not null THEN
IF arr_cuenta1[curr].cuenta_no is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
END IF
LET tiene_cta = "N"
FOR idx = 1 TO arr_count()
IF arr_cuenta1[idx].cuenta_no is not null THEN
LET tiene_cta = "S"
END IF
END FOR
IF tiene_cta = "N" THEN
LET numero_msg = 84
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
END INPUT
IF sale_arr = "S" THEN
GOTO arr2
END IF
LET monto = 0
LET valor = 0
FOR idx = 1 TO arr_count()
IF arr_cuenta1[idx].debito is null THEN
LET arr_cuenta1[idx].debito = 0
END IF
IF arr_cuenta1[idx].credito is null THEN
LET arr_cuenta1[idx].credito = 0
END IF
LET valor = valor + arr_cuenta1[idx].debito
LET monto = arr_cuenta1[idx].credito + monto
END FOR
LET monto = valor - monto
IF monto != recibo.monto THEN
LET numero_msg = 178
CALL msg(numero_msg)
GOTO vuelve
END IF
PROMPT "Toda la Informacion Esta Correcta (S/N) ?" FOR char opc
LET opc = upshift(opc)
LET limpia = "N"
IF opc = "S" THEN
LET limpia = "S"
# Actualizacion de las tablas de cuentas por pagar y contabilidad general
IF recibo.cod_sp > 1 THEN
IF opcion = "S" THEN
LET opcion = null
LET numero1 = recibo.numero
DELETE FROM cptb00001 WHERE @tipo_doc = tipo_doc1 AND @num_doc = numero1
AND @cod_sp = recibo.cod_sp AND
@cod_sp_sec = recibo.cod_sp_sec
FOR idx = 1 to ins_cp
IF arr_recibo[idx].valor_pag <> 0 and
arr_recibo[idx].valor_pag is not null THEN
##### Proceso para insertar valores en cuentas por pagar
IF arr_recibo[idx].valor_pag > 0 THEN
LET arr_recibo[idx].valor_pag = arr_recibo[idx].valor_pag * -1
END IF
IF arr_recibo[idx].orden_no IS NOT NULL OR
arr_recibo[idx].aplica_a IS NOT NULL THEN
INSERT INTO cptb00001 values (tipo_doc1,recibo.numero,
recibo.cod_sp,recibo.cod_sp_sec,recibo.fecha,recibo.fecha,
arr_recibo[idx].orden_no,
arr_recibo[idx].tipo,arr_recibo[idx].aplica_a,recibo.cuenta_p,
arr_recibo[idx].valor_pag,detalle_1,null,USER,CURRENT,null,null)
END IF
END IF
IF arr_recibo[idx].aplica_a is not null THEN
IF idx < 6 THEN
LET factura1 = arr_recibo[idx].aplica_a CLIPPED
LET facturas = facturas CLIPPED,",",factura1 CLIPPED
END IF
END IF
IF arr_recibo[idx].orden_no is not null and
arr_recibo[idx].orden_no != 999999 THEN
IF idx < 10 THEN
LET orden1 = arr_recibo[idx].orden_no USING "######"
LET ordenes = ordenes CLIPPED,",",orden1 CLIPPED
END IF
END IF
END FOR
CALL integridad()
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
ERROR "INSERTE EN CUENTAS POR PAGAR"
END IF
END IF
DISPLAY " "
# Actualizacion de la tabla datos generales del cheque
INSERT INTO cgtb00005 values (recibo.cuenta_p,recibo.numero,null,recibo.fecha,
recibo.nom_sup,recibo.tasa,recibo.monto,opc1,
null,user,current,null,null)
# Actualizacion de la tabla control de los cheques
UPDATE cgtb00012 set cheque_no = recibo.numero
WHERE cuenta_no = recibo.cuenta_p
# Actualizacion de la tabla transacciones de contabildad general
LET referencia = "CK.",recibo.numero using "&&&&&&"
FOR idx = 1 TO arr_count()
IF arr_cuenta1[idx].cuenta_no is not null THEN
IF arr_recibo[idx].orden_no is not null THEN
LET refe[idx] = arr_recibo[idx].orden_no
END IF
IF arr_recibo[idx].orden_no is not null THEN
LET refe[idx] = arr_recibo[idx].tipo using "&&","-",
arr_recibo[idx].aplica_a using "&&&&&&"
END IF
IF arr_recibo[idx].aplica_a is not null THEN
LET refe[idx] = arr_recibo[idx].aplica_a
END IF
INSERT INTO cgtb00004 values (recibo.fecha,2,referencia,
arr_cuenta1[idx].cuenta_no,arr_cuenta1[idx].departamento,
arr_cuenta1[idx].num_doc,arr_cuenta1[idx].cod_aux,
arr_cuenta1[idx].cod_sec,recibo.cuenta_p,
detalle_1,detalle_2,
arr_cuenta1[idx].debito,
arr_cuenta1[idx].credito,null,user,current,null,null)
CALL integridad()
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
END IF
END FOR
# Inserta los registros necesarios para la tabla de tesoreria
INSERT INTO tetb00006 values (recibo.numero,recibo.cuenta_p,
recibo.codigo,null,user,current,null,null)
#----------------------------------------------------------------------------
INSERT INTO cgtb00004 values (recibo.fecha,2,referencia,
recibo.cuenta_p,null,
null,null,null,recibo.cuenta_p,
detalle_1,detalle_2,0,recibo.monto,
null,user,current,null,null)
LET arr_cuenta1[1].cuenta_no = recibo.cuenta_p
LET arr_cuenta1[1].nom_cuenta = p_descripcion
LET arr_cuenta1[1].debito = 0
LET arr_cuenta1[1].num_doc = null
LET arr_cuenta1[1].departamento = null
LET arr_cuenta1[1].cod_aux = null
LET arr_cuenta1[1].cod_sec = null
LET arr_cuenta1[1].credito = recibo.monto
LET numero_msg = 1
CALL msg(numero_msg)
CLEAR FORM
FOR idx = 1 TO 50
LET arr_cuenta1[idx].cuenta_no = null
LET arr_cuenta1[idx].num_doc = null
LET arr_cuenta1[idx].cod_aux = null
LET arr_cuenta1[idx].cod_sec = null
LET arr_cuenta1[idx].nom_cuenta = null
LET arr_cuenta1[idx].departamento = null
LET arr_cuenta1[idx].debito = null
LET arr_cuenta1[idx].credito = null
END FOR
END IF
IF opc = "N" THEN
GOTO volver
ELSE
GOTO volver1
END IF
END FUNCTION
FUNCTION cgprmd013()
CLEAR FORM
CONSTRUCT criterio ON a.cheque_no,a.cuenta_no
FROM numero,cuenta_p
LET selec_p =
"SELECT 'CK',a.cuenta_no,a.cheque_no,12,1,a.portador, ",
" a.fecha,a.tasa,a.monto,c.codigo,a.us_crea,a.fech_crea ",
"FROM cgtb00005 a ,OUTER tetb00006 c ",
"WHERE a.status_t IS NULL AND ", criterio clipped,
" AND c.cheque_no = a.cheque_no AND a.cuenta_no = '1108' ORDER BY 3 "
PREPARE comando FROM selec_p
DECLARE accion5 SCROLL CURSOR FOR comando
OPEN accion5
FETCH FIRST accion5 INTO recibo.*,usuario,fecha_crea
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
RETURN
END IF
CALL busca_cheque()
LET referencia = "CK.",recibo.numero USING "&&&&&&"
SELECT UNIQUE a.detalle_1,a.detalle_2 INTO detalle_1,detalle_2
FROM cgtb00004 a
WHERE a.ref = referencia AND a.status_t IS NULL AND
a.cuenta_no = recibo.cuenta_p
CALL procede()
DISPLAY BY NAME recibo.*
MENU "Consulta"
COMMAND "Primero"
FETCH FIRST accion5 INTO recibo.*,usuario,fecha_crea
CALL busca_cheque()
LET referencia = "CK.",recibo.numero USING "&&&&&&"
SELECT UNIQUE a.detalle_1,a.detalle_2 INTO detalle_1,detalle_2
FROM cgtb00004 a
WHERE a.ref = referencia AND a.status_t IS NULL AND
a.cuenta_no = recibo.cuenta_p
CALL procede()
DISPLAY BY NAME recibo.*,p_descrip
LET numero_msg = 5
CALL msg(numero_msg)
COMMAND "Siguiente"
FETCH NEXT accion5 INTO recibo.*,usuario,fecha_crea
IF STATUS = NOTFOUND THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
CALL busca_cheque()
LET referencia = "CK.",recibo.numero USING "&&&&&&"
SELECT UNIQUE a.detalle_1,a.detalle_2
INTO detalle_1,detalle_2
FROM cgtb00004 a
WHERE a.ref = referencia AND a.status_t IS NULL AND
a.cuenta_no = recibo.cuenta_p
CALL procede()
DISPLAY BY NAME recibo.*,p_descrip
COMMAND "Anterior"
FETCH PREVIOUS accion5 INTO recibo.*,usuario,fecha_crea
IF STATUS = NOTFOUND THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
CALL busca_cheque()
LET referencia = "CK.",recibo.numero USING "&&&&&&"
SELECT UNIQUE a.detalle_1,a.detalle_2
INTO detalle_1,detalle_2
FROM cgtb00004 a
WHERE a.ref = referencia AND a.status_t IS NULL AND
a.cuenta_no = recibo.cuenta_p
CALL procede()
DISPLAY BY NAME recibo.*,p_descrip
COMMAND "Ultimo"
FETCH LAST accion5 INTO recibo.*,usuario,fecha_crea
CALL busca_cheque()
LET referencia = "CK.",recibo.numero USING "&&&&&&"
SELECT UNIQUE a.detalle_1,a.detalle_2
INTO detalle_1,detalle_2
FROM cgtb00004 a
WHERE a.ref = referencia AND a.status_t IS NULL AND
a.cuenta_no = recibo.cuenta_p
CALL procede()
DISPLAY BY NAME recibo.*,p_descrip
LET numero_msg = 4
CALL msg(numero_msg)
COMMAND "Escoger"
"Presione ESC Para Grabar Ctrl-C Cancela Ctrl-F Moverse Sobre Pantalla"
LET p_fechas = recibo.fecha
CALL prd()
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
LABEL vuelve10:
INPUT BY NAME recibo.* WITHOUT DEFAULTS
AFTER FIELD codigo
IF recibo.codigo is not null THEN
SELECT a.descripcion INTO p_descrip
FROM tetb00003 a
WHERE a.codigo = recibo.codigo
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD codigo
END IF
DISPLAY BY NAME p_descrip
END IF
AFTER FIELD tipo_doc
NEXT FIELD cod_sp
AFTER FIELD cod_sp
NEXT FIELD cod_sp_sec
AFTER FIELD monto
IF recibo.monto is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD monto
END IF
AFTER FIELD cuenta_p
IF recibo.cuenta_p is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta_p
END IF
SELECT cheque_no INTO numero FROM cgtb00012
WHERE cuenta_no = recibo.cuenta_p
IF status = notfound THEN
LET numero_msg = 205
CALL msg(numero_msg)
NEXT FIELD cuenta_p
END IF
LET numero = numero + 1
# LET recibo.numero = numero
DISPLAY BY NAME recibo.numero
AFTER FIELD cod_sp_sec
##### Selecionando datos referentes al suplidor
IF recibo.cod_sp_sec is not null THEN
IF recibo.cod_sp != 1 THEN
SELECT a.nom_sp INTO recibo.nom_sup FROM cotb00001 a
WHERE a.cod_sp = recibo.cod_sp AND
a.cod_sp_sec = recibo.cod_sp_sec
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_sp
END IF
DISPLAY BY NAME recibo.cod_sp,recibo.cod_sp_sec,recibo.nom_sup
NEXT FIELD nom_sup
END IF
END IF
IF recibo.cod_sp = 1 THEN
SELECT nom1_emp,apell1_emp,departamento,nomina
INTO nombre_emp,apellido_emp,depto,tipo_d FROM adtb00003
WHERE num_emp = recibo.cod_sp_sec
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_sp_sec
END IF
LET recibo.nom_sup = nombre_emp clipped," ",apellido_emp clipped
DISPLAY BY NAME recibo.nom_sup
END IF
BEFORE FIELD tipo_doc
LET recibo.tipo_doc = "CK"
AFTER FIELD tipo_doc
IF recibo.tipo_doc IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD tipo_doc
END IF
##### Igualando la descripcion de la operacion dependiendo de la clave
##### digitada en el proceso.
LET tipo_doc1 = recibo.tipo_doc
CASE
WHEN recibo.tipo_doc = "CK"
LET nom_tipo = "CHEQUE"
EXIT CASE
WHEN recibo.tipo_doc = "CP"
LET nom_tipo = "PAGO ADELANTADO"
EXIT CASE
END CASE
DISPLAY BY NAME nom_tipo ATTRIBUTE (BOLD)
NEXT FIELD cod_sp
AFTER FIELD fecha
IF recibo.fecha is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha
END IF
LET p_fechas = recibo.fecha
CALL prd()
IF bandera = 1 THEN
LET bandera = 0
NEXT FIELD fecha
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
EXIT INPUT
END INPUT
####### Creando la facilidad para cancelar proceso mediante DELETE o SUPR
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
RETURN
END IF
LET numero1 = recibo.numero USING "<<<<<<<"
DECLARE buscara CURSOR FOR
SELECT b.tipo,b.orden_no,b.aplica_a,b.valor*-1,b.valor*-1
FROM cptb00001 b
WHERE b.status_t IS NULL AND b.num_doc = numero1 AND
b.tipo_doc = recibo.tipo_doc
# b.cta_ctble = recibo.cuenta_p
LET idx = 1
LET i = 0
FOREACH buscara INTO arr_recibo[idx].*
LET arr_recibo[idx].valor_pen = 0
LET idx = idx + 1
LET i = i + 1
END FOREACH
CALL SET_COUNT(idx -1)
IF i = 0 THEN
LET existe = "N"
END IF
IF recibo.cod_sp_sec is not null THEN
LABEL vuelta1:
PROMPT "Afecta Cuentas Por Pagar?(S/N) " FOR CHAR opcion
LET opcion = upshift(opcion)
IF opcion != "S" AND
opcion != "N" THEN
LET numero_msg = -1301
CALL msg(numero_msg)
GOTO vuelta1
END IF
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
CLEAR FORM
RETURN
END IF
IF opcion = "N" THEN
FOR idx = 1 to 30
LET arr_recibo[idx].tipo = null
LET arr_recibo[idx].orden_no = null
LET arr_recibo[idx].aplica_a = null
LET arr_recibo[idx].valor_pen = null
LET arr_recibo[idx].valor_pag = null
END FOR
LET valor_f = 0
FOR idx = 1 TO 2
DISPLAY arr_recibo[idx].aplica_a TO s_recibo[idx].aplica_a
DISPLAY arr_recibo[idx].valor_pen TO s_recibo[idx].valor_pen
DISPLAY arr_recibo[idx].valor_pag TO s_recibo[idx].valor_pag
DISPLAY arr_recibo[idx].tipo TO s_recibo[idx].tipo
DISPLAY arr_recibo[idx].orden_no TO s_recibo[idx].orden_no
END FOR
END IF
LABEL arr10:
IF opcion = "N" THEN
GOTO arr2
END IF
IF opcion = "S" THEN
#LET sale_arr = "N"
INPUT ARRAY arr_recibo WITHOUT DEFAULTS FROM s_recibo.*
ON KEY (CONTROL-F)
LET opc = "N"
LET sale_arr = "S"
EXIT INPUT
ON KEY (CONTROL-W)
LET curr = arr_curr()
LET scr_l = scr_line()
###### Proceso para abrir window en caso de desconocer el numero de orden
###### perteneciente a la factura que se aplicara el pago.
CASE
WHEN INFIELD (aplica_a)
CALL busca_aplicacion()
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
NEXT FIELD aplica_a
END IF
IF existe = "N" THEN
LET existe = "S"
NEXT FIELD aplica_a
END IF
DISPLAY arr_recibo[curr].aplica_a to s_recibo[scr_l].aplica_a
DISPLAY arr_recibo[curr].valor_pen to s_recibo[scr_l].valor_pen
LET arr_recibo[curr].valor_pag = arr_recibo[curr].valor_pen
DISPLAY arr_recibo[curr].valor_pag to s_recibo[scr_l].valor_pag
NEXT FIELD valor_pag
LET verdad = "N"
CALL repetir1()
IF verdad = "S" THEN
NEXT FIELD aplica_a
END IF
END CASE
BEFORE ROW
LET curr = arr_curr()
LET scr_l = scr_line()
AFTER FIELD orden_no
IF arr_recibo[curr].orden_no != 999999 THEN #IS NOT NULL THEN
IF recibo.cod_sp IS NULL THEN
##### Chequeando que el numero de orden a digitar exista en la maestra de pago[
SELECT UNIQUE a.tipo,a.orden_no,a.cod_sp,a.cod_sp_sec
INTO p_tipo,p_orden,recibo.cod_sp,recibo.cod_sp_sec
FROM cptb00001 a WHERE a.tipo = arr_recibo[curr].tipo AND
a.orden_no = arr_recibo[curr].orden_no
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD tipo
END IF
ELSE
###### Chequeando que el numero de orden exista en la maestra de orden
SELECT b.num_oc
FROM cotb00014 b WHERE b.tipo = arr_recibo[curr].tipo AND
b.num_oc = arr_recibo[curr].orden_no AND
b.cod_sp = recibo.cod_sp AND
b.cod_sp_sec = recibo.cod_sp_sec
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD tipo
END IF
END IF
ELSE
IF recibo.tipo_doc = "CP" THEN
LET arr_recibo[curr].tipo = "99"
NEXT FIELD valor_pag
END IF
END IF
AFTER FIELD aplica_a
IF arr_recibo[curr].orden_no is not null AND
arr_recibo[curr].aplica_a IS NULL THEN
LET tipo_doc1= "CP"
# LET nom_tipo = "PAGO ADELANTADO"
# DISPLAY BY NAME nom_tipo,recibo.tipo_doc attribute (bold)
ELSE
LET tipo_doc1 = recibo.tipo_doc
END IF
IF arr_recibo[curr].aplica_a IS NOT NULL THEN
IF recibo.cod_sp != 1 THEN
IF recibo.tipo_doc = "CP" THEN
IF arr_recibo[curr].orden_no IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD orden_no
ELSE
NEXT FIELD valor_pag
END IF
END IF
IF arr_recibo[curr].aplica_a IS NOT NULL THEN
# LET arr_recibo[curr].orden_no = null
# LET arr_recibo[curr].tipo = null
LET verdad = "N"
CALL repetir1()
IF verdad = "S" THEN
NEXT FIELD aplica_a
END IF
# Controla que la factura pertenezca al suplidor
SELECT a.tipo,a.orden_no,a.valor
INTO arr_recibo[curr].tipo,arr_recibo[curr].orden_no,valor_fac
FROM cptb00001 a
WHERE a.num_doc = arr_recibo[curr].aplica_a AND
a.cod_sp=recibo.cod_sp AND a.cod_sp_sec=recibo.cod_sp_sec
AND a.tipo_doc = "FT" AND a.status_t is null
IF status = notfound THEN
LET numero_msg = 126
CALL msg(numero_msg)
NEXT FIELD aplica_a
END IF
# Busca el valor pendiente de la factura
LET valor_fac1 = 0
SELECT sum(a.valor) INTO valor_fac1 FROM cptb00001 a
WHERE a.cod_sp=recibo.cod_sp AND a.cod_sp_sec=recibo.cod_sp_sec
AND a.aplica_a = arr_recibo[curr].aplica_a
AND a.status_t IS NULL
IF valor_fac1 IS NULL THEN
LET valor_fac1 = 0
END IF
IF valor_fac IS NULL THEN
LET valor_fac = 0
END IF
####### Calculando el valor pendiente de la factura
LET arr_recibo[curr].valor_pen = valor_fac1
# LET arr_recibo[curr].valor_pag = arr_recibo[curr].valor_pen
# DISPLAY arr_recibo[curr].valor_pag to s_recibo[scr_l].valor_pag
DISPLAY arr_recibo[curr].valor_pen to s_recibo[scr_l].valor_pen
END IF
END IF
END IF
AFTER FIELD valor_pag
IF recibo.tipo_doc = "CP" THEN
IF arr_recibo[curr].orden_no IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD orden_no
END IF
END IF
IF arr_recibo[curr].aplica_a IS NOT NULL AND
arr_recibo[curr].valor_pen IS NOT NULL THEN
LET verdad = "N"
CALL repetir1()
IF verdad = "S" THEN
NEXT FIELD aplica_a
END IF
END IF
IF arr_recibo[curr].valor_pag IS NULL THEN
LET arr_recibo[curr].valor_pag = 0
END IF
IF arr_recibo[curr].aplica_a is not null THEN
IF arr_recibo[curr].valor_pag = 0 THEN
LET numero_msg = 207
CALL msg(numero_msg)
NEXT FIELD valor_pag
END IF
END IF
IF arr_recibo[curr].aplica_a is not null THEN
IF arr_recibo[curr].valor_pag = 0 THEN
LET numero_msg = 207
CALL msg(numero_msg)
NEXT FIELD valor_pag
END IF
END IF
LET valor_f = 0
FOR idx = 1 TO arr_count()
IF arr_recibo[idx].valor_pag is null THEN
LET arr_recibo[idx].valor_pag = 0
END IF
LET valor_f = arr_recibo[idx].valor_pag + valor_f
LET m = idx
END FOR
LET remanente = recibo.monto - valor_f
DISPLAY BY NAME remanente attribute (bold)
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
RETURN
END IF
EXIT INPUT
END INPUT
END IF
IF sale_arr = "S" THEN
GOTO vuelve10
END IF
END IF
LABEL arr2:
FOR idx = 1 TO 50
LET arr_cuenta1[idx].cuenta_no = null
LET arr_cuenta1[idx].num_doc = null
LET arr_cuenta1[idx].cod_aux = null
LET arr_cuenta1[idx].cod_sec = null
LET arr_cuenta1[idx].nom_cuenta = null
LET arr_cuenta1[idx].departamento = null
LET arr_cuenta1[idx].debito = null
LET arr_cuenta1[idx].credito = null
END FOR
LET referencia = "CK.",recibo.numero USING "&&&&&&"
DECLARE buscara1 CURSOR FOR
SELECT c.cuenta_no,c.departamento,c.cod_aux,c.cod_sec,c.num_doc,
d.descripcion,c.debito,c.credito
FROM cgtb00004 c,cgtb00001 d
WHERE c.cuenta_no = d.cuenta_no AND c.ref = referencia AND
d.status_t IS NULL AND c.cuenta_no NOT IN (recibo.cuenta_p) AND
c.detalles = recibo.cuenta_p
LET idx = 1
FOREACH buscara1 INTO arr_cuenta1[idx].*
LET idx = idx + 1
END FOREACH
CALL SET_COUNT(idx - 1)
LABEL err1:
# Captura de la codificacion del cheque para contabilidad
INPUT ARRAY arr_cuenta1 WITHOUT DEFAULTS FROM s_cuenta.*
ON KEY (CONTROL-F)
LET opc = "N"
LET sale_Arr = "S"
EXIT INPUT
ON KEY(CONTROL-P)
NEXT FIELD cuenta_no
ON KEY(CONTROL-W)
IF INFIELD(cuenta_no) THEN
# CALL busca_cuenta()
IF int_flag THEN
LET int_flag = false
NEXT FIELD cuenta_no
END IF
LET arr_cuenta1[curr].cuenta_no = cuentas[curr1].cuenta_no
LET arr_cuenta1[curr].nom_cuenta = cuentas[curr1].descripcion
DISPLAY arr_cuenta1[curr].cuenta_no TO s_cuenta[scr_l].cuenta_no
DISPLAY arr_cuenta1[curr].nom_cuenta TO s_cuenta[scr_l].nom_cuenta
IF cuentas[curr1].nivel != 3 THEN
LET numero_msg = 175
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
END IF
BEFORE ROW
LET curr = arr_curr()
LET scr_l = scr_line()
AFTER FIELD cuenta_no
#LET arr_cuenta1[curr].cod_aux = recibo.cod_sp
#LET arr_cuenta1[curr].cod_sec = recibo.cod_sp_sec
DISPLAY arr_cuenta1[curr].cod_aux to s_cuenta[scr_l].cod_aux
DISPLAY arr_cuenta1[curr].cod_sec to s_cuenta[scr_l].cod_sec
IF arr_cuenta1[curr].cuenta_no is not null or
arr_cuenta1[curr].cuenta_no != " " THEN
SELECT a.descripcion,a.origen,a.depto,a.nivel,a.ref,a.cata
INTO p_descripcion,p_origen,acept_dpto,p_nivel,p_ref,p_cata
FROM cgtb00001 a
WHERE a.cuenta_no = arr_cuenta1[curr].cuenta_no and
a.status_t is null
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
LET arr_cuenta1[curr].nom_cuenta = p_descripcion
DISPLAY arr_cuenta1[curr].nom_cuenta TO s_cuenta[scr_l].nom_cuenta
# Controla que la cuenta del banco no sea igual a una cuenta digitada
# en el arreglo
LET cuenta_a = arr_cuenta1[curr].cuenta_no clipped
LET cuenta_b = recibo.cuenta_p clipped
IF cuenta_a = cuenta_b THEN
LET numero_msg = 192
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
#-----------------------------------------------------------------------------
IF acept_dpto = "S" THEN
NEXT FIELD departamento
ELSE
LET arr_cuenta1[curr].departamento = null
DISPLAY arr_cuenta1[curr].departamento TO s_cuenta[scr_l].departamento
END IF
IF p_cata = "S" THEN
NEXT FIELD cod_aux
ELSE
LET arr_cuenta1[curr].cod_aux = null
LET arr_cuenta1[curr].cod_sec = null
DISPLAY arr_cuenta1[curr].cod_aux TO s_cuenta[scr_l].cod_aux
DISPLAY arr_cuenta1[curr].cod_sec TO s_cuenta[scr_l].cod_sec
IF p_ref = "S" THEN
NEXT FIELD num_doc
ELSE
LET arr_cuenta1[curr].num_doc = null
DISPLAY arr_cuenta1[curr].num_doc TO s_cuenta[scr_l].num_doc
END IF
NEXT FIELD debito
END IF
END IF
AFTER FIELD departamento
IF arr_cuenta1[curr].cuenta_no is not null THEN
IF acept_dpto = "S" THEN
IF arr_cuenta1[curr].departamento is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD departamento
END IF
SELECT a.nom_dpto INTO nombre_dpto FROM adtb00001 a
WHERE a.departamento = arr_cuenta1[curr].departamento and
a.status_t is null
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD departamento
END IF
DISPLAY BY NAME nombre_dpto ATTRIBUTE(blue)
END IF
ELSE
LET arr_cuenta1[curr].departamento = null
DISPLAY arr_cuenta1[curr].departamento TO s_cuenta[scr_l].departamento
NEXT FIELD cod_aux
END IF
AFTER FIELD cod_aux
IF arr_cuenta1[curr].cuenta_no is not null THEN
IF p_cata = "S" THEN
IF arr_cuenta1[curr].cod_aux is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
ELSE
LET arr_cuenta1[curr].cod_aux = null
LET arr_cuenta1[curr].cod_sec = null
DISPLAY arr_cuenta1[curr].cod_aux TO s_cuenta[scr_l].cod_aux
DISPLAY arr_cuenta1[curr].cod_sec TO s_cuenta[scr_l].cod_sec
NEXT FIELD num_doc
END IF
END IF
AFTER FIELD cod_sec
IF arr_cuenta1[curr].cuenta_no THEN
IF p_cata = "S" THEN
IF arr_cuenta1[curr].cod_sec is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
IF arr_cuenta1[curr].cod_aux != 1 THEN
SELECT a.nom_sp INTO nombre_cata FROM cotb00001 a
WHERE a.cod_sp = arr_cuenta1[curr].cod_aux AND
a.cod_sp_sec = arr_cuenta1[curr].cod_sec
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
DISPLAY BY NAME nombre_cata ATTRIBUTE(blue)
END IF
IF arr_cuenta1[curr].cod_aux = 1 THEN
SELECT nom1_emp,apell1_emp,departamento,nomina INTO nombre_cata
FROM adtb00003
WHERE num_emp = arr_cuenta1[curr].cod_sec
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD cod_aux
END IF
DISPLAY BY NAME nombre_cata
END IF
END IF
END IF
IF p_ref = "S" THEN
NEXT FIELD num_doc
ELSE
NEXT FIELD debito
END IF
AFTER FIELD num_doc
IF arr_cuenta1[curr].cuenta_no is not null THEN
IF p_ref = "S" THEN
IF arr_cuenta1[curr].num_doc IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD num_doc
END IF
ELSE
LET arr_cuenta1[curr].num_doc = null
DISPLAY arr_cuenta1[curr].num_doc TO s_cuenta[scr_l].num_doc
END IF
END IF
AFTER FIELD debito
IF arr_cuenta1[curr].debito is not null or
arr_cuenta1[curr].debito != 0 THEN
IF arr_cuenta1[curr].debito != 0 THEN
IF arr_cuenta1[curr].cuenta_no is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
END IF
END IF
AFTER ROW
IF arr_cuenta1[curr].cuenta_no is not null THEN
IF arr_cuenta1[curr].debito = 0 and
arr_cuenta1[curr].credito = 0 THEN
LET numero_msg = 207
CALL msg(numero_msg)
NEXT FIELD cuenta_no
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
IF valor_f is null THEN
LET valor_f = 0
END IF
IF arr_cuenta1[curr].debito is not null THEN
IF arr_cuenta1[curr].cuenta_no is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
END IF
IF arr_cuenta1[curr].credito is not null THEN
IF arr_cuenta1[curr].cuenta_no is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cuenta_no
END IF
END IF
END INPUT
IF sale_arr = "S" THEN
GOTO arr10
END IF
LET monto = 0
LET valor = 0
FOR idx = 1 TO arr_count()
IF arr_cuenta1[idx].debito is null THEN
LET arr_cuenta1[idx].debito = 0
END IF
IF arr_cuenta1[idx].credito is null THEN
LET arr_cuenta1[idx].credito = 0
END IF
LET valor = valor + arr_cuenta1[idx].debito
LET monto = arr_cuenta1[idx].credito + monto
END FOR
LET monto = valor - monto
IF monto != recibo.monto THEN
LET numero_msg = 178
CALL msg(numero_msg)
GOTO err1
END IF
PROMPT "Toda la Informacion Esta Correcta (S/N) ?" FOR char opc
LET opc = upshift(opc)
IF opc = "S" THEN
{
PROMPT "Desea Imprimir el Cheque Ahora (S/N) ?" FOR char opc1
LET opc1 = upshift(opc1)
IF opc1 != "S" THEN
START REPORT cheque TO "cheques1"
END IF
IF opc1 = "S" THEN
START REPORT cheque TO "%USHOME%\\archivo"
END IF
}
# Actualizacion de las tablas de cuentas por pagar y contabilidad general
IF m > 0 or opcion = "S" THEN
LET numero1 = recibo.numero
DELETE FROM cptb00001
WHERE @tipo_doc = tipo_doc1 AND @num_doc = numero1 AND
@cod_sp = recibo.cod_sp AND @cod_sp_sec = recibo.cod_sp_sec
FOR idx = 1 to m
IF arr_recibo[idx].valor_pag <> 0 and
arr_recibo[idx].valor_pag is not null THEN
##### Proceso para insertar valores en cuentas por pagar
#IF arr_recibo[idx].valor_pag > 0 THEN
LET arr_recibo[idx].valor_pag = arr_recibo[idx].valor_pag * -1
#END IF
IF arr_recibo[idx].orden_no IS NOT NULL OR
arr_recibo[idx].aplica_a IS NOT NULL THEN
INSERT INTO cptb00001
values (tipo_doc1,recibo.numero,recibo.cod_sp,recibo.cod_sp_sec,
recibo.fecha,recibo.fecha,arr_recibo[idx].orden_no,
arr_recibo[idx].tipo,arr_recibo[idx].aplica_a,
recibo.cuenta_p,arr_recibo[idx].valor_pag,detalle_1,null,
usuario,fecha_crea,USER,CURRENT)
END IF
IF arr_recibo[idx].aplica_a is not null THEN
IF idx < 6 THEN
LET factura1 = arr_recibo[idx].aplica_a CLIPPED
LET facturas = facturas CLIPPED,",",factura1 CLIPPED
END IF
END IF
IF arr_recibo[idx].orden_no is not null and
arr_recibo[idx].orden_no != 999999 THEN
IF idx < 10 THEN
LET orden1 = arr_recibo[idx].orden_no USING "######"
LET ordenes = ordenes CLIPPED,",",orden1 CLIPPED
END IF
END IF
END IF
END FOR
CALL integridad()
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
END IF
# Actualizacion de la tabla transacciones de contabildad general
LET referencia = "CK.",recibo.numero using "&&&&&&"
DELETE FROM cgtb00004 WHERE ref = referencia
FOR idx = 1 TO arr_count()
IF arr_cuenta1[idx].cuenta_no is not null THEN
IF arr_recibo[idx].orden_no is not null THEN
LET refe[idx] = arr_recibo[idx].orden_no
END IF
IF arr_recibo[idx].orden_no is not null THEN
LET refe[idx] = arr_recibo[idx].tipo using "&&","-",
arr_recibo[idx].aplica_a using "&&&&&&"
END IF
IF arr_recibo[idx].aplica_a is not null THEN
LET refe[idx] = arr_recibo[idx].aplica_a
END IF
INSERT INTO cgtb00004
values (recibo.fecha,2,referencia,arr_cuenta1[idx].cuenta_no,
arr_cuenta1[idx].departamento,arr_cuenta1[idx].num_doc,
arr_cuenta1[idx].cod_aux,arr_cuenta1[idx].cod_sec,null,detalle_1,
detalle_2,arr_cuenta1[idx].debito,arr_cuenta1[idx].credito,null,
usuario,fecha_crea,user,current)
CALL integridad()
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
END IF
END FOR
DISPLAY " "
# Actualiza La Tabla Datos Generales Del Cheque
UPDATE cgtb00005 set fecha = recibo.fecha,
portador = recibo.nom_sup,
tasa = recibo.tasa
WHERE cheque_no = recibo.numero and cuenta_no = "1108"
# Agregar La Cuenta Contable del Banco
INSERT INTO cgtb00004 values (recibo.fecha,2,referencia,recibo.cuenta_p,null,
null,recibo.cod_sp,recibo.cod_sp_sec,null,detalle_1,
detalle_2,0,recibo.monto,null,usuario,fecha_crea,
user,current)
LET numero_msg = 13
CALL msg(numero_msg)
CLEAR FORM
FOR idx = 1 TO 50
LET arr_cuenta1[idx].cuenta_no = null
LET arr_cuenta1[idx].num_doc = null
LET arr_cuenta1[idx].cod_aux = null
LET arr_cuenta1[idx].cod_sec = null
LET arr_cuenta1[idx].nom_cuenta = null
LET arr_cuenta1[idx].departamento = null
LET arr_cuenta1[idx].debito = null
LET arr_cuenta1[idx].credito = null
END FOR
END IF
COMMAND "Retornar"
EXIT MENU
END MENU
END FUNCTION
FUNCTION busca_cheque()
DEFINE cheque_num CHAR(10)
LET recibo.cod_sp = NULL
LET recibo.cod_sp_sec = NULL
LET cheque_num = recibo.numero USING "<<<<<<<<<<"
SELECT UNIQUE a.cod_sp,a.cod_sp_sec INTO recibo.cod_sp,recibo.cod_sp_sec
FROM cptb00001 a WHERE a.num_doc = cheque_num AND a.tipo_doc = "CK"
IF STATUS = NOTFOUND THEN
LET recibo.cod_sp = NULL
LET recibo.cod_sp_sec = NULL
END IF
END FUNCTION