Files
DECOMARMOL/PROYECTO/vedir/veprmt049.4gl
T
2026-09-22 20:38:51 -04:00

3376 lines
132 KiB
Plaintext

{
------------------------------------------------------------------
PROGRAMA : veprmt049
OBJETIVO : Generar las Cotizaciones de clientes
PROGRAMADOR : JUAN SOTO
FECHA REALIZACION : Tuesday, 27 November, 2001 11:56:20 AM
MODIFICADO POR :
Empresa : MARMOTECH, S.A.
------------------------------------------------------------------
}
IMPORT os
GLOBALS "veprgb000.4gl"
DEFINE fecha_t DATE,SELEC_r string
DEFINE file,fila_excel,chconvierte,chmensaje,cmd STRING,
correo CHAR(50),pcelular1,pcelular2 CHAR(15),
factor DEC(12,5),
tmpnumero INTEGER,
ptipo_orden VARCHAR(50),
pdescrip CHAR(40), punidad CHAR(4),
pexistencia DEC(12,4),controlE CHAR(2),
orden_cliente CHAR(25),
prtb12 RECORD LIKE prtb00012.*,
exito,pestado BOOLEAN,
respuesta_req,desc_permitido CHAR(3),
chdescuento VARCHAR(10),
precio_ant DEC(12,2),
d_tipos,f_tipos, mensaje,dir_file,filepath,filedestino STRING,
chcliente,chcliente1 CHAR(12),
pcomentario VARCHAR(80),
primera VARCHAR(1),
control_descuento VARCHAR(2),
ptasa DEC(7,3),
etiqueta_cotiza CHAR(30),
pdescuento1,pdescuento2,descuento_aplicado DEC(8,2),
numero_soporte INT,
paga_itbis CHAR(1),
idx1 SMALLINT,
tipoDocumento VARCHAR(2),
pimagen BYTE
DEFINE
actualiza CHAR(1),
telefono,prog CHAR(9),
esta CHAR(3),
xorden,pvend,ultimo_numero,p_res,tmpnumero1,ttipo_cliente,tsec_cliente,pkit INTEGER,
vetb05 RECORD LIKE vetb00005.*,
p_vetb49 RECORD LIKE vetb00049.*,
cantidad_ant LIKE vetb00051.cantidad
DEFINE xsoporte_Ventas DYNAMIC ARRAY OF RECORD
num_emp INT,
nombre_adicional VARCHAR(80)
END RECORD
DEFINE soporte_Ventas DYNAMIC ARRAY OF RECORD
num_emp INT,
nombre_adicional VARCHAR(80)
END RECORD
DEFINE arr_kit DYNAMIC ARRAY OF RECORD
area SMALLINT,
cod_n SMALLINT,
cod_grupo SMALLINT,
cod_tipo SMALLINT,
cod_sec SMALLINT,
descripcion VARCHAR(100),
cantidad DEC(12,5),
precio DEC(12,2),
porc_desc DEC(12,2)
END RECORD
DEFINE despiece DYNAMIC ARRAY OF RECORD
etiqueta CHAR(20),
cod_n SMALLINT,
cod_grupo SMALLINT,
cod_tipo SMALLINT,
cod_sec SMALLINT,
lado_1 DEC(12,5),
lado_2 DEC(12,5),
lado_3 DEC(12,5),
cantidad DEC(12,5),
medida DEC(12,5)
END RECORD,
cuenta_item,i,idx_soporte SMALLINT,
total_medida DEC(12,4),
pporciento,pporc_desc DEC(8,2),
pfecha_desc DATE,
valor1,valor2,balancecxc,cantidad_orden,pcantidadConduce,transito,existencia,reservado,pprecio DEC(12,2)
DEFINE salida STRING
MAIN
DEFER INTERRUPT
CALL STARTLOG("veprmt049.log")
CALL ARG_VAL(1) RETURNING usuarios
CALL ARG_VAL(2) RETURNING clave
CALL ARG_VAL(3) RETURNING impresor
CALL ARG_VAL(4) RETURNING copia
# CONNECT TO "marmotech" AS "IFMX" USER usuarios USING clave
CONNECT TO "decomarmol" AS "MSSQL" USER usuarios USING clave
CALL startlog("veprmt049.log")
SELECT a.* INTO p_companias.* FROM companias a
SELECT a.sec_vend,a.email,a.celular,a.celular2,b.descuento1,b.descuento2
INTO pvend,correo,pcelular1,pcelular2,pdescuento1,pdescuento2
FROM seg0000 a,seg0001 b
WHERE a.usuario = usuarios AND a.usuario = b.usuario
SELECT a.controldescuento INTO control_descuento FROM seg0003 a
WHERE a.usuario = usuarios
IF pdescuento2 IS NULL THEN
LET pdescuento2 = 0
END IF
LET filedestino="tmpfoto49.jpg"
CALL veprmt049()
END MAIN
FUNCTION veprmt049()
CLEAR SCREEN
OPTIONS
FORM LINE 3,
ERROR LINE 24,
COMMENT LINE 24
OPEN FORM vefmmt049 FROM "vefmmt049"
DISPLAY FORM vefmmt049
#CALL f_canvas()
# BUSCA EL ULTIMO NUMERO TEMPORAL PARA EL CONTROL DE CODIGOS
# DUPLICADOS DE PRODUCTOS
SET CONNECTION "MSSQL"
SELECT a.documento INTO tmpnumero1
FROM repitecodigotmp a WHERE tipo_doc = 'CO'
IF tmpnumero1 IS NULL OR tmpnumero1 = 0 THEN
LET tmpnumero1=1000
INSERT INTO repitecodigotmp VALUES (tmpnumero1,'CO')
END IF
LET tmpnumero1 = tmpnumero1 + 1
UPDATE repitecodigotmp set documento = tmpnumero1
LET selec =
"SELECT a.razon_social,RTRIM(a.calle),' NO.'+RTRIM(a.no_local),a.sector ",
"FROM DGII.dbo.empresas a ",
"WHERE a.rnc = ? "
PREPARE query2 FROM selec
MENU
ON ACTION nuevo
SET CONNECTION "MSSQL"
LET INT_FLAG = FALSE
CLEAR FORM
LET actualiza = "N"
INITIALIZE p_vetb50.* TO NULL
CALL arr_cotiza.clear()
CALL vepcad008()
ON ACTION buscar
SET CONNECTION "MSSQL"
LET INT_FLAG = FALSE
INITIALIZE p_vetb50.* TO NULL
CALL arr_cotiza.clear()
CLEAR FORM
LET actualiza = "S"
CALL vepcmf008()
ON ACTION salir
EXIT MENU
END MENU
END FUNCTION
FUNCTION vepcad008()
DEFINE pasa BOOLEAN
## Captura los datos que va a contener el registro
SET CONNECTION "MSSQL"
LET INT_FLAG = false
#LET p_vetb50.tipo_cliente = NULL
#LET p_Vetb50.sec_cliente = NULL
LET p_vetb50.fecha_entrega = TODAY USING "dd/mm/yyyy"
LET p_vetb50.fecha = TODAY USING "dd/mm/yyyy"
IF actualiza = 'N' THEN
LET p_vetb50.sec_vend = pvend
SELECT a.nom1_emp,a.apell1_emp,a.telefono
INTO nombres,apellidos,telefono
FROM adtb00003 a
WHERE a.num_emp = p_vetb50.sec_vend
SELECT a.sec_vend,a.email,a.celular,a.celular2 INTO pvend,correo,pcelular1,pcelular2
FROM seg0000 a
WHERE a.usuario = usuarios
LET nombre_vend = nombres CLIPPED, " ",apellidos CLIPPED,pcelular1 CLIPPED," / ",
pcelular2 CLIPPED
DISPLAY BY NAME nombre_vend
END IF
DELETE FROM repitecodigo WHERE repitecodigo.documento = tmpnumero1 AND
repitecodigo.TIPO_DOC = 'CO'
DIALOG ATTRIBUTE(UNBUFFERED)
INPUT BY NAME p_vetb50.cod_cia,p_vetb50.cotizacion_no,
p_vetb50.ventas,p_vetb50.tipo_cliente,
p_vetb50.sec_cliente,p_vetb50.nombre_cliente,
p_vetb50.rnc,p_vetb50.porc_itbi,p_vetb50.nombre_proyecto,
p_vetb50.direccion_proyecto,
p_vetb50.direccion_cliente,p_vetb50.direccion_facturacion,
p_vetb50.cod_provincia,
p_vetb50.fecha,p_vetb50.fecha_entrega,
p_vetb50.plazo_entrega,p_vetb50.cond_pago,p_vetb50.sec_vend,
p_vetb50.comentario,p_vetb50.contacto,
p_vetb50.tipo_precio,p_vetb50.num_emp_inst,p_Vetb50.telefono_r,
p_vetb50.celular,p_vetb50.telefono_o,
p_vetb50.beeper, p_vetb50.fax,p_vetb50.email ATTRIBUTE (WITHOUT DEFAULTS)
BEFORE INPUT
LET etiqueta_cotiza = "COTIZACION"
LET p_vetb50.cod_cia=1
LET primera = 'S'
# LET p_vetb50.direccion_proyecto = NULL
# DISPLAY BY NAME p_vetb50.direccion_proyecto
CALL cinstalador()
ON ACTION etiqueta
CASE
WHEN etiqueta_cotiza = "COTIZACION"
LET etiqueta_cotiza = "FACTURA PROFORMA"
EXIT CASE
WHEN etiqueta_cotiza = "FACTURA PROFORMA"
LET etiqueta_cotiza = "COTIZACION"
EXIT CASE
END CASE
AFTER FIELD nombre_proyecto
IF p_vetb50.nombre_proyecto IS NULL THEN
CALL msg(16)
NEXT FIELD nombre_proyecto
END IF
AFTER FIELD direccion_proyecto
IF p_vetb50.direccion_proyecto IS NULL THEN
CALL msg(16)
NEXT FIELD direccion_proyecto
END IF
ON ACTION busca_direccion
IF p_vetb50.tipo_cliente IS NOT NULL AND
p_vetb50.sec_cliente IS NOT NULL THEN
LET chconvierte = null
IF p_vetb50.direccion_proyecto IS NOT NULL THEN
LET chconvierte = fgl_winquestion("DIRECCION","EL CAMPO ESTA LLENO CON UNA DIRECCION, DESEA SUSTITUIRLA?","NO","YES|NO","QUESTION",0)
END IF
IF chconvierte = 'SI' OR p_vetb50.direccion_proyecto IS NULL THEN
LET selec =
"SELECT ISNULL(RTRIM(a.calle),' ')+', '+ISNULL(RTRIM(a.casa_num),' ')+', '+
ISNULL(RTRIM(a.urbanizacion),' ') +', '+ISNULL(RTRIM(a.barrio),' ')
FROM vetb00005 a
WHERE a.tipo_cliente =? AND ",
" a.sec_cliente =?"
PREPARE cbusca FROM selec
EXECUTE cbusca USING p_vetb50.tipo_cliente,p_vetb50.sec_cliente
INTO p_vetb50.direccion_proyecto
DISPLAY BY NAME p_vetb50.direccion_proyecto
END IF
END IF
ON ACTION busca_cliente
CALL busca_cliente8()
DISPLAY BY NAME p_vetb50.tipo_cliente,p_vetb50.sec_cliente,p_vetb50.nombre_cliente
LET int_flag = FALSE
ON ACTION busca_provincia
call busca_provincia1()
DISPLAY BY NAME p_vetb50.cod_provincia,nombre_ciudad
LET int_flag = FALSE
BEFORE FIELD cod_cia
IF actualiza ="S" THEN
SELECT a.porciento,a.prima
INTO pporciento,ptasa FROM vetb00019 a WHERE a.disponible = 'S'
NEXT FIELD tipo_cliente
ELSE
SELECT a.itbi,a.porciento,a.prima
INTO p_vetb50.porc_itbi,pporciento,ptasa FROM vetb00019 a WHERE a.disponible = 'S'
DISPLAY BY NAME p_vetb50.porc_itbi
END IF
BEFORE FIELD ventas
IF actualiza <> "S" THEN
LET pventas = ui.ComboBox.forName("formonly.ventas")
CALL cventas()
END IF
BEFORE FIELD cond_pago
LET pcondicion = ui.ComboBox.forName("formonly.cond_pago")
CALL ccondicion()
AFTER FIELD tipo_cliente
IF p_vetb50.tipo_cliente IS NOT NULL THEN
SELECT DISTINCT a.paga_itbis INTO paga_itbis FROM vetb00060 a
WHERE a.tipo_cliente = p_vetb50.tipo_cliente AND
a.ventas = p_vetb50.ventas
IF STATUS = NOTFOUND THEN
LET numero_msg =386
CALL msg(numero_msg)
NEXT FIELD tipo_cliente
END IF
# IF paga_itbis = 'N' THEN
# LET p_vetb50.porc_itbi = NULL
# DISPLAY p_vetb50.porc_itbi
# END IF
END IF
AFTER FIELD cod_cia
IF p_vetb50.cod_cia IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cod_cia
END IF
CASE
WHEN p_vetb50.cod_cia = 1
LET nombre_cia = p_companias.nombre
EXIT CASE
WHEN p_vetb50.cod_cia = 3
LET nombre_cia = "EMPRESA GENERAL"
EXIT CASE
WHEN p_vetb50.cod_cia = 4
LET nombre_cia = "FERIA"
EXIT CASE
END CASE
DISPLAY BY NAME nombre_cia
BEFORE FIELD fecha
IF actualiza = "N" THEN
LET p_vetb50.fecha = TODAY
DISPLAY BY NAME p_vetb50.fecha
END IF
AFTER FIELD fecha
IF actualiza = "N" THEN
LET p_vetb50.fecha_entrega = p_vetb50.fecha + 19
DISPLAY BY NAME p_vetb50.fecha_entrega
END IF
AFTER FIELD telefono_r
IF p_vetb50.telefono_r IS NOT NULL THEN
IF LENGTH(p_vetb50.telefono_r) != 12 THEN
LET numero_msg =77
CALL msg(numero_msg)
#NEXT FIELD telefono_r
END IF
END IF
AFTER FIELD fax
IF p_vetb50.fax IS NOT NULL THEN
IF LENGTH(p_vetb50.fax) != 12 THEN
LET numero_msg =77
CALL msg(numero_msg)
#NEXT FIELD fax
END IF
END IF
AFTER FIELD celular
IF p_vetb50.celular IS NOT NULL THEN
IF LENGTH(p_vetb50.celular) != 12 THEN
LET numero_msg =77
CALL msg(numero_msg)
#NEXT FIELD celular
END IF
END IF
AFTER FIELD sec_cliente
IF p_vetb50.sec_cliente IS NOT NULL THEN
SELECT a.nombre,a.telefono_casa,a.telefono,a.telex,a.patente,a.cod_provincia,
b.nombre_provincia,
a.num_rnc,a.tipo_negocio,a.zona_postal
INTO p_vetb50.nombre_cliente,p_vetb50.telefono_r,p_vetb50.telefono_o,
p_vetb50.celular,
p_vetb50.email,p_vetb50.cod_provincia,nombre_ciudad,p_vetb50.rnc,
cliente_bas.tipo_negocio,tipoDocumento
FROM vetb00004 a,vetb00020 b
WHERE a.tipo_cliente = p_vetb50.tipo_cliente AND
a.sec_cliente = p_vetb50.sec_cliente AND
a.cod_provincia = b.cod_provincia AND
a.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD sec_cliente
END IF
IF cliente_bas.tipo_negocio IS NULL THEN
CALL fgl_winmessage("ERROR","TIPO DE NEGOCIO ESTA NULO EN LA MAESTRA, FAVOR ACTUALIZAR","INFO")
NEXT FIELD sec_cliente
END IF
#CONTROL NUMERO RNC CLIENTE
IF tipoDocumento = '1' THEN
SELECT UNIQUE a.tipo_cliente FROM vetb00060 a
WHERE a.tipo_cliente = p_vetb50.tipo_cliente AND
a.ncf = 'S' AND a.paga_itbis ="S"
IF STATUS <> NOTFOUND THEN
IF p_vetb50.rnc IS NULL THEN
CALL fgl_winmessage("ERROR","CLIENTE NO TIENE RNC","INFO")
NEXT FIELD sec_cliente
ELSE
EXECUTE query2 USING p_vetb50.rnc
IF STATUS = NOTFOUND THEN
CALL fgl_winmessage("ERROR","RNC CLIENTE INVALIDO","INFO")
NEXT FIELD sec_cliente
END IF
END IF
END IF
#---------------------------------------------------------------------
END IF
SELECT a.* INTO vetb05.*
FROM vetb00005 a
WHERE a.tipo_cliente = p_vetb50.tipo_cliente AND
a.sec_cliente = p_vetb50.sec_cliente AND
a.status_t IS NULL
LET p_vetb50.direccion_cliente = vetb05.calle CLIPPED," ,",vetb05.casa_num CLIPPED,
vetb05.barrio CLIPPED," ,",vetb05.urbanizacion CLIPPED
LET p_vetb50.direccion_facturacion = p_vetb50.direccion_cliente
DISPLAY BY NAME p_vetb50.direccion_cliente,p_vetb50.direccion_facturacion
{ VOY A COLOCAR EL CONTROL ABRIENDOLE UNA VENTANA PARA QUE EL USUARIO COLOQUE CORRECTAMENTE LA DIRECCION EN
ESTOS CASOS
IF LENGTH(p_vetb50.direccion_cliente) < 10 THEN
CALL fgl_winmessage("INFO","LA DIRECCION DEL CLIENTE EN LA MAESTRA TIENE MENOS DE 10 CARACTERES","INFO")
NEXT FIELD tipo_cliente
END IF }
# BUSCA INFORMACION CONTACTO DE LAS ULTIMAS COTIZACIONES
IF p_vetb50.celular IS NULL THEN
SELECT MAX(a.celular) INTO p_vetb50.celular
FROM vetb00050 a
WHERE a.tipo_cliente = p_vetb50.tipo_cliente AND
a.sec_cliente = p_vetb50.sec_cliente AND
a.status_t IS NULL
DISPLAY BY NAME p_vetb50.celular
END IF
LET p_vetb50.nombre_proyecto = NULL
SELECT a.* INTO p_vetb49.*
FROM vetb00049 a
WHERE a.tipo_cliente = p_vetb50.tipo_cliente AND
a.sec_cliente = p_vetb50.sec_cliente AND
a.status_t IS NULL
IF p_vetb50.nombre_proyecto IS NULL THEN
LET p_vetb50.nombre_proyecto = p_vetb49.nombre_proyecto
END IF
IF p_vetb50.direccion_proyecto IS NULL THEN
LET p_vetb50.direccion_proyecto = p_vetb49.direccion_proyecto
END IF
DISPLAY BY NAME p_vetb50.*,nombre_ciudad
# BUSCA VENDEDOR
SELECT a.sec_vend INTO p_vetb50.sec_vend FROM vetb00028 a
WHERE a.tipo_cliente = p_vetb50.tipo_cliente AND
a.sec_cliente = p_vetb50.sec_cliente
CALL control_vendedor(p_vetb50.sec_vend,p_vetb50.tipo_cliente,p_vetb50.sec_cliente) RETURNING pasa
IF pasa = TRUE THEN
NEXT FIELD sec_vend
END IF
SELECT a.nom1_emp,a.apell1_emp,a.telefono
INTO nombres,apellidos,telefono
FROM adtb00003 a
WHERE a.num_emp = p_vetb50.sec_vend
LET nombre_vend = nombres CLIPPED, " ",apellidos CLIPPED," ",pcelular1 CLIPPED,
" / ",pcelular2 CLIPPED
DISPLAY BY NAME p_vetb50.sec_vend,nombre_vend
END IF
IF p_vetb50.sec_cliente IS NOT NULL THEN
# BUSCA BALANCE CON AVANCES
SELECT SUM(a.valor+a.monto_desc) INTO valor1
FROM cctb00001 a
WHERE a.fecha_orig <= today AND
a.tipo_cliente = p_vetb50.tipo_cliente AND
a.sec_cliente = p_Vetb50.sec_cliente AND
a.tipo_doc IN ("AV") AND a.num_doc = a.aplica_a AND a.status_t IS NULL
IF valor1 IS NULL THEN
LET valor1 = 0
END IF
# BUSCA BALANCE SIN AVANCES
SELECT SUM(a.valor+a.monto_desc) INTO valor2
FROM cctb00001 a
WHERE a.fecha_orig <= today AND
a.tipo_cliente = p_Vetb50.tipo_cliente AND
a.sec_cliente = p_vetb50.sec_cliente AND
a.tipo_doc NOT IN ("AV","PC") AND a.status_t IS NULL
IF valor1 IS NULL THEN
LET valor1 = 0
END IF
LET balancecxc = valor2-valor1
DISPLAY BY NAME balancecxc
# CONTROL AVANCE
SELECT UNIQUE a.tipo_cliente,a.sec_cliente INTO ttipo_cliente,tsec_cliente
FROM cctb00001 a
WHERE a.num_cheque = p_vetb50.cotizacion_no AND
a.tipo_doc = 'AV' AND a.status_t IS NULL
IF STATUS <> NOTFOUND THEN
LET chcliente = ttipo_cliente USING "&&",tsec_cliente USING "&&&&&&"
LET chcliente1 = p_vetb50.tipo_cliente USING "&&",p_vetb50.sec_cliente USING "&&&&&&"
IF chcliente <> chcliente1 THEN
CALL fgl_winmessage("ERROR","CLIENTE TIENE AVANCE, NO PUEDES CAMBIARLO","INFO")
NEXT FIELD tipo_cliente
END IF
END IF
NEXT FIELD nombre_proyecto
END IF
BEFORE FIELD nombre_cliente
IF p_vetb50.sec_cliente IS NOT NULL THEN
NEXT FIELD nombre_proyecto
END IF
AFTER FIELD cod_provincia
SELECT a.nombre_provincia INTO nombre_ciudad
FROM vetb00020 a
WHERE a.cod_provincia = p_vetb50.cod_provincia
IF STATUS = NOTFOUND THEN
LET numero_msg= 3
CALL msg(numero_msg)
NEXT FIELD cod_provincia
END IF
DISPLAY BY NAME nombre_ciudad
AFTER FIELD sec_vend
SELECT a.nom1_emp,a.apell1_emp,a.telefono
INTO nombres,apellidos,telefono
FROM adtb00003 a
WHERE a.num_emp = p_vetb50.sec_vend
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD sec_vend
END IF
LET nombre_vend = nombres CLIPPED, " ",apellidos CLIPPED," ",pcelular1 CLIPPED,
" / ",pcelular2 CLIPPED
DISPLAY BY NAME nombre_vend
# CONTROL VENDEDOR
CALL control_vendedor(p_vetb50.sec_vend,p_vetb50.tipo_cliente,p_vetb50.sec_cliente) RETURNING pasa
IF pasa = TRUE THEN
NEXT FIELD sec_vend
END IF
AFTER INPUT
LET d_tipos="Images"
LET f_tipos="*.jpg *.png *.gif"
LET mensaje=%"Elige Imagen"
IF p_vetb50.tipo_cliente IS NOT NULL THEN
SELECT a.tipo_cliente FROM vetb00060 a
WHERE a.tipo_cliente = p_vetb50.tipo_cliente AND
a.ventas = p_vetb50.ventas
IF STATUS = NOTFOUND THEN
LET numero_msg =386
CALL msg(numero_msg)
NEXT FIELD tipo_cliente
END IF
END IF
IF p_vetb50.cond_pago < 1 OR p_vetb50.cond_pago IS NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD cond_pago
END IF
IF p_vetb50.ventas IS NULL THEN
CALL msg(16)
NEXT FIELD ventas
END IF
IF p_vetb50.sec_vend = 0 OR p_vetb50.sec_Vend IS NULL THEN
CALL msg(16)
NEXT FIELD sec_vend
END IF
IF p_vetb50.porc_itbi IS NULL THEN
LET p_vetb50.porc_itbi = 0
END IF
IF p_vetb50.porc_itbi = 0 THEN
CALL fgl_Winmessage("INFO","EL ITBIS ESTA EN CERO","INFO")
END IF
END INPUT
INPUT ARRAY arr_cotiza FROM s_pedido.* ATTRIBUTE(WITHOUT DEFAULTS)
BEFORE FIELD porc_Desc
IF arr_cotiza[curr].id_kit IS NOT NULL THEN
NEXT FIELD ruta
END IF
IF arr_cotiza[curr].porc_desc > pdescuento2 THEN
SELECT DISTINCT a.cotizacion_no FROM vetb00088 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_Sec = arr_cotiza[curr].cod_sec AND
a.area = arr_cotiza[curr].area AND
a.autoriza = "SI"
IF STATUS <> NOTFOUND THEN
NEXT FIELD ruta
END IF
END IF
# IF arr_cotiza[curr].cod_sec IS NOT NULL THEN
# CALL control_descuento() RETURNING arr_cotiza[curr].porc_desc
# END IF
BEFORE FIELD fecha_inicial_reserva
IF arr_cotiza[arr_curr()].cantidad_reservada IS NOT NULL THEN
LET arr_cotiza[arr_curr()].fecha_inicial_reserva = TODAY USING "dd/mm/yyyy"
DISPLAY arr_cotiza[arr_curr()].fecha_inicial_reserva TO s_pedido[scr_line()].fecha_inicial_reserva
END IF
AFTER FIELD fecha_inicial_reserva
IF arr_cotiza[arr_curr()].cantidad_reservada IS NOT NULL THEN
LET arr_cotiza[arr_curr()].fecha_vence_reserva=arr_cotiza[arr_curr()].fecha_vence_reserva + dia
DISPLAY arr_cotiza[arr_curr()].fecha_vence_reserva TO s_pedido[scr_line()].fecha_vence_reserva
END IF
BEFORE INPUT
LET d_tipos="Images"
LET f_tipos="*.jpg *.png *.gif"
LET mensaje=%"Elige Imagen"
LET chdescuento = 'NO'
LET idx_soporte = 1
SELECT a.controldescuento INTO chdescuento
FROM seg0003 a
WHERE a.usuario = usuarios
IF chdescuento IS NULL THEN
LET chdescuento = 'NO'
END IF
IF actualiza <> "N" THEN
DECLARE buscaitm CURSOR FOR
SELECT a.secuencia,a.area,a.descripcion_area,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,a.descripcion,b.unidad_med,
a.cantidad_1,a.cantidad,a.precio,a.porc_desc,'0',a.foto_producto,'SI',a.id_kit
FROM vetb00051 a,iptb00002 b
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
a.cod_cia = p_vetb50.cod_cia 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
ORDER BY a.secuencia
LET idx = 1
LOCATE arr_cotiza[idx].ruta IN MEMORY
FOREACH buscaitm INTO arr_cotiza[idx].*
LET idx = idx + 1
LOCATE arr_cotiza[idx].ruta IN MEMORY
END FOREACH
CALL arr_cotiza.deleteElement(idx)
CALL set_count(idx-1)
END IF
ON ACTION busca_descrip
LET curr = arr_curr()
CALL busca_descripcion() RETURNING arr_cotiza[curr].nombre_p
DISPLAY arr_cotiza[curr].nombre_p TO s_pedido[scr_l].nombre_p
ON ACTION busca_producto
CALL busca_prod1()
DISPLAY arr_cotiza[curr].cod_n TO s_pedido[scr_l].cod_n
DISPLAY arr_cotiza[curr].cod_grupo TO s_pedido[scr_l].cod_grupo
DISPLAY arr_cotiza[curr].cod_tipo TO s_pedido[scr_l].cod_tipo
DISPLAY arr_cotiza[curr].cod_sec TO s_pedido[scr_l].cod_sec
DISPLAY arr_cotiza[curr].nombre_p TO s_pedido[scr_l].nombre_p
DISPLAY arr_cotiza[curr].unidad TO s_pedido[scr_l].unidad
LET int_flag = FALSE
NEXT FIELD cod_n
ON ACTION busca_area
CALL busca_area()
DISPLAY arr_cotiza[curr].area TO s_pedido[scr_l].area
DISPLAY arr_cotiza[curr].nombre_area TO s_pedido[scr_l].nombre_area
BEFORE ROW
LET curr = arr_curr()
LET scr_l = scr_line()
# busca la autorizacion del descuento
LET chdescuento = 'NO'
SELECT a.controldescuento INTO chdescuento
FROM seg0003 a
WHERE a.usuario = usuarios
IF chdescuento IS NULL THEN
LET chdescuento = 'NO'
END IF
LET cantidad_ant = arr_cotiza[curr].cantidad
AFTER FIELD cod_n
IF arr_cotiza[arr_curr()].cod_n IS NOT NULL THEN
CALL cuenta_soporte(arr_cotiza[arr_curr()].cod_n) RETURNING numero_soporte
IF numero_soporte > 1 THEN
CALL busca_soporte(arr_cotiza[arr_curr()].cod_n) RETURNING xsoporte_ventas
LET soporte_ventas[arr_curr()].num_emp=xsoporte_ventas[arr_curr()].num_emp
LET soporte_Ventas[arr_curr()].nombre_adicional = xsoporte_Ventas[arr_curr()].nombre_adicional
ELSE
SELECT DISTINCT a.sec_vend,b.nom1_emp||' '||b.apell1_Emp
INTO soporte_ventas[arr_curr()].num_emp,soporte_ventas[arr_curr()].nombre_adicional
FROM vetb00076 a,adtb00003 b
WHERE a.cod_n = arr_cotiza[arr_curr()].cod_n AND a.tipo_usuario = "S" AND
a.sec_vend = b.num_emp
END IF
LET idx_soporte = idx_soporte + 1
END IF
AFTER FIELD area
IF arr_cotiza[curr].area IS NOT NULL THEN
LET nombre_area = NULL
SELECT a.nombre_area INTO nombre_area
FROM prtb00016 a
WHERE a.area_num = arr_cotiza[curr].area
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD area
END IF
LET arr_cotiza[curr].nombre_area = nombre_area
DISPLAY arr_cotiza[curr].nombre_area TO s_pedido[scr_l].nombre_area
END IF
AFTER FIELD cantidad_reservada
IF arr_cotiza[curr].cod_sec IS NOT NULL THEN
IF arr_cotiza[curr].cantidad_reservada > 0 THEN
IF arr_cotiza[curr].cantidad_reservada > arr_cotiza[curr].cantidad THEN
CALL fgl_winmessage("ERROR","NO PUEDES RESERVAR CANTIDAD MAYOR A COTIZADA","INFO")
NEXT FIELD cantidad_reservada
END IF
IF pfecha_desc > TODAY THEN
CALL fgl_winmessage("ERROR","NO PUEDES RESERVAR CANTIDAD EN PRODUCTOS CON OFERTAS","INFO")
LET arr_cotiza[curr].cantidad_reservada = 0
DISPLAY arr_cotiza[curr].cantidad_reservada TO s_pedido[scr_l].cantidad_reservada
NEXT FIELD cod_sec
END IF
LET arr_cotiza[curr].fecha_vence_reserva = TODAY + p_companias.dias_vence_reservas
DISPLAY arr_cotiza[curr].fecha_vence_reserva TO s_pedido[scr_l].fecha_vence_reserva
END IF
END IF
AFTER FIELD ruta
LET curr=arr_curr()
IF arr_cotiza[curr].cod_sec IS NOT NULL THEN
IF arr_cotiza[curr].ruta IS NULL OR LENGTH(arr_cotiza[curr].ruta) < 4 THEN
LOCATE arr_cotiza[curr].ruta IN MEMORY
CALL arr_cotiza[curr].ruta.readFile("fotodefault.jpg")
END IF
END IF
AFTER FIELD cod_sec
LET scr_l = scr_line()
LET curr = arr_curr()
LET pporc_desc = 0
LET pfecha_desc = null
IF arr_cotiza[curr].cod_sec IS NOT NULL THEN
LET controlE= NULL
IF actualiza = 'N' THEN # OPERACION PARA CUANDO ES ADICIONANDO COTIZACION
LOCATE arr_cotiza[curr].ruta IN MEMORY
SELECT a.descrip_esp,a.unidad_med,b.factor_conv,a.control_existencia,
a.porc_desc,CONVERT(VARCHAR(10),a.fecha_desc,103),a.imagen,a.descuento_permitido
INTO arr_cotiza[curr].nombre_p,arr_cotiza[curr].unidad,factor,controle,
pporc_desc,pfecha_desc,arr_cotiza[curr].ruta,desc_permitido
FROM iptb00002 a,iptb00001 b
WHERE a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec 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.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD area
END IF
DISPLAY arr_cotiza[curr].nombre_p TO s_pedido[scr_l].nombre_p
DISPLAY arr_cotiza[curr].unidad TO s_pedido[scr_l].unidad
DISPLAY arr_cotiza[curr].porc_desc TO s_pedido[scr_l].porc_desc
CALL arr_cotiza[curr].ruta.writeFile(filedestino)
DISPLAY filedestino TO foto_producto
LET pdescrip = arr_cotiza[curr].nombre_p
LET punidad = arr_cotiza[curr].unidad
#--------------------------------------- TERMINO ADICIONAR ------------------------------
ELSE # MODIFICACION
IF arr_cotiza[curr].nombre_p IS NULL THEN # OPERACION CUANDO ESTA MODIFICANDO COTIZACION
IF arr_cotiza[curr].ruta IS NULL OR LENGTH(arr_cotiza[curr].ruta) < 4 THEN
LOCATE arr_cotiza[curr].ruta IN MEMORY
CALL arr_cotiza[curr].ruta.readFile("fotodefault.jpg")
END IF
SELECT a.descrip_esp,a.unidad_med,b.factor_conv,a.control_existencia,a.imagen,a.descuento_permitido
INTO arr_cotiza[curr].nombre_p,arr_cotiza[curr].unidad,factor,controlE,
arr_cotiza[curr].ruta,desc_permitido
FROM iptb00002 a,iptb00001 b
WHERE a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec 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.status_t IS NULL
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD area
END IF
IF curr > 1 THEN
LET arr_cotiza[curr].fila = arr_cotiza[curr-1].fila + 1
ELSE
LET arr_cotiza[curr].fila = curr
END IF
DISPLAY arr_cotiza[curr].fila TO s_pedido[scr_l].fila
DISPLAY arr_cotiza[curr].nombre_p TO s_pedido[scr_l].nombre_p
DISPLAY arr_cotiza[curr].unidad TO s_pedido[scr_l].unidad
LET pdescrip = arr_cotiza[curr].nombre_p
LET punidad = arr_cotiza[curr].unidad
CALL arr_cotiza[curr].ruta.writeFile(filedestino)
DISPLAY filedestino TO foto_producto
END IF
IF arr_cotiza[curr].ruta IS NULL OR LENGTH(arr_cotiza[curr].ruta) < 4 THEN
LOCATE arr_cotiza[curr].ruta IN MEMORY
CALL arr_cotiza[curr].ruta.readFile("fotodefault.jpg")
DISPLAY filedestino TO foto_producto
END IF
END IF
LET verdad = "N"
# CONTROL KIT
SELECT UNIQUE a.cod_sec FROM vetb00029 a
WHERE a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec AND
a.disponible = 'SI' AND a.costeo_orden ="NO"
IF STATUS <> NOTFOUND THEN
CALL arr_kit.clear()
CALL visualiza_kit(arr_cotiza[curr].cod_n,arr_cotiza[curr].cod_grupo,
arr_cotiza[curr].cod_tipo,arr_cotiza[curr].cod_sec,arr_cotiza[curr].id_kit,"SI")
RETURNING pkit,arr_cotiza[curr].precio,arr_cotiza[curr].nombre_p
CALL visualiza_detalle_kit(pkit) RETURNING arr_kit
LET arr_cotiza[curr].id_kit=pkit
DELETE FROM tmp_kit WHERE cotizacion_no = tmpnumero1 AND id_kit = pkit
DECLARE dtmp_kit CURSOR FOR SELECT a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,a.cantidad,
a.precio,a.porc_desc
FROM vetb00030 a
WHERE a.id_kit = pkit
LET i = 1
FOREACH dtmp_kit INTO
arr_kit[i].cod_n,
arr_kit[i].cod_grupo,
arr_kit[i].cod_tipo,
arr_kit[i].cod_sec,
arr_kit[i].cantidad,
arr_kit[i].precio,
arr_kit[i].porc_desc
LET arr_kit[i].area = arr_cotiza[curr].area
LET arr_kit[i].cantidad = arr_cotiza[curr].cantidad
IF p_vetb50.ventas = 1 THEN
LET arr_kit[i].precio = arr_kit[i].precio * ptasa
END IF
INSERT INTO tmp_kit (id_kit,cotizacion_no,area,cod_n,cod_grupo,cod_tipo,
cod_sec,cantidad,precio,porc_desc)
VALUES
(pkit,tmpnumero1,arr_cotiza[curr].area,arr_kit[i].cod_n,
arr_kit[i].cod_grupo,
arr_kit[i].cod_tipo,
arr_kit[i].cod_sec,arr_kit[i].cantidad,arr_kit[i].precio,
arr_kit[i].porc_desc)
LET i = i + 1
END FOREACH
IF arr_cotiza[curr].precio IS NULL OR arr_cotiza[curr].precio = 0 THEN
CALL fgl_winmessage("ERROR","ESTE KIT NO TIENE PRECIOS","INFO")
NEXT FIELD cod_sec
ELSE
IF p_vetb50.ventas = 1 THEN
LET arr_cotiza[curr].precio = arr_cotiza[curr].precio * ptasa
END IF
NEXT FIELD cantidad_1
END IF
ELSE
CALL arr_cotiza[curr].ruta.writeFile(filedestino)
DISPLAY filedestino TO foto_producto
LET p_vetb50.prima = 1
CALL precios(p_vetb50.ventas,arr_cotiza[curr].cod_n,arr_cotiza[curr].cod_grupo,arr_cotiza[curr].cod_tipo,
arr_cotiza[curr].cod_Sec,p_vetb50.tipo_cliente,p_vetb50.sec_cliente)
RETURNING arr_cotiza[curr].precio,existe
IF existe = 'N' THEN
CALL fgl_winmessage("ERROR","PRODUCTO NO TIENE PRECIO, NO PUEDES VENDERLO. ESTA LINEA SE BORRARA DESPUES DE CLICKER SOBRE OK","INFO")
DISPLAY " " TO foto_producto
LET existe = 'S'
CALL arr_cotiza.deleteElement(curr)
NEXT FIELD cod_n
END IF
LET precio_ant = arr_cotiza[curr].precio
IF precio_ant IS NULL THEN
LET precio_ant = 0
END IF
END IF
DISPLAY arr_cotiza[curr].precio TO s_pedido[scr_l].precio
DISPLAY arr_cotiza[curr].nombre_p TO s_pedido[scr_l].nombre_p
# CONTROL DUPLICADO EN CAPTURA DE DATOS
CALL repite_codigo()
IF verdad="S" THEN
NEXT FIELD cod_sec
END IF
{ DELETE FROM repitecodigo WHERE documento = tmpnumero1 and
tipo_doc = 'CO'
FOR idx = 1 TO arr_count()
LET pcodigo = arr_cotiza[idx].area USING "&&&",
arr_cotiza[idx].cod_n USING "&&&&",
arr_cotiza[idx].cod_grupo USING "&&&&",
arr_cotiza[idx].cod_tipo USING "&&&&",
arr_cotiza[idx].cod_sec USING "&&&&"
IF pcodigo IS NOT NULL OR pcodigo <> ' ' THEN
WHENEVER ERROR CONTINUE
INSERT INTO repitecodigo (documento,tipo_doc,codigo,codid,us_crea,fech_crea)
VALUES (tmpnumero1,'CO',pcodigo,idx,usuarios,getdate())
IF sqlca.sqlcode THEN
DISPLAY "error ",sqlca.sqlcode
CALL fgl_winmessage("DUPLICADO","CODIGO DUPLICADO EN CAPTURA DE DATOS","STOP")
CALL arr_cotiza.deleteElement(curr)
DELETE FROM repitecodigo WHERE documento = tmpnumero1 and
tipo_doc = 'CO'
NEXT FIELD area
END IF
END IF
END FOR
}
# BUSCA MENSAJE DE LA CLASE DEL PRODUCTO
SELECT a.comentario INTO pcomentario
FROM iptb00020 a
WHERE a.cod_n = arr_cotiza[curr].cod_n
IF pcomentario IS NOT NULL THEN
LET primera = 'N'
END IF
# CONTROL DESPIECE
SELECT a.cod_n FROM iptb00027 a
WHERE a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec
IF STATUS <> NOTFOUND THEN
CALL despiece()
DISPLAY arr_cotiza[curr].cantidad_1 TO s_pedido[scr_l].cantidad_1
END IF
END IF
AFTER FIELD precio
IF arr_cotiza[curr].cod_Sec IS NOT NULL THEN
IF arr_cotiza[curr].precio < precio_ant THEN
CALL fgl_winmessage("ERROR","PRECIO ES MENOR AL PRECIO DE LISTA","INFO")
LET arr_cotiza[curr].precio=precio_ant
DISPLAY arr_cotiza[curr].precio TO s_pedido[scr_l].precio
NEXT FIELD precio
END IF
END IF
{ AFTER ROW
# CONTROL DESPIECE
IF arr_cotiza[curr].cod_sec IS NOT NULL AND
arr_cotiza[curr].cod_n IS NOT NULL AND
arr_cotiza[curr].cod_grupo IS NOT NULL AND
arr_cotiza[curr].cod_tipo IS NOT NULL THEN
SELECT a.cod_n FROM iptb00027 a
WHERE a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec
IF STATUS <> NOTFOUND THEN
IF actualiza = 'N' THEN
LET p_vetb50.cotizacion_no = tmpnumero1
END IF
SELECT a.cod_n FROM vetb00022 a
WHERE a.area = arr_cotiza[curr].area AND
a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_Sec = arr_cotiza[curr].cod_sec AND
a.cotizacion_no = p_vetb50.cotizacion_no
IF STATUS = NOTFOUND THEN
CALL despiece()
DISPLAY arr_cotiza[curr].cantidad_1 TO s_pedido[scr_l].cantidad_1
END IF
END IF
END IF}
ON ACTION dibujo
LET curr = arr_curr()
CALL ui.Interface.frontCall("standard","openfile", [dir_file,d_tipos,f_tipos,mensaje], [filepath] )
IF filepath IS NOT NULL THEN
# LET arr_cotiza[curr].ruta= filepath CLIPPED
# DISPLAY arr_cotiza[curr].ruta TO foto_producto
# LET filedestino = FGL_GETENV("IMAGENNOMINA")
# LET filedestino = filedestino CLIPPED,"\\PRODUCTOS\\",p_vetb50.cotizacion_no USING "&&&&&&","-",
# arr_cotiza[curr].cod_n USING "&&&&",
# arr_cotiza[curr].cod_grupo USING "&&&&",'-',
# arr_cotiza[curr].cod_tipo USING "&&&&",'-',
# arr_cotiza[curr].cod_sec USING "&&&&",
# ".jpg"
# CALL fgl_winmessage("2",filedestino,"info")
# CALL fgl_winmessage("3",ruta[idx],"info")
CALL fgl_getfile(filepath,filedestino)
CALL arr_cotiza[curr].ruta.readFile(filedestino)
DISPLAY filedestino TO foto_producto
END IF
BEFORE FIELD precio
IF arr_cotiza[curr].cod_sec IS NOT NULL THEN
# CONTROL KIT
SELECT UNIQUE a.cod_sec FROM vetb00029 a
WHERE a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec AND
a.disponible = 'SI'
IF STATUS <> NOTFOUND THEN
NEXT FIELD ruta
END IF
END IF
AFTER FIELD porc_desc
LET curr = arr_curr()
IF arr_cotiza[curr].cod_sec IS NOT NULL THEN
IF control_descuento <> "SI" THEN
SELECT a.porciento
INTO pporciento FROM vetb00019 a WHERE a.disponible = 'S'
SELECT a.porc_desc,CONVERT(VARCHAR(10),a.fecha_desc,103),a.descuento_permitido
INTO pporc_desc,pfecha_desc,desc_permitido
FROM iptb00002 a,iptb00001 b
WHERE a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec 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.status_t IS NULL
IF TODAY < pfecha_desc THEN
IF arr_cotiza[curr].porc_desc > pporc_desc THEN
CALL fgl_winmessage("ERROR","PORCIENTO DESCUENTO MAYOR AL PERMITIDO PARA EL PRODUCTO","INFO")
LET arr_cotiza[curr].porc_desc = 0
NEXT FIELD porc_desc
END IF
ELSE
IF control_descuento = "NO" THEN
IF arr_cotiza[curr].porc_desc > pdescuento2 THEN
CALL fgl_winmessage("ERROR","PORCIENTO DESCUENTO MAYOR AL PERMITIDO","INFO")
LET arr_cotiza[curr].porc_desc = 0
NEXT FIELD porc_desc
END IF
END IF
END IF
END IF
IF arr_cotiza[curr].porc_desc IS NULL THEN
LET arr_cotiza[curr].porc_desc =0
END IF
IF desc_permitido = "NO" THEN
LET arr_cotiza[curr].porc_desc=0
END IF
LET arr_cotiza[curr].total_p = arr_cotiza[curr].precio * arr_cotiza[curr].cantidad
LET arr_cotiza[curr].total_p = arr_cotiza[curr].total_p -
(arr_cotiza[curr].total_p * (arr_cotiza[curr].porc_desc / 100))
DISPLAY arr_cotiza[curr].total_p TO s_pedido[scr_l].total_p
DISPLAY arr_cotiza[curr].porc_desc TO s_pedido[scr_l].porc_desc
END IF
AFTER FIELD cantidad_1
IF actualiza = "S" THEN
SELECT UNIQUE a.cotizacion_no FROM prtb00012 a,prtb00013 b
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
a.num_oc = b.num_oc AND
# b.area = arr_cotiza[curr].area and
b.cod_n = arr_cotiza[curr].cod_n and
b.cod_grupo = arr_cotiza[curr].cod_grupo and
b.cod_tipo = arr_cotiza[curr].cod_tipo and
b.cod_sec = arr_cotiza[curr].cod_sec and
a.status_t is null
IF STATUS != NOTFOUND THEN
LET numero_msg =392
CALL msg(numero_msg)
LET arr_cotiza[curr].cantidad = cantidad_ant
DISPLAY arr_cotiza[curr].cantidad TO s_pedido[scr_l].cantidad
END IF
END IF
IF arr_cotiza[curr].cod_sec IS NOT NULL THEN
SELECT a.factor_conv iNTO factor FROM iptb00001 a
WHERE a.cod_n = arr_cotiza[curr].cod_n and
a.cod_grupo = arr_cotiza[curr].cod_grupo and
a.cod_tipo = arr_cotiza[curr].cod_tipo and
a.cod_sec = arr_cotiza[curr].cod_sec and
a.status_t IS NULL
LET arr_cotiza[curr].cantidad = arr_cotiza[curr].cantidad_1 * factor
DISPLAY arr_cotiza[curr].cantidad TO s_pedido[scr_l].cantidad
# BUSCA EXISTENCIA
IF controlE = "SI" THEN
LET pexistencia = 0
# SELECT SUM(a.cantidad_2) iNTO pexistencia FROM iptb00006 a
# WHERE a.cod_n = arr_cotiza[curr].cod_n AND
# a.cod_grupo = arr_cotiza[curr].cod_grupo AND
# a.cod_tipo = arr_cotiza[curr].cod_tipo AND
# a.cod_Sec = arr_cotiza[curr].cod_sec AND
# a.status_t IS NULL
CALL disponibles(arr_cotiza[curr].cod_n,arr_cotiza[curr].cod_grupo,arr_cotiza[curr].cod_tipo,
arr_cotiza[curr].cod_sec,today)
RETURNING cantidad_orden,pcantidadConduce,transito,existencia,reservado
LET pexistencia = existencia-(cantidad_orden +pcantidadconduce)
IF pexistencia < 0 THEN
call FGL_WINMESSAGE('ADVERTENCIA','DISPONIBLE EN NEGATIVO','STOP')
END IF
IF arr_cotiza[curr].cantidad > pexistencia THEN
call FGL_WINMESSAGE('ADVERTENCIA','CANTIDAD EXCEDE A CANTIDAD DISPONIBLE ','STOP')
END IF
END IF
SELECT UNIQUE a.cod_sec FROM vetb00029 a
WHERE a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec AND
a.disponible = 'SI'
IF STATUS <> NOTFOUND THEN
IF arr_cotiza[curr].porc_desc IS NULL THEN
LET arr_cotiza[curr].porc_desc =0
END IF
LET arr_cotiza[curr].total_p = arr_cotiza[curr].precio * arr_cotiza[curr].cantidad
LET arr_cotiza[curr].total_p = arr_cotiza[curr].total_p -
(arr_cotiza[curr].total_p * (arr_cotiza[curr].porc_desc / 100))
DISPLAY arr_cotiza[curr].total_p TO s_pedido[scr_l].total_p
NEXT FIELD ruta
END IF
END IF
AFTER INPUT
LET p_vetb50.total_bruto = 0
LET p_vetb50.monto_desc = 0
FOR idx = 1 TO arr_cotiza.getLength()
IF arr_cotiza[idx].cod_sec IS NOT NULL AND
arr_cotiza[idx].area IS NULL THEN
CALL fgl_winmessage("ERROR","AREA ESTA EN BLANCO","INFO")
NEXT FIELD area
END IF
IF arr_cotiza[idx].cod_sec IS NOT NULL THEN
# CONTROL DUPLICADO EN CAPTURA DE DATOS
CALL repite_codigo()
IF verdad="S" THEN
NEXT FIELD cod_sec
END IF
IF arr_cotiza[idx].porc_desc IS NULL THEN
LET arr_cotiza[idx].porc_desc = 0
END IF
IF arr_cotiza[idx].precio IS NULL OR
arr_cotiza[idx].precio = 0 THEN
CALL msg(16)
NEXT FIELD precio
END IF
# CONTROL KIT PARA LOS PRECIOS DE LOS PRODUCTOS QUE NO ESTAN EN LA TABLA DE LOS KIT
SELECT UNIQUE a.cod_sec FROM vetb00029 a
WHERE a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_sec = arr_cotiza[idx].cod_sec AND
a.disponible = 'SI'
IF STATUS = NOTFOUND THEN
# CONTROL PRECIO INDEPENDIENTE
SELECT DISTINCT a.cod_n FROM vetb00025 a
WHERE a.ventas = p_vetb50.ventas AND
a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_sec = arr_cotiza[idx].cod_sec AND
a.status_t IS NULL
IF STATUS = NOTFOUND THEN
CALL fgl_winmessage("ERROR","EXISTE UN PRODUCTO QUE NO TIENE PRECIOS PARA ESTA MONEDA, FAVOR CORREGIR","INFO")
NEXT FIELD cod_n
END IF
IF arr_cotiza[idx].precio < precio_ant THEN
CALL fgl_winmessage("ERROR","PRECIO ES MENOR AL PRECIO DE LISTA","INFO")
LET arr_cotiza[idx].precio=precio_ant
DISPLAY arr_cotiza[idx].precio TO s_pedido[scr_l].precio
NEXT FIELD precio
END IF
END IF
#CONTROL PERMITIR COLOCAR DESCUENTO
SELECT a.descuento_permitido INTO desc_permitido FROM iptb00002 a
WHERE a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_sec = arr_cotiza[idx].cod_sec
IF desc_permitido = "NO" THEN
LET arr_cotiza[idx].porc_desc=0
END IF
# CONTROL DESPIECE
SELECT a.cod_n FROM iptb00027 a
WHERE a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_sec = arr_cotiza[idx].cod_sec
IF STATUS <> NOTFOUND THEN
SELECT DISTINCT a.cod_n FROM vetb00022 a
WHERE a.area = arr_cotiza[idx].area AND
a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_Sec = arr_cotiza[idx].cod_sec AND
a.cotizacion_no = p_vetb50.cotizacion_no
IF STATUS = NOTFOUND THEN
CALL fgl_winmessage("ERROR","EXISTE UN CODIGO QUE NECESITA DESPIEZAR, FAVOR DE DIRIGIRSE AL CODIGO Y REALIZAR EL DESPIECE","INFO")
NEXT FIELD area
END IF
END IF
LET p_vetb50.total_bruto = p_vetb50.total_bruto + (arr_cotiza[idx].precio * arr_cotiza[idx].cantidad)
LET p_vetb50.monto_desc = (arr_cotiza[idx].precio * arr_cotiza[idx].cantidad) *
(arr_cotiza[idx].porc_desc / 100) + p_vetb50.monto_desc
END IF
END FOR
IF p_vetb50.porc_itbi IS NULL THEN
LET p_vetb50.porc_itbi = 0
END IF
IF p_vetb50.porc_itbi = 0 THEN
CALL fgl_Winmessage("INFO","EL ITBIS ESTA EN CERO","INFO")
END IF
LET p_vetb50.sub_total = p_vetb50.total_bruto - p_vetb50.monto_desc
LET p_vetb50.monto_itbi = p_vetb50.sub_total * (p_vetb50.porc_itbi / 100)
LET p_vetb50.total_neto = p_vetb50.sub_total + p_vetb50.monto_itbi
DISPLAY BY NAME p_vetb50.*
CALL busca_duplicado(soporte_Ventas,usuarios) RETURNING soporte_Ventas
END INPUT
INPUT ARRAY soporte_Ventas FROM soporte.* ATTRIBUTE(WITHOUT DEFAULTS)
AFTER FIELD num_emp
LET idx = arr_curr()
IF soporte_ventas[idx].num_emp IS NOT NULL THEN
SELECT a.nom1_emp||' '||a.apell1_emp INTO soporte_ventas[idx].nombre_adicional FROM adtb00003 a
WHERE a.num_emp = soporte_ventas[idx].num_emp
IF STATUS = NOTFOUND THEN
CALL fgl_Winmessage("ERROR","REGISTRO NO EXISTE","INFO")
NEXT FIELD num_emp
END IF
END IF
AFTER INPUT
CALL busca_duplicado(soporte_Ventas,usuarios) RETURNING soporte_Ventas
END INPUT
ON ACTION cancel
LET tipo2 = FGL_WINQUESTION("Pregunta","Esta seguro que desea salir del programa?","no","yes|no","question",0)
LET tipo2 = UPSHIFT(tipo2)
DELETE FROM repitecodigo WHERE documento = tmpnumero1 and
tipo_doc = 'CO'
DELETE FROM tmp_kit WHERE cotizacion_no = tmpnumero1
LET int_flag = FALSE
IF tipo2 = "YES" THEN
LET numero_msg = 2
CALL msg(numero_msg)
EXIT DIALOG
ELSE
CONTINUE DIALOG
END IF
ON ACTION actualiza
LET chdescuento = 'NO'
SELECT a.controldescuento INTO chdescuento
FROM seg0003 a
WHERE a.usuario = usuarios
LET p_vetb50.total_bruto = 0
LET p_vetb50.monto_desc = 0
FOR idx = 1 TO arr_cotiza.getLength()
IF arr_cotiza[idx].cod_sec IS NOT NULL THEN
IF arr_cotiza[idx].porc_desc IS NULL THEN
LET arr_cotiza[idx].porc_desc = 0
END IF
IF arr_cotiza[idx].precio IS NULL OR
arr_cotiza[idx].precio = 0 THEN
CALL msg(16)
NEXT FIELD cod_n
END IF
IF arr_cotiza[idx].cod_sec IS NOT NULL THEN
# CONTROL PRECIO
IF arr_cotiza[idx].id_kit IS NULL THEN
SELECT a.precio INTO pprecio FROM vetb00025 a
WHERE a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_Grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_Sec = arr_cotiza[idx].cod_sec AND
a.ventas = p_vetb50.ventas
IF STATUS = NOTFOUND THEN
CALL fgl_winmessage("INFO","PRODUCTO NO TIENE PRECIO","INFO")
CALL arr_cotiza.deleteElement(idx)
NEXT FIELD area
ELSE
IF arr_cotiza[idx].precio < pprecio THEN
CALL fgl_winmessage("INFO","PRECIO MENOR AL PRECIO DE LISTA","INFO")
CALL arr_cotiza.deleteElement(idx)
NEXT FIELD area
END IF
END IF
# CONTROL DESCUENTO
SELECT DISTINCT a.cotizacion_no FROM vetb00088 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_Sec = arr_cotiza[idx].cod_sec AND
a.area = arr_cotiza[idx].area AND
a.autoriza = "SI"
IF STATUS <> NOTFOUND THEN
GOTO salta_descuento
END IF
IF control_descuento <> "SI" THEN
SELECT a.porciento
INTO pporciento FROM vetb00019 a WHERE a.disponible = 'S'
SELECT a.porc_desc,CONVERT(VARCHAR(10),a.fecha_desc,103),a.descuento_permitido
INTO pporc_desc,pfecha_desc,desc_permitido
FROM iptb00002 a,iptb00001 b
WHERE a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_sec = arr_cotiza[idx].cod_sec 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.status_t IS NULL
IF TODAY < pfecha_desc THEN
IF arr_cotiza[idx].porc_desc > pporc_desc THEN
CALL fgl_winmessage("ERROR","PORCIENTO DESCUENTO MAYOR AL PERMITIDO PARA EL PRODUCTO","INFO")
LET arr_cotiza[idx].porc_desc = 0
NEXT FIELD porc_desc
END IF
ELSE
IF control_descuento = "NO" THEN
IF arr_cotiza[idx].porc_desc > pdescuento2 THEN
SELECT DISTINCT a.porc_descuento INTO descuento_aplicado FROM vetb00088 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_Sec = arr_cotiza[idx].cod_sec AND
a.area = arr_cotiza[idx].area AND
a.autoriza = "SI"
IF arr_cotiza[idx].porc_desc <> descuento_aplicado THEN
CALL fgl_winmessage("INFO","DESCUENTO DIFERENTE AL AUTORIZADO, FAVOR DE VERIFICAR","INFO")
NEXT FIELD precio
END IF
END IF
END IF
END IF
END IF
IF arr_cotiza[idx].porc_desc IS NULL THEN
LET arr_cotiza[idx].porc_desc =0
END IF
END IF
END IF
#----------------------------------- TERMINA CONTROL DESCUENTO------------
LABEL salta_Descuento:
# Comentario de la clase
IF primera = 'N' THEN
LET tipo2 = NULL
IF pcomentario IS NOT NULL THEN
LET tipo2 = FGL_WINQUESTION("Pregunta",pcomentario,"no","yes|no","question",0)
IF tipo2 = "YES" THEN
CONTINUE DIALOG
END IF
END IF
END IF
# CONTROL KIT PARA LOS PRECIOS DE LOS PRODUCTOS QUE NO ESTAN EN LA TABLA DE LOS KIT
SELECT UNIQUE a.cod_sec FROM vetb00029 a
WHERE a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_sec = arr_cotiza[idx].cod_sec AND
a.disponible = 'SI'
IF STATUS = NOTFOUND THEN
# CONTROL PRECIO INDEPENDIENTE
SELECT DISTINCT a.cod_n FROM vetb00025 a
WHERE a.ventas = p_vetb50.ventas AND
a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_sec = arr_cotiza[idx].cod_sec AND
a.status_t IS NULL
IF STATUS = NOTFOUND THEN
CALL fgl_winmessage("ERROR","EXISTE UN PRODUCTO QUE NO TIENE PRECIOS PARA ESTA MONEDA, FAVOR CORREGIR","INFO")
NEXT FIELD cod_n
END IF
END IF
# CONTROL DESPIECE
SELECT a.cod_n FROM iptb00027 a
WHERE a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_sec = arr_cotiza[idx].cod_sec
IF STATUS <> NOTFOUND THEN
SELECT UNIQUE a.cod_n FROM vetb00022 a
WHERE a.area = arr_cotiza[idx].area AND
a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_Sec = arr_cotiza[idx].cod_sec AND
a.cotizacion_no = p_vetb50.cotizacion_no
IF STATUS = NOTFOUND THEN
CALL fgl_winmessage("ERROR","EXISTE UN CODIGO QUE NECESITA DESPIEZAR, FAVOR DE DIRIGIRSE AL CODIGO Y REALIZAR EL DESPIECE","INFO")
NEXT FIELD area
END IF
END IF
LET p_vetb50.total_bruto = p_vetb50.total_bruto + (arr_cotiza[idx].precio * arr_cotiza[idx].cantidad)
LET p_vetb50.monto_desc = (arr_cotiza[idx].precio * arr_cotiza[idx].cantidad) *
(arr_cotiza[idx].porc_desc / 100) + p_vetb50.monto_desc
# CONTROL KIT
SELECT UNIQUE a.cod_sec FROM vetb00029 a
WHERE a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_sec = arr_cotiza[idx].cod_sec AND
a.disponible = 'SI'
IF STATUS <> NOTFOUND THEN
IF arr_cotiza[idx].id_kit IS NULL THEN
CALL arr_kit.clear()
CALL visualiza_kit(arr_cotiza[idx].cod_n,arr_cotiza[idx].cod_grupo,
arr_cotiza[idx].cod_tipo,arr_cotiza[idx].cod_sec,arr_cotiza[idx].id_kit,"SI")
RETURNING pkit,arr_cotiza[idx].precio,arr_cotiza[idx].nombre_p
CALL visualiza_detalle_kit(pkit) RETURNING arr_kit
LET arr_cotiza[curr].id_kit=pkit
DELETE FROM tmp_kit WHERE cotizacion_no = tmpnumero1 AND id_kit = pkit
DECLARE dtmp_kit1 CURSOR FOR SELECT a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,a.cantidad,
a.precio,a.porc_desc
FROM vetb00030 a
WHERE a.id_kit = pkit
LET i = 1
FOREACH dtmp_kit1 INTO
arr_kit[i].cod_n,
arr_kit[i].cod_grupo,
arr_kit[i].cod_tipo,
arr_kit[i].cod_sec,
arr_kit[i].cantidad,
arr_kit[i].precio,
arr_kit[i].porc_desc
LET arr_kit[i].cantidad = arr_cotiza[idx].cantidad * arr_kit[i].cantidad
IF p_vetb50.ventas = 1 THEN
LET arr_kit[i].precio = arr_kit[i].precio * ptasa
END IF
LET arr_kit[i].area=arr_cotiza[idx].area
INSERT INTO tmp_kit (id_kit,cotizacion_no,area,cod_n,cod_grupo,cod_tipo,
cod_sec,cantidad,precio,porc_desc)
VALUES
(pkit,tmpnumero1,arr_cotiza[idx].area,arr_kit[i].cod_n,
arr_kit[i].cod_grupo,
arr_kit[i].cod_tipo,
arr_kit[i].cod_sec,
arr_kit[i].cantidad,
arr_kit[i].precio,
arr_kit[i].porc_desc)
LET i = i + 1
END FOREACH
ELSE
DELETE FROM tmp_kit WHERE cotizacion_no = tmpnumero1 AND id_kit = arr_cotiza[idx].id_kit
DECLARE busca_kit CURSOR FOR
SELECT a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_Sec,a.cantidad,a.precio,a.porc_desc
FROM vetb00030 a
WHERE a.id_kit = arr_cotiza[idx].id_kit
LET i = 1
FOREACH busca_kit INTO arr_kit[i].cod_n,arr_kit[i].cod_grupo,
arr_kit[i].cod_tipo,arr_kit[i].cod_sec,
arr_kit[i].cantidad,arr_kit[i].precio,
arr_kit[i].porc_desc
LET arr_kit[i].cantidad = arr_kit[i].cantidad * arr_cotiza[idx].cantidad
IF p_vetb50.ventas = 1 THEN
LET arr_kit[i].precio = arr_kit[i].precio * ptasa
END IF
INSERT INTO tmp_kit (id_kit,cotizacion_no,area,cod_n,cod_grupo,cod_tipo,
cod_sec,cantidad,precio,porc_desc)
VALUES
(arr_cotiza[idx].id_kit,tmpnumero1,arr_cotiza[idx].area,
arr_kit[i].cod_n,
arr_kit[i].cod_grupo,
arr_kit[i].cod_tipo,
arr_kit[i].cod_sec,
arr_kit[i].cantidad,
arr_kit[i].precio,
arr_kit[i].porc_desc)
LET i = i + 1
END FOREACH
END IF
END IF
END IF
END FOR
IF p_vetb50.porc_itbi IS NULL THEN
LET p_vetb50.porc_itbi = 0
END IF
IF p_vetb50.prima IS NULL THEN
LET p_vetb50.prima = 1
END IF
LET p_vetb50.sub_total = p_vetb50.total_bruto - p_vetb50.monto_desc
LET p_vetb50.monto_itbi = p_vetb50.sub_total * (p_vetb50.porc_itbi / 100)
LET p_vetb50.total_neto = p_vetb50.sub_total + p_vetb50.monto_itbi
DISPLAY BY NAME p_vetb50.*
#======================================================================
# CONTROL NUMERO COTIZACION
#======================================================================
LET tipo2 = FGL_WINQUESTION("Pregunta","Guardo esta cotizacion?","no","yes|no","question",0)
LET tipo2= UPSHIFT(tipo2)
IF tipo2 = "YES" THEN
SET CONNECTION "MSSQL"
IF actualiza = "N" THEN
#SELECT MAX(a.cotizacion_no) INTO ultimo_numero
#FROM vetb00050 a
#WHERE a.cod_cia = p_vetb50.cod_cia
SELECT a.cotizacion_no INTO ultimo_numero FROM vetb00053 a
IF ultimo_numero IS NULL THEN
LET ultimo_numero = 1
END IF
LET p_vetb50.cotizacion_no = ultimo_numero + 1
DISPLAY BY NAME p_vetb50.cotizacion_no
UPDATE vetb00053 SET cotizacion_no = p_vetb50.cotizacion_no,
us_mod = SUSER_SNAME()
END IF
LET cuenta_item = arr_count()
UPDATE vetb00022 set cotizacion_no = p_vetb50.cotizacion_no
WHERE cotizacion_no = tmpnumero1
UPDATE tmp_kit SET cotizacion_no = p_vetb50.cotizacion_no
WHERE cotizacion_no = tmpnumero1
# AQUI WHENEVER ERROR CONTINUE
IF actualiza = "S" THEN
BEGIN WORK
UPDATE vetb00050 SET
(cod_cia,ventas,cotizacion_no,tipo_cliente,sec_cliente,
nombre_cliente,rnc,nombre_proyecto,direccion_cliente,
cod_provincia,direccion_proyecto,telefono_r,telefono_o,
email,tipo_precio,beeper,celular,prima,fax1,celular1,
fax,fecha,fecha_entrega,plazo_entrega,comentario,contacto,
cond_pago,sec_vend,porc_itbi,total_bruto,sub_total,
monto_desc,monto_itbi,total_neto,monto_dolar,
us_mod,fech_mod,num_emp_inst) =
(p_vetb50.cod_cia,p_vetb50.ventas,p_vetb50.cotizacion_no,p_vetb50.tipo_cliente,p_vetb50.sec_cliente,
p_vetb50.nombre_cliente,p_vetb50.rnc,p_vetb50.nombre_proyecto,p_vetb50.direccion_cliente,
p_vetb50.cod_provincia,p_vetb50.direccion_proyecto,p_vetb50.telefono_r,p_vetb50.telefono_o,
p_vetb50.email,p_vetb50.tipo_precio,p_vetb50.beeper,p_vetb50.celular,p_vetb50.prima,p_vetb50.fax1,p_vetb50.celular1,
p_vetb50.fax,p_vetb50.fecha,p_vetb50.fecha_entrega,p_vetb50.plazo_entrega,p_vetb50.comentario,p_vetb50.contacto,
p_vetb50.cond_pago,p_vetb50.sec_vend,p_vetb50.porc_itbi,p_vetb50.total_bruto,p_vetb50.sub_total,
p_vetb50.monto_desc,p_vetb50.monto_itbi,p_vetb50.total_neto,p_vetb50.monto_dolar,usuarios,GETDATE(),
p_vetb50.num_emp_inst)
WHERE cotizacion_no = p_vetb50.cotizacion_no AND
cod_cia = p_vetb50.cod_cia
IF STATUS < 0 THEN
ROLLBACK WORK
EXIT PROGRAM
END IF
DELETE FROM vetb00051 WHERE vetb00051.cotizacion_no = p_vetb50.cotizacion_no
IF STATUS < 0 THEN
ROLLBACK WORK
EXIT PROGRAM
END IF
DELETE FROM vetb00031 WHERE vetb00031.cotizacion_no = p_vetb50.cotizacion_no
IF STATUS < 0 THEN
ROLLBACK WORK
EXIT PROGRAM
END IF
INSERT INTO vetb00031 SELECT * FROM tmp_kit WHERE cotizacion_no = p_vetb50.cotizacion_no AND cantidad IS NOT null
IF STATUS < 0 THEN
ROLLBACK WORK
EXIT PROGRAM
END IF
DELETE FROM tmp_kit WHERE cotizacion_no = p_vetb50.cotizacion_no
FOR idx = 1 TO arr_cotiza.getLength()
IF arr_cotiza[idx].cod_sec IS NOT NULL THEN
IF arr_cotiza[idx].porc_Desc IS NULL THEN
LET arr_cotiza[idx].porc_desc = 0
END IF
IF arr_cotiza[idx].area IS NOT NULL THEN
INSERT INTO vetb00051
(cod_cia,cotizacion_no,ventas,area,cod_n,cod_grupo,cod_tipo,cod_Sec,descripcion,cantidad_1,cantidad,precio,
porc_desc,status_t,us_crea,fech_crea,descripcion_area,id_kit,cantidad_reservada,fecha_inicio_reserva,fecha_vence_reserva,secuencia)
VALUES
(p_vetb50.cod_cia,p_vetb50.cotizacion_no,p_vetb50.ventas,
arr_cotiza[idx].area,arr_cotiza[idx].cod_n,
arr_cotiza[idx].cod_grupo,arr_cotiza[idx].cod_tipo,
arr_cotiza[idx].cod_sec, arr_cotiza[idx].nombre_p, arr_cotiza[idx].cantidad_1,arr_cotiza[idx].cantidad,
arr_cotiza[idx].precio,arr_cotiza[idx].porc_desc,null,
suser_sname(),GETDATE(),
arr_cotiza[idx].nombre_area,arr_cotiza[idx].id_kit,arr_cotiza[idx].cantidad_reservada,arr_cotiza[idx].fecha_inicial_reserva, arr_cotiza[idx].fecha_vence_reserva,arr_cotiza[idx].fila)
IF STATUS < 0 THEN
ROLLBACK WORK
EXIT PROGRAM
END IF
IF arr_cotiza[idx].ruta IS NULL OR LENGTH(arr_cotiza[idx].ruta) < 4 THEN
LOCATE arr_cotiza[idx].ruta IN MEMORY
CALL arr_cotiza[idx].ruta.readFile("fotodefault.jpg")
END IF
UPDATE vetb00051 SET foto_producto = arr_cotiza[idx].ruta
WHERE cotizacion_no = p_vetb50.cotizacion_no AND cod_n = arr_cotiza[idx].cod_n AND
cod_grupo = arr_cotiza[idx].cod_grupo AND
cod_tipo = arr_cotiza[idx].cod_tipo AND
cod_sec = arr_cotiza[idx].cod_sec
FREE arr_cotiza[idx].ruta
END IF
END IF
END FOR
#Actualiza SOPORTE A VENTAS
DELETE FROM vetb00093 WHERE cotizacion_no = p_vetb50.cotizacion_no
FOR idx = 1 TO soporte_ventas.getLength()
IF soporte_ventas[idx].num_emp IS NOT NULL THEN
SELECT a.sec_vend FROM vetb00093 a WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
a.sec_vend = soporte_ventas[idx].num_emp
IF STATUS = NOTFOUND THEN
INSERT INTO vetb00093 (cotizacion_no,sec_vend,nombre_vendedor)
VALUES (p_vetb50.cotizacion_no,soporte_ventas[idx].num_emp,soporte_ventas[idx].nombre_adicional)
IF STATUS < 0 THEN
ROLLBACK WORK
EXIT PROGRAM
END IF
END IF
END IF
END FOR
COMMIT WORK
ELSE
BEGIN WORK
INSERT INTO vetb00031 SELECT * FROM tmp_kit WHERE cotizacion_no = p_vetb50.cotizacion_no
DELETE FROM tmp_kit WHERE cotizacion_no = p_vetb50.cotizacion_no
INSERT INTO vetb00050 (cod_cia,ventas,cotizacion_no,tipo_cliente,sec_cliente,
nombre_cliente,rnc,nombre_proyecto,direccion_cliente,
cod_provincia,direccion_proyecto,telefono_r,telefono_o,
email,tipo_precio,beeper,celular,prima,fax1,celular1,
fax,fecha,fecha_entrega,plazo_entrega,comentario,contacto,
cond_pago,sec_vend,porc_itbi,total_bruto,sub_total,
monto_desc,monto_itbi,total_neto,monto_dolar,status_t,
us_crea,fech_crea,direccion_facturacion,num_emp_inst)
VALUES (p_vetb50.cod_cia,p_vetb50.ventas,p_vetb50.cotizacion_no,p_vetb50.tipo_cliente,p_vetb50.sec_cliente,
p_vetb50.nombre_cliente,p_vetb50.rnc,p_vetb50.nombre_proyecto,p_vetb50.direccion_cliente,
p_vetb50.cod_provincia,p_vetb50.direccion_proyecto,p_vetb50.telefono_r,p_vetb50.telefono_o,
p_vetb50.email,p_vetb50.tipo_precio,p_vetb50.beeper,p_vetb50.celular,p_vetb50.prima,p_vetb50.fax1,p_vetb50.celular1,
p_vetb50.fax,p_vetb50.fecha,p_vetb50.fecha_entrega,p_vetb50.plazo_entrega,p_vetb50.comentario,p_vetb50.contacto,
p_vetb50.cond_pago,p_vetb50.sec_vend,p_vetb50.porc_itbi,p_vetb50.total_bruto,p_vetb50.sub_total,
p_vetb50.monto_desc,p_vetb50.monto_itbi,p_vetb50.total_neto,p_vetb50.monto_dolar,null,usuarios,GETDATE(),
p_vetb50.direccion_facturacion,p_vetb50.num_emp_inst)
IF STATUS < 0 THEN
ROLLBACK WORK
EXIT PROGRAM
END IF
FOR idx = 1 TO arr_cotiza.getLength()
IF arr_cotiza[idx].cod_sec IS NOT NULL THEN
IF arr_cotiza[idx].porc_Desc IS NULL THEN
LET arr_cotiza[idx].porc_desc = 0
END IF
IF arr_cotiza[idx].area IS NOT NULL THEN
INSERT INTO vetb00051
(cod_cia,cotizacion_no,ventas,area,cod_n,cod_grupo,cod_tipo,cod_Sec,descripcion,cantidad_1,cantidad,precio,
porc_desc,status_t,us_crea,fech_crea,descripcion_area,id_kit,cantidad_reservada,fecha_inicio_reserva,fecha_vence_reserva,secuencia)
VALUES
(p_vetb50.cod_cia,p_vetb50.cotizacion_no,p_vetb50.ventas,
arr_cotiza[idx].area,arr_cotiza[idx].cod_n,
arr_cotiza[idx].cod_grupo,arr_cotiza[idx].cod_tipo,
arr_cotiza[idx].cod_sec, arr_cotiza[idx].nombre_p, arr_cotiza[idx].cantidad_1,arr_cotiza[idx].cantidad,
arr_cotiza[idx].precio,arr_cotiza[idx].porc_desc,null,
suser_sname(),GETDATE(),arr_cotiza[idx].nombre_area,
arr_cotiza[idx].id_kit,arr_cotiza[idx].cantidad_reservada,arr_cotiza[idx].fecha_inicial_reserva,arr_cotiza[idx].fecha_vence_reserva,idx)
IF STATUS < 0 THEN
ROLLBACK WORK
EXIT PROGRAM
END IF
IF arr_cotiza[idx].ruta IS NULL OR LENGTH(arr_cotiza[idx].ruta) < 4 THEN
LOCATE arr_cotiza[idx].ruta IN MEMORY
CALL arr_cotiza[idx].ruta.readFile("fotodefault.jpg")
END IF
UPDATE vetb00051 SET foto_producto = arr_cotiza[idx].ruta
WHERE cotizacion_no = p_vetb50.cotizacion_no AND cod_n = arr_cotiza[idx].cod_n AND
cod_grupo = arr_cotiza[idx].cod_grupo AND
cod_tipo = arr_cotiza[idx].cod_tipo AND
cod_sec = arr_cotiza[idx].cod_sec
FREE arr_cotiza[idx].ruta
END IF
END IF
END FOR
#Actualiza SOPORTE A VENTAS
DELETE FROM vetb00093 WHERE cotizacion_no = p_vetb50.cotizacion_no
FOR idx = 1 TO soporte_ventas.getLength()
IF soporte_ventas[idx].num_emp IS NOT NULL THEN
SELECT a.sec_vend FROM vetb00093 a WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
a.sec_vend = soporte_ventas[idx].num_emp
IF STATUS = NOTFOUND THEN
INSERT INTO vetb00093 (cotizacion_no,sec_vend,nombre_vendedor)
VALUES (p_vetb50.cotizacion_no,soporte_ventas[idx].num_emp,soporte_ventas[idx].nombre_adicional)
IF STATUS < 0 THEN
ROLLBACK WORK
EXIT PROGRAM
END IF
END IF
END IF
END FOR
COMMIT WORK
END IF
DELETE FROM repitecodigo WHERE documento = tmpnumero1 and tipo_doc = 'CO'
IF p_vetb50.tipo_cliente IS NOT NULL THEN
LET chconvierte = fgl_winquestion("ORDEN","DESEA CONVERTIR ESTA COTIZACION EN ORDEN DE PEDIDOS?","NO","YES|NO","QUESTION",0)
IF chconvierte = "YES" THEN
INPUT BY NAME orden_cliente,ptipo_orden ATTRIBUTE(MAGENTA)
AFTER INPUT
IF orden_cliente IS NULL THEN
CALL msg(16)
NEXT FIELD orden_cliente
END IF
IF ptipo_orden <> 'GENERAL' THEN
SELECT a.printer_cheque INTO copia FROM seg0001 a WHERE a.usuario = usuarios
END IF
END INPUT
CALL convierteorden(p_vetb50.cotizacion_no,orden_cliente,usuarios,clave,impresor,copia,ptipo_orden) RETURNING prtb12.num_oc,exito
SET CONNECTION "MSSQL"
IF NOT exito THEN
CALL fgl_winmessage("ERROR","NO SE REALIZO LA ORDEN","STOP")
ELSE
LET respuesta_req = fgl_winquestion("REQUISICION","ADICIONO LA REQUISICION DE DESPACHO AHORA?","NO","YES|NO","QUESTION",0)
IF respuesta_req = "YES" THEN
SELECT a.num_oc INTO prtb12.num_oc FROM prtb00012 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no and a.status_t is NULL
CALL requisiciondespacho(prtb12.num_oc,p_vetb50.tipo_cliente,
p_vetb50.sec_cliente,p_vetb50.cond_pago,p_vetb50.total_neto,p_vetb50.fecha,
p_vetb50.sec_vend,usuarios) RETURNING xnum_req,xmonto
IF xnum_req = 0 AND xmonto= 0 THEN
CONTINUE DIALOG
END IF
CALL evaluaclientes(p_vetb50.tipo_cliente,p_vetb50.sec_cliente,
p_vetb50.cond_pago ,xnum_req,prtb12.num_oc,p_vetb50.sec_vend,
'CO',xmonto) RETURNING pestado
END IF
END IF
END IF
END IF
CALL impresion(p_vetb50.cotizacion_no,'veprmt049.4rp','PDF',cuenta_item,etiqueta_cotiza) RETURNING salida
LET cmd="del ",filedestino CLIPPED
#RUN cmd
#=================================================================================================
SELECT a.ncf INTO xncf FROM vetb00060 a
WHERE a.tipo_cliente = p_vetb50.tipo_cliente
IF xncf = "S" THEN
# INSERTA EN INFORMIX
SET CONNECTION "IFMX"
BEGIN WORK
DELETE FROM vetb00050 WHERE cotizacion_no = p_vetb50.cotizacion_no
INSERT INTO vetb00050 (cod_cia,ventas,cotizacion_no,tipo_cliente,sec_cliente,
nombre_cliente,rnc,nombre_proyecto,direccion_cliente,
cod_provincia,direccion_proyecto,telefono_r,telefono_o,
email,tipo_precio,beeper,celular,prima,fax1,celular1,
fax,fecha,fecha_entrega,plazo_entrega,comentario,contacto,
cond_pago,sec_vend,porc_itbi,total_bruto,sub_total,
monto_desc,monto_itbi,total_neto,monto_dolar,status_t,
us_crea,fech_crea,direccion_facturacion)
VALUES (p_vetb50.cod_cia,p_vetb50.ventas,p_vetb50.cotizacion_no,p_vetb50.tipo_cliente,p_vetb50.sec_cliente,
p_vetb50.nombre_cliente,p_vetb50.rnc,p_vetb50.nombre_proyecto,p_vetb50.direccion_cliente,
p_vetb50.cod_provincia,p_vetb50.direccion_proyecto,p_vetb50.telefono_r,p_vetb50.telefono_o,
p_vetb50.email,p_vetb50.tipo_precio,p_vetb50.beeper,p_vetb50.celular,p_vetb50.prima,p_vetb50.fax1,p_vetb50.celular1,
p_vetb50.fax,p_vetb50.fecha,p_vetb50.fecha_entrega,p_vetb50.plazo_entrega,p_vetb50.comentario,p_vetb50.contacto,
p_vetb50.cond_pago,p_vetb50.sec_vend,p_vetb50.porc_itbi,p_vetb50.total_bruto,p_vetb50.sub_total,
p_vetb50.monto_desc,p_vetb50.monto_itbi,p_vetb50.total_neto,p_vetb50.monto_dolar,null,usuarios,getdate(),
p_vetb50.direccion_facturacion)
IF STATUS < 0 THEN
ROLLBACK WORK
CALL fgl_winmessage("ERROR","NO FUE POSIBLE LA CREACION DE LA COTIZACION","STOP")
EXIT PROGRAM
END IF
IF actualiza = "S" THEN
UPDATE vetb00050 set us_mod = usuarios,
fech_mod = getdate()
WHERE cotizacion_no = p_vetb50.cotizacion_no AND
cod_cia = p_vetb50.cod_cia
ELSE
UPDATE vetb00050 set us_crea = usuarios,
fech_crea = getdate()
WHERE cotizacion_no = p_vetb50.cotizacion_no AND
cod_cia = p_vetb50.cod_cia
END IF
DELETE FROM vetb00051 WHERE vetb00051.cotizacion_no = p_vetb50.cotizacion_no
FOR idx = 1 TO arr_cotiza.getLength()
IF arr_cotiza[idx].cod_sec IS NOT NULL THEN
IF arr_cotiza[idx].porc_Desc IS NULL THEN
LET arr_cotiza[idx].porc_desc = 0
END IF
INSERT INTO vetb00051
(cod_cia,cotizacion_no,ventas,area,cod_n,cod_grupo,cod_tipo,cod_Sec,cantidad_1,cantidad,precio,
porc_desc,status_t,us_crea,fech_crea,id_kit)
VALUES
(p_vetb50.cod_cia,p_vetb50.cotizacion_no,p_vetb50.ventas,
arr_cotiza[idx].area,arr_cotiza[idx].cod_n,
arr_cotiza[idx].cod_grupo,arr_cotiza[idx].cod_tipo,
arr_cotiza[idx].cod_sec,arr_cotiza[idx].cantidad_1,arr_cotiza[idx].cantidad,
arr_cotiza[idx].precio,arr_cotiza[idx].porc_desc,null,
usuarios,getdate(),arr_cotiza[idx].id_kit)
IF STATUS < 0 THEN
ROLLBACK WORK
CALL fgl_winmessage("ERROR","NO FUE POSIBLE LA CREACION DE LA COTIZACION","STOP")
EXIT PROGRAM
END IF
END IF
END FOR
#ADICION KIT
IF arr_kit.getLength() > 0 THEN
FOR idx=1 TO arr_kit.getLength()
IF arr_kit[idx].cod_n IS NOT NULL THEN
INSERT INTO vetb00031 (cotizacion_no,area,cod_n,cod_grupo,cod_tipo,cod_sec,cantidad,
precio,porc_desc,id_kit)
VALUES
(p_vetb50.cotizacion_no,arr_kit[idx].area,arr_kit[idx].cod_n,arr_kit[idx].cod_grupo,
arr_kit[idx].cod_tipo,
arr_kit[idx].cod_Sec,arr_kit[idx].cantidad,arr_kit[idx].precio,arr_kit[idx].porc_desc,pkit)
END IF
END FOR
END IF
COMMIT WORK
END IF
###################### TERMINA INSERT EN INFORMIX ##################################
SET CONNECTION "MSSQL"
LET numero_msg = 1
CALL msg(numero_msg)
ELSE
DELETE FROM repitecodigo WHERE documento = tmpnumero1 and
tipo_doc = 'CO'
CONTINUE DIALOG
END IF
EXIT DIALOG
END DIALOG
END FUNCTION
FUNCTION vepcmf008()
DEFINE chanula CHAR(3)
## Aqui se prepara para la captura del criterio de seleccion
CONSTRUCT BY NAME criterio ON a.cod_cia,a.cotizacion_no,a.tipo_cliente,a.sec_cliente,
a.nombre_cliente,a.rnc,a.nombre_proyecto,
a.direccion_proyecto,a.fecha
BEFORE CONSTRUCT
CALL cinstalador()
AFTER CONSTRUCT
IF INT_FLAG THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET INT_FLAG = FALSE
RETURN
END IF
EXIT CONSTRUCT
END CONSTRUCT
LET SELEC = " SELECT DISTINCT a.cod_cia,a.ventas,a.cotizacion_no,a.tipo_cliente,a.sec_cliente,a.nombre_cliente, " ||
" a.rnc,a.nombre_proyecto,a.direccion_cliente,a.cod_provincia,a.direccion_proyecto, " ||
" a.telefono_r,a.telefono_o,a.email,a.tipo_precio,a.beeper,a.celular,a.prima,a.fax1,a.celular1, " ||
" a.fax, CONVERT(CHAR(10),a.fecha,103),CONVERT(CHAR(10),a.fecha_entrega,103), " ||
" a.plazo_entrega,a.comentario,a.contacto, a.cond_pago,a.sec_Vend,a.porc_itbi," ||
" a.total_bruto,a.sub_total,a.monto_Desc,a.monto_itbi,a.total_neto,a.monto_dolar,a.num_emp_inst " ||
" FROM vetb00050 a " ||
" WHERE " || criterio CLIPPED || " AND a.status_t is null ",
" ORDER BY a.cotizacion_no"
PREPARE busca FROM selec
DECLARE datos SCROLL CURSOR FOR busca
OPEN datos
FETCH FIRST datos INTO p_vetb50.cod_cia,p_vetb50.ventas,p_vetb50.cotizacion_no,p_vetb50.tipo_cliente,p_vetb50.sec_cliente,p_vetb50.nombre_cliente,
p_vetb50.rnc,p_vetb50.nombre_proyecto,p_vetb50.direccion_cliente,p_vetb50.cod_provincia,p_vetb50.direccion_proyecto,
p_vetb50.telefono_r,p_vetb50.telefono_o,p_vetb50.email,p_vetb50.tipo_precio,p_vetb50.beeper,p_vetb50.celular,p_vetb50.prima,p_vetb50.fax1,p_vetb50.celular1,
p_vetb50.fax, p_vetb50.fecha,p_vetb50.fecha_entrega,
p_vetb50.plazo_entrega,p_vetb50.comentario,p_vetb50.contacto, p_vetb50.cond_pago,p_vetb50.sec_Vend,p_vetb50.porc_itbi,
p_vetb50.total_bruto,p_vetb50.sub_total,p_vetb50.monto_Desc,p_vetb50.monto_itbi,p_vetb50.total_neto,p_vetb50.monto_dolar,
p_vetb50.num_emp_inst
IF STATUS = NOTFOUND THEN
LET numero_msg = 3
CALL msg(numero_msg)
RETURN
END IF
CALL busca_info()
LET etiqueta_cotiza = "COTIZACION"
MENU "OPCIONES "
ON ACTION etiqueta
CASE
WHEN etiqueta_cotiza = "COTIZACION"
LET etiqueta_cotiza = "FACTURA PROFORMA"
EXIT CASE
WHEN etiqueta_cotiza = "FACTURA PROFORMA"
LET etiqueta_cotiza = "COTIZACION"
EXIT CASE
END CASE
COMMAND "Siguiente" "Presenta en pantalla la siguiente cotizacion encontrada"
FETCH NEXT datos INTO p_vetb50.cod_cia,p_vetb50.ventas,p_vetb50.cotizacion_no,p_vetb50.tipo_cliente,p_vetb50.sec_cliente,p_vetb50.nombre_cliente,
p_vetb50.rnc,p_vetb50.nombre_proyecto,p_vetb50.direccion_cliente,p_vetb50.cod_provincia,p_vetb50.direccion_proyecto,
p_vetb50.telefono_r,p_vetb50.telefono_o,p_vetb50.email,p_vetb50.tipo_precio,p_vetb50.beeper,p_vetb50.celular,p_vetb50.prima,p_vetb50.fax1,p_vetb50.celular1,
p_vetb50.fax, p_vetb50.fecha,p_vetb50.fecha_entrega,
p_vetb50.plazo_entrega,p_vetb50.comentario,p_vetb50.contacto, p_vetb50.cond_pago,p_vetb50.sec_Vend,p_vetb50.porc_itbi,
p_vetb50.total_bruto,p_vetb50.sub_total,p_vetb50.monto_Desc,p_vetb50.monto_itbi,p_vetb50.total_neto,p_vetb50.monto_dolar
IF STATUS = NOTFOUND THEN
LET numero_msg = 4
CALL msg(numero_msg)
END IF
CALL busca_info()
COMMAND "anterior" "Presenta en pantalla el registro anterior encontrado"
FETCH PREVIOUS datos INTO p_vetb50.cod_cia,p_vetb50.ventas,p_vetb50.cotizacion_no,p_vetb50.tipo_cliente,p_vetb50.sec_cliente,p_vetb50.nombre_cliente,
p_vetb50.rnc,p_vetb50.nombre_proyecto,p_vetb50.direccion_cliente,p_vetb50.cod_provincia,p_vetb50.direccion_proyecto,
p_vetb50.telefono_r,p_vetb50.telefono_o,p_vetb50.email,p_vetb50.tipo_precio,p_vetb50.beeper,p_vetb50.celular,p_vetb50.prima,p_vetb50.fax1,p_vetb50.celular1,
p_vetb50.fax, p_vetb50.fecha,p_vetb50.fecha_entrega,
p_vetb50.plazo_entrega,p_vetb50.comentario,p_vetb50.contacto, p_vetb50.cond_pago,p_vetb50.sec_Vend,p_vetb50.porc_itbi,
p_vetb50.total_bruto,p_vetb50.sub_total,p_vetb50.monto_Desc,p_vetb50.monto_itbi,p_vetb50.total_neto,p_vetb50.monto_dolar
IF STATUS = NOTFOUND THEN
LET numero_msg = 5
CALL msg(numero_msg)
END IF
CALL busca_info()
COMMAND "Primero" "Presenta en pantalla el primer registro encontrado"
FETCH FIRST datos INTO p_vetb50.cod_cia,p_vetb50.ventas,p_vetb50.cotizacion_no,p_vetb50.tipo_cliente,p_vetb50.sec_cliente,p_vetb50.nombre_cliente,
p_vetb50.rnc,p_vetb50.nombre_proyecto,p_vetb50.direccion_cliente,p_vetb50.cod_provincia,p_vetb50.direccion_proyecto,
p_vetb50.telefono_r,p_vetb50.telefono_o,p_vetb50.email,p_vetb50.tipo_precio,p_vetb50.beeper,p_vetb50.celular,p_vetb50.prima,p_vetb50.fax1,p_vetb50.celular1,
p_vetb50.fax, p_vetb50.fecha,p_vetb50.fecha_entrega,
p_vetb50.plazo_entrega,p_vetb50.comentario,p_vetb50.contacto, p_vetb50.cond_pago,p_vetb50.sec_Vend,p_vetb50.porc_itbi,
p_vetb50.total_bruto,p_vetb50.sub_total,p_vetb50.monto_Desc,p_vetb50.monto_itbi,p_vetb50.total_neto,p_vetb50.monto_dolar
CALL busca_info()
COMMAND "Ultimo" "Presenta en pantalla el ultimo registro encontrado"
FETCH LAST datos INTO p_vetb50.cod_cia,p_vetb50.ventas,p_vetb50.cotizacion_no,p_vetb50.tipo_cliente,p_vetb50.sec_cliente,p_vetb50.nombre_cliente,
p_vetb50.rnc,p_vetb50.nombre_proyecto,p_vetb50.direccion_cliente,p_vetb50.cod_provincia,p_vetb50.direccion_proyecto,
p_vetb50.telefono_r,p_vetb50.telefono_o,p_vetb50.email,p_vetb50.tipo_precio,p_vetb50.beeper,p_vetb50.celular,p_vetb50.prima,p_vetb50.fax1,p_vetb50.celular1,
p_vetb50.fax, p_vetb50.fecha,p_vetb50.fecha_entrega,
p_vetb50.plazo_entrega,p_vetb50.comentario,p_vetb50.contacto, p_vetb50.cond_pago,p_vetb50.sec_Vend,p_vetb50.porc_itbi,
p_vetb50.total_bruto,p_vetb50.sub_total,p_vetb50.monto_Desc,p_vetb50.monto_itbi,p_vetb50.total_neto,p_vetb50.monto_dolar
CALL busca_info()
ON ACTION copiar
CALL duplicar(p_vetb50.cotizacion_no,usuarios)
ON ACTION impresion
CALL impresion(p_vetb50.cotizacion_no,'veprmt049.4rp','PDF',cuenta_item,etiqueta_cotiza) RETURNING salida
ON ACTION Borrar
SELECT DISTINCT a.banco FROM cctb00001 a WHERE a.banco = p_vetb50.cotizacion_no
IF STATUS <> NOTFOUND THEN
CALL fgl_Winmessage("INFO","COTIZACION TIENE AVANCE, NO PUEDE ANULAR","INFO")
CONTINUE MENU
END IF
SELECT DISTINCT a.cotizacion_no FROM prtb00012 a WHERE a.cotizacion_no = p_vetb50.cotizacion_no
AND a.status_t IS NULL
IF STATUS <> NOTFOUND THEN
CALL fgl_Winmessage("INFO","COTIZACION TIENE ORDEN PEDIDO, NO PUEDE ANULAR","INFO")
CONTINUE MENU
END IF
CALL busca_info()
LET esta = fgl_winquestion("BORRAR","ESTA SEGURO?","NO","YES|NO","QUESTION",0)
IF esta = "YES" THEN
UPDATE vetb00050 set status_t = "E",
us_mod = usuarios,
fech_mod = GETDATE()
WHERE @cotizacion_no = p_vetb50.cotizacion_no
UPDATE vetb00051 set status_t = "E",
us_mod = usuarios,
fech_mod = GETDATE()
WHERE @cotizacion_no = p_vetb50.cotizacion_no
LET numero_msg = 39
CALL msg(numero_msg)
END IF
COMMAND "Soporte"
INPUT ARRAY soporte_Ventas FROM soporte.* ATTRIBUTE(WITHOUT DEFAULTS)
AFTER FIELD num_emp
LET idx = arr_curr()
IF soporte_ventas[idx].num_emp IS NOT NULL THEN
SELECT a.nom1_emp||' '||a.apell1_emp INTO soporte_ventas[idx].nombre_adicional FROM adtb00003 a
WHERE a.num_emp = soporte_ventas[idx].num_emp
IF STATUS = NOTFOUND THEN
CALL fgl_Winmessage("ERROR","REGISTRO NO EXISTE","INFO")
NEXT FIELD num_emp
END IF
END IF
AFTER INPUT
CALL busca_duplicado(soporte_Ventas,usuarios) RETURNING soporte_Ventas
FOR idx1=1 TO soporte_ventas.getLength()
IF soporte_ventas[idx1].num_emp IS NOT NULL THEN
SELECT DISTINCT a.cotizacion_no FROM vetb00093 a
WHERE a.sec_vend = soporte_ventas[idx1].num_emp AND
a.cotizacion_no = p_vetb50.cotizacion_no
IF STATUS = NOTFOUND THEN
INSERT INTO vetb00093 (cotizacion_no,sec_vend,nombre_vendedor)
VALUES (p_vetb50.cotizacion_no,soporte_ventas[idx1].num_emp,
soporte_ventas[idx1].nombre_adicional)
END IF
END IF
END FOR
END INPUT
COMMAND "Escoger" "Actualiza Cotizacion"
LET actualiza = "S"
IF p_Vetb50.tipo_cliente IS NOT NULL THEN
{ SELECT UNIQUE a.num_cheque FROM cctb00001 a
WHERE a.num_cheque = p_vetb50.cotizacion_no AND
a.tipo_doc = 'AV' AND
a.tipo_cliente = p_vetb50.tipo_cliente AND
a.sec_cliente = p_vetb50.sec_cliente AND
a.status_t IS NULL
IF STATUS <> NOTFOUND THEN
CALL fgl_winmessage("ERROR","NO PUEDE MODIFICAR COTIZACION, TIENE AVANCE","INFO")
EXIT MENU
END IF
}
SELECT UNIQUE a.cotizacion_no FROM prtb00012 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no and
a.status_t is null
IF STATUS != NOTFOUND THEN
LET numero_msg =392
CALL msg(numero_msg)
EXIT MENU
END IF
END IF
CALL vepcad008()
LET numero_msg = 13
CALL msg(numero_msg)
COMMAND "Orden" "Hacer Orden Pedidos"
IF xorden IS NOT NULL THEN
CALL fgl_winmessage("ERROR","ESTA COTIZACION YA TIENE ORDEN","STOP")
ELSE
INPUT BY NAME orden_cliente,ptipo_orden ATTRIBUTE(MAGENTA)
AFTER INPUT
IF orden_cliente IS NULL THEN
CALL msg(16)
NEXT FIELD orden_cliente
END IF
IF ptipo_orden <> 'GENERAL' THEN
SELECT a.printer_cheque INTO copia FROM seg0001 a WHERE a.usuario = usuarios
END IF
END INPUT
IF p_vetb50.tipo_cliente IS NOT NULL THEN
CALL convierteorden(p_vetb50.cotizacion_no,orden_cliente,usuarios,clave,impresor,copia,ptipo_orden) RETURNING prtb12.num_oc,exito
IF NOT exito THEN
CALL fgl_winmessage("ERROR","NO SE REALIZO LA ORDEN","STOP")
END IF
DISPLAY prtb12.num_oc TO orden
CALL msg(1)
END IF
END IF
COMMAND "Anula Orden" "Anulacion de la orden de pedidos"
IF xorden IS NOT NULL THEN
LET chanula = fgl_winquestion("ORDEN","ESTA SEGURO DE ANULAR ESTA ORDEN?","NO","YES|NO","QUESTION",0)
IF chanula = "YES" THEN
UPDATE cctb00026
SET status_t="E"
WHERE num_oc=xorden
UPDATE cctb00025
SET status_t="E"
WHERE num_req=xorden
{ SET CONNECTION "IFMX"
SELECT DISTINCT a.orden FROM vetb00002 a WHERE a.orden = xorden AND a.status_t IS NULL
IF STATUS <> NOTFOUND THEN
CALL fgl_winmessage("INFO","NO PUEDE ANULAR ESTA ORDEN, TIENE FACTURA CON NCF","INFO")
CONTINUE MENU
END IF}
SET CONNECTION "MSSQL"
# VERIFICA SI TIENE REQUISICION
SELECT UNIQUE a.num_oc FROM cctb00026 a
WHERE a.num_oc = xorden AND
a.status_t IS NULL
IF STATUS <> NOTFOUND THEN
CALL fgl_winmessage("ERROR","NO PUEDE ANULAR ORDEN, TIENE REQUISICION","INFO")
CONTINUE MENU
END IF
# VERIFICA SI ESTA FACTURADA LA ORDEN
SELECT UNIQUE a.orden FROM vetb00002 a
WHERE a.orden = xorden AND
a.status_t is null
IF STATUS != NOTFOUND THEN
ERROR "NO PUEDE ANULAR ORDEN, TIENE FACTURAS"
CONTINUE MENU
END IF
# VERIFICACION DESPACHO
SELECT UNIQUE a.conduce_no FROM iptb00006 a
WHERE a.num_oc = xorden AND
a.fech_Crea > '01/01/2007' and
a.status_t is null
IF STATUS != NOTFOUND THEN
ERROR "NO PUEDE ANULAR ORDEN, TIENE TRANSACCIONES DE INVENTARIO"
CONTINUE MENU
END IF
UPDATE prtb00012 SET status_t = 'E',
cerrada='E',
us_mod = usuarios,
fech_mod = getdate()
WHERE num_oc =xorden
UPDATE prtb00013 SET status_t = 'E',
us_mod = usuarios,
fech_mod = getdate()
WHERE num_oc =xorden
{ SET CONNECTION "IFMX"
UPDATE prtb00012 SET status_t = 'E',
cerrada = 'E',
us_mod = usuarios,
fech_mod = getdate()
WHERE num_oc =xorden
UPDATE prtb00013 SET status_t = 'E',
us_mod = usuarios,
fech_mod = getdate()
WHERE num_oc =xorden
}
CALL fgl_winmessage("WARNING","ORDEN ANULADA","INFO")
END IF
END IF
COMMAND "Requisicion" "Hacer requisicion"
SET CONNECTION "MSSQL"
SELECT a.num_oc INTO xorden FROM prtb00012 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND a.status_t IS NULL
IF xorden IS NULL THEN
CALL fgl_winmessage("ERROR","ESTA COTIZACION NO TIENE ORDEN, NO PUEDE HACER REQUISICION","STOP")
CONTINUE MENU
END IF
LET respuesta_req = fgl_winquestion("REQUISICION","ESTA SEGURO DE HACER LA REQUISICION?","NO","YES|NO","QUESTION",0)
IF respuesta_req = "YES" THEN
SELECT UNIQUE a.num_oc FROM cctb00026 a
WHERE a.num_oc = xorden AND a.status_t IS NULL
IF STATUS != NOTFOUND THEN
CALL fgl_winmessage("ERROR","ORDEN TIENE REQUISICION, DEBE HACERLA POR EL PROGRAMA NORMAL","STOP")
CONTINUE MENU
END IF
CALL requisiciondespacho(prtb12.num_oc,p_vetb50.tipo_cliente,p_vetb50.sec_cliente,p_vetb50.cond_pago,p_vetb50.total_neto,p_vetb50.fecha,p_vetb50.sec_vend,usuarios)
RETURNING xnum_req,xmonto
IF xnum_req = 0 AND xmonto=0 THEN
CONTINUE MENU
END IF
CALL evaluaclientes(p_vetb50.tipo_cliente,p_vetb50.sec_cliente,
p_vetb50.cond_pago ,xnum_req,prtb12.num_oc,p_vetb50.sec_vend,
'CO',xmonto) RETURNING pestado
END IF
COMMAND "Salir" "Retorna al menu anterior"
EXIT MENU
END MENU
END FUNCTION
FUNCTION busca_area()
OPEN WINDOW busqueda AT 7,12 WITH FORM "vefmwd102"
ATTRIBUTE (BORDER,FORM LINE FIRST + 2,COMMENT LINE LAST,MESSAGE LINE LAST)
LET INT_FLAG = false
CONSTRUCT criterio ON a.nombre_area FROM nombre_area
LET selec2 = "SELECT a.area_num, a.nombre_area ",
" FROM prtb00016 a",
" WHERE ",
"a.status_t is NULL AND ",
criterio clipped,
"ORDER BY 2 "
IF INT_FLAG THEN
LET numero_msg = 2
CALL msg(numero_msg)
GO TO salir_consulta_c
END IF
PREPARE busca_area FROM selec2
IF status >= 0 THEN
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
END IF
ELSE
END IF
DECLARE buscar_area1 CURSOR FOR busca_area
LET idx = 1
FOREACH buscar_area1 INTO arr_area[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 " <Esc> Selecciona Cliente donde esta el cursor"
DISPLAY ARRAY arr_area TO s_area.*
LET curr1 = arr_curr()
LET int_flag = FALSE
LET arr_cotiza[curr].area = arr_area[curr1].area_num
LET arr_cotiza[curr].nombre_area = arr_area[curr1].nombre_area
LABEL salir_consulta_c:
CLOSE WINDOW busqueda
END FUNCTION
FUNCTION busca_provincia1()
DEFINE arr_provincias DYNAMIC ARRAY OF RECORD
cod_provincia LIKE vetb00020.cod_provincia,
nombre_provincia LIKE vetb00020.nombre_provincia
END RECORD
OPEN WINDOW busqueda AT 7,12 WITH FORM "vefmwd018"
ATTRIBUTE (BORDER,FORM LINE FIRST + 2,COMMENT LINE LAST,MESSAGE LINE LAST)
LET INT_FLAG = false
CONSTRUCT criterio ON a.nombre_provincia FROM nombre_provincia
LET selec2 = "SELECT a.cod_provincia, a.nombre_provincia ",
" FROM vetb00020 a",
" WHERE ",
"a.status_t is NULL AND ",
criterio clipped,
"ORDER BY 2 "
IF INT_FLAG THEN
LET numero_msg = 2
CALL msg(numero_msg)
GO TO salir_consulta_c
END IF
PREPARE busca_provp FROM selec2
IF status >= 0 THEN
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
END IF
ELSE
END IF
DECLARE buscar_prov CURSOR FOR busca_provp
LET idx = 1
FOREACH buscar_prov INTO arr_provincias[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 " <Esc> Selecciona Cliente donde esta el cursor"
DISPLAY ARRAY arr_provincias TO s_provincias.*
LET curr1 = arr_curr()
LET int_flag = FALSE
LET p_vetb50.cod_provincia = arr_provincias[curr1].cod_provincia
LET nombre_ciudad = arr_provincias[curr1].nombre_provincia
LABEL salir_consulta_c:
CLOSE WINDOW busqueda
END FUNCTION
FUNCTION busca_cliente8()
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.tipo_cliente,a.nombre,b.nombre_proyecto
FROM tipo_cliente,nombre,nombre_proyecto
LET selec2 = "SELECT a.tipo_cliente, a.sec_cliente, a.nombre,b.nombre_proyecto ",
" FROM vetb00004 a,outer vetb00049 b ",
" where a.tipo_cliente = b.tipo_cliente and a.sec_cliente = b.sec_cliente and ",
"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_cliente8s FROM selec2
IF status >= 0 THEN
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
END IF
ELSE
END IF
DECLARE buscar_clientes CURSOR FOR busca_cliente8s
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 " <Esc> Selecciona Cliente donde esta el cursor"
DISPLAY ARRAY arr_clientes TO s_clientes.*
LET curr1 = arr_curr()
IF INT_FLAG THEN
LET numero_msg = 2
CALL msg(numero_msg)
GOTO salir_consulta_c
END IF
LET int_flag = FALSE
LET p_vetb50.tipo_cliente = arr_clientes[curr1].tipo_cliente
LET p_vetb50.sec_cliente = arr_clientes[curr1].sec_cliente
LET p_vetb50.nombre_cliente = arr_clientes[curr1].nombre
LABEL salir_consulta_c:
CLOSE WINDOW busqueda
END FUNCTION
FUNCTION busca_prod1()
DEFINE arr_prod DYNAMIC ARRAY OF RECORD
cod_n INTEGER,
cod_grupo INTEGER,
cod_tipo INTEGER,
cod_sec INTEGER,
descrip_esp CHAR(50),
unidad_med LIKE intb00001.unidad_med,
existencia1 DEC(18,4),
cantidad_o DEC(18,4),
cantidad_c DEC(18,4),
existencia DEC(18,4)
END RECORD,
selec_pt CHAR(1500),
cantidad_orden,pcantidadConduce,transito,existencia,reservado DEC(12,2)
OPEN WINDOW busca_2 AT 8,4 WITH FORM "vefmwd100" ATTRIBUTE (BORDER,FORM LINE
FIRST + 1,PROMPT LINE LAST)
CONSTRUCT criterio ON a.cod_n,a.cod_grupo,a.cod_tipo,a.descrip_esp FROM
cod_n,cod_grupo,cod_tipo,descrip_esp
{ ESTE FUE EL QUERY ORIGINAL, LE QUITE LA TABLA VETB00051 y PRTB00013 PORQUE NO
TRAIA LOS CODIGOS EN LA CONSULTA
"SELECT a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,a.descrip_esp,a.unidad_med,SUM(e.cantidad),SUM(d.cantidad),SUM(b.cantidad_2) ",
" FROM iptb00002 AS a INNER JOIN iptb00001 AS c ON 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 LEFT OUTER JOIN ",
" iptb00006 AS b ON 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 b.status_t IS NULL LEFT OUTER JOIN ",
" vetb00051 AS e ON a.cod_n = e.cod_n AND a.cod_grupo = e.cod_grupo AND ",
" a.cod_tipo = e.cod_tipo AND a.cod_sec = e.cod_sec LEFT OUTER JOIN ",
" prtb00013 AS d ON ",
" a.cod_n = d.cod_n AND a.cod_grupo = d.cod_grupo AND ",
" a.cod_tipo = d.cod_tipo AND a.cod_sec = d.cod_sec INNER JOIN ",
" prtb00012 AS f ON d.num_oc = f.num_oc and f.cotizacion_no = e.cotizacion_no ",
" AND f.cerrada = 'N' ",
" WHERE a.status_t IS NULL AND ",CRITERIO CLIPPED,
" GROUP BY a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,a.descrip_esp,a.unidad_med ",
" ORDER BY a.descrip_esp "
}
LET selec_pt =
"SELECT a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,a.descrip_esp,a.unidad_med,'0','0','0' ",
" FROM iptb00002 AS a INNER JOIN iptb00001 AS c ON 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 ",
" WHERE a.status_t IS NULL AND ",CRITERIO CLIPPED,
" ORDER BY a.descrip_esp "
IF int_flag THEN
LET Int_flag = FALSE
CLOSE WINDOW busca_2
RETURN
END IF
PREPARE comando_p FROM selec_pt
DECLARE busca_2 CURSOR FOR comando_p
LET idx = 1
FOREACH busca_2 INTO arr_prod[idx].*
LET arr_prod[idx].cantidad_o=0
LET arr_prod[idx].existencia=0
CALL disponibles(arr_prod[idx].cod_n,arr_prod[idx].cod_grupo,arr_prod[idx].cod_tipo,arr_prod[idx].cod_sec,today)
RETURNING cantidad_orden,pcantidadConduce,transito,existencia,reservado
#CANTIDAD COTIZACIONES
LET fecha_t=today
LET reservado=0
LET selec_r=
" SELECT SUM(a.cantidad) FROM vetb00051 a,vetb00050 b ",
" WHERE (a.cod_n = ? AND ",
" a.cod_grupo=? AND ",
" a.cod_tipo=? AND ",
" a.cod_sec=?) AND ",
" (a.cotizacion_no=b.cotizacion_no) AND ",
" (b.fecha BETWEEN DATEADD(day,-30,?) AND ?) AND ",
" b.status_t IS NULL "
DISPLAY selec_r
PREPARE reserva FROM selec_r
EXECUTE reserva USING arr_prod[idx].cod_n,arr_prod[idx].cod_grupo,
arr_prod[idx].cod_tipo,arr_prod[idx].cod_sec,fecha_t,fecha_t
INTO reservado
DISPLAY reservado
LET arr_prod[idx].existencia1=existencia
LET arr_prod[idx].cantidad_c = reservado
LET arr_prod[idx].cantidad_o=cantidad_orden+pcantidadConduce
LET arr_prod[idx].existencia=existencia-cantidad_orden
LET idx = idx + 1
END FOREACH
# CALL SET_COUNT(idx - 1)
IF idx-1 >0 THEN
DISPLAY idx-1 TO numero_registros
ELSE
CALL fgl_Winmessage("INFO","NO EXISTEN REGISTROS CON ESTA CONDICION","INFO")
CLOSE WINDOW busca_2
RETURN
END IF
DISPLAY ARRAY arr_prod TO s_prod.*
LET idx = ARR_CURR()
LET arr_cotiza[curr].cod_n = arr_prod[idx].cod_n
LET arr_cotiza[curr].cod_grupo = arr_prod[idx].cod_grupo
LET arr_cotiza[curr].cod_tipo = arr_prod[idx].cod_tipo
LET arr_cotiza[curr].cod_sec = arr_prod[idx].cod_sec
LET arr_cotiza[curr].nombre_p = arr_prod[idx].descrip_esp
LET arr_cotiza[curr].unidad = arr_prod[idx].unidad_med
LET pexistencia = arr_prod[idx].existencia
CLOSE WINDOW busca_2
END FUNCTION
FUNCTION vendedor8es()
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 UNIQUE a.num_emp,a.nom1_emp,a.apell1_emp,a.telefono ",
" FROM adtb00003 a,vetb00028 b",
" WHERE a.num_emp = b.sec_vend AND ",
"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
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 " <Esc> Selecciona Empleado donde esta el cursor"
DISPLAY ARRAY empleados TO s_empleados.*
LET curr1 = scr_line()
IF INT_FLAG THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = FALSE
GOTO salir_consulta_e
END IF
LET p_vetb50.sec_vend = empleados[curr1].cod_emp_sec
LET nombre_vend = empleados[curr1].descrip6
LABEL salir_consulta_e:
CLOSE WINDOW busqueda2
END FUNCTION
FUNCTION busca_vendm8()
IF p_vetb50.sec_vend IS NOT NULL THEN
SELECT a.nom1_emp,a.apell1_emp INTO nombres,apellidos
FROM adtb00003 a
WHERE a.num_emp = p_vetb50.sec_vend
LET nombre_vend = nombres CLIPPED," ",apellidos CLIPPED
DISPLAY BY NAME nombre_vend ATTRIBUTE(BLUE)
END IF
END FUNCTION
FUNCTION busca_info()
IF p_vetb50.cod_cia = 1 THEN
LET nombre_cia = p_companias.nombre
ELSE
LET nombre_cia = "EMPRESA DEMO 2"
END IF
LET pventas = ui.ComboBox.forName("formonly.ventas")
CALL cventas()
LET pcondicion = ui.ComboBox.forName("formonly.cond_pago")
CALL ccondicion()
LET xorden = NULL
SELECT DISTINCT a.num_oc,a.nombre_file
INTO xorden,orden_cliente FROM prtb00012 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND a.status_t is null
DISPLAY BY NAME p_vetb50.*,nombre_cia
DISPLAY xorden TO orden
LET prtb12.num_oc = xorden
SELECT a.nombre_provincia INTO nombre_ciudad
FROM vetb00020 a
WHERE a.cod_provincia = p_vetb50.cod_provincia
DISPLAY BY NAME nombre_ciudad
# BUSCA BALANCE CON AVANCES
SELECT SUM(a.valor+a.monto_desc) INTO valor1
FROM cctb00001 a
WHERE a.fecha_orig <= today AND
a.tipo_cliente = p_vetb50.tipo_cliente AND
a.sec_cliente = p_vetb50.sec_cliente AND
a.tipo_doc IN ("AV") AND a.num_doc = a.aplica_a AND a.status_t IS NULL
IF valor1 IS NULL THEN
LET valor1 = 0
END IF
# BUSCA BALANCE SIN AVANCES
SELECT SUM(a.valor+a.monto_desc) INTO valor2
FROM cctb00001 a
WHERE a.fecha_orig <= today AND
a.tipo_cliente = p_vetb50.tipo_cliente AND
a.sec_cliente = p_vetb50.sec_cliente AND
a.tipo_doc NOT IN ("AV","PC") AND a.status_t IS NULL
IF valor1 IS NULL THEN
LET valor1 = 0
END IF
LET balancecxc = valor2-valor1
DISPLAY BY NAME balancecxc
CALL arr_cotiza.clear()
DECLARE buscaitm1 CURSOR FOR
SELECT a.secuencia,a.area,a.descripcion_area,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,a.descripcion,b.unidad_med,
a.cantidad_1,a.cantidad,a.precio,a.porc_desc,'0',a.foto_producto,' ',a.id_kit,a.cantidad_reservada,CONVERT(CHAR(10),a.fecha_vence_reserva,103)
FROM vetb00051 a,iptb00002 b
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
a.cod_cia = p_vetb50.cod_cia 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
ORDER BY a.secuencia
LET idx = 1
LOCATE arr_cotiza[idx].ruta IN MEMORY
FOREACH buscaitm1 INTO arr_cotiza[idx].*
LET arr_cotiza[idx].total_p = (arr_cotiza[idx].cantidad * arr_cotiza[idx].precio) -
((arr_cotiza[idx].cantidad * arr_cotiza[idx].precio) *
(arr_cotiza[idx].porc_desc / 100))
IF arr_cotiza[idx].nombre_p IS NULL THEN
SELECT a.descrip_esp INTO arr_cotiza[idx].nombre_p
FROM iptb00002 a
WHERE a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_sec = arr_cotiza[idx].cod_sec
END IF
SELECT UNIQUE a.autoriza INTO arr_cotiza[idx].chactualiza
FROM vetb00088 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
a.cod_n = arr_cotiza[idx].cod_n AND
a.cod_grupo = arr_cotiza[idx].cod_grupo AND
a.cod_tipo = arr_cotiza[idx].cod_tipo AND
a.cod_sec = arr_cotiza[idx].cod_sec
LET idx = idx + 1
LOCATE arr_cotiza[idx].ruta IN MEMORY
END FOREACH
CALL set_count(idx)
DISPLAY ARRAY arr_cotiza TO s_pedido.*
ON KEY (CONTROL-W)
CALL despiece()
{EN COMENTARIO FECHA 8/12/2015, ESTO FUE PORQUE NO SE COMO CONTROLAR CUANDO DIGITEN VARIOS CODIGOS DE DIFERENTES SOPORTES
ON ACTION soporte
INPUT ARRAY soporte_Ventas FROM soporte.* ATTRIBUTE(WITHOUT DEFAULTS)
AFTER FIELD num_emp
LET idx = arr_curr()
IF soporte_ventas[idx].num_emp IS NOT NULL THEN
SELECT a.nom1_emp||' '||a.apell1_emp INTO soporte_ventas[idx].nombre_adicional FROM adtb00003 a
WHERE a.num_emp = soporte_ventas[idx].num_emp
IF STATUS = NOTFOUND THEN
CALL fgl_Winmessage("ERROR","REGISTRO NO EXISTE","INFO")
NEXT FIELD num_emp
END IF
END IF
AFTER INPUT
IF INT_FLAG THEN
IF fgl_winquestion("INFO","ESTAS SEGURO DE CANCELAR OPERACION?","NO","YES|NO","QUESTION",0) THEN
EXIT INPUT
ELSE
CONTINUE INPUT
END IF
END IF
LET tiene_soporte = "N"
FOR idx = 1 TO arr_cotiza.getLength()
IF arr_cotiza[idx].cod_n IS NOT NULL THEN
SELECT DISTINCT a.cod_n FROM vetb00076 a
WHERE a.cod_n = arr_cotiza[idx].cod_n AND
a.sec_Vend = soporte_ventas[arr_curr()].num_emp
IF STATUS <> NOTFOUND THEN
LET tiene_soporte = "S"
END IF
END IF
END FOR
IF tiene_soporte = "N" THEN
CALL fgl_winmessage("E
END IF
END INPUT}
BEFORE ROW
LET idx = arr_curr()
CALL arr_cotiza[idx].ruta.writeFile(filedestino)
DISPLAY filedestino TO foto_producto
ON ACTION modifica_kit
SELECT UNIQUE a.cotizacion_no FROM cctb00026 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
a.status_T IS NULL
IF STATUS <> NOTFOUND THEN
CALL fgl_Winmessage("ERROR","COTIZACION TIENE REQUISICION, NO PUEDES MODIFICAR EL KIT","INFO")
CONTINUE DISPLAY
END IF
IF arr_cotiza[arr_curr()].id_kit IS NOT NULL THEN
CALL modifica_detalle_kit(arr_cotiza[idx].id_kit,p_vetb50.cotizacion_no)
ELSE
CALL fgl_winmessage("ERROR","ESE ARTICULO NO TIENE KIT","INFO")
END IF
AFTER DISPLAY
END DISPLAY
CALL soporte_ventas.clear()
DECLARE busca_soporte CURSOR FOR
SELECT a.sec_vend,a.nombre_vendedor
FROM vetb00093 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no
LET idx = 1
FOREACH busca_soporte INTO soporte_ventas[idx].*
LET idx = idx + 1
END FOREACH
CALL set_count(idx)
DISPLAY ARRAY soporte_ventas TO soporte.*
END FUNCTION
{
FUNCTION f_canvas()
-- Define parameters
DEFINE porciento ,l_offset SMALLINT
DEFINE test CHAR(1)
-- Define local variables
DEFINE l_span smallint,
l_objid smallint,
valor_cotizado,valor_facturado INT,
str_facturado,str_cotizado CHAR(25),
fecha1 LIKE vetb00002.fecha_factura
LET l_offset = 50
CALL drawinit()
# OPEN WINDOW w_card AT 2,2 WITH FORM "canvas"
-- Select and initialize drawing room
CALL DisableColorlines(0)
CALL DrawSelect("canvas1")
CALL DrawClear()
LET fecha1 = TODAY - 30
SELECT SUM(a.neto) INTO valor_facturado FROM vetb00002 a
WHERE a.fecha_factura BETWEEN fecha1 AND TODAY AND
a.cod_cia = 1 AND
a.status_t is null
SELECT SUM(a.total_neto) INTO valor_cotizado FROM vetb00050 a
WHERE a.cod_cia = 1 AND
a.fecha BETWEEN fecha1 AND TODAY AND a.status_t is null
# LET valor_facturado = 500000
# LET valor_cotizado = 2000000
LET Porciento = (valor_facturado / valor_cotizado) * 100
LET l_span = 360 * (porciento / 100)
-- Select the color for the first arc
CALL DrawFillColor("blue")
-- Draw the first arc.
# LET l_span = 0
CALL DrawArc(900,200,600,0,100) RETURNING l_objid
# CALL DrawArc(900,200,600,0,l_span) RETURNING l_objid
-- Compute the next arc.
# LET l_span = l_offset
LET l_offset = l_span
LET l_offset = 360 - l_span
CALL drawfillcolor("red")
CALL DrawArc(900,200,600,100,260) RETURNING l_objid
# CALL DrawArc(900,200,600,l_span,l_offset) RETURNING l_objid
-- Write the legend
LET str_facturado = "Facturado ",valor_facturado USING "<<,<<<,<<<"
LET str_cotizado = "Cotizado ", Valor_cotizado USING "##,###,###"
CALL drawanchor("w")
CALL drawtext(200,90, str_facturado) RETURNING l_objid
CALL drawtext(100,90, str_cotizado) RETURNING l_objid
CALL drawfillcolor("blue")
CALL drawrectangle(180,50,30,30) RETURNING l_objid
CALL drawfillcolor("red")
CALL drawrectangle(80,50,30,30) RETURNING l_objid
# PROMPT "Press a key Con 300 : " FOR test
# CLOSE WINDOW w_card
END FUNCTION
}
FUNCTION chqDdeError(p_res,p_msg)
DEFINE p_res INTEGER,
p_msg STRING,
m_err STRING,
m_log STRING
IF p_res THEN
RETURN
END IF
CALL ui.Interface.frontCall("WINDDE","DDEError",[],[m_err])
CALL ui.Interface.frontCall("WINDDE","DDEFinishAll", [], [p_res] )
LET m_log="DDE Error: ",m_err CLIPPED," (",p_msg,")"
CALL errorlog(m_log)
LET m_log="Se ha producido un Error en '",p_msg CLIPPED,"'. Para mas detalle revise el LOG de errores."
CALL fgl_winmessage("DDE Error", m_log, "stop")
EXIT PROGRAM
END FUNCTION
FUNCTION pru_new_dde(xval,xcol,i)
DEFINE celda,rval,xval,xcol STRING
DEFINE i INTEGER
LET celda = fila_excel,i USING "<<<<&",xcol CLIPPED
LET rval = xval
CALL ui.Interface.frontCall("WINDDE","DDEPoke", [prog,file,celda,rval], [p_res] )
CALL chqDdeError(p_res,"DDEPoke "||celda)
{
MESSAGE "Salvando la planilla ",file CLIPPED," !"
CALL ui.Interface.refresh()
LET p_cmd="[save()]"
CALL ui.Interface.frontCall("WINDDE","DDEExecute", [prog,file,p_cmd], [p_res] )
IF p_res THEN
CALL fgl_winmessage("Planilla salvada", "Nombre = "||file, "information")
ELSE
CALL chqDdeError(p_res,"DDEExecute save")
END IF
CAL ui.Interface.frontCall("WINDDE","DDEFinish", [prog,file], [p_res] )
CALL chqDdeError(p_res,"DDEFinish")
CALL ui.Interface.frontCall("WINDDE","DDEFinishAll", [], [p_res] )
CALL chqDdeError(p_res,"DDEFinishAll")
}
END FUNCTION
FUNCTION cotizacion_display()
DEFINE arr_display DYNAMIC ARRAY OF RECORD
cotizacion_no INTEGER,
fecha DATE,
nombre_cliente CHAR(50),
nombre_proyecto CHAR(50)
END RECORD
OPEN WINDOW cotizaciones WITH FORM "vefmmt149"
DECLARE busca_cotiza CURSOR FOR
SELECT a.cotizacion_no,a.fecha,a.nombre_cliente,a.nombre_proyecto FROM vetb00050 a
WHERE a.sec_Vend = pvend
ORDER BY a.fecha DESC
LET idx = 1
FOREACH busca_cotiza INTO arr_display[idx].*
LET idx = idx + 1
END FOREACH
CALL set_count(idx-1)
DISPLAY ARRAY arr_display TO s_cotiza.*
AFTER DISPLAY
LET idx = arr_curr()
EXIT DISPLAY
END DISPLAY
END FUNCTION
FUNCTION despiece()
DEFINE vuelve BOOLEAN
OPEN WINDOW wdespiece AT 5,3 WITH FORM "vefmwd019" ATTRIBUTE (BORDER,FORM LINE
FIRST + 1,PROMPT LINE LAST)
DISPLAY arr_cotiza[curr].nombre_p TO descrip_esp ATTRIBUTE(BLUE)
DISPLAY arr_cotiza[curr].unidad TO unidad_med ATTRIBUTE(BLUE)
DISPLAY arr_cotiza[curr].area TO area ATTRIBUTE(BLUE)
DISPLAY arr_cotiza[curr].nombre_area TO descripcion_area ATTRIBUTE(BLUE)
CALL despiece.clear()
IF actualiza = "N" THEN
LET p_vetb50.cotizacion_no = tmpnumero1
DECLARE busca_despiece CURSOR FOR
SELECT a.etiqueta,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,a.lado_1,a.lado_2,a.lado_3,a.cantidad,a.medida
FROM vetb00022 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
# a.secuencia = curr AND
a.area = arr_cotiza[curr].area AND
a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec
LET idx = 1
FOREACH busca_despiece INTO despiece[idx].*
LET idx = idx + 1
END FOREACH
ELSE
DECLARE busca_despiece1 CURSOR FOR
SELECT a.etiqueta,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,
a.lado_1,a.lado_2,a.lado_3,a.cantidad,a.medida
FROM vetb00022 a
WHERE a.cotizacion_no = p_vetb50.cotizacion_no AND
#a.secuencia = curr AND
a.area = arr_cotiza[curr].area AND
a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec
LET idx = 1
FOREACH busca_despiece1 INTO despiece[idx].*
LET idx = idx + 1
END FOREACH
END IF
# LET despiece[1].cod_n = arr_cotiza[curr].cod_n
# LET despiece[1].cod_grupo = arr_cotiza[curr].cod_grupo
# LET despiece[1].cod_tipo = arr_cotiza[curr].cod_tipo
# LET despiece[1].cod_sec = arr_cotiza[curr].cod_sec
CALL set_count(idx-1)
INPUT ARRAY despiece WITHOUT DEFAULTS FROM sdespiece.*
BEFORE ROW
LET curr1 = arr_curr()
LET fila = scr_line()
# LET petiquetas = ui.ComboBox.forName("formonly.etiqueta")
CALL cetiquetas()
LET despiece[curr1].cod_n = arr_cotiza[curr].cod_n
LET despiece[curr1].cod_grupo = arr_cotiza[curr].cod_grupo
LET despiece[curr1].cod_tipo = arr_cotiza[curr].cod_tipo
LET despiece[curr1].cod_sec = arr_cotiza[curr].cod_sec
IF curr1 > 1 THEN
IF despiece[curr1].etiqueta IS NULL THEN
LET despiece[curr1].etiqueta = despiece[curr1-1].etiqueta
END IF
END IF
DISPLAY despiece[curr1].etiqueta TO sdespiece[fila].etiqueta
DISPLAY arr_cotiza[curr].cod_n TO sdespiece[fila].cod_n
DISPLAY arr_cotiza[curr].cod_grupo TO sdespiece[fila].cod_grupo
DISPLAY arr_cotiza[curr].cod_tipo TO sdespiece[fila].cod_tipo
DISPLAY arr_cotiza[curr].cod_sec TO sdespiece[fila].cod_sec
AFTER FIELD cantidad
IF arr_cotiza[curr].unidad = "M2" THEN
LET despiece[curr1].medida =
despiece[curr1].cantidad * (despiece[curr1].lado_1 * despiece[curr1].lado_2)
END IF
IF arr_cotiza[curr].unidad= "M3" THEN
LET despiece[curr1].medida =
despiece[curr1].cantidad * (despiece[curr1].lado_1 * despiece[curr1].lado_2 * despiece[curr1].lado_3)
END IF
IF arr_cotiza[curr].unidad= "ML" THEN
LET despiece[curr1].medida =
despiece[curr1].cantidad * despiece[curr1].lado_1
LET despiece[curr1].lado_2 = 0
END IF
IF arr_cotiza[curr].unidad= "UD" OR arr_cotiza[curr].unidad= "GL" THEN
LET despiece[curr1].medida = despiece[curr1].cantidad
END IF
DISPLAY despiece[curr1].medida TO sdespiece[fila].medida
AFTER ROW
IF despiece[curr1].medida IS NULL AND despiece[curr1].lado_1 IS NOT NULL THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD lado_1
END IF
LET total_medida = 0
FOR idx = 1 TO arr_count()
IF despiece[idx].medida IS NOT NULL THEN
LET total_medida = total_medida + despiece[idx].medida
END IF
END FOR
DISPLAY BY NAME total_medida
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
EXIT INPUT
END IF
LET total_medida = 0
LET vuelve = FALSE
FOR idx = 1 TO despiece.getLength()
IF despiece[idx].lado_1 IS NOT NULL AND
despiece[idx].cantidad IS NULL THEN
CALL msg(16)
NEXT FIELD cantidad
END IF
IF despiece[idx].medida IS NOT NULL THEN
IF despiece[idx].etiqueta IS NULL THEN
LET vuelve = TRUE
EXIT FOR
END IF
LET total_medida = total_medida + despiece[idx].medida
END IF
END FOR
IF vuelve THEN
CALL msg(16)
NEXT FIELD medida
CONTINUE INPUT
END IF
DISPLAY BY NAME total_medida
END INPUT
IF int_flag THEN
LET int_flag = FALSE
CLOSE WINDOW wdespiece
RETURN
END IF
# CONTROL NUMERICO
BEGIN WORK
#WHENEVER ERROR CONTINUE
DELETE FROM veTB00022 WHERE cotizacion_no = p_vetb50.cotizacion_no AND
# secuencia = curr AND
area = arr_cotiza[curr].area AND
cod_n = arr_cotiza[curr].cod_n AND
cod_grupo = arr_cotiza[curr].cod_grupo AND
cod_tipo = arr_cotiza[curr].cod_tipo AND
cod_sec = arr_cotiza[curr].cod_sec
IF SQLSTATE > 02 THEN
LET chmensaje = SQLERRMESSAGE CLIPPED,"NO ES POSIBLE GUARDAR LA TRANSACCION"
ROLLBACK WORK
CALL fgl_winmessage("ERROR",chmensaje,"STOP")
CLOSE WINDOW wdespiece
RETURN
END IF
LET total_medida = 0
FOR idx = 1 TO despiece.getLength()
IF despiece[idx].medida IS NOT NULL THEN
INSERT INTO vetb00022 VALUES (despiece[idx].etiqueta,p_vetb50.cotizacion_no,curr,
arr_cotiza[curr].area,arr_cotiza[curr].cod_n,arr_cotiza[curr].cod_grupo,
arr_cotiza[curr].cod_tipo,arr_cotiza[curr].cod_sec,
despiece[idx].lado_1,despiece[idx].lado_2,
despiece[idx].lado_3,despiece[idx].cantidad,
despiece[idx].medida,null,SUSER_SNAME(),GETDATE(),null,null)
IF SQLSTATE > 02 THEN
LET chmensaje = SQLERRMESSAGE CLIPPED,"NO ES POSIBLE GUARDAR LA TRANSACCION"
ROLLBACK WORK
CALL fgl_winmessage("ERROR",chmensaje,"STOP")
CLOSE WINDOW wdespiece
RETURN
END IF
LET total_medida = total_medida + despiece[idx].medida
END IF
END FOR
COMMIT WORK
LET arr_cotiza[curr].cantidad_1 = total_medida
CLOSE WINDOW wdespiece
END FUNCTION
FUNCTION control_vendedor(xvendedor,xtipo,xcliente)
DEFINE xvendedor SMALLINT,
xtipo,xcliente INT,
existe BOOLEAN
# CONTROL VENDEDOR
LET existe = FALSE
IF xtipo IS NOT NULL THEN
SELECT UNIQUE a.sec_vend FROM vetb00028 a
WHERE a.tipo_cliente = xtipo AND
a.sec_cliente = xcliente and
a.sec_vend = xvendedor and
a.status_t is null
IF STATUS = NOTFOUND THEN
CALL fgl_winmessage("ERROR","USTED NO PUEDE VENDERLE A ESTE CLIENTE, TIENE EJECUTIVO ASINADO","STOP")
LET existe = TRUE
END IF
END IF
RETURN existe
END FUNCTION
FUNCTION busca_descripcion()
DEFINE pdescripcion LIKE iptb00002.descrip_esp
SELECT a.descrip_esp INTO pdescripcion
FROM iptb00002 a
WHERE a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec
RETURN pdescripcion
END FUNCTION
FUNCTION control_descuento()
DEFINE pporc DEC(12,2)
SELECT AVG(a.porc_Desc) INTO pporc FROM vetb00033 a
WHERE a.cod_n = arr_cotiza[curr].cod_n AND
a.cod_grupo = arr_cotiza[curr].cod_grupo AND
a.cod_tipo = arr_cotiza[curr].cod_tipo AND
a.cod_sec = arr_cotiza[curr].cod_sec AND
a.fecha_final > GETDATE() and a.fecha_inicial < GETDATE()
RETURN pporc
END FUNCTION
FUNCTION repite_codigo()
LET verdad = NULL
LET ant_art.area = arr_cotiza[curr].area
LET ant_art.cod_n = arr_cotiza[curr].cod_n
LET ant_art.cod_grupo = arr_cotiza[curr].cod_grupo
LET ant_art.cod_tipo = arr_cotiza[curr].cod_tipo
LET ant_art.cod_sec = arr_cotiza[curr].cod_sec
LET ant_art.cantidad = arr_cotiza[curr].cantidad
LET ant_art.precio = arr_cotiza[curr].precio
FOR idx = 1 TO arr_cotiza.getLength()
IF idx != curr THEN
IF arr_cotiza[idx].cod_n IS NOT NULL AND
arr_cotiza[idx].cod_grupo IS NOT NULL AND
arr_cotiza[idx].cod_tipo IS NOT NULL AND
arr_cotiza[idx].cod_sec IS NOT NULL THEN
IF arr_cotiza[idx].area = ant_art.area AND
arr_cotiza[idx].cod_n = ant_art.cod_n AND
arr_cotiza[idx].cod_grupo = ant_art.cod_grupo AND
arr_cotiza[idx].cod_tipo = ant_art.cod_tipo AND
arr_cotiza[idx].cod_sec = ant_art.cod_sec
THEN
LET numero_msg = 21
CALL msg(numero_msg)
LET verdad = "S"
ELSE
IF verdad != "S" THEN
LET verdad = "N"
END IF
END IF
END IF
END IF
END FOR
END FUNCTION