{ ------------------------------------------------------------------------------- PROGRAMA : COPRRP031 OBJETIVO : Reportar el registro de compras,itbis,devoluciones,etc en un rango de fecha determinado. PROGRAMADOR : Ing. Juan Soto FECHA REALIZACION : Diciembre 12, 1996. ------------------------------------------------------------------------------- } GLOBALS "coprgb000.4gl" ###### Definicion de variables usadas en el reporte # clientes_act - es para control del cliente que el reporte no busque las # notas de debito mas de una vez por cliente DEFINE cliente_act,cliente_ant CHAR(6) DEFINE enc CHAR(1) DEFINE vend,sec SMALLINT DEFINE tipo_venta CHAR(1) DEFINE fecha_ini,fecha_fin,fecha_corte DATE DEFINE idx_1, idx_2 SMALLINT DEFINE mes DATE DEFINE sele CHAR(500) ##### Funcion para ejecutar la informacion a imprimir FUNCTION coprrp031() DEFINE cotb09 RECORD LIKE cotb00009.* # WHENEVER ERROR CONTINUE OPTIONS FORM LINE 8, ERROR LINE 23, COMMENT LINE 21 OPEN FORM ccfmrp031 FROM "ccfmrp031" DISPLAY FORM ccfmrp031 CALL pantalla() DISPLAY "coprrp031" AT 4,3 DISPLAY "Registro de Ventas (ITBIS)" AT 6,27 LET tipo_papel = 2 CALL msgrp000(tipo_papel) LET fecha_ini = today LET fecha_fin = today ###### Entrada de valores para fines de busqueda en un rango de fecha INPUT BY NAME fecha_fin WITHOUT DEFAULTS AFTER FIELD fecha_fin IF fecha_fin is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fecha_fin 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 IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = FALSE RETURN END IF ###### Creando el criterio de busqueda CONSTRUCT criterio ON a.tipo_cliente,a.sec_cliente FROM tipo_cliente,sec_cliente ##### Selecionando la informacion requerida de ventas. ###### Enviando la informacion al printer del usuario START REPORT r_itbis TO PIPE "lp -dcentral" DECLARE busca CURSOR FOR SELECT * FROM cotb00009 WHERE fecha_rep = fecha_fin ORDER BY tipo,num_oc DISPLAY " " AT 19,14 DISPLAY "<< Reporte Generandose ... Por Favor Espere. >>" AT 19,14 ATTRIBUTE (REVERSE) ###### Loop para enviar la inforacion a la rutina de impresion FOREACH busca INTO cotb09.* OUTPUT TO REPORT r_itbis(cotb09.*) END FOREACH FINISH REPORT r_itbis CLEAR SCREEN RUN "type C:\\archivo > %USPRINT%" END FUNCTION ##### Funcion del reporte, crea el formato de salida REPORT r_itbis(x) DEFINE x RECORD LIKE cotb00009.*, estatus CHAR(1), nombre LIKE cotb00001.nom_sp, fecha DATE DEFINE doble_on CHAR(3) DEFINE doble_off CHAR(3) DEFINE negrillas_on CHAR(6) DEFINE negrillas_off CHAR(6) DEFINE comp_on CHAR(3) DEFINE comp_off CHAR(3) DEFINE comprimido CHAR(3) DEFINE doce CHAR(3) DEFINE normal CHAR(3) DEFINE normall CHAR(3) DEFINE hora CHAR(5) OUTPUT TOP MARGIN 0 LEFT MARGIN 6 BOTTOM MARGIN 2 ##### Sorteando a la salida de la informacion #ORDER BY x.factura ,x.nombre ##### Formateando la salida o condicionandola al tamano del papel o reporte FORMAT PAGE HEADER LET doble_on = ASCII 116 # LET doble_off = ASCII 20 LET negrillas_on = ASCII 027,ASCII 098 LET negrillas_off = ASCII 027,ASCII 099 # LET comp_on = ASCII 15 LET comp_off = ASCII 18 LET comprimido = ASCII 031 LET doce = ASCII 27, ASCII 77 LET normall = ASCII 030 LET normal = ASCII 27, ASCII 80 LET hora = time LET l = (179 - LENGTH(p_companias.nombre CLIPPED))/2 PRINT COLUMN 1, comprimido PRINT COLUMN 1, "coprrp031", COLUMN l, p_companias.nombre CLIPPED, COLUMN 172, "Pag. ",pageno using "###" PRINT COLUMN 73, " Sistema de Compras", COLUMN 171, today using "dd/mm/yyyy" PRINT COLUMN 78, "R E G I S T R O D E C O M P R A S", COLUMN 175, hora PRINT COLUMN 83, fecha_ini using "dd/mm/yy"," AL ", fecha_fin using "dd/mm/yy" SKIP 1 LINE PRINT COLUMN 1, "--------------------------------------------------", "--------------------------------------------------", "-------------------------------", "------------------------------------------------" PRINT COLUMN 138, "D E V O L U C I O N E S " PRINT COLUMN 33 , "NUMERO DE ", COLUMN 51 , "LIQUIDACION", COLUMN 82 , "C O M P R A S", COLUMN 152, "N O T A S", COLUMN 161, "COMPROBANTE NO." PRINT COLUMN 6, "P R O V E E D O R", COLUMN 33, "ORDEN", COLUMN 43, "FECHA", COLUMN 51, "PLANILLA", COLUMN 62, "TOTAL COMPRAS", COLUMN 79, "EXENTAS", COLUMN 94, "GRAVADAS", COLUMN 104, "IMPORTE ITBIS |", COLUMN 120, "VALOR DEVOL.", COLUMN 136, "IMPORTE ITBIS", COLUMN 152, "DR/CR", COLUMN 161, "AFECTADA" # COLUMN , "FECHA" PRINT COLUMN 1, "--------------------------------------------------", "--------------------------------------------------", "----------------------------------------", "---------------------------------------" # , negrillas_off ON EVERY ROW # Busca el nombre del SUPLIDOR SELECT a.nom_sp,b.status_t,b.fecha_oc INTO nombre,estatus,fecha FROM cotb00001 a,cotb00014 b WHERE b.tipo = x.tipo AND b.num_oc = x.num_oc AND a.cod_sp = b.cod_sp AND a.cod_sp_sec = b.cod_sp_Sec IF estatus = "E" THEN LET nombre = "---- NULA ----" LET x.valor_credito = 0 LET x.exenta = 0 LET x.itbi_cr = 0 END IF PRINT COLUMN 1, nombre, COLUMN 33, x.num_oc USING "&&&&&&", COLUMN 44, x.fecha USING "dd/mm/yy", COLUMN 55, x.planilla USING "&&&&&&&&&", COLUMN 71, x.exentas using "###,###,###.##", COLUMN 88, x.valor - x.descuento using "###,###,###.##", COLUMN 104, x.itbi using "##,###,###.##"; END IF ##### Imprime el valor del documento sin el itbi PRINT COLUMN 117, x.valor_doc - (x.valor_doc *(x.porc_itbi/100)) using "###,###,###.##", ###### Imprime y calcula el itbi COLUMN 134, x.valor_doc*(x.porc_itbi/100) using "###,###,###.##", COLUMN 152, x.num_doc using "&&&&&&", COLUMN 164, x.aplica_a using "&&&&&", COLUMN 170, x.fecha_orig using "dd/mm/yy" IF imprime = "N" THEN LET x.valor = 0 LET x.descuento = 0 LET x.itbi = 0 LET x.exentas = 0 END IF LET imprime = "N" # Acumulacion Totales del reporte IF x.valor is null THEN LET x.valor = 0 END IF IF x.exentas is null THEN LET x.exentas = 0 END IF IF x.valor_doc is null THEN LET x.valor_doc = 0 END IF IF x.descuento is null THEN LET x.descuento = 0 END IF LET total_ventas = total_ventas + x.valor LET t_exentas = t_exentas + x.exentas LET t_gravadas = t_gravadas + (x.valor - x.descuento) LET t_itbi = t_itbi + x.itbi LET t_devol_i = t_devol_i + (x.valor_doc * (x.porc_itbi/100)) LET t_devol = t_devol + x.valor_doc ON LAST ROW ######### Imprimiendo los totales por columna PRINT negrillas_on PRINT COLUMN 24, "T O T A L M E S: ", COLUMN 55, total_ventas using "###,###,###.##", COLUMN 71, t_exentas using "###,###,###.##", COLUMN 88, t_gravadas - t_exentas using "###,###,###.##", COLUMN 104, t_itbi using "##,###,###.##", COLUMN 117, t_devol using "###,###,###.##", COLUMN 134, t_devol_i using "###,###,###.##" LET total_ventas = 0 LET t_exentas = 0 LET t_gravadas = 0 LET t_itbi = 0 LET t_devol_i = 0 LET t_devol = 0 PRINT negrillas_off END REPORT