{ -------------------------------------------------------------------------- PROGRAMA : VEPRMT999 OBJETIVO : Este programa captura la factura comercial REALIZADO POR : Ing. Juan Fco. Soto. FECHA : Enero 12,1993. -------------------------------------------------------------------------- } GLOBALS "veprgb000.4gl" DEFINE mes_chequeo SMALLINT FUNCTION veprmt999() DEFINE t_valor,valor_p,balance DECIMAL(12,2) DEFINE tipo_fact,p_cod,p_bonif,cantidad_total,ano_act,ano_fe,credito,t_bonif, provincia,factor INTEGER DEFINE hoy DATE DEFINE hice,primera,tipo_p,opt2,opt1,opt CHAR(1) DEFINE tipo_f,tipo2 CHAR(2) DEFINE cod_desc,tipo1 SMALLINT DEFINE precio_ant,cantidad_ant,precio DECIMAL(12,3), i,longitud SMALLINT DEFINE tot_porc1,porc_desc,tot_porc DECIMAL(8,3) OPTIONS FORM LINE 2, ERROR LINE 24, COMMENT LINE 23, PROMPT LINE 22 CLEAR SCREEN OPEN FORM vefmmt999 FROM "vefmmt999" DISPLAY FORM vefmmt999 DISPLAY "veprmt999" AT 1,1 ATTRIBUTE (YELLOW) LET hoy = today DISPLAY hoy using "dd/mm/yy" AT 1,70 ATTRIBUTE (YELLOW) DISPLAY "Factura de Ventas" AT 3,30 ATTRIBUTE (YELLOW) DISPLAY " Adiciona " AT 3,1 ATTRIBUTE (BOLD) DISPLAY " Cancela Operacion" AT 3,56 ATTRIBUTE (BOLD) # WHENEVER ERROR CONTINUE ERROR "Para Anular Una Factura Que este Hecha Precione Ctrl-B" LABEL exito: INITIALIZE fact_gral.*,primera TO NULL LET porc_desc = 0 LET descrip1 = NULL LET descrip2 = NULL LET p_bonif = NULL LET fact_gral.cod_cia = 1 LET fact_gral.fecha_factura = today LET tot_porc1 = 0 LET fact_gral.itbi = 0 LET fact_gral.sub_total = 0 LET fact_gral.total_fact = 0 LET fact_gral.desc_valor = 0 LET tot_porc = 0 DISPLAY BY NAME descrip1,descrip2 FOR idx = 1 to 20 LET fact_det[idx].cod_n = null LET fact_det[idx].cod_grupo = null LET fact_det[idx].cod_tipo = null LET fact_det[idx].cod_sec = null LET fact_det[idx].cantidad = null LET fact_det[idx].despacho = null LET fact_det[idx].existencia = null LET fact_det[idx].unidades = null LET fact_det[idx].precio = null LET fact_det[idx].monto_fact = null END FOR FOR idx = 1 to 4 DISPLAY fact_det[idx].cod_n to s_fact[idx].cod_n DISPLAY fact_det[idx].cod_grupo to s_fact[idx].cod_grupo DISPLAY fact_det[idx].cod_tipo to s_fact[idx].cod_tipo DISPLAY fact_det[idx].cod_sec to s_fact[idx].cod_sec DISPLAY fact_det[idx].cantidad to s_fact[idx].cantidad DISPLAY fact_det[idx].despacho to s_fact[idx].despacho DISPLAY fact_det[idx].existencia to s_fact[idx].existencia DISPLAY fact_det[idx].unidades to s_fact[idx].unidades DISPLAY fact_det[idx].precio to s_fact[idx].precio DISPLAY fact_det[idx].monto_fact to s_fact[idx].monto_fact END FOR DISPLAY BY NAME descrip1,descrip2 LABEL vuelve: LET descrip1 = null LET descrip2 = null LET p_bonif = null LET tot_porc1 = 0 LET t_valor = 0 LET fact_gral.cond_pago = 2 LET fact_gral.porc_itbi = null LET fact_gral.prima_us = null DISPLAY BY NAME fact_gral.porc_itbi,fact_gral.prima_us, descrip1,descrip2 LET hice = "S" LET h = 1 INPUT BY NAME fact_gral.* WITHOUT DEFAULTS ATTRIBUTE (YELLOW) ON KEY (CONTROL-B) LET mes_chequeo = MONTH(TODAY) CALL anular1() NEXT FIELD cod_cia ON KEY (CONTROL-W) CASE WHEN INFIELD(cod_tarifa) CALL tarifas() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD cod_tarifa END IF LET descrip5 = descrip6[1,15] clipped LET descrip6 = descrip6[16,30] clipped DISPLAY BY NAME descrip5,descrip6 ATTRIBUTE (BOLD) NEXT FIELD nombre_tran WHEN INFIELD(zona) IF fact_gral.ventas = "1" THEN CALL busca_zona1() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD zona END IF ELSE CALL busca_pais() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD zona END IF END IF LET p_cod = fact_gral.zona LET fact_gral.zona = p_cod using "&&&" DISPLAY BY NAME fact_gral.zona,descrip1 ATTRIBUTE (BOLD) NEXT FIELD fecha_factura WHEN INFIELD(tipo_cliente) CALL consulta_clientes() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD tipo_cliente END IF LET fact_gral.tipo_cliente = cliente_dir.tipo_cliente LET fact_gral.sec_cliente = cliente_dir.sec_cliente INITIALIZE descrip1,descrip2,descrip3 TO NULL LET fact_gral.direccion = descrip1 clipped," ",descrip2 clipped,", ", descrip3 clipped DISPLAY BY NAME fact_gral.tipo_cliente ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.sec_cliente ATTRIBUTE(YELLOW) DISPLAY BY NAME fact_gral.nombre ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.direccion ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.ciudad ATTRIBUTE (YELLOW) NEXT FIELD prima_us WHEN INFIELD(sec_cliente) CALL consulta_clientes() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD tipo_cliente END IF LET fact_gral.tipo_cliente = cliente_dir.tipo_cliente LET fact_gral.sec_cliente = cliente_dir.sec_cliente INITIALIZE descrip1,descrip2,descrip3 TO NULL SELECT a.nombre,b.calle,b.casa_num,b.barrio, d.nombre_provincia,a.limite_credito INTO fact_gral.nombre,descrip1,descrip2,descrip3, fact_gral.ciudad,credito FROM vetb00004 a,vetb00005 b,vetb00009 c,vetb00020 d WHERE a.tipo_cliente = fact_gral.tipo_cliente and a.sec_cliente = fact_gral.sec_cliente and b.tipo_cliente = a.tipo_cliente and b.sec_cliente = a.sec_cliente and a.cod_zona = c.cod_zona and a.cod_provincia = c.cod_provincia and a.cod_provincia = d.cod_provincia and a.status_t IS NULL LET fact_gral.direccion = descrip1 clipped," ",descrip2 clipped,", ", descrip3 clipped DISPLAY BY NAME fact_gral.tipo_cliente ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.sec_cliente ATTRIBUTE(YELLOW) DISPLAY BY NAME fact_gral.nombre ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.direccion ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.ciudad ATTRIBUTE (YELLOW) NEXT FIELD prima_us WHEN INFIELD(cond_pago) CALL condiciones() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD cond_pago END IF DISPLAY BY NAME fact_gral.cond_pago ATTRIBUTE(YELLOW) DISPLAY BY NAME fact_gral.descrip ATTRIBUTE(YELLOW) NEXT FIELD orden # WHEN INFIELD(cod_vend) # CALL consulta_empleados() # IF int_flag THEN # LET numero_msg = 2 # CALL msg(numero_msg) # LET int_flag = false # NEXT FIELD cod_vend # END IF # # LET fact_gral.cod_vend = transportista.cod_transp # LET fact_gral.sec_vend = transportista.sec_transp # LET fact_gral.nombre_vend = descrip6 # DISPLAY BY NAME fact_gral.cod_vend ATTRIBUTE (YELLOW) # DISPLAY BY NAME fact_gral.sec_vend ATTRIBUTE (YELLOW) # DISPLAY BY NAME fact_gral.nombre_vend ATTRIBUTE (YELLOW) # NEXT FIELD cod_transp WHEN INFIELD(sec_vend) CALL consulta_empleados() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD cod_vend END IF # LET fact_gral.cod_vend = transportista.cod_transp LET fact_gral.sec_vend = transportista.sec_transp LET fact_gral.nombre_vend = descrip6 # DISPLAY BY NAME fact_gral.cod_vend ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.sec_vend ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.nombre_vend ATTRIBUTE (YELLOW) NEXT FIELD cod_transp WHEN INFIELD(cod_transp) # CALL cons_transp() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD cons_transp END IF DISPLAY BY NAME fact_gral.cod_transp ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.sec_transp ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.nombre_tran ATTRIBUTE (YELLOW) NEXT FIELD cod_tarifa WHEN INFIELD(sec_transp) # CALL cons_transp() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD cons_transp END IF DISPLAY BY NAME fact_gral.cod_transp ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.sec_transp ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.nombre_tran ATTRIBUTE (YELLOW) NEXT FIELD cod_tarifa END CASE AFTER FIELD cod_cia IF fact_gral.cod_cia is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_cia END IF IF fact_gral.cod_cia = 1 THEN LET compania = "R A Y - O - V A C D O M I N I C A N A, S. A." END IF IF fact_gral.cod_cia = 2 THEN LET compania = "DISTRIBUIDORA DOMINICANA DE PILAS, S. A." END IF DISPLAY BY NAME compania ATTRIBUTE (YELLOW) AFTER FIELD ventas IF fact_gral.ventas is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD ventas END IF SELECT prima,@itbi INTO fact_gral.prima_us,fact_gral.porc_itbi FROM vetb00019 WHERE disponible = "S" IF fact_gral.ventas = "1" THEN IF fact_gral.porc_itbi is null THEN LET numero_msg = 87 CALL msg(numero_msg) NEXT FIELD ventas END IF LET tipo_fact = 30 LET tipo_f = "FT" LET fact_gral.nombre_tipo = "LOCAL" LET fact_gral.prima_us = null ELSE LET fact_gral.porc_itbi = null IF fact_gral.prima_us is null THEN LET numero_msg = 87 CALL msg(numero_msg) NEXT FIELD ventas END IF LET fact_gral.nombre_tipo = "EXPORTACION" LET tipo_fact = 31 LET tipo_f = "FE" END IF DISPLAY BY NAME fact_gral.prima_us,fact_gral.porc_itbi ATTRIBUTE(BOLD) DISPLAY BY NAME fact_gral.nombre_tipo ATTRIBUTE (BOLD) DISPLAY BY NAME descrip1 ATTRIBUTE (BOLD) AFTER FIELD zona LET longitud = LENGTH(fact_gral.zona) IF longitud < 3 THEN LET numero_msg = 77 CALL msg(numero_msg) NEXT FIELD zona END IF LET tipo1 = fact_gral.zona CALL integridad() IF bandera = 1 THEN LET bandera = 0 NEXT FIELD zona END IF LET tipo2 = fact_gral.zona[2,3] IF fact_gral.ventas = "1" THEN SELECT unique descrip INTO descrip1 FROM vetb00008 WHERE cod_zona = tipo1 IF status < 0 THEN CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF ELSE IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD ventas END IF END IF END IF IF fact_gral.ventas = "2" THEN SELECT unique nom_pais INTO descrip1 FROM cotb00018 WHERE cod_pais = tipo2 IF status < 0 THEN CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF ELSE IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD ventas END IF END IF END IF SELECT max(ult_factura) INTO fact_gral.factura FROM vetb77777 LET fact_gral.factura = fact_gral.factura + 1 DISPLAY BY NAME fact_gral.factura ATTRIBUTE (YELLOW) DISPLAY BY NAME descrip1 ATTRIBUTE(YELLOW) AFTER FIELD sec_cliente IF fact_gral.sec_cliente is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD sec_cliente ELSE SELECT a.nombre,a.limite_credito,a.cod_provincia INTO fact_gral.nombre,credito,provincia FROM vetb00004 a WHERE a.tipo_cliente = fact_gral.tipo_cliente and a.sec_cliente = fact_gral.sec_cliente AND a.status_t IS NULL IF status < 0 THEN CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF ELSE IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD tipo_cliente END IF END IF DISPLAY BY NAME fact_gral.nombre ATTRIBUTE (YELLOW) SELECT b.calle,b.casa_num,b.barrio INTO descrip1,descrip2,descrip3 FROM vetb00005 b WHERE b.tipo_cliente = fact_gral.tipo_cliente and b.sec_cliente = fact_gral.sec_cliente SELECT d.nombre_provincia INTO fact_gral.ciudad FROM vetb00020 d WHERE d.cod_provincia = provincia IF status < 0 THEN CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF ELSE IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD tipo_cliente END IF END IF LET fact_gral.direccion = descrip1 clipped," ",descrip2 clipped,", ", descrip3 clipped DISPLAY BY NAME fact_gral.direccion ATTRIBUTE (YELLOW) DISPLAY BY NAME fact_gral.ciudad ATTRIBUTE (YELLOW) END IF BEFORE FIELD prima_us IF fact_gral.ventas = "1" THEN NEXT FIELD cond_pago END IF BEFORE FIELD cond_pago LET fact_gral.cond_pago = 2 DISPLAY BY NAME fact_gral.cond_pago AFTER FIELD cond_pago IF fact_gral.cond_pago is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cond_pago END IF SELECT @descrip,@dias INTO fact_gral.descrip,dias_v FROM vetb00012 WHERE cond_pago = fact_gral.cond_pago IF status < 0 THEN CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF ELSE IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cond_pago END IF END IF DISPLAY BY NAME fact_gral.descrip ATTRIBUTE (YELLOW) BEFORE FIELD porc_itbi IF fact_gral.ventas = "2" THEN NEXT FIELD sec_vend END IF AFTER FIELD porc_itbi IF fact_gral.porc_itbi is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD porc_itbi END IF # AFTER FIELD cod_vend # IF fact_gral.cod_vend is null THEN # LET numero_msg = 16 # CALL msg(numero_msg) # NEXT FIELD cod_vend # END IF AFTER FIELD sec_vend IF fact_gral.sec_vend is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD sec_vend END IF SELECT nom1_emp, apell1_emp INTO descrip5,descrip6 FROM adtb00003 WHERE #cod_emp = fact_gral.cod_vend and num_emp = fact_gral.sec_vend IF status < 0 THEN CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF ELSE IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD sec_vend END IF END IF LET fact_gral.nombre_vend = descrip5 clipped,", ",descrip6 clipped DISPLAY BY NAME fact_gral.nombre_vend ATTRIBUTE (YELLOW) BEFORE FIELD cod_transp IF fact_gral.cond_pago = 1 or fact_gral.ventas = "2" THEN NEXT FIELD fecha_embarque END IF AFTER FIELD cod_transp IF fact_gral.cod_transp is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_transp END IF AFTER FIELD sec_transp IF fact_gral.sec_transp is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD sec_transp END IF SELECT nombre,cedula,serie INTO fact_gral.nombre_tran,p_cedula,p_serie FROM vetb00015 WHERE cod_transp = fact_gral.cod_transp and sec_transp = fact_gral.sec_transp and status_t is null IF status < 0 THEN CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF ELSE IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cod_transp END IF END IF DISPLAY BY NAME fact_gral.nombre_tran ATTRIBUTE (YELLOW) AFTER FIELD cod_tarifa IF fact_gral.cod_tarifa is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_tarifa END IF SELECT descrip INTO descrip6 FROM vetb00023 WHERE cod_tarifa = fact_gral.cod_tarifa and status_t is null LET descrip5 = descrip6[1,15] clipped LET descrip6 = descrip6[16,30] clipped DISPLAY BY NAME descrip5,descrip6 ATTRIBUTE (BOLD) BEFORE FIELD fecha_embarque IF fact_gral.ventas = "1" THEN NEXT FIELD placa_transp END IF AFTER FIELD fecha_embarque IF fact_gral.fecha_embarque is null THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD fecha_embarque END IF # No permite que el usuario introduzca un ano que no corresponda al actual LET ano_act = year(today) LET ano_fe = year(fact_gral.fecha_embarque) IF ano_fe < ano_act THEN LET numero_msg = 59 CALL msg(numero_msg) NEXT FIELD fecha_embarque END IF IF fact_gral.fecha_embarque < fact_gral.fecha_factura THEN LET numero_msg = 100 CALL msg(numero_msg) NEXT FIELD fecha_embarque END IF IF fact_gral.ventas = "2" THEN EXIT INPUT END IF AFTER FIELD placa_transp IF fact_gral.placa_transp is null THEN LET numero_msg = 16 CALL msg(numero_msg) 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 LET fact_gral.itbi = 0 LET fact_gral.sub_total = 0 LET fact_gral.total_fact = 0 LET fact_gral.desc_valor = 0 LET tot_porc = 0 LABEL alla: INPUT ARRAY fact_det WITHOUT DEFAULTS FROM s_fact.* ON KEY (CONTROL-W) LET curr = arr_curr() LET scr_l = scr_line() CASE WHEN INFIELD (cod_n) CALL busca_pt() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD cod_n END IF LET fact_det[curr].cod_n = pterminado.cod_n LET fact_det[curr].cod_grupo = pterminado.cod_grupo LET fact_det[curr].cod_tipo = pterminado.cod_tipo LET fact_det[curr].cod_sec = pterminado.cod_sec CALL repite_codigo() IF verdad = "S" THEN NEXT FIELD cod_n END IF LET verdad = null # CALL precios() IF verdad = "S" THEN NEXT FIELD cod_n END IF SELECT a.descrip_esp INTO descrip1 FROM iptb00002 a WHERE a.cod_n = fact_det[curr].cod_n AND a.cod_grupo = fact_det[curr].cod_grupo AND a.cod_tipo = fact_det[curr].cod_tipo AND a.cod_sec = fact_det[curr].cod_sec AND a.status_t is null SELECT SUM(a.cantidad_2) INTO p_existencia FROM iptb00006 a WHERE a.cod_n = fact_det[curr].cod_n AND a.cod_grupo = fact_det[curr].cod_grupo AND a.cod_tipo = fact_det[curr].cod_tipo AND a.cod_sec = fact_det[curr].cod_sec AND a.status_t is null LET descrip2 = descrip1 DISPLAY fact_det[curr].cod_n TO s_fact[scr_l].cod_n DISPLAY fact_det[curr].cod_grupo TO s_fact[scr_l].cod_grupo DISPLAY fact_det[curr].cod_tipo TO s_fact[scr_l].cod_tipo DISPLAY fact_det[curr].cod_sec TO s_fact[scr_l].cod_sec DISPLAY fact_det[curr].precio TO s_fact[scr_l].precio DISPLAY BY NAME descrip2 NEXT FIELD cantidad WHEN INFIELD (cod_grupo) CALL busca_pt() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD cod_n END IF LET fact_det[curr].cod_n = pterminado.cod_n LET fact_det[curr].cod_grupo = pterminado.cod_grupo LET fact_det[curr].cod_tipo = pterminado.cod_tipo LET fact_det[curr].cod_sec = pterminado.cod_sec CALL repite_codigo() IF verdad = "S" THEN NEXT FIELD cod_n END IF LET verdad = null # CALL precios() IF verdad = "S" THEN NEXT FIELD cod_n END IF SELECT a.descrip_esp,b.existencia INTO descrip1,p_existencia FROM iptb00002 a,iptb00002 b WHERE a.cod_n = fact_det[curr].cod_n AND a.cod_grupo = fact_det[curr].cod_grupo AND a.cod_tipo = fact_det[curr].cod_tipo AND a.cod_sec = fact_det[curr].cod_sec AND b.cod_n = fact_det[curr].cod_n AND b.cod_grupo = fact_det[curr].cod_grupo AND b.cod_tipo = fact_det[curr].cod_tipo AND b.cod_sec = fact_det[curr].cod_sec AND a.status_t is null and b.status_t is null LET descrip2 = descrip1 DISPLAY fact_det[curr].cod_n TO s_fact[scr_l].cod_n DISPLAY fact_det[curr].cod_grupo TO s_fact[scr_l].cod_grupo DISPLAY fact_det[curr].cod_tipo TO s_fact[scr_l].cod_tipo DISPLAY fact_det[curr].cod_sec TO s_fact[scr_l].cod_sec DISPLAY fact_det[curr].precio TO s_fact[scr_l].precio DISPLAY BY NAME descrip2 NEXT FIELD cantidad WHEN INFIELD (cod_tipo) CALL busca_pt() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD cod_n END IF LET fact_det[curr].cod_n = pterminado.cod_n LET fact_det[curr].cod_grupo = pterminado.cod_grupo LET fact_det[curr].cod_tipo = pterminado.cod_tipo LET fact_det[curr].cod_sec = pterminado.cod_sec CALL repite_codigo() IF verdad = "S" THEN NEXT FIELD cod_n END IF LET verdad = null # CALL precios() IF verdad = "S" THEN NEXT FIELD cod_n END IF SELECT a.descrip_esp,b.existencia INTO descrip1,p_existencia FROM iptb00002 a,iptb00002 b WHERE a.cod_n = fact_det[curr].cod_n AND a.cod_grupo = fact_det[curr].cod_grupo AND a.cod_tipo = fact_det[curr].cod_tipo AND a.cod_sec = fact_det[curr].cod_sec AND b.cod_n = fact_det[curr].cod_n AND b.cod_grupo = fact_det[curr].cod_grupo AND b.cod_tipo = fact_det[curr].cod_tipo AND b.cod_sec = fact_det[curr].cod_sec AND a.status_t is null and b.status_t is null LET descrip2 = descrip1 DISPLAY fact_det[curr].cod_n TO s_fact[scr_l].cod_n DISPLAY fact_det[curr].cod_grupo TO s_fact[scr_l].cod_grupo DISPLAY fact_det[curr].cod_tipo TO s_fact[scr_l].cod_tipo DISPLAY fact_det[curr].cod_sec TO s_fact[scr_l].cod_sec DISPLAY fact_det[curr].precio TO s_fact[scr_l].precio DISPLAY BY NAME descrip2 NEXT FIELD cantidad WHEN INFIELD (cod_sec) CALL busca_pt() IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false NEXT FIELD cod_n END IF LET fact_det[curr].cod_n = pterminado.cod_n LET fact_det[curr].cod_grupo = pterminado.cod_grupo LET fact_det[curr].cod_tipo = pterminado.cod_tipo LET fact_det[curr].cod_sec = pterminado.cod_sec CALL repite_codigo() IF verdad = "S" THEN NEXT FIELD cod_n END IF LET verdad = null # CALL precios() IF verdad = "S" THEN NEXT FIELD cod_n END IF SELECT a.descrip_esp,b.existencia INTO descrip1,p_existencia FROM iptb00002 a,iptb00002 b WHERE a.cod_n = fact_det[curr].cod_n AND a.cod_grupo = fact_det[curr].cod_grupo AND a.cod_tipo = fact_det[curr].cod_tipo AND a.cod_sec = fact_det[curr].cod_sec AND b.cod_n = fact_det[curr].cod_n AND b.cod_grupo = fact_det[curr].cod_grupo AND b.cod_tipo = fact_det[curr].cod_tipo AND b.cod_sec = fact_det[curr].cod_sec AND a.status_t is null and b.status_t is null LET descrip2 = descrip1 DISPLAY fact_det[curr].cod_n TO s_fact[scr_l].cod_n DISPLAY fact_det[curr].cod_grupo TO s_fact[scr_l].cod_grupo DISPLAY fact_det[curr].cod_tipo TO s_fact[scr_l].cod_tipo DISPLAY fact_det[curr].cod_sec TO s_fact[scr_l].cod_sec DISPLAY fact_det[curr].precio TO s_fact[scr_l].precio DISPLAY BY NAME descrip2 NEXT FIELD cantidad END CASE AFTER FIELD cod_n LET curr = arr_curr() LET scr_l = scr_line() IF fact_det[curr].cod_n is not null AND fact_det[curr].cod_grupo is not null AND fact_det[curr].cod_tipo is not null AND fact_det[curr].cod_sec is not null THEN CALL repite_codigo() IF verdad = "S" THEN NEXT FIELD cod_grupo END IF END IF AFTER FIELD cod_grupo IF fact_det[curr].cod_n is not null AND fact_det[curr].cod_grupo is not null AND fact_det[curr].cod_tipo is not null AND fact_det[curr].cod_sec is not null THEN CALL repite_codigo() IF verdad = "S" THEN NEXT FIELD cod_tipo END IF END IF AFTER FIELD cod_tipo IF fact_det[curr].cod_n is not null AND fact_det[curr].cod_grupo is not null AND fact_det[curr].cod_tipo is not null AND fact_det[curr].cod_sec is not null THEN CALL repite_codigo() IF verdad = "S" THEN NEXT FIELD cod_sec END IF END IF AFTER FIELD cod_sec IF fact_det[curr].cod_n is not null AND fact_det[curr].cod_grupo is not null AND fact_det[curr].cod_tipo is not null AND fact_det[curr].cod_sec is not null THEN CALL repite_codigo() IF verdad = "S" THEN NEXT FIELD cod_n END IF # Calcula el precio por la cantidad vendida para el monto y el # calculo del precio por la prima digitdada LET verdad = null CALL precios() IF verdad = "S" THEN NEXT FIELD cod_n END IF # Busca la descripcion del producto con su existencia SELECT a.descrip_esp,SUM(b.cantidad_2) INTO descrip2,p_existencia FROM iptb00002 a,iptb00006 b WHERE a.cod_n = fact_det[curr].cod_n AND a.cod_grupo = fact_det[curr].cod_grupo AND a.cod_tipo = fact_det[curr].cod_tipo AND a.cod_sec = fact_det[curr].cod_sec AND b.cod_n = a.cod_n and b.cod_grupo = a.cod_grupo and b.cod_tipo = a.cod_tipo and b.cod_sec = a.cod_sec and a.status_t is null and b.status_t is null IF status < 0 THEN CALL integridad() IF bandera = 1 THEN LET bandera = 0 RETURN END IF ELSE IF status = notfound THEN LET numero_msg = 3 CALL msg(numero_msg) NEXT FIELD cod_n END IF END IF ELSE LET fact_det[curr].cod_n = null LET fact_det[curr].cod_grupo = null LET fact_det[curr].cod_tipo = null LET fact_det[curr].cod_sec = null DISPLAY fact_det[curr].cod_n to s_fact[scr_l].cod_n DISPLAY fact_det[curr].cod_grupo to s_fact[scr_l].cod_grupo DISPLAY fact_det[curr].cod_tipo to s_fact[scr_l].cod_tipo DISPLAY fact_det[curr].cod_sec to s_fact[scr_l].cod_sec NEXT FIELD cod_n END IF DISPLAY BY NAME descrip2 AFTER FIELD cantidad IF fact_det[curr].cod_n is not null AND fact_det[curr].cod_grupo is not null AND fact_det[curr].cod_tipo is not null AND fact_det[curr].cod_sec is not null THEN IF fact_det[curr].cantidad is null OR fact_det[curr].cantidad = 0 THEN LET numero_msg = 16 CALL msg(numero_msg) NEXT FIELD cod_n END IF # Busca factor de conversion de cada pila SELECT cantidad INTO p_cantidad FROM vetb00014 WHERE cod_n = fact_det[curr].cod_n and cod_grupo = fact_det[curr].cod_grupo and cod_tipo = fact_det[curr].cod_tipo and cod_sec = fact_det[curr].cod_sec and status_t is null IF status = notfound THEN LET numero_msg = 94 CALL msg(numero_msg) NEXT FIELD cod_n END IF LET fact_det[curr].unidades = fact_det[curr].cantidad * p_cantidad DISPLAY fact_det[curr].unidades TO s_fact[scr_l].unidades # Calcula el precio por las unidades y da el monto LET fact_det[curr].monto_fact = fact_det[curr].unidades * fact_det[curr].precio DISPLAY fact_det[curr].monto_fact to s_fact[scr_l].monto_fact DISPLAY fact_det[curr].precio TO s_fact[scr_l].precio LET excede[curr] = null END IF { Convertir la existencia en cajas para desplegarla LET p_existencia = p_existencia / p_cantidad LET fact_det[curr].despacho = p_existencia LET fact_det[curr].existencia = p_existencia LET cant_pend[curr] = fact_det[curr].despacho * p_cantidad DISPLAY fact_det[curr].existencia TO s_fact[scr_l].existencia DISPLAY fact_det[curr].despacho TO s_fact[scr_l].despacho NEXT FIELD despacho ELSE NEXT FIELD precio END IF} # Tiene Este Comentario por estar controlado en otro lado # Esta decicion es para el precio del producto si no tiene { IF fact_det[curr].monto_fact is null or fact_det[curr].monto_fact = 0 THEN LET numero_msg = 85 CALL msg(numero_msg) LET fact_det[curr].cod_n = null LET fact_det[curr].cod_grupo = null LET fact_det[curr].cod_tipo = null LET fact_det[curr].cod_sec = null LET fact_det[curr].cantidad = null LET fact_det[curr].despacho = null LET fact_det[curr].existencia = null LET fact_det[curr].despacho = null LET fact_det[curr].existencia = null LET fact_det[curr].unidades = null LET fact_det[curr].precio = null LET fact_det[curr].monto_fact = null DISPLAY fact_det[curr].cod_n TO s_fact[scr_l].cod_n DISPLAY fact_det[curr].cod_grupo TO s_fact[scr_l].cod_grupo DISPLAY fact_det[curr].cod_tipo TO s_fact[scr_l].cod_tipo DISPLAY fact_det[curr].cod_sec TO s_fact[scr_l].cod_sec DISPLAY fact_det[curr].cantidad to s_fact[scr_l].cantidad DISPLAY fact_det[curr].despacho to s_fact[scr_l].desacho DISPLAY fact_det[curr].existencia to s_fact[scr_l].existencia DISPLAY fact_det[curr].despacho to s_fact[scr_l].despacho DISPLAY fact_det[curr].existencia to s_fact[scr_l].existencia DISPLAY fact_det[curr].precio to s_fact[scr_l].precio DISPLAY fact_det[curr].monto_fact to s_fact[scr_l].monto_fact DISPLAY fact_det[curr].unidades to s_fact[scr_l].unidades NEXT FIELD cod_n END IF} AFTER FIELD precio IF fact_det[curr].precio is not null THEN LET fact_det[curr].monto_fact = fact_det[curr].precio * fact_det[curr].unidades DISPLAY fact_det[curr].monto_fact to s_fact[scr_l].monto_fact END IF BEFORE FIELD despacho NEXT FIELD precio AFTER INPUT IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false RETURN END IF # Busca la existencia de la pilas IF fact_det[curr].cod_n is not null and fact_det[curr].cod_grupo is not null and fact_det[curr].cod_tipo is not null and fact_det[curr].cod_sec is not null THEN SELECT a.descrip_esp,b.existencia INTO descrip2,p_existencia FROM iptb00002 a,iptb00002 b WHERE a.cod_n = fact_det[curr].cod_n AND a.cod_grupo = fact_det[curr].cod_grupo AND a.cod_tipo = fact_det[curr].cod_tipo AND a.cod_sec = fact_det[curr].cod_sec AND b.cod_n = a.cod_n and b.cod_grupo = a.cod_grupo and b.cod_tipo = a.cod_tipo and b.cod_sec = a.cod_sec and a.status_t is null and b.status_t is null # Busca factor de conversion de cada pila SELECT cantidad INTO p_cantidad FROM vetb00014 WHERE cod_n = fact_det[curr].cod_n and cod_grupo = fact_det[curr].cod_grupo and cod_tipo = fact_det[curr].cod_tipo and cod_sec = fact_det[curr].cod_sec and status_t is null IF status = notfound THEN LET numero_msg = 94 CALL msg(numero_msg) NEXT FIELD cod_n END IF END IF # Calculo del sub-total de la factura LET t_costos = 0 FOR idx = 1 to arr_count() IF fact_det[idx].monto_fact is not null THEN SELECT material,labor,gasto_ind,max(mes_ini),max(mes_fin),max(ano) INTO p_costos1,p_costos2,p_costos3 FROM iptb00004 WHERE cod_n = fact_det[idx].cod_n and cod_grupo = fact_det[idx].cod_grupo and cod_tipo = fact_det[idx].cod_tipo and cod_sec = fact_det[idx].cod_sec and ventas = fact_gral.ventas and status_t is null GROUP BY 1,2,3 LET p_costos = p_costos1 + p_costos2 + p_costos3 LET p_costos = fact_det[idx].unidades * p_costos LET t_costos = t_costos + p_costos LET fact_gral.sub_total = fact_gral.sub_total + fact_det[idx].monto_fact END IF END FOR LET cantidad_total = 0 IF primera is null THEN LET primera = "S" END IF # Calculo descuento de la factura IF fact_gral.porc_desc > 0 and fact_gral.ventas = "1" THEN LET p_desc = fact_gral.sub_total * (fact_gral.porc_desc / 100) LET fact_gral.desc_valor = p_desc END IF IF fact_gral.porc_desc > 0 and fact_gral.ventas = "2" THEN LET fact_gral.desc_valor = fact_gral.porc_desc END IF IF fact_gral.desc_valor is null THEN LET fact_gral.desc_valor = 0 END IF LET desc_valor = fact_gral.desc_valor using "###,###.##" DISPLAY BY NAME desc_valor ATTRIBUTE (BOLD) # Calcula el porciento de ITBIS de la factura dependiendo del porciento # especificado por el usuario IF fact_gral.porc_itbi is not null THEN LET fact_gral.total_fact = fact_gral.sub_total - fact_gral.desc_valor LET fact_gral.itbi = (fact_gral.total_fact * (fact_gral.porc_itbi / 100)) LET itbi = fact_gral.itbi using "###,###,###.##" DISPLAY BY NAME itbi ATTRIBUTE (BOLD) END IF # Calculo total de la factura IF fact_gral.ventas = "1" THEN LET fact_gral.total_fact = fact_gral.sub_total - fact_gral.desc_valor + fact_gral.itbi END IF # Cargos varios por conceptos varios en factura de exportacion IF fact_gral.ventas = "2" THEN LET fact_gral.total_fact = fact_gral.sub_total + fact_gral.desc_valor LET desc_valor = fact_gral.desc_valor using "###,###.##" DISPLAY BY NAME desc_valor ATTRIBUTE (BOLD) END IF LET sub_total = fact_gral.sub_total using "###,###,###.##" LET total_fact = fact_gral.total_fact using "###,###,###.##" DISPLAY BY NAME total_fact ATTRIBUTE (BOLD) DISPLAY BY NAME sub_total ATTRIBUTE (BOLD) # Si el usuario no introdujo ningun item en el arreglo IF fact_gral.sub_total = 0 or fact_gral.sub_total is null THEN LET numero_msg = 84 CALL msg(numero_msg) NEXT FIELD cod_n END IF EXIT INPUT END INPUT LABEL anterior: PROMPT "Las Informaciones Estan Correctas (S/N)" FOR CHAR opt IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false RETURN END IF IF opt is null THEN LET numero_msg = 16 CALL msg(numero_msg) GOTO anterior END IF IF (opt != "S" and opt != "s") THEN IF (opt != "n" and opt != "N") THEN LET numero_msg = -1301 CALL msg(numero_msg) GOTO anterior END IF END IF IF opt = "S" or opt = "s" THEN # Actualiza la tabla de datos generales de la factura INSERT INTO vetb88888 (cod_cia, factura, fecha_factura, ventas,zona, orden, fecha_orden, conduce, fecha_conduce, tipo_cliente, sec_cliente, sec_vend, cond_pago, porc_itbi,porc_desc, prima_us, sub_total, monto_desc, monto_itbi, neto, fecha_embarque, status_impresion, status_t, us_crea, fech_crea, us_mod, fech_mod) VALUES (fact_gral.cod_cia, fact_gral.factura, fact_gral.fecha_factura, fact_gral.ventas, fact_gral.zona, fact_gral.orden, fact_gral.fecha_orden, fact_gral.conduce, fact_gral.fecha_conduce, fact_gral.tipo_cliente, fact_gral.sec_cliente, fact_gral.sec_vend, fact_gral.cond_pago, fact_gral.porc_itbi, fact_gral.porc_desc, fact_gral.prima_us, fact_gral.sub_total, fact_gral.desc_valor, fact_gral.itbi, fact_gral.total_fact, fact_gral.fecha_embarque, impresion, null, user, current, null, null) # Actualiza la tabla control de la numeracion de la factura UPDATE vetb77777 set ult_factura = fact_gral.factura, us_crea = user, fech_crea = current # Actualizacion de la tabla de cuentas por cobrar FOR idx = 1 TO arr_count() IF fact_det[idx].cod_n is not null AND fact_det[idx].cod_grupo is not null AND fact_det[idx].cod_tipo is not null AND fact_det[idx].cod_sec is not null THEN # Actualiza la tabla de datos detallados de la factura INSERT INTO vetb99999 values (fact_gral.cod_cia,fact_gral.factura,fact_det[idx].cod_n, fact_det[idx].cod_grupo,fact_det[idx].cod_tipo,fact_det[idx].cod_sec, fact_det[idx].unidades,p_bonifica[idx],fact_det[idx].precio,null,user, current,null,null) # Actualizando la tabla de movimientos de inventario cuando la factura es # normal o Tiene Cantidad a despachar # LET cant_pend[idx] = cant_pend[idx] * -1 LET fact_det[idx].unidades = fact_det[idx].unidades * -1 LET fact_det[idx].unidades = fact_det[idx].unidades * -1 LET cant_pend[idx] = cant_pend[idx] * -1 # Actualiza la tabla maestra de producto terminados en la existencia IF p_bonifica[idx] is null THEN LET p_bonifica[idx] = 0 END IF IF opt4 = "N" or opt4 = "n" THEN LET p_bonifica[idx] = 0 END IF # Cuando la cantidad excede a la existencia hay que guardar la existencia y # ademas imprimir las cajas bonificadas pero no rebajar del inventario LET p_cantidad_1 = null IF excede[idx] = "S" THEN IF p_bonifica[idx] > 0 THEN LET p_cantidad_1 = p_bonifica[idx] LET p_bonifica[idx] = 0 END IF END IF END IF IF excede[idx] = "S" THEN LET p_bonifica[idx] = p_cantidad_1 END IF END FOR # Impresion de la factura IF opt1 = "S" or opt1 = "s" THEN START REPORT imp_fact TO "%USHOME%\\archivo" FOR idx = 1 TO arr_count() IF fact_det[idx].cod_n is not null AND fact_det[idx].cod_grupo is not null AND fact_det[idx].cod_tipo is not null AND fact_det[idx].cod_sec is not null THEN OUTPUT TO REPORT imp_fact(fact_gral.*,fact_det[idx].*,tot_porc,p_bonifica[idx]) END IF END FOR FINISH REPORT imp_fact LET impresion = "S" END IF IF fact_gral.cond_pago = 1 THEN PROMPT "Desea Imprimir Volante de Pago Ahora? (S/N) " FOR CHAR opt3 { IF opt3 = "S" or opt3 = "s" THEN CALL captura_pago() END IF} END IF LET numero_msg = 1 CALL msg(numero_msg) GOTO exito ELSE # Borra la factura de la tabla de descuentos para cuando el usuario # haga alguna modificacion se le actualice en el proceso destinado para los # descuentos LET primera = null DELETE FROM vetb00026 WHERE factura = fact_gral.factura GOTO vuelve END IF FOR idx = 1 to 4 LET fact_det[idx].cod_n = null LET fact_det[idx].cod_grupo = null LET fact_det[idx].cod_tipo = null LET fact_det[idx].cod_sec = null LET fact_det[idx].cantidad = null LET fact_det[idx].despacho = null LET fact_det[idx].existencia = null LET fact_det[idx].unidades = null LET fact_det[idx].precio = null LET fact_det[idx].monto_fact = null DISPLAY fact_det[idx].cod_n to s_fact[idx].cod_n DISPLAY fact_det[idx].cod_grupo to s_fact[idx].cod_grupo DISPLAY fact_det[idx].cod_tipo to s_fact[idx].cod_tipo DISPLAY fact_det[idx].cod_sec to s_fact[idx].cod_sec DISPLAY fact_det[idx].cantidad to s_fact[idx].cantidad DISPLAY fact_det[idx].despacho to s_fact[idx].despacho DISPLAY fact_det[idx].existencia to s_fact[idx].existencia DISPLAY fact_det[idx].unidades to s_fact[idx].unidades DISPLAY fact_det[idx].precio to s_fact[idx].precio DISPLAY fact_det[idx].monto_fact to s_fact[idx].monto_fact END FOR END FUNCTION FUNCTION anular1() OPEN WINDOW anula AT 7,5 WITH FORM "vefmwd006" ATTRIBUTE (BORDER, COMMENT LINE LAST - 1,PROMPT LINE LAST - 2,FORM LINE FIRST + 1) LABEL vuelve: INPUT BY NAME p_fact_no AFTER FIELD p_fact_no SELECT month(fecha_factura) INTO mes_chequeo FROM vetb88888 where factura = p_fact_no and status_t is null IF status = notfound THEN LET numero_msg = 102 CALL msg(numero_msg) GOTO vuelve END IF AFTER INPUT IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) EXIT INPUT END IF EXIT INPUT END INPUT # Este Int_flag es porque tuve que salir del input con el int_flag verdadero # y asi poder salir del window sin problemas IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false GOTO salir END IF LABEL atras: PROMPT "Esta seguro de Anular Esta Factura? (S/N)" FOR CHAR opt3 IF int_flag THEN LET numero_msg = 2 CALL msg(numero_msg) LET int_flag = false GOTO salir END IF IF opt3 != "S" and opt3 != "s" and opt3 != "N" and opt3 != "n" THEN LET numero_msg = -1301 CALL msg(numero_msg) GOTO atras END IF IF opt3 = "N" or opt3 = "n" THEN GOTO salir END IF IF opt3 = "S" or opt3 = "s" THEN UPDATE vetb88888 set status_t = "E", us_mod = user, fech_mod = current WHERE factura = p_fact_no UPDATE vetb99999 set status_t = "E", us_mod = user, fech_mod = current WHERE factura = p_fact_no LET numero_msg = 82 CALL msg(numero_msg) END IF LABEL salir: CLOSE FORM vefmwd006 CLOSE WINDOW anula END FUNCTION