{ ------------------------------------------------------------------------------- PROGRAMA : VEPRRP023 OBJETIVO : Relacion de Ventas al Contado PROGRAMADOR : Tadeo Alberto Ferreras F. FECHA REALIZACION : Mayo 27, 1993 ------------------------------------------------------------------------------- } GLOBALS "veprgb000.4gl" DEFINE idx_1, idx_2, idx_3 SMALLINT DEFINE fecha_inicial, fecha_final DATE DEFINE salir, salir2, salir3, tipo_venta CHAR(1) DEFINE selec4,selec5, selec6 CHAR(1500) DEFINE opt CHAR(1) DEFINE tot_gen RECORD tot_1 DECIMAL(10,2), tot_2 DECIMAL(10,2), tot_3 DECIMAL(10,2), tot_4 DECIMAL(10,2), tot_5 DECIMAL(10,2) END RECORD DEFINE ventas RECORD compania SMALLINT, factura INTEGER, fecha_factura DATE, tipo_cliente SMALLINT, sec_cliente SMALLINT, monto_bruto DECIMAL(10,2), monto_desc DECIMAL(10,2), monto_itbi DECIMAL(10,2), monto_neto DECIMAL(10,2), prima DECIMAL(10,2), status_t CHAR(1), nombre CHAR(30) END RECORD DEFINE desc_ft RECORD cod_n SMALLINT, cod_grupo SMALLINT, cod_tipo SMALLINT, cod_sec SMALLINT, porc DECIMAL(10,2) END RECORD DEFINE det_ft RECORD cod_n SMALLINT, cod_grupo SMALLINT, cod_tipo SMALLINT, cod_sec SMALLINT, valor DECIMAL(10,2) END RECORD DEFINE monto_desc DECIMAL(10,2) DEFINE monto_ft DECIMAL(10,2) MAIN DEFER INTERRUPT CALL ARG_VAL(1) RETURNING usuarios CALL ARG_VAL(2) RETURNING clave CONNECT TO "smarmotech" USER usuarios USING clave SELECT * INTO p_companias.* FROM companias CALL veprrp023() END MAIN FUNCTION veprrp023() WHENEVER ERROR CONTINUE OPTIONS FORM LINE 8, ERROR LINE 23, COMMENT LINE 21 OPEN FORM vefmrp023 FROM "vefmrp023" DISPLAY FORM vefmrp023 LET tipo_papel = 1 CALL msgrp000(tipo_papel) INPUT BY NAME fecha_inicial,fecha_final,tipo_venta AFTER FIELD fecha_inicial IF fecha_inicial is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fecha_inicial END IF BEFORE FIELD fecha_final LET fecha_final = today AFTER FIELD fecha_final IF fecha_final is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fecha_final END IF IF fecha_final < fecha_inicial THEN LET numero_msg = 86 CALL msg(numero_msg) NEXT FIELD fecha_final END IF AFTER FIELD tipo_venta IF tipo_venta is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD tipo_venta END IF IF tipo_venta != "1" AND tipo_venta != "2" THEN LET numero_msg = 7 CALL msg(numero_msg) NEXT FIELD tipo_venta END IF AFTER INPUT IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false RETURN END IF IF fecha_inicial is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fecha_inicial END IF IF fecha_final is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fecha_final END IF IF fecha_final < fecha_inicial THEN LET numero_msg = 86 CALL msg(numero_msg) NEXT FIELD fecha_final END IF IF tipo_venta is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD tipo_venta END IF IF tipo_venta != "1" AND tipo_venta != "2" THEN LET numero_msg = 7 CALL msg(numero_msg) NEXT FIELD tipo_venta END IF EXIT INPUT END INPUT CONSTRUCT criterio ON d.cod_cia FROM cod_cia # Busca las ventas locales para el rango de fechas especificado IF tipo_venta = "1" THEN LET selec4 = "SELECT d.cod_cia, d.factura, d.fecha_factura, d.tipo_cliente, ", " d.sec_cliente, d.sub_total, d.monto_desc, d.monto_itbi, ", " d.neto, d.porc_itbi, d.status_t,e.nombre ", "FROM vetb00002 d,vetb00004 e ", "WHERE d.tipo_cliente=e.tipo_cliente AND d.sec_cliente=e.sec_cliente AND ", " d.fecha_factura between ? and ? and d.cond_pago = 1 and ", " e.status_t IS NULL AND d.status_t IS NULL AND ",criterio clipped, " ORDER BY 1,2,3 " DISPLAY "<< Buscando Informacion ... Espere Por Favor. >>" AT 19,14 ATTRIBUTE (REVERSE,BOLD) DISPLAY " " AT 19,14 DISPLAY "<< Estoy Buscando las Ventas Locales. >>" AT 19,14 ATTRIBUTE (REVERSE,BOLD) PREPARE ventas_locales FROM selec4 DECLARE lfacturas SCROLL CURSOR FOR ventas_locales OPEN lfacturas USING fecha_inicial, fecha_final DISPLAY " " AT 19,14 END IF IF tipo_venta = "2" THEN # Busca las ventas de exportacion para el rango de fechas especificado LET selec3 = "SELECT d.cod_cia, d.factura, d.fecha_factura, d.tipo_cliente, ", " d.sec_cliente, d.sub_total, d.monto_desc, d.monto_itbi, ", " d.neto, d.prima_us, d.status_t,e.nombre ", "FROM vetb00002 d,vetb00004 e ", "WHERE d.tipo_cliente=e.tipo_cliente AND e.sec_cliente=e.sec_cliente AND ", " d.fecha_factura between ? and ? and d.cond_pago = 1 and ", " e.status_t IS NULL AND d.status_t IS NULL AND ",criterio clipped, " ORDER BY 1,2,3 " DISPLAY "<< Estoy Buscando las Ventas de Exportacion. >>" AT 19,14 ATTRIBUTE (REVERSE,BOLD) PREPARE ventas_export FROM selec3 DECLARE facturas SCROLL CURSOR FOR ventas_export OPEN facturas USING fecha_inicial, fecha_final END IF DISPLAY " " AT 19,14 START REPORT ventas_cc TO "relacv1" DISPLAY " " AT 19,14 DISPLAY "<< Reporte Generandose ... Por Favor Espere. >>" AT 19,14 ATTRIBUTE (REVERSE) # Procesa las ventas de exportacion IF tipo_venta = "2" THEN LET salir = "N" LET idx_1 = 1 WHILE salir = "N" FETCH ABSOLUTE idx_1 facturas INTO ventas.* IF status = NOTFOUND THEN LET salir = "S" EXIT WHILE END IF IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false RETURN END IF IF ventas.status_t = "E" THEN LET ventas.monto_bruto = 0 LET ventas.monto_desc = 0 LET ventas.monto_itbi = 0 LET ventas.monto_neto = 0 LET ventas.prima = 0 END IF LET idx_1 = idx_1 + 1 OUTPUT TO REPORT ventas_cc(ventas.*) END WHILE END IF # Procesa las ventas locales IF tipo_venta = "1" THEN LET salir = "N" LET idx_1 = 1 WHILE salir = "N" FETCH ABSOLUTE idx_1 lfacturas INTO ventas.* IF status = NOTFOUND THEN LET salir = "S" EXIT WHILE END IF IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false RETURN END IF LET idx_1 = idx_1 + 1 IF ventas.status_t = "E" THEN LET ventas.monto_bruto = 0 LET ventas.monto_desc = 0 LET ventas.monto_itbi = 0 LET ventas.monto_neto = 0 LET ventas.prima = 0 END IF OUTPUT TO REPORT ventas_cc(ventas.*) END WHILE END IF FINISH REPORT ventas_cc DISPLAY BY NAME tot_gen.* PROMPT "Desea Imprimir Reporte [S/N]...?" FOR CHAR opt LET opt = UPSHIFT(opt) IF opt = "S" THEN RUN "lp relacv1" END IF CLEAR SCREEN RUN "type C:\\archivo > %USPRINT%" END FUNCTION REPORT ventas_cc(x) DEFINE x RECORD compania SMALLINT, factura INTEGER, fecha_factura DATE, tipo_cliente SMALLINT, sec_cliente SMALLINT, monto_bruto DECIMAL(10,2), monto_desc DECIMAL(10,2), monto_itbi DECIMAL(10,2), monto_neto DECIMAL(10,2), prima DECIMAL(10,2), status_t CHAR(1), nombre CHAR(30) END RECORD DEFINE tot_1,tot_2,tot_3,tot_4,tot_5 DECIMAL(10,2) DEFINE descuento DECIMAL(10,2) DEFINE valor_factura DECIMAL(10,2) DEFINE doble_on CHAR(2) DEFINE doble_off CHAR(2) DEFINE negrillas_on CHAR(2) DEFINE negrillas_off CHAR(2) DEFINE comp_on CHAR(2) DEFINE comp_off CHAR(2) DEFINE doce CHAR(2) DEFINE normal CHAR(2) DEFINE normall CHAR(3) DEFINE comprimido CHAR(3) DEFINE hora CHAR(5) OUTPUT TOP MARGIN 0 LEFT MARGIN 0 BOTTOM MARGIN 2 ORDER BY x.compania FORMAT PAGE HEADER LET doble_on = ASCII 14 LET doble_off = ASCII 20 LET negrillas_on = ASCII 27, ASCII 69 LET negrillas_off = ASCII 27, ASCII 70 LET comp_on = ASCII 15 LET comp_off = ASCII 18 LET doce = ASCII 27, ASCII 77 LET normal = ASCII 27, ASCII 80 LET normall = ASCII 030 LET hora = time LET lj = (133 - LENGTH(p_companias.nombre CLIPPED))/2 PRINT COLUMN 1, comp_on PRINT COLUMN 1, "veprrp023", COLUMN lj, p_companias.nombre CLIPPED, COLUMN 126, "Pag.", COLUMN 131, pageno using "###" PRINT COLUMN 43, " Sistema de Ventas", COLUMN 124, today using "dd/mm/yyyy" IF tipo_venta = "1" THEN PRINT COLUMN 43, " Relacion de Ventas Locales Al Contado", COLUMN 129, hora ELSE PRINT COLUMN 43, "Relacion de Ventas de Exportacion Al Contado", COLUMN 129, hora END IF PRINT COLUMN 57, "Del ", fecha_inicial using "dd/mm/yy", " Al ", fecha_final using "dd/mm/yy" SKIP 1 LINES IF tipo_venta = "2" THEN SKIP 1 LINE PRINT COLUMN 1, "--------------------------------------------------", "--------------------------------------------------", "-------------------------------------" PRINT COLUMN 1, "Factura", COLUMN 11, "Fecha", COLUMN 20, "C l i e n t e", COLUMN 68, "Monto US$", COLUMN 83, "Otros US$", COLUMN 98, "Total US$", COLUMN 117, "Prima", COLUMN 128, "Monto RD$" PRINT COLUMN 1, "--------------------------------------------------", "--------------------------------------------------", "-------------------------------------" ELSE PRINT COLUMN 1, "--------------------------------------------------", "--------------------------------------------------", "----------------------------------" PRINT COLUMN 128, "Valor a" PRINT COLUMN 1, "Factura", COLUMN 11, "Fecha", COLUMN 20, "C l i e n t e", COLUMN 66, "Monto RD$", COLUMN 81, "Descuento", COLUMN 97, "Neto RD$", COLUMN 115, "ITBIS", COLUMN 129, "Cobrar" PRINT COLUMN 1, "--------------------------------------------------", "--------------------------------------------------" , "----------------------------------" END IF BEFORE GROUP OF x.compania IF x.compania = "1" THEN SKIP 1 LINE PRINT COLUMN 1, p_companias.nombre CLIPPED SKIP 1 LINE END IF ON EVERY ROW IF tipo_venta = "2" THEN PRINT COLUMN 1, x.factura using "######", COLUMN 9, x.fecha_factura using "dd/mm/yy", COLUMN 20, x.tipo_cliente using "&&","-", x.sec_cliente using "&&&&"," ",x.nombre clipped, COLUMN 62, x.monto_bruto using "####,###,###.##", COLUMN 74, x.monto_desc using "####,###,###.##", COLUMN 86, x.monto_neto using "####,###,###.##", COLUMN 98, x.monto_neto * (x.prima - 1) using "####,###,###.##", COLUMN 110, x.monto_neto + (x.monto_neto * (x.prima - 1)) using "####,###,###.##" END IF IF tipo_venta = "1" THEN PRINT COLUMN 1, x.factura using "######", COLUMN 9, x.fecha_factura using "dd/mm/yy", COLUMN 20, x.tipo_cliente using "&&","-", x.sec_cliente using "&&&&"," ",x.nombre clipped, COLUMN 60, x.monto_bruto using "####,###,###.##", COLUMN 71, x.monto_desc using "####,###,###.##", COLUMN 82, x.monto_bruto - x.monto_desc using "####,###,###.##", COLUMN 93, x.monto_itbi using "####,###,###.##", COLUMN 104, x.monto_neto using "####,###,###.##" END IF AFTER GROUP OF x.compania IF tipo_venta = "1" THEN SKIP 1 LINE PRINT COLUMN 41, "Total Ventas ---> ", COLUMN 60, GROUP SUM(x.monto_bruto) using "####,###,###.##", COLUMN 71, GROUP SUM(x.monto_desc) using "####,###,###.##", COLUMN 82, GROUP SUM(x.monto_bruto - x.monto_desc) using "####,###,###.##", COLUMN 93, GROUP SUM(x.monto_itbi) using "####,###,###.##", COLUMN 104, GROUP SUM(x.monto_neto) using "####,###,###.##" END IF IF tipo_venta = "2" THEN SKIP 1 LINE PRINT COLUMN 42, "Total Ventas ---> ", COLUMN 62, GROUP SUM(x.monto_bruto) using "####,###,###.##", COLUMN 74, GROUP SUM(x.monto_desc) using "####,###,###.##", COLUMN 86, GROUP SUM(x.monto_neto) using "####,###,###.##", COLUMN 98, GROUP SUM(x.monto_neto * (x.prima - 1)) using "####,###,###.##", COLUMN 110, GROUP SUM (x.monto_neto + (x.monto_neto * (x.prima - 1))) using "####,###,###.##" END IF ON LAST ROW IF tipo_venta = "1" THEN SKIP 1 LINE PRINT COLUMN 33, "Total General Ventas ---> ", COLUMN 60, SUM(x.monto_bruto) using "####,###,###.##", COLUMN 71, SUM(x.monto_desc) using "####,###,###.##", COLUMN 82, SUM(x.monto_bruto - x.monto_desc) using "####,###,###.##", COLUMN 93, SUM(x.monto_itbi) using "####,###,###.##", COLUMN 104, SUM(x.monto_neto) using "####,###,###.##" LET tot_1 = SUM(x.monto_bruto) LET tot_2 = SUM(x.monto_desc) LET tot_3 = SUM(x.monto_bruto - x.monto_desc) LET tot_4 = SUM(x.monto_itbi) LET tot_5 = SUM(x.monto_neto) END IF IF tipo_venta = "2" THEN SKIP 1 LINE PRINT COLUMN 34, "Total General Ventas ---> ", COLUMN 62, SUM(x.monto_bruto) using "####,###,###.##", COLUMN 74, SUM(x.monto_desc) using "####,###,###.##", COLUMN 86, SUM(x.monto_neto) using "####,###,###.##", COLUMN 98, SUM(x.monto_neto * (x.prima - 1)) using "####,###,###.##", COLUMN 110, SUM (x.monto_neto + (x.monto_neto * (x.prima - 1))) using "####,###,###.##" LET tot_1 = SUM(x.monto_bruto) LET tot_2 = SUM(x.monto_desc) LET tot_3 = SUM(x.monto_neto) LET tot_4 = SUM(x.monto_neto * (x.prima -1)) LET tot_5 = SUM(x.monto_neto + (x.monto_neto * (x.prima - 1))) END IF LET tot_gen.tot_1 = tot_1 LET tot_gen.tot_2 = tot_2 LET tot_gen.tot_3 = tot_3 LET tot_gen.tot_4 = tot_4 LET tot_gen.tot_5 = tot_5 PRINT comp_off,normall END REPORT