{ ----------------------------------------------------------------------------- PROGRAMA : VEPRMT031 OBJETIVO : de notas de credito REALIZADO POR : Juan F. soto FECHA : Junio 08, 1994 MODIFICADO POR : Juan F. Soto DESCRIPCION : Despues de la ultima modificacion que consistia en la impresion de los codigos de los productos que se habian devueltos. Esta Modificacion Consiste en quitar el codigo del usuario 9999 y que el precio para el calculo de nota de credito sea el precio de venta que tiene el producto en el momento de hacer este documento. FECHA : Agosto 1, 1995. ----------------------------------------------------------------------------- } GLOBALS "veprgb000.4gl" DEFINE arr_recibo ARRAY [1] OF RECORD cod_mov LIKE iptb00006.cod_mov, aplica_a LIKE cctb00001.aplica_a, valor_pen DECIMAL(12,2), desc_p LIKE cctb00001.monto_desc, val_desc DECIMAL(12,2), valor_pag DECIMAL(12,2) END RECORD, busca1,busca2,p_status,reimpresion,chitbis CHAR(10), pitbis,pdescuento,xporc_Desc DEC(12,2), xbodega VARCHAR(30) DEFINE nombre_emp,nom_cli CHAR(30) DEFINE p_num_doc INTEGER DEFINE p_itbi,valor_fac,p_total DECIMAL(12,2) DEFINE fecha1 DATE DEFINE codi_cia SMALLINT DEFINE p_tipo_cliente,p_sec_cliente SMALLINT, salir,via CHAR(1), ptotalb,xdescuento DEC(12,2) DEFINE normal,negrilla_on,negrillas_of,comp_on,comp_off,doce,doble_on,doble_off CHAR(3), usuarios,clave CHAR(80), HANDLER om.SaxDocumentHandler, salida VARCHAR(4) DEFINE p_companias RECORD LIKE companias.*, r_output STRING MAIN DEFER INTERRUPT CALL ARG_VAL(1) RETURNING usuarios CALL ARG_VAL(2) RETURNING clave CALL ARG_VAL(4) RETURNING impresor # CONNECT to "marmotech" AS "IFMX" CONNECT TO "smarmotech" USER usuarios USING clave SELECT * INTO p_companias.* FROM companias CALL veprmt031() END MAIN ####### Funcion para agregar un recibo de pago FUNCTION veprmt031() OPTIONS FORM LINE 8, ERROR LINE 24, COMMENT LINE 22, PROMPT LINE 22 OPEN FORM vefmmt031 FROM "vefmmt031" DISPLAY FORM vefmmt031 MENU ON ACTION nuevo CALL ccpcad001() ON ACTION buscar CALL ccpcmf001() ON ACTION salir EXIT MENU END MENU END FUNCTION FUNCTION ccpcad001() DEFINE porc_p DECIMAL(10,2) DEFINE emp SMALLINT DEFINE hoy DATE LET hoy = null LABEL volver: LET recibo.fecha_orig = fecha1 # Control Secuencial de las notas de creditos LET recibo.cod_emp_sec = null LET recibo.fecha_orig = null LET recibo.tipo_cliente = null LET recibo.sec_cliente = null LET recibo.itbi = 0 LET reimpresion="N" LET chitbis = fgl_winquestion("PREGUNTA","Esta nota de credito calcula ITBIS?","NO","NO|YES|CANCEL","QUESTION",0) LET chitbis = UPSHIFT(chitbis) INPUT BY NAME recibo.fecha_orig,recibo.concepto,fact_gral.bodega WITHOUT DEFAULTS BEFORE INPUT CALL bodegas(1) ## VENTANAS PARA BUSCAR LOS CLIENTES Y LOS EMPLEADOS BEFORE FIELD fecha_orig SELECT UNIQUE a.num_doc FROM cctb00001 a WHERE a.tipo_doc = "NC" AND a.num_doc = recibo.num_doc IF STATUS != NOTFOUND THEN SELECT MAX(a.num_doc)+1 INTO recibo.num_doc FROM cctb00001 a WHERE a.tipo_doc = "NC" DISPLAY BY NAME recibo.num_doc ATTRIBUTE(BOLD) END IF LET recibo.fecha_orig = today DISPLAY BY NAME recibo.fecha_orig AFTER FIELD bodega SELECT a.descripcion INTO xbodega FROM intb00009 a WHERE a.cod_bodega = fact_gral.bodega AFTER FIELD fecha_orig IF recibo.fecha_orig IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fecha_orig END IF LET p_fechas = recibo.fecha_orig CALL prd() IF bandera = 1 THEN LET bandera = 0 NEXT FIELD fecha_orig END IF LET fecha1 = recibo.fecha_orig AFTER INPUT IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE CLEAR FORM RETURN END IF IF fact_gral.bodega IS NULL THEN CALL msg(16) NEXT FIELD bodega END IF END INPUT LABEL arreglo: ## AQUI SE INTRODUCEN LOS DATOS DEL ARREGLO INPUT ARRAY arr_recibo WITHOUT DEFAULTS FROM s_recibo.* ## VENTANA PARA BUSCAR LOS DOCUMENTOS BEFORE ROW LET curr = arr_curr() LET scr_l = scr_line() LET p_itbi = 0 AFTER FIELD aplica_a IF arr_recibo[curr].aplica_a IS NOT NULL THEN LET bandera = 0 CALL repetir1() IF fact_gral.bodega IS NULL THEN CALL fgl_winmessage("ERROR","BODEGA EN BALNCO","INFO") NEXT FIELD aplica_a END IF # Chequea que la devolucion tenga su nota de credito SELECT unique a.num_cheque FROM cctb00001 a WHERE a.num_cheque = arr_recibo[curr].aplica_a AND a.tipo_doc = "NC" AND a.banco = arr_recibo[curr].cod_mov AND a.bodega = fact_gral.bodega and a.status_t IS NULL IF STATUS != NOTFOUND THEN LET numero_msg = 364 CALL msg(numero_msg) NEXT FIELD aplica_a END IF IF bandera = 1 THEN NEXT FIELD aplica_a END IF # Busca el codigo del cliente y chequea que el documento de almacen # exista LET fact_gral.factura = NULL SELECT unique a.cod_sp,a.cod_sp_sec,a.cod_cia,a.factura,a.status_t INTO p_tipo_cliente,p_sec_cliente,codi_cia,fact_gral.factura, p_status FROM iptb00006 a WHERE (a.num_doc = arr_recibo[curr].aplica_a) and (a.cod_mov = arr_recibo[curr].cod_mov) AND (a.bodega = fact_gral.bodega) IF status = notfound or p_status = "E" THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD aplica_a END IF IF recibo.tipo_cliente is null or recibo.sec_cliente is null THEN LET recibo.tipo_cliente = p_tipo_cliente LET recibo.sec_cliente = p_sec_cliente END IF IF recibo.sec_cliente != p_sec_cliente THEN LET numero_msg = 214 CALL msg(numero_msg) NEXT FIELD aplica_a END IF DISPLAY BY NAME fact_gral.factura SELECT a.sec_vend INTO recibo.cod_emp_sec FROM vetb00028 a WHERE a.tipo_cliente = recibo.tipo_cliente and a.sec_cliente = recibo.sec_cliente SELECT b.nombre,a.calle||' '||a.casa_num||' '||a.urbanizacion||' '||a.barrio,c.ventas INTO nom_cli,fact_gral.direccion,fact_gral.ventas FROM vetb00004 b,vetb00060 c,OUTER vetb00005 a WHERE (b.tipo_cliente = recibo.tipo_cliente) and (b.sec_cliente = recibo.sec_cliente) AND b.tipo_cliente = a.tipo_cliente AND b.sec_cliente = a.sec_cliente AND b.tipo_cliente = c.tipo_cliente IF status = notfound THEN LET nom_cli = "NO E X I S T E" END IF DISPLAY BY NAME recibo.tipo_cliente,recibo.sec_cliente, nom_cli ATTRIBUTE (BOLD) LET descrip2 = null LET descrip3 = null SELECT nom1_emp,apell1_emp INTO descrip2,descrip3 FROM adtb00003 WHERE num_emp = recibo.cod_emp_sec IF status = notfound THEN LET nombre_emp = "NO E X I S T E" ELSE LET nombre_emp = descrip2 clipped," ",descrip3 clipped END IF DISPLAY BY NAME recibo.cod_emp_sec,nombre_emp ATTRIBUTE (BOLD) # BUSCA PORCENTAJE ITBIS FACTURA LET pitbis = 0 IF chitbis <> "NO" THEN SELECT a.porc_itbi INTO pitbis FROM vetb00002 a WHERE a.factura = fact_gral.factura IF pitbis IS NULL OR pitbis = 0 THEN CALL fgl_winmessage("ITBIS","ITBIS EN BLANCO","INFO") NEXT FIELD aplica_a END IF END IF IF fact_gral.bodega IS NULL THEN CALL fgl_winmessage("BODEGA","BODEGA EN BLANCO","INFO") NEXT FIELD aplica_a END IF LET busca1 = "S" SELECT sum(a.cantidad_2*b.precio) INTO valor_fac FROM iptb00006 a,vetb00003 b WHERE (a.num_doc = arr_recibo[curr].aplica_a) AND (a.cod_n = b.cod_n) and (a.cod_grupo = b.cod_grupo) and (a.cod_tipo = b.cod_tipo) and (a.cod_sec = b.cod_sec) and (a.cod_mov = arr_recibo[curr].cod_mov) and (b.factura = a.factura) AND a.area = b.area AND (a.bodega = fact_gral.bodega) LET arr_recibo[curr].valor_pen = valor_fac DISPLAY arr_recibo[curr].valor_pen TO s_recibo[scr_l].valor_pen IF valor_fac IS NULL THEN CALL fgl_winmessage("INFO","VALOR DEL PRODUCTO EN CERO","INFO") NEXT FIELD aplica LET busca2 = "S" LET busca1 = "N" { SELECT sum(a.cantidad_2*b.precio) INTO valor_fac FROM iptb00006 a,vetb00025 b WHERE (a.num_doc = arr_recibo[curr].aplica_a) and (a.cod_n = b.cod_n) and (a.cod_grupo = b.cod_grupo) and (a.cod_tipo = b.cod_tipo) and (a.cod_sec = b.cod_sec) and (a.cod_mov = arr_recibo[curr].cod_mov) and a.bodega = fact_gral.bodega and b.ventas = "1" and b.tipo_cliente is null} END IF LET arr_recibo[curr].valor_pen = valor_fac DISPLAY arr_recibo[curr].valor_pen TO s_recibo[scr_l].valor_pen LET pdescuento = 0 # BUSCA EL DESCUENTO SELECT SUM(a.cantidad_2 * b.precio *(b.cantidad_2/100)),AVG(b.cantidad_2) INTO pdescuento,xporc_desc FROM iptb00006 a,vetb00003 b WHERE (a.num_doc = arr_recibo[curr].aplica_a) and (a.cod_n = b.cod_n) and (a.cod_grupo = b.cod_grupo) and (a.cod_tipo = b.cod_tipo) and (a.cod_sec = b.cod_sec) and (a.cod_mov = arr_recibo[curr].cod_mov) and (b.factura = fact_gral.factura) AND a.area = b.area AND a.bodega = fact_gral.bodega IF pdescuento IS NULL THEN LET pdescuento = 0 END IF LET arr_recibo[curr].val_desc = pdescuento LET arr_recibo[curr].desc_p = xporc_Desc DISPLAY arr_recibo[curr].val_desc to s_recibo[scr_l].val_desc DISPLAY arr_recibo[curr].desc_p to s_recibo[scr_l].desc_p END IF LET arr_recibo[curr].val_desc=pdescuento # El campo VALOR_PEN gruarda el valor bruto de la nota de credito obtenida # por la multiplicacion de las cantidades devueltas por el movimiento 12 # por el precio actual del producto # LET arr_recibo[curr].val_desc = arr_recibo[curr].valor_pen * # (arr_recibo[curr].desc_p / 100) # Calcula el itbi despues de restar el descuento al monto bruto IF chitbis = "YES" THEN LET p_itbi = (arr_recibo[curr].valor_pen - arr_recibo[curr].val_desc) * (pitbis / 100) LET recibo.itbi = recibo.itbi + p_itbi ELSE LET recibo.itbi = 0 END IF LET arr_recibo[curr].valor_pag = (arr_recibo[curr].valor_pen - arr_recibo[curr].val_desc) + p_itbi DISPLAY BY NAME recibo.itbi DISPLAY arr_recibo[curr].valor_pag to s_recibo[scr_l].valor_pag DISPLAY arr_recibo[curr].val_desc to s_recibo[scr_l].val_desc AFTER FIELD valor_pag IF arr_recibo[curr].aplica_a IS NOT NULL THEN IF arr_recibo[curr].valor_pag is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD valor_pag END IF END IF IF arr_recibo[curr].valor_pag is not null THEN IF arr_recibo[curr].aplica_a IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD aplica_a END IF END IF IF arr_recibo[curr].aplica_a is not null and arr_recibo[curr].valor_pen is not null THEN IF arr_recibo[curr].aplica_a IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD aplica_a END IF LET bandera = 0 CALL repetir1() IF bandera = 1 THEN NEXT FIELD aplica_a END IF IF arr_recibo[curr].valor_pag IS NULL THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD valor_pag END IF LET p_total = 0 FOR idx = 1 TO arr_count() IF arr_recibo[idx].valor_pag is not null THEN LET p_total = p_total + arr_recibo[idx].valor_pag END IF END FOR DISPLAY BY NAME p_total ATTRIBUTE(BOLD) END IF EXIT INPUT AFTER INPUT IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE CLEAR FORM RETURN END IF IF arr_recibo[curr].aplica_a IS NOT NULL THEN IF arr_recibo[curr].valor_pag is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD valor_pag END IF END IF IF arr_recibo[curr].valor_pag is null THEN LET arr_recibo[curr].valor_pag = 0 END IF EXIT INPUT END INPUT LET via = "S" IF via = "S" THEN INPUT BY NAME recibo.tipo_cliente,recibo.sec_cliente,recibo.cod_emp_sec WITHOUT DEFAULTS AFTER FIELD sec_cliente SELECT b.nombre,a.calle||' '||a.casa_num||' '||a.urbanizacion||' '||a.barrio INTO nom_cli,fact_gral.direccion FROM vetb00004 b,vetb00005 a WHERE (b.tipo_cliente = recibo.tipo_cliente) and (b.sec_cliente = recibo.sec_cliente) AND b.tipo_cliente = a.tipo_cliente AND b.sec_cliente = a.sec_cliente IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD tipo_cliente END IF DISPLAY BY NAME nom_cli AFTER FIELD cod_emp_sec LET descrip2 = null LET descrip3 = null SELECT nom1_emp,apell1_emp INTO descrip2,descrip3 FROM adtb00003 WHERE num_emp = recibo.cod_emp_sec IF status = notfound THEN LET nombre_emp = "NO E X I S T E" ELSE LET nombre_emp = descrip2 clipped," ",descrip3 clipped END IF DISPLAY BY NAME nombre_emp 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 # SECUENCIA RECIBO SELECT ult_recibo INTO p_num_doc FROM cctb00003 WHERE tipo_doc = "NC" LET p_num_doc = p_num_doc + 1 LET recibo.num_doc = p_num_doc DISPLAY BY NAME recibo.num_doc ATTRIBUTE (BOLD) CALL defecto(usuarios,clave,impresor) RETURNING imprime,negrilla_on,negrillas_of, doble_on,doble_off,comp_on,comp_off, doce,normal,archivo,copia IF salida IS NULL THEN LET salida = 'PDF' END IF CALL configureoutput(salida) RETURNING HANDLER START REPORT cr_edito TO XML HANDLER HANDLER IF arr_recibo[1].aplica_a is not null THEN OUTPUT TO REPORT cr_edito (recibo.*,arr_recibo[1].*,nom_cli, descrip2,descrip3,codi_cia) END IF FINISH REPORT cr_edito #RUN imprime LET numero_msg = 1 CALL msg(numero_msg) LET emp = recibo.cod_emp_sec CLEAR FORM GOTO volver END FUNCTION ## Funcion para consultar/modificar un recibo de pago FUNCTION ccpcmf001() DEFINE usuario RECORD us_crea CHAR(9), fech_crea LIKE cctb00001.fech_crea END RECORD ## SE PREPARA EL CRITERIO PARA CONSULTAR/MODIFICAR UN REGISTRO CONSTRUCT CRITERIO ON a.num_doc,a.tipo_cliente,a.sec_cliente FROM num_doc,tipo_cliente, sec_cliente IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE CLEAR FORM RETURN END IF LET reimpresion="N" LET selec = "SELECT distinct a.num_doc,a.tipo_cliente,a.sec_cliente,a.cod_emp_sec, ", " a.fecha_orig,a.valor_efectivo,b.comentario,a.banco,a.num_cheque,a.valor*-1,a.valor_cheque,a.monto_desc, ", " b.bodega,b.factura ", "FROM cctb00001 a, cctb00011 b ", "WHERE ",criterio clipped," and a.tipo_doc = 'NC' AND ", " a.num_doc = b.num_doc and a.tipo_doc = b.tipo_doc and a.status_t is null ORDER BY a.num_doc" PREPARE busca FROM selec DECLARE datos SCROLL CURSOR FOR busca OPEN datos FETCH FIRST datos INTO recibo.*,arr_recibo[1].cod_mov,arr_recibo[1].aplica_a,arr_recibo[1].valor_pag,ptotalb,xdescuento, fact_gral.bodega,fact_gral.factura IF status = NOTFOUND THEN LET numero_msg = 3 CALL msg(numero_msg) RETURN END IF CALL informacion() LABEL vuelve: MENU "OPCION" COMMAND "Siguiente" "Presenta en pantalla el proximo registro encontrado" FETCH NEXT datos INTO recibo.*,arr_recibo[1].cod_mov,arr_recibo[1].aplica_a,arr_recibo[1].valor_pag,ptotalb,xdescuento, fact_gral.bodega,fact_gral.factura IF status = NOTFOUND THEN LET numero_msg = 4 CALL msg(numero_msg) END IF CALL informacion() COMMAND "Anterior" "Presenta en pantalla el registro anterior encontrado" FETCH PREVIOUS datos INTO recibo.*,arr_recibo[1].cod_mov,arr_recibo[1].aplica_a,arr_recibo[1].valor_pag,ptotalb,xdescuento, fact_gral.bodega IF status = NOTFOUND THEN LET numero_msg = 5 CALL msg(numero_msg) END IF CALL informacion() COMMAND "Primero" "Presenta en pantalla el primer registro encontrado" FETCH FIRST datos INTO recibo.*,arr_recibo[1].cod_mov,arr_recibo[1].aplica_a,arr_recibo[1].valor_pag,ptotalb,xdescuento, fact_gral.bodega IF status = NOTFOUND THEN LET numero_msg = 5 CALL msg(numero_msg) END IF CALL informacion() COMMAND "Ultimo" "Presenta en pantalla el ultimo registro encontrado" FETCH LAST datos INTO recibo.*,arr_recibo[1].cod_mov,arr_recibo[1].aplica_a,arr_recibo[1].valor_pag,ptotalb,xdescuento, fact_gral.bodega IF STATUS = NOTFOUND THEN LET numero_msg = 4 CALL msg(numero_msg) END IF CALL informacion() COMMAND KEY ("N") "aNular" LET p_fechas = recibo.fecha_orig CALL prd() IF bandera = 1 THEN LET bandera = 0 CONTINUE MENU END IF ## AQUI SE REALIZA LA ANULACION DE UN REGISTRO UPDATE cctb00001 set status_t = "E", us_mod = SUSER_SNAME(), fech_mod = GETDATE() WHERE tipo_doc = "NC" and num_doc = recibo.num_doc LET numero_msg = 82 CALL msg(numero_msg) COMMAND KEY("P") "imPrimir" LET reimpresion = "S" LET busca1 = "N" CALL defecto(usuarios,clave,impresor) RETURNING imprime,negrilla_on,negrillas_of, doble_on,doble_off,comp_on,comp_off, doce,normal,archivo,copia IF salida IS NULL THEN LET salida = 'PDF' END IF CALL configureoutput(salida) RETURNING HANDLER START REPORT cr_edito TO XML HANDLER HANDLER IF arr_recibo[1].aplica_a is not null THEN OUTPUT TO REPORT cr_edito (recibo.*,arr_recibo[1].*,nom_cli, descrip2,descrip3,codi_cia) END IF FINISH REPORT cr_edito RUN imprime COMMAND "Retornar" CLEAR FORM CALL arr_recibo.clear() EXIT MENU END MENU END FUNCTION FUNCTION repetir1() DEFINE ant_art RECORD aplica_a INTEGER, valor_pag INTEGER END RECORD LET ant_art.aplica_a = arr_recibo[curr].aplica_a LET ant_art.valor_pag = arr_recibo[curr].valor_pag FOR idx = 1 to arr_count() IF idx != curr THEN IF arr_recibo[idx].aplica_a IS NOT NULL AND arr_recibo[idx].valor_pag IS NOT NULL THEN IF arr_recibo[idx].aplica_a = ant_art.aplica_a AND arr_recibo[idx].valor_pag = ant_art.valor_pag THEN LET numero_msg = 21 CALL msg(numero_msg) LET bandera = 1 ELSE IF bandera != 1 THEN LET bandera = 0 END IF END IF END IF END IF END FOR END FUNCTION { FUNCTION consulta_clientes() OPEN WINDOW busqueda AT 7,12 WITH FORM "vefmwd002" ATTRIBUTE (BORDER,FORM LINE FIRST + 2,COMMENT LINE LAST,MESSAGE LINE LAST) LET int_flag = false CONSTRUCT criterio ON a.nombre FROM nombre LET selec2 = "SELECT a.tipo_cliente, a.sec_cliente, a.nombre ", " FROM vetb00004 a", " WHERE ", "a.status_t is null AND ", criterio clipped, "ORDER BY 1,2 " IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) GO TO salir_consulta_c END IF PREPARE busca_clientes FROM selec2 IF status >= 0 THEN IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) END IF ELSE CALL integridad() IF bandera = 1 THEN LET bandera = 0 END IF END IF DECLARE buscar_clientes CURSOR FOR busca_clientes LET idx = 1 FOREACH buscar_clientes INTO arr_clientes[idx].* IF status = NOTFOUND THEN EXIT FOREACH END IF IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) EXIT FOREACH END IF LET idx = idx + 1 END FOREACH CALL set_count(idx-1) MESSAGE " Selecciona Cliente donde esta el cursor" DISPLAY ARRAY arr_clientes TO s_clientes.* LET curr1 = arr_curr() LET cliente_dir.tipo_cliente = arr_clientes[curr1].tipo_cliente LET cliente_dir.sec_cliente = arr_clientes[curr1].sec_cliente LET descrip1 = arr_clientes[curr1].nombre LABEL salir_consulta_c: CLOSE WINDOW busqueda END FUNCTION FUNCTION consulta_empleados() OPEN WINDOW busqueda2 AT 7,12 WITH FORM "vefmwd001" ATTRIBUTE (BORDER,FORM LINE FIRST + 2,COMMENT LINE LAST,MESSAGE LINE LAST) LET int_flag = false CONSTRUCT criterio ON a.nom1_emp FROM descrip6 LET selec2 = "SELECT num_emp,a.nom1_emp,a.apell1_emp FROM adtb00003 a", "WHERE a.status_t is null AND ",criterio clipped," ORDER BY 1 " IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) GO TO salir_consulta_e END IF PREPARE busca_empleados FROM selec2 IF status >= 0 THEN IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) END IF ELSE CALL integridad() IF bandera = 1 THEN LET bandera = 0 END IF END IF DECLARE buscar_empleados CURSOR FOR busca_empleados LET idx = 1 FOREACH buscar_empleados INTO arr_empleados[idx].* IF status = NOTFOUND THEN EXIT FOREACH END IF IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) EXIT FOREACH END IF LET empleados[idx].cod_emp_sec = arr_empleados[idx].num_emp LET empleados[idx].descrip6 = arr_empleados[idx].nom1_emp clipped," ",arr_empleados[idx].apell1_emp clipped LET idx = idx + 1 END FOREACH CALL set_count(idx-1) MESSAGE " Selecciona Empleado donde esta el cursor" DISPLAY ARRAY empleados TO s_empleados.* LET curr1 = arr_curr() LET transportista.sec_transp = empleados[curr1].cod_emp_sec LET descrip6 = empleados[curr1].descrip6 LABEL salir_consulta_e: CLOSE WINDOW busqueda2 END FUNCTION } REPORT cr_edito(x,z,nombre_cli,nombre,apellido,cia) DEFINE x RECORD num_doc LIKE cctb00001.num_doc, tipo_cliente LIKE cctb00001.tipo_cliente, sec_cliente LIKE cctb00001.sec_cliente, cod_emp_sec LIKE cctb00001.cod_emp_sec, fecha_orig LIKE cctb00001.fecha_orig , itbi DECIMAL(12,2), concepto CHAR(60) END RECORD DEFINE z RECORD cod_mov LIKE iptb00006.cod_mov, aplica_a LIKE cctb00001.aplica_a, valor_pen DECIMAL(12,2), desc_p LIKE cctb00001.monto_desc, valor_desc DECIMAL(12,2), valor_pag DECIMAL(12,2) END RECORD DEFINE cia SMALLINT DEFINE total_nc,total_bruto,sub_total,total_desc,itbis DECIMAL(12,2) DEFINE nombre_cli,nombre,apellido CHAR(30) DEFINE comp_on,comp_off,negrillas_on,negrillas_off,doble_on,doble_off, doce,normal CHAR(2) DEFINE reg_i RECORD area SMALLINT, cod_n INTEGER, cod_grupo INTEGER, cod_tipo INTEGER, cod_sec INTEGER, descrip_esp CHAR(30), cantidad DEC(18,5), precio DECIMAL(12,2), descuento DEC(12,2) END RECORD, lj,j,i,h SMALLINT, factura_ncf INT, xtipo_doc CHAR(2) OUTPUT TOP MARGIN 0 LEFT MARGIN 4 # PAGE LENGTH 33 ORDER BY x.num_doc FORMAT BEFORE GROUP OF x.num_doc LET negrillas_on = ASCII 27, ASCII 69 LET negrillas_off = ASCII 27, ASCII 70 LET doce = ASCII 27, ASCII 77 LET normal = ASCII 27, ASCII 80 LET doble_on = ASCII 14 LET doble_off = ASCII 20 LET comp_off = ASCII 18 LET comp_on = ASCII 15 LET lj = (80 - LENGTH(p_companias.nombre CLIPPED))/2 LET j = (90 - LENGTH(p_companias.direccion CLIPPED))/2 LET i = (90 - LENGTH(p_companias.telefono CLIPPED))/2 LET h = (90 - LENGTH(p_companias.rnc CLIPPED))/2 PRINT comp_on PRINT COLUMN lj, normal,doble_on,p_companias.nombre CLIPPED PRINT COLUMN j+3, p_companias.direccion PRINT COLUMN i-9, "Tels : ",p_companias.telefono , " Fax : ",p_companias.fax PRINT COLUMN h-1, "RNC : ",p_companias.rnc CLIPPED, COLUMN 100, "Pag. ", pageno using "###" PRINT COLUMN h, "NOTAS DE CREDITOS" IF reimpresion = "S" THEN PRINT COLUMN i,"RE-IMPRESION" ELSE PRINT " " END IF PRINT negrillas_on LET total_bruto = 0 LET total_Desc = 0 PRINT COLUMN 1, "Numero : ",doble_on,x.num_doc using "&&&&&&",doble_off, negrillas_off PRINT COLUMN 1, "Cliente : ",x.tipo_cliente using "&&","-",x.sec_cliente using "&&&&&&&&"," ",nombre_cli PRINT COLUMN 1, "Direccion: ",fact_gral.direccion PRINT COLUMN 1, "Vendedor : ",x.cod_emp_sec using "&&&&"," ",nombre clipped,",", apellido PRINT COLUMN 1, "Fecha : ",x.fecha_orig using "dd/mm/yy",negrillas_on PRINT COLUMN 1, "Doc. Dev : ",z.aplica_a USING "&&&&&&"," Factura : ",fact_gral.factura USING "&&&&&&" PRINT COLUMN 1, "Bodega : ",xbodega PRINT COLUMN 1, "Concepto : ",x.concepto CLIPPED PRINT COLUMN 1,"-----------------------------------------------------------", "------------------------------------------" PRINT COLUMN 1, "Producto", COLUMN 53, "Cantidad", COLUMN 64, "Precio", COLUMN 74, "%Desc", COLUMN 86, "Valor Desc", COLUMN 97, "Total" PRINT COLUMN 1,"-----------------------------------------------------------", "------------------------------------------" PRINT COLUMN 1, negrillas_off AFTER GROUP OF x.num_doc IF busca1 = "S" THEN # DISPLAY "bodega ",fact_gral.bodega," COD_MOV ",z.cod_mov," aplica ",z.aplica_a DECLARE venta1 CURSOR FOR SELECT DISTINCT a.area,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,b.descrip_esp, SUM(a.cantidad_2),c.precio,avg(c.cantidad_2) FROM iptb00006 a, iptb00002 b, vetb00003 c WHERE a.cod_n = b.cod_n AND a.cod_grupo = b.cod_grupo AND a.cod_tipo = b.cod_tipo AND a.cod_sec = b.cod_sec AND a.cod_n = c.cod_n AND a.cod_grupo = c.cod_grupo AND a.cod_tipo = c.cod_tipo AND a.cod_sec = c.cod_sec AND a.factura = c.factura AND a.cod_mov = z.cod_mov AND a.num_doc = z.aplica_a AND a.bodega = fact_gral.bodega AND a.area = c.area GROUP BY a.area,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,b.descrip_esp,c.precio ORDER BY a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec END IF IF busca2 = "S" THEN DECLARE venta2 CURSOR FOR SELECT DISTINCT a.area, a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec, c.descrip_esp,SUM(a.cantidad_2),b.precio,'0' FROM iptb00006 a,vetb00025 b,iptb00002 c WHERE (a.num_doc = z.aplica_a) and (a.cod_n = b.cod_n) and (a.cod_grupo = b.cod_grupo) and (a.cod_tipo = b.cod_tipo) and (a.cod_sec = b.cod_sec) AND (a.cod_n = c.cod_n) AND (a.cod_grupo=c.cod_grupo) AND (a.cod_tipo = c.cod_tipo) AND (a.cod_sec = c.cod_sec) AND (a.cod_mov = z.cod_mov) AND a.bodega = fact_gral.bodega and b.ventas = "1" and b.tipo_cliente is null GROUP BY a.area, a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,b.precio, c.descrip_esp END IF LET total_bruto = 0 LET salir = "N" IF busca1 = "S" THEN FOREACH venta1 INTO reg_i.area,reg_i.cod_n,reg_i.cod_grupo,reg_i.cod_tipo,reg_i.cod_sec,reg_i.descrip_esp, reg_i.cantidad,reg_i.precio,reg_i.descuento IF reg_i.cantidad IS NULL THEN LET reg_i.cantidad = 0 END IF IF reg_i.precio IS NULL THEN LET reg_i.precio = 0 END IF LET total_bruto = total_bruto + (reg_i.cantidad * reg_i.precio) LET pdescuento = (reg_i.cantidad * reg_i.precio) * (reg_i.descuento/100) LET total_desc = pdescuento + total_desc PRINT COLUMN 1,reg_i.area," ", reg_i.cod_n USING "&&&&",'-',reg_i.cod_grupo USING "&&&&","-", reg_i.cod_tipo USING "&&&","-",reg_i.cod_sec USING "&&&&", " ",reg_i.descrip_esp CLIPPED, COLUMN 40, reg_i.cantidad USING "###,###.#####", 2 spaces, reg_i.precio USING "##,###.##", 2 spaces, reg_i.descuento USING "##,###.##", 2 spaces, pdescuento USING "###,###.##", COLUMN 88, reg_i.cantidad * reg_i.precio USING "###,###,###.##" IF reimpresion = "N" THEN INSERT INTO cctb00004 (tipo_Doc,num_Doc,cod_n,cod_grupo,cod_tipo,cod_sec,cantidad,precio,descuento,cod_mov,num_doc_almacen,bodega, porc_Desc) VALUES ('NC',x.num_doc,reg_i.cod_n,reg_i.cod_grupo,reg_i.cod_tipo,reg_i.cod_sec,reg_i.cantidad,reg_i.precio,pdescuento, z.cod_mov,z.aplica_a,fact_gral.bodega,reg_i.descuento) END IF END FOREACH END IF IF busca2 = "S" THEN FOREACH venta2 INTO reg_i.area,reg_i.cod_n,reg_i.cod_grupo,reg_i.cod_tipo,reg_i.cod_sec,reg_i.descrip_esp, reg_i.cantidad,reg_i.precio,reg_i.descuento IF reg_i.cantidad IS NULL THEN LET reg_i.cantidad = 0 END IF IF reg_i.precio IS NULL THEN LET reg_i.precio = 0 END IF LET pdescuento = (reg_i.cantidad * reg_i.precio) * (reg_i.descuento/100) LET total_desc = pdescuento + total_desc # LET reg_i.descuento = pdescuento IF reimpresion = "N" THEN LET total_bruto = total_bruto + (reg_i.cantidad * reg_i.precio) ELSE LET total_bruto = ptotalb END IF PRINT COLUMN 1, reg_i.cod_n USING "&&&&",'-',reg_i.cod_grupo USING "&&&&","-", reg_i.cod_tipo USING "&&&&","-",reg_i.cod_sec USING "&&&&", " ",reg_i.descrip_esp CLIPPED, COLUMN 40, reg_i.cantidad USING "###,###.####", 2 spaces, reg_i.precio USING "##,###.##", 2 spaces, reg_i.descuento USING "##,###.##", 2 spaces, pdescuento USING "###,###.##", COLUMN 88, (reg_i.cantidad * reg_i.precio) - pdescuento USING "###,###,###.##" IF reimpresion = "N" THEN INSERT INTO cctb00004 (tipo_Doc,num_Doc,cod_n,cod_grupo,cod_tipo,cod_sec,cantidad,precio,descuento,cod_mov,num_doc_almacen,bodega, porc_Desc) VALUES ('NC',x.num_doc,reg_i.cod_n,reg_i.cod_grupo,reg_i.cod_tipo,reg_i.cod_sec,reg_i.cantidad,reg_i.precio,pdescuento, z.cod_mov,z.aplica_a,fact_gral.bodega,reg_i.descuento) END IF END FOREACH END IF IF reimpresion ="S" THEN DECLARE busca_codigos CURSOR FOR SELECT a.cod_n,a.cod_Grupo,a.cod_tipo,a.cod_sec,b.descrip_esp,a.cantidad,a.precio,a.porc_desc FROM cctb00004 a,iptb00002 b WHERE a.tipo_doc = 'NC' AND a.num_doc = x.num_doc AND a.cod_n = b.cod_n AND a.cod_grupo =b.cod_grupo AND a.cod_tipo = b.cod_tipo AND a.cod_sec = b.cod_Sec LET total_Desc = 0 LET total_bruto = 0 FOREACH busca_codigos INTO reg_i.cod_n,reg_i.cod_grupo,reg_i.cod_tipo,reg_i.cod_sec,reg_i.descrip_esp, reg_i.cantidad,reg_i.precio,reg_i.descuento IF reg_i.cantidad IS NULL THEN LET reg_i.cantidad = 0 END IF IF reg_i.precio IS NULL THEN LET reg_i.precio = 0 END IF LET pdescuento = (reg_i.cantidad * reg_i.precio) * (reg_i.descuento/100) LET total_desc = pdescuento + total_desc LET total_bruto = total_bruto + (reg_i.cantidad * reg_i.precio) PRINT COLUMN 1, reg_i.cod_n USING "&&&&",'-',reg_i.cod_grupo USING "&&&&","-", reg_i.cod_tipo USING "&&&&","-",reg_i.cod_sec USING "&&&&", " ",reg_i.descrip_esp CLIPPED, COLUMN 40, reg_i.cantidad USING "###,###.####", 2 spaces, reg_i.precio USING "##,###.##", 2 spaces, pdescuento USING "##,###.##", COLUMN 88, (reg_i.cantidad * reg_i.precio) - pdescuento USING "###,###,###.##" END FOREACH END IF IF z.valor_desc IS NULL THEN LET z.valor_desc = 0 END IF IF pitbis IS NULL THEN LET pitbis = 0 END IF IF x.itbi IS NULL THEN LET x.itbi = 0 END IF IF reimpresion = "N" THEN IF chitbis ="YES" THEN LET x.itbi = (total_bruto - total_desc) * (pitbis/100) ELSE LET x.itbi = 0 END IF END IF PRINT COLUMN 88, "--------------" PRINT COLUMN 60, " BRUTO : ", COLUMN 88, total_bruto USING "###,###,###.##" PRINT COLUMN 60, " DESC : ", COLUMN 88, total_Desc using "---,---,###.##" PRINT COLUMN 60, "SUB-TOTAL : ", COLUMN 88, (total_bruto - total_desc) USING "---,---,###.##" PRINT COLUMN 60, " ITBIS : ",pitbis USING "<<<.##","% : ", COLUMN 88, x.itbi using "---,---,###.##" PRINT COLUMN 60, " NETO : ", COLUMN 88, total_bruto - total_desc + x.itbi USING "---,---,###.##" LET total_nc = (total_bruto + x.itbi) IF z.valor_desc IS NULL THEN LET z.valor_desc = 0 END IF IF x.itbi IS NULL THEN LET x.itbi = 0 END IF { ACTUALIZACION DE LA TABLA DE CUENTAS POR COBRAR =============================================== VALOR NETO (total_nc) SE GUARDA EN EL CAMPO: valor, ITBI (x.itbi) SE GUARDA EN EL CAMPO: valor_efectivo, EL VALOR BRUTO (total_bruto) SE GUARDA EN EN CAMPO: valor_cheque, MONTO DE DESCUENTO(total_desc) EN EL CAMPO: monto_desc EL CAMPO NUM_CHEQUE SE UTILIZA PARA EL NUMERO DE DOCUMENTOS DE INVENTARIO DEL MOVIMIENTO 12 DE PRODUCTO TERMINADOS} IF reimpresion= "N" THEN IF chitbis = 'YES' THEN LET chitbis = 'SI' ELSE LET chitbis = 'NO' END IF INSERT INTO cctb00011 (num_doc,tipo_doc,tipo_cliente,sec_cliente,comentario,chitbis,bodega,porc_itbis,valor_recibo,descuento, monto_itbis,valor_bruto) VALUES (x.num_doc,"NC",x.tipo_cliente,x.sec_cliente,recibo.concepto,chitbis,fact_gral.bodega,pitbis,total_nc, total_desc,x.itbi,total_bruto) LET total_nc = total_nc * -1 LET total_bruto = total_bruto * -1 IF fact_gral.ventas = '1' THEN LET xtipo_doc ='FT' ELSE LET xtipo_Doc = 'FE' END IF INSERT INTO cctb00001 (cod_cia,tipo_doc,num_doc,tipo_cliente,sec_cliente,cod_emp_sec,fecha_orig, aplica_a,banco,num_cheque,valor,valor_efectivo,valor_cheque,monto_desc, us_crea,fech_crea,bodega,tipo_doc_aplica ) VALUES (cia,"NC",x.num_doc,x.tipo_cliente, x.sec_cliente,x.cod_emp_sec,x.fecha_orig, fact_gral.factura,z.cod_mov,z.aplica_a, total_nc,x.itbi, total_bruto,total_desc, SUSER_SNAME(),GETDATE(),fact_gral.bodega,xtipo_doc) {SET CONNECTION "IFMX" LET factura_ncf = 0 SELECT a.factura INTO factura_ncf FROM vetb00002 a WHERE a.factura_c = fact_gral.factura IF STATUS <> NOTFOUND THEN INSERT INTO cctb00001 values (null,cia,"NC",x.num_doc,x.tipo_cliente, x.sec_cliente,null,x.cod_emp_sec,x.fecha_orig, null,factura_ncf,z.cod_mov,z.aplica_a, total_nc,x.itbi, total_bruto,null,total_desc,null, SUSER_SNAME(),GETDATE(),null,null,fact_gral.bodega,fact_gral.factura) ELSE CALL fgl_winmessage("INFO","NO SE ENCONTRO FACTURA CON NCF","INFO") END IF } END IF PRINT normal PAGE TRAILER SKIP 1 LINE PRINT COLUMN 6, " Preparado Por", COLUMN 40, " Autorizado Por" PRINT " " PRINT COLUMN 6, "---------------------------", COLUMN 36, "---------------------------" ON LAST ROW IF reimpresion = "N" THEN UPDATE cctb00003 set ult_recibo = x.num_doc, us_crea = SUSER_SNAME(), fech_crea = GETDATE(), us_mod = SUSER_SNAME(), fech_mod = GETDATE() WHERE tipo_doc in ("NC") END IF END REPORT FUNCTION integridad() IF sqlca.sqlcode < 0 THEN LET numero_msg = sqlca.sqlcode CALL msg(numero_msg) #DISPLAY numero_msg AT 23,70 LET bandera = 1 LET status = 0 #SLEEP 2 RETURN END IF RETURN END FUNCTION FUNCTION prd() 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 SELECT MIN(dias_gracia) INTO dia FROM prdtable WHERE fecha_corte = fecha_c IF dia IS NULL THEN LET dia = 0 END IF SELECT UNIQUE a.usuario FROM seg0003 a WHERE a.usuario = SUSER_SNAME() IF STATUS != NOTFOUND THEN LET fecha_c = fecha_c + dia END IF 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 END FUNCTION FUNCTION informacion() CALL bodegas(1) SELECT a.descripcion INTO xbodega FROM intb00009 a WHERE a.cod_bodega = fact_gral.bodega SELECT b.nombre,a.calle||' '||a.casa_num||' '||a.urbanizacion||' '||a.barrio INTO nom_cli,fact_gral.direccion FROM vetb00004 b,vetb00005 a WHERE (b.tipo_cliente = recibo.tipo_cliente) and (b.sec_cliente = recibo.sec_cliente) AND b.tipo_cliente = a.tipo_cliente AND b.sec_cliente = a.sec_cliente SELECT a.nom1_emp,a.apell1_emp INTO descrip2,descrip3 FROM adtb00003 a WHERE a.num_emp = recibo.cod_emp_sec LET nombre_emp = descrip2 clipped," ",descrip3 clipped DISPLAY BY NAME recibo.*,nom_cli,nombre_emp,fact_gral.bodega DISPLAY arr_recibo[1].cod_mov TO s_recibo[1].cod_mov DISPLAY arr_recibo[1].aplica_a TO s_recibo[1].aplica_a DISPLAY arr_recibo[1].valor_pag TO s_recibo[1].valor_pag DISPLAY arr_recibo[1].valor_pag TO s_recibo[1].valor_pag DISPLAY xdescuento TO s_recibo[1].val_desc DISPLAY ptotalb TO s_recibo[1].valor_pen END FUNCTION