{ ------------------------------------------------------------------ PROGRAMA : TEPRMT001 OBJETIVO : Capturar, Modificar, Eliminar registros de la Tabla de Depositos. PROGRAMADOR : Luis Miguel Soto Fuertes FECHA REALIZACION : Febrero 15, 2025. ------------------------------------------------------------------ } GLOBALS "teprgb000.4gl" DEFINE descrip_s CHAR(30), suma, total DEC(12, 2) DEFINE fecha_inicial, fecha_final DATE, aparecer BOOLEAN, entradaDiario VARCHAR(25) DEFINE recibos DYNAMIC ARRAY OF RECORD check1 CHAR(1), fecha_doc DATE, documento1 INT, tipo_doc CHAR(2), tipo_cliente1 INT, sec_cliente1 INT, nom_cliente VARCHAR(200), valor1 DEC(12, 2), tasa DECIMAL(2, 2), valor_p DECIMAL(12, 2) END RECORD, cuenta_no1 CHAR(20), pregunta CHAR(1), referencia VARCHAR(20), detalle VARCHAR(100) DEFINE bdocumento DYNAMIC ARRAY OF RECORD moneda1 VARCHAR(60), num_doc3 INT, fecha3 DATE, cuenta_no3 CHAR(19), valor3 DEC(12, 2), descripcion VARCHAR(100), monto_link1, monto_efectivo1, monto_ck1, monto_tarjeta1 DECIMAL(12, 2), entrada_no CHAR(30), ventas1 VARCHAR(1) END RECORD, tt_recibos DEC(12, 2) MAIN DEFER INTERRUPT CALL ARG_VAL(1) RETURNING usuarios CALL ARG_VAL(2) RETURNING clave CALL STARTLOG("teprmt001.txt") CONNECT TO "smarmotech" USER usuarios USING clave SELECT a.sucid, b.sucnombre, b.telefono, b.fax, b.rnc INTO deposito.sucursal, descrip_s, p_compania.telefono, p_compania.fax, p_compania.rnc FROM seg0001 a, sucursales b, vetb00020 c WHERE a.usuario = usuarios AND a.sucid = b.sucid AND b.localidad = c.cod_provincia CALL teprmt001() END MAIN FUNCTION teprmt001() CLEAR SCREEN OPTIONS FORM LINE 9, ERROR LINE 23, MESSAGE LINE 24, COMMENT LINE 21 CALL ui.Interface.loadStyles("formularios") OPEN FORM tefmmt001 FROM "tefmmt001" DISPLAY FORM tefmmt001 DISPLAY descrip_s TO nombrecia DISPLAY "teprmt001" AT 4, 3 ATTRIBUTE(RED) DISPLAY "Mantenimiento de Depositos" AT 6, 27 ATTRIBUTE(BLACK) MENU "OPCIONES" ON ACTION Adicionar CALL documentos.clear() LET INT_FLAG = FALSE CLEAR FORM DISPLAY descrip_s TO nombrecia CALL tepcad001() ON ACTION Consulta_modifica LET int_flag = FALSE DISPLAY descrip_s TO nombrecia CALL tepcmf001() ON ACTION Salir EXIT MENU END MENU END FUNCTION FUNCTION tepcad001() # WHENEVER ERROR CONTINUE ## Captura los datos que va a contener el registro INITIALIZE deposito.* TO NULL #LET deposito.procedencia=null LET deposito.monto_ck = 0 LET deposito.monto_efectivo = 0 LET deposito.monto_link = 0 LET deposito.monto = 0 LET deposito.monto_tarjeta = 0 LET descrip1 = NULL LET descrip2 = NULL DIALOG ATTRIBUTES(UNBUFFERED, FIELD ORDER FORM) INPUT BY NAME deposito.* BEFORE INPUT SELECT a.sucid, b.sucnombre, b.telefono, b.fax, b.rnc INTO deposito.sucursal, descrip_s, p_compania.telefono, p_compania.fax, p_compania.rnc FROM seg0001 a, sucursales b, vetb00020 c WHERE a.usuario = usuarios AND a.sucid = b.sucid AND b.localidad = c.cod_provincia LET deposito.fecha = TODAY DISPLAY BY NAME descrip_s SELECT num_doc INTO deposito.num_doc FROM tetb00009 IF deposito.num_doc IS NULL THEN LET deposito.num_doc = 0 ELSE LET deposito.num_doc = deposito.num_doc + 1 END IF DISPLAY BY NAME deposito.num_doc CALL cuenta() CALL busca_procedencia() # LET deposito.procedencia = proced DISPLAY BY NAME deposito.procedencia NEXT FIELD fecha AFTER FIELD sucursal SELECT a.nombre INTO descrip_s FROM companias a WHERE a.cod_comp = deposito.sucursal IF STATUS = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD sucursal END IF DISPLAY BY NAME descrip_s BEFORE FIELD num_doc AFTER FIELD cuenta_no IF deposito.cuenta_no = " " OR deposito.cuenta_no IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cuenta_no END IF { LET descrip1 = NULL SELECT i.descripcion INTO descrip1 FROM cgtb00001 i,cgtb00012 b WHERE i.cuenta_no = b.cuenta_no AND i.cuenta_no= deposito.cuenta_no AND i.status_t is null IF descrip1 IS NULL THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cuenta_no END IF DISPLAY BY NAME descrip1 } AFTER FIELD procedencia { IF deposito.cta_banco IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cta_banco END IF} LET descrip2 = NULL { IF deposito.procedencia IS NOT NULL THEN SELECT unique a.descripcion INTO descrip2 FROM tetb00002 a WHERE a.status_t IS NULL AND a.procedencia=deposito.procedencia IF descrip2 IS NULL THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD procedencia END IF DISPLAY BY NAME descrip2 END IF} AFTER FIELD fecha { IF deposito.procedencia IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD procedencia END IF} IF deposito.fecha IS NOT NULL THEN IF deposito.fecha > TODAY THEN LET numero_msg = 189 CALL msg(numero_msg) NEXT FIELD fecha END IF LET p_fechas = deposito.fecha CALL prd(p_fechas, usuarios) RETURNING bandera IF bandera = 1 THEN LET bandera = 0 NEXT FIELD fecha END IF END IF AFTER FIELD monto IF deposito.fecha IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fecha END IF IF deposito.monto IS NULL OR deposito.monto = 0 THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD monto END IF AFTER FIELD monto_efectivo LET deposito.monto = 0 LET deposito.monto = deposito.monto_efectivo + deposito.monto_ck + deposito.monto_link + deposito.monto_tarjeta AFTER FIELD monto_ck LET deposito.monto = 0 LET deposito.monto = deposito.monto_efectivo + deposito.monto_ck + deposito.monto_link + deposito.monto_tarjeta AFTER FIELD monto_link LET deposito.monto = 0 LET deposito.monto = deposito.monto_efectivo + deposito.monto_ck + deposito.monto_link + deposito.monto_tarjeta END INPUT INPUT BY NAME fecha_inicial, fecha_final BEFORE INPUT AFTER FIELD fecha_inicial LET fecha_final = TODAY # AFTER INPUT ON ACTION buscar_rec CALL recibos.clear() LET selec = "select distinct a.tipo_doc,a.num_doc,a.tipo_cliente,a.sec_cliente,b.nombre,a.fecha_orig,", " a.valor ", " from cctb00001 a,vetb00004 b", " where a.tipo_cliente=b.tipo_cliente and a.sec_cliente=b.sec_cliente ", " and a.cuenta_no is null and a.tipo_doc in ('PG','PC') and a.fecha_orig between ? and ? ", " UNION ", " select distinct a.tipo_doc,a.num_doc,a.tipo_cliente,a.sec_cliente,b.nombre,a.fecha_orig,", " a.valor ", " from cctb00001 a,vetb00004 b", " where a.tipo_cliente=b.tipo_cliente and a.sec_cliente=b.sec_cliente ", " and a.cuenta_no is null and a.tipo_doc in ('AV') and a.fecha_orig between ? and ? AND a.num_doc!=a.aplica_a ", " order by a.num_doc" PREPARE comando FROM selec DECLARE busca CURSOR FOR comando LET idx = 1 FOREACH busca USING fecha_inicial, fecha_final, fecha_inicial, fecha_final INTO recibos[idx].tipo_doc, recibos[idx].documento1, recibos[idx].tipo_cliente1, recibos[idx].sec_cliente1, recibos[idx].nom_cliente, recibos[idx].fecha_doc, recibos[idx].valor1 IF recibos[idx].valor1 < 0 THEN LET recibos[idx].valor1 = recibos[idx].valor1 * -1 END IF LET idx = idx + 1 END FOREACH IF idx = 1 THEN CALL FGL_winmessage( "error", "NO HAY REGISTROS CON ESA CONDICION", "STOP") NEXT FIELD fecha_inicial END IF END INPUT INPUT ARRAY recibos FROM ri.* ATTRIBUTES(WITHOUT DEFAULTS) BEFORE INPUT IF deposito.monto_efectivo IS NULL THEN LET deposito.monto_efectivo = 0 END IF IF deposito.monto_ck IS NULL THEN LET deposito.monto_ck = 0 END IF IF deposito.monto_link IS NULL THEN LET deposito.monto_link = 0 END IF IF deposito.monto_tarjeta IS NULL THEN LET deposito.monto_tarjeta = 0 END IF IF deposito.monto_efectivo = 0 AND deposito.monto_ck = 0 AND deposito.monto_link = 0 AND deposito.monto_tarjeta = 0 THEN CALL fgl_winmessage( "advertencia", "NO PUEDE QUEDAR EN BALNCO MONTO EFECTIVO,CHEQUE Y MONTO LINK LLENAR AL MENOS UNO DE LOS CAMPOS", "STOP") NEXT FIELD monto_efectivo END IF IF deposito.cta_banco IS NULL THEN CALL fgl_winmessage( "ERROR", "CUENTA DE BANCO NO PUEDE ESTAR EN BLANCO", "CUENTA") NEXT FIELD cta_banco END IF IF deposito.sucursal IS NULL THEN CALL fgl_winmessage( "ERROR", "SUCURSAL NO PUEDE ESTAR EN BLANCO", "SUCURSAL") NEXT FIELD sucursal END IF IF deposito.monto IS NULL THEN CALL fgl_winmessage( "ERROR", "MONTO NO PUEDE ESTAR EN BLANCO", "CUENTA") NEXT FIELD monto END IF # AFTER ROW # LET tt_recibos=0 ON CHANGE check1 LET tt_recibos = 0 FOR idx = 1 TO recibos.getLength() IF recibos[idx].check1 = 'S' THEN LET tt_recibos = tt_recibos + recibos[idx].valor1 #ELSE # LET tt_recibos=tt_recibos-recibos[arr_curr()].valor1 END IF DISPLAY BY NAME tt_recibos END FOR # END change END INPUT # ON ACTION recibos INPUT ARRAY documentos FROM record4.* ATTRIBUTES(WITHOUT DEFAULTS) BEFORE INPUT # LET suma=0 IF tt_recibos != deposito.monto THEN CALL fgl_winmessage( "ERROR", "CANTIDAD DE RECIBOS DIFERENTE AL MONTO DEL DEPOSITO", "STOP") NEXT FIELD check1 END IF FOR idx = 1 TO recibos.getLength() IF recibos[idx].check1 = "S" THEN IF recibos[idx].documento1 IS NOT NULL THEN LET documentos[idx].fecha = recibos[idx].fecha_doc LET documentos[idx].documento = recibos[idx].documento1 LET documentos[idx].tipo_cliente = recibos[idx].tipo_cliente1 LET documentos[idx].sec_cliente = recibos[idx].sec_cliente1 LET documentos[idx].cliente = recibos[idx].nom_cliente LET documentos[idx].tipodocumento = recibos[idx].tipo_doc IF recibos[idx].valor1 < 0 THEN LET documentos[idx].valor = recibos[idx].valor1 * -1 ELSE LET documentos[idx].valor = recibos[idx].valor1 END IF IF documentos[idx].documento IS NULL THEN CALL documentos.clear() END IF END IF # IF recibos[idx].check1="S" THEN # END IF END IF END FOR IF total IS NULL THEN LET total = 0 END IF #IF suma IS NULL THEN LET suma = 0 #END IF FOR idx = 1 TO documentos.getLength() LET suma = suma + documentos[idx].valor END FOR DISPLAY BY NAME suma END INPUT ON ACTION guardar SELECT num_doc INTO deposito.num_doc FROM tetb00009 IF deposito.num_doc IS NULL THEN LET deposito.num_doc = 0 ELSE LET deposito.num_doc = deposito.num_doc + 1 END IF DISPLAY BY NAME deposito.num_doc IF suma != deposito.monto THEN CALL fgl_winmessage( "ERROR", "EL VALOR SUMADO DE LOS RECIBOS NO PUEDE SER DIFERENTE AL MONTO DEL DEPOSITO", "STOP") NEXT FIELD valor END IF BEGIN WORK UPDATE tetb00009 SET num_doc = deposito.num_doc INSERT INTO tetb00001( num_doc, cuenta_no, cta_banco, procedencia, fecha, monto, sucursal, us_crea, fech_crea, monto_efectivo, monto_ck, monto_link, monto_tarjeta) VALUES(deposito.num_doc, deposito.cuenta_no, deposito.cta_banco, deposito.procedencia, deposito.fecha, deposito.monto, deposito.sucursal, usuarios, getdate(), deposito.monto_efectivo, deposito.monto_ck, deposito.monto_link, deposito.monto_tarjeta) FOR idx = 1 TO documentos.getLength() IF documentos[idx].documento IS NOT NULL THEN INSERT INTO tetb00008( num_doc, tipo_doc, documento, fecha, tipo_cliente, sec_cliente, nombre, valor, us_crea, fech_crea) VALUES(deposito.num_doc, documentos[idx].tipodocumento, documentos[idx].documento, documentos[idx].fecha, documentos[idx].tipo_cliente, documentos[idx].sec_cliente, documentos[idx].cliente, documentos[idx].valor, usuarios, getdate()) UPDATE cctb00001 SET cuenta_no = deposito.cuenta_no, numdoc_t = deposito.num_doc WHERE num_doc = documentos[idx].documento AND tipo_doc = documentos[idx].tipodocumento END IF END FOR IF status < 0 THEN ROLLBACK WORK CALL fgl_winmessage( "error", "NO SE PUDO INSERTAR LA DATA LA DATA", "STOP") ELSE COMMIT WORK LET r_output = "PDF" LET r_filename = "teprmt001.4rp" IF fgl_report_loadCurrentSettings( r_filename) THEN -- load the .4rp file CALL fgl_report_selectDevice(r_output) -- changing default CALL fgl_report_selectPreview(TRUE) LET handler = fgl_report_commitCurrentSettings() -- commit changes ELSE EXIT PROGRAM END IF START REPORT depositos TO XML HANDLER HANDLER OUTPUT TO REPORT depositos(deposito.*) FINISH REPORT depositos LET numero_msg = 13 CALL msg(numero_msg) CALL documentos.clear() CALL recibos.clear() CLEAR FORM RETURN END IF ON ACTION CANCEL LET int_flag = FALSE CLEAR FORM DISPLAY descrip_s TO nombrecia EXIT DIALOG END DIALOG { INSERT INTO tetb00001 VALUES (deposito.*) UPDATE tetb00001 SET (us_crea,fech_crea) = (usuarios,getdate()) WHERE @num_doc = deposito.num_doc} END FUNCTION FUNCTION tepcmf001() DEFINE fecha1, fecha2 DATE ## Aqui se prepara para la captura del criterio de seleccion DIALOG ATTRIBUTES(UNBUFFERED, FIELD ORDER FORM) INPUT BY NAME fecha1, fecha2, cuenta_no1 BEFORE INPUT LET criterio = NULL CLEAR FORM CALL bdocumento.clear() DISPLAY descrip_s TO nombrecia AFTER FIELD fecha1 LET fecha2 = fecha1 AFTER INPUT IF fecha2 < fecha1 THEN CALL msg(51) NEXT FIELD fecha1 END IF END INPUT CONSTRUCT criterio ON a.num_doc FROM num_doc1 END CONSTRUCT ON ACTION buscar IF cuenta_no1 IS NULL THEN CALL fgl_winmessage( "ERROR", "NO PUEDE DEJAR LA CUENTA EN BLANCO", "STOP") NEXT FIELD cuenta_no1 END IF IF criterio IS NOT NULL THEN LET criterio = criterio CLIPPED, ' AND ' END IF IF fecha2 IS NOT NULL THEN IF criterio IS NOT NULL THEN LET criterio = criterio CLIPPED, " a.fecha BETWEEN '", fecha1 USING "mm/dd/yyyy", "' AND '", fecha2 USING "mm/dd/yyyy", "' and " ELSE LET criterio = " a.fecha BETWEEN '", fecha1 USING "mm/dd/yyyy", "' AND '", fecha2 USING "mm/dd/yyyy", "' and " END IF END IF LET selec = " SELECT DISTINCT d.descripcion,a.num_doc,a.fecha,a.cuenta_no,a.monto,b.descripcion,", " a.monto_efectivo,a.monto_ck,a.monto_link,a.monto_tarjeta,a.entrada_no,a.ventas ", " FROM tetb00001 a INNER JOIN cgtb00001 b ON b.cuenta_no = a.cuenta_no ", " inner join seg0012 c on c.usuario = '", usuarios CLIPPED, "' and c.sucid =a.sucursal ", " inner join vetb00061 d on d.ventas = a.ventas", " WHERE ", criterio CLIPPED, " a.status_t is null and a.cuenta_no='", cuenta_no1, "' ", " ORDER BY a.num_doc " PREPARE busca1 FROM selec DECLARE datos CURSOR FOR busca1 LET idx = 1 LET criterio = NULL FOREACH datos INTO bdocumento[idx].moneda1, bdocumento[idx].num_doc3, bdocumento[idx].fecha3, bdocumento[idx].cuenta_no3, bdocumento[idx].valor3, bdocumento[idx].descripcion, bdocumento[idx].monto_efectivo1, bdocumento[idx].monto_ck1, bdocumento[idx].monto_link1, bdocumento[idx].monto_tarjeta1, bdocumento[idx].entrada_no, bdocumento[idx].ventas1 LET idx = idx + 1 END FOREACH IF idx = 1 THEN CALL FGL_winmessage( "error", "NO HAY REGISTROS CON ESA CONDICION", "STOP") CALL b_procedencias.clear() EXIT DIALOG END IF DISPLAY ARRAY bdocumento TO bdoc1.* ON ACTION imprimir SELECT UNIQUE a.num_doc, a.cuenta_no, a.cta_banco, a.procedencia, a.fecha, a.monto, a.us_crea, fech_crea, a.us_mod, a.fech_mod, a.sucursal INTO deposito.num_doc, deposito.cuenta_no, deposito.cta_banco, deposito.procedencia, deposito.fecha, deposito.monto, deposito.us_crea, deposito.fech_crea, deposito.us_mod, deposito.fech_mod, deposito.sucursal FROM tetb00001 a WHERE a.num_doc = bdocumento[arr_curr()].num_doc3 AND a.us_crea = usuarios SELECT a.sucnombre INTO descrip_s FROM sucursales a WHERE a.sucid = deposito.sucursal LET selec = "select a.tipo_doc,a.documento,a.fecha,a.tipo_cliente,a.sec_cliente,a.nombre,", " a.valor", " from tetb00008 a", " where a.num_doc=", deposito.num_doc PREPARE busca3 FROM selec DECLARE datos3 SCROLL CURSOR WITH HOLD FOR busca3 LET idx = 1 FOREACH datos3 INTO documentos[idx].tipodocumento, documentos[idx].documento, documentos[idx].fecha, documentos[idx].tipo_cliente, documentos[idx].sec_cliente, documentos[idx].cliente, documentos[idx].valor DISPLAY "documentos>", documentos[idx].documento LET idx = idx + 1 END FOREACH LET r_output = "PDF" LET r_filename = "teprmt001.4rp" IF fgl_report_loadCurrentSettings( r_filename) THEN -- load the .4rp file CALL fgl_report_selectDevice( r_output) -- changing default CALL fgl_report_selectPreview(TRUE) LET handler = fgl_report_commitCurrentSettings() -- commit changes ELSE EXIT PROGRAM END IF START REPORT depositos TO XML HANDLER HANDLER OUTPUT TO REPORT depositos(deposito.*) FINISH REPORT depositos ON ACTION entrada CALL registraEntrada(bdocumento[arr_curr()].num_doc3,bdocumento[arr_curr()].cuenta_no3, bdocumento[arr_curr()].fecha3,bdocumento[arr_curr()].ventas1, bdocumento[arr_curr()].valor3, usuarios) ON ACTION actualiza CALL documentos.clear() INPUT BY NAME deposito.* WITHOUT DEFAULTS BEFORE INPUT SELECT UNIQUE a.num_doc, a.cuenta_no, a.cta_banco, a.procedencia, a.fecha, a.monto, a.us_crea, fech_crea, a.us_mod, a.fech_mod, a.sucursal, a.monto_efectivo, a.monto_ck, a.monto_link, a.monto_tarjeta INTO deposito.num_doc, deposito.cuenta_no, deposito.cta_banco, deposito.procedencia, deposito.fecha, deposito.monto, deposito.us_crea, deposito.fech_crea, deposito.us_mod, deposito.fech_mod, deposito.sucursal, deposito.monto_efectivo, deposito.monto_ck, deposito.monto_link, deposito.monto_tarjeta FROM tetb00001 a WHERE a.num_doc = bdocumento[arr_curr()].num_doc3 LET p_fechas = deposito.fecha DISPLAY "p_fechas ", p_fechas, " ", deposito.fecha CALL prd(p_fechas, usuarios) RETURNING bandera IF bandera = 1 THEN LET bandera = 0 RETURN END IF CALL cuenta() CALL busca_procedencia() # LET deposito.procedencia = proced DISPLAY BY NAME deposito.* NEXT FIELD fecha AFTER FIELD sucursal SELECT a.nombre INTO descrip_s FROM companias a WHERE a.cod_comp = deposito.sucursal IF STATUS = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD sucursal END IF DISPLAY BY NAME descrip_s BEFORE FIELD num_doc AFTER FIELD cuenta_no IF deposito.cuenta_no = " " OR deposito.cuenta_no IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cuenta_no END IF LET descrip1 = NULL SELECT e.descripcion INTO descrip1 FROM cgtb00001 e, cgtb00012 b WHERE e.cuenta_no = b.cuenta_no AND e.cuenta_no = deposito.cuenta_no AND e.status_t IS NULL IF descrip1 IS NULL THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cuenta_no END IF DISPLAY BY NAME descrip1 AFTER FIELD procedencia { IF deposito.cta_banco IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cta_banco END IF} LET descrip2 = NULL IF deposito.procedencia IS NOT NULL THEN SELECT UNIQUE a.descripcion INTO descrip2 FROM tetb00002 a WHERE a.status_t IS NULL AND a.procedencia = deposito.procedencia IF descrip2 IS NULL THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD procedencia END IF DISPLAY BY NAME descrip2 END IF AFTER FIELD fecha IF deposito.fecha IS NOT NULL THEN IF deposito.fecha > TODAY THEN LET numero_msg = 189 CALL msg(numero_msg) NEXT FIELD fecha END IF LET p_fechas = deposito.fecha CALL prd(p_fechas, usuarios) RETURNING bandera IF bandera = 1 THEN LET bandera = 0 NEXT FIELD fecha END IF END IF AFTER FIELD monto IF deposito.monto IS NULL OR deposito.monto = 0 THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD monto END IF END INPUT INPUT ARRAY documentos FROM record4.* ATTRIBUTES(WITHOUT DEFAULTS) BEFORE INPUT LET selec = "select a.tipo_doc,a.documento,a.fecha,a.tipo_cliente,a.sec_cliente,a.nombre,", " a.valor,c.descripcion, c.ventas ", " from tetb00008 a inner join vetb00060 b on b.tipo_cliente = a.tipo_cliente ", " inner join vetb00061 c on c.ventas = b.ventas ", " where a.num_doc=", deposito.num_doc PREPARE busca2 FROM SELEC DECLARE datos1 SCROLL CURSOR WITH HOLD FOR busca2 LET idx = 1 FOREACH datos1 INTO documentos[idx].tipodocumento, documentos[idx].documento, documentos[idx].fecha, documentos[idx].tipo_cliente, documentos[idx].sec_cliente, documentos[idx].cliente, documentos[idx].valor, documentos[idx].moneda, documentos[idx].ventas LET idx = idx + 1 END FOREACH ON ACTION guardar BEGIN WORK IF suma < 0 THEN LET suma = suma * -1 END IF IF suma != deposito.monto THEN CALL fgl_winmessage( "ERROR", "EL VALOR SUMADO DE LOS RECIBOS NO PUEDE SER DIFERENTE AL MONTO DEL DEPOSITO", "STOP") NEXT FIELD documento END IF UPDATE tetb00001 SET (cuenta_no, cta_banco, procedencia, fecha, monto, us_mod, fech_mod, monto_efectivo, monto_ck, monto_tarjeta) = (deposito.cuenta_no, deposito.cta_banco, deposito.procedencia, deposito.fecha, deposito.monto, usuarios, getdate(), deposito.monto_efectivo, deposito.monto_ck, deposito.monto_tarjeta) WHERE @num_doc = deposito.num_doc DELETE FROM tetb00008 WHERE num_doc = deposito.num_doc FOR idx = 1 TO documentos.getLength() IF documentos[idx].documento IS NOT NULL THEN UPDATE cctb00001 SET banco = NULL WHERE num_doc = documentos[idx].documento AND tipo_doc = documentos[idx].tipodocumento INSERT INTO tetb00008( num_doc, tipo_doc, documento, fecha, tipo_cliente, sec_cliente, nombre, valor, us_mod, fech_mod) VALUES(deposito.num_doc, documentos[idx].tipodocumento, documentos[idx].documento, documentos[idx].fecha, documentos[idx].tipo_cliente, documentos[idx].sec_cliente, documentos[idx].cliente, documentos[idx].valor, usuarios, getdate()) UPDATE cctb00001 SET banco = deposito.cta_banco WHERE num_doc = documentos[idx].documento AND tipo_doc = documentos[idx].tipodocumento END IF END FOR IF status < 0 THEN ROLLBACK WORK CALL fgl_winmessage( "error", "NO SE PUDO INSERTAR LA DATA LA DATA", "STOP") ELSE COMMIT WORK LET numero_msg = 13 CALL msg(numero_msg) CALL documentos.clear() CALL recibos.clear() CLEAR FORM RETURN END IF DISPLAY ARRAY documentos TO record4.* END INPUT { UPDATE tetb00001 SET (cuenta_no,cta_banco,procedencia, fecha,monto,us_mod,fech_mod) = (deposito.cuenta_no,deposito.cta_banco, deposito.procedencia,deposito.fecha, deposito.monto,USER,CURRENT) WHERE @num_doc = deposito.num_doc LET numero_msg = 13 } CALL msg(numero_msg) ON ACTION eLiminar # FOR idx=1 TO bdocumento.getLength() UPDATE tetb00001 SET status_t = "E" WHERE num_doc = bdocumento[arr_curr()].num_doc3 UPDATE tetb00008 SET status_t = "E" WHERE num_doc = bdocumento[arr_curr()].num_doc3 LET selec = "select a.num_Doc,a.tipo_doc,a.documento,a.fecha,a.tipo_cliente,a.sec_cliente,a.nombre,", " a.valor", " from tetb00008 a", " where a.num_doc=", bdocumento[arr_curr()].num_doc3 PREPARE busca3 FROM SELEC DECLARE datos2 SCROLL CURSOR WITH HOLD FOR busca3 LET idx = 1 FOREACH datos2 INTO deposito.num_doc, documentos[idx].tipodocumento, documentos[idx].documento, documentos[idx].fecha, documentos[idx].tipo_cliente, documentos[idx].sec_cliente, documentos[idx].cliente, documentos[idx].valor UPDATE cctb00001 SET (cuenta_no, numdoc_t) = (NULL, NULL) WHERE num_doc = documentos[idx].documento AND tipo_doc = documentos[idx].tipodocumento AND numdoc_t = bdocumento[arr_curr()].num_doc3 LET idx = idx + 1 END FOREACH LET numero_msg = 39 CALL msg(numero_msg) # END for END DISPLAY ON ACTION CANCEL LET int_flag = FALSE CLEAR FORM DISPLAY descrip_s TO nombrecia EXIT DIALOG END DIALOG END FUNCTION FUNCTION busca_cuenta() # Esta funcion busca el nombre del cuenta y lo despliega en pantalla # Esta funcion es valida solamente para la consulta-modificacion. SELECT e.descripcion INTO descrip1 FROM cgtb00001 e WHERE e.cuenta_no = deposito.cuenta_no AND e.status_t IS NULL IF status >= 0 THEN IF status = NOTFOUND THEN LET numero_msg = 68 CALL msg(numero_msg) ELSE IF status_reg = "E" THEN LET numero_msg = 67 CALL msg(numero_msg) END IF END IF ELSE # CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF END IF END FUNCTION FUNCTION busca_procedencia() # Esta funcion busca el nombre de la Procedencia DEFINE kid INT, kdescripcion CHAR(80), kprocedencia ui.ComboBox LET kprocedencia = ui.combobox.forName("formonly.procedencia") DECLARE buscador CURSOR FOR SELECT e.procedencia, e.descripcion FROM tetb00002 e WHERE e.status_t IS NULL ORDER BY 1 CALL kprocedencia.clear() FOREACH buscador INTO kid, kdescripcion CALL kprocedencia.addItem(kid, kdescripcion) END FOREACH END FUNCTION FUNCTION cuenta() DEFINE kcuenta VARCHAR(20), kdescripcion CHAR(80), cuenta_no ui.ComboBox, cuentaForm STRING LET cuentaForm = "formonly.cuenta_no" LET cuenta_no = ui.combobox.forname(cuentaForm) DECLARE busca_cuenta CURSOR FOR SELECT DISTINCT RTRIM(a.cuenta_no), '(' + RTRIM(a.cuenta_no) + ')' + RTRIM(a.descripcion) FROM cgtb00001 a, cgtb00012 b WHERE a.status_t IS NULL AND a.cuenta_no = b.cuenta_no ORDER BY 1 CALL cuenta_no.clear() FOREACH busca_cuenta INTO kcuenta, kdescripcion CALL cuenta_no.additem(kcuenta, kdescripcion) END FOREACH END FUNCTION REPORT depositos(z) DEFINE z RECORD num_doc INT, cuenta_no CHAR(8), cta_banco CHAR(8), procedencia INT, fecha DATE, monto DEC(12, 2), status_t CHAR(1), us_crea CHAR(50), fech_crea DATE, us_mod CHAR(50), fech_mod DATE, sucursal INT, monto_efectivo, monto_ck, monto_link, monto_tarjeta DECIMAL(12, 2) END RECORD, fecha DATE, hora CHAR(10), descrion_pro VARCHAR(100), monto_efectivo, monto_ck, monto_link DECIMAL(12, 2) OUTPUT TOP MARGIN 0 LEFT MARGIN 0 BOTTOM MARGIN 2 FORMAT FIRST PAGE HEADER LET fecha = TODAY LET hora = TIME SELECT e.descripcion INTO descrion_pro FROM tetb00002 e WHERE e.procedencia = deposito.procedencia { IF z.documento IS NOT NULL OR z.documento>0 THEN LET imprime=true ELSE LET imrpime =false END IF } DISPLAY "boolean", aparecer ON EVERY ROW DISPLAY "sucursal" PRINTX z.*, descrip_s, fecha, hora, descrion_pro, aparecer FOR idx = 1 TO documentos.getLength() LET aparecer = TRUE PRINTX documentos[idx].* END FOR END REPORT FUNCTION msg(numero_msg) DEFINE numero_msg SMALLINT DEFINE descripcion CHAR(60) SELECT desc_msg INTO descripcion FROM msgtable WHERE cod_msg = numero_msg IF status = NOTFOUND THEN SELECT desc_msg INTO descripcion FROM msgtable WHERE cod_msg = 22 LET descripcion = descripcion CLIPPED, numero_msg USING "<<<<" ERROR descripcion ATTRIBUTE(BOLD) ELSE ERROR descripcion ATTRIBUTE(BOLD) LET numero_msg = 0 END IF END FUNCTION FUNCTION prd(p_fechas, puser) DEFINE c_ano, a_ano INT, mes_control, mes_calc, numero_msg, bandera, dia SMALLINT, p_fechas, fecha_c, comp_fech, comp_fech1 DATE, puser CHAR(50) LET a_ano = YEAR(p_fechas) LET mes_control = MONTH(TODAY) LET mes_calc = mes_control IF mes_calc = 01 THEN LET mes_calc = 13 LET a_ano = YEAR(TODAY - 32) END IF #Aqui la funcion se posicionaba en dos meses para el control del documento #LET mes_calc = mes_calc - 2 IF mes_calc <= 0 THEN LET mes_calc = 12 LET a_ano = YEAR(TODAY) - 1 END IF LET c_ano = YEAR(TODAY) SELECT MIN(fecha_corte) INTO fecha_c FROM prdtable WHERE fecha_corte >= p_fechas IF status = NOTFOUND THEN LET numero_msg = 58 CALL msg(numero_msg) LET bandera = 1 END IF DISPLAY "Fecha c 1 ", fecha_c SELECT MIN(dias_gracia) INTO dia FROM prdtable WHERE fecha_corte = fecha_c IF dia IS NULL THEN LET dia = 0 END IF DISPLAY "usuario ", puser SELECT a.nom_puesto FROM seg0003 a WHERE a.usuario = puser AND a.nom_puesto IN ('ADMINISTRATOR', 'FINANZAS') IF STATUS <> NOTFOUND THEN LET fecha_c = fecha_c + dia END IF DISPLAY "fecha ", fecha_c, " dia ", dia LET comp_fech = fecha_c LET comp_fech1 = TODAY IF comp_fech < comp_fech1 THEN LET numero_msg = 57 CALL msg(numero_msg) LET bandera = 1 END IF RETURN bandera END FUNCTION