185 lines
6.7 KiB
Plaintext
185 lines
6.7 KiB
Plaintext
FUNCTION ccvisualiza_detalle_kit(pkit,pcantidad)
|
|
DEFINE pkit INT,
|
|
idx,pcantidad SMALLINT
|
|
|
|
DEFINE arr_kit1 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),
|
|
valor DEC(12,2)
|
|
END RECORD,
|
|
arr_kit_p 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,
|
|
pfactor DEC(12,5)
|
|
|
|
OPEN WINDOW w1 WITH FORM "visualiza_detalle_kit"
|
|
|
|
DECLARE busca_kit CURSOR FOR
|
|
SELECT a.area,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,b.descrip_esp,a.cantidad,a.porc_desc,a.precio
|
|
FROM vetb0031 a,iptb00002 b
|
|
WHERE a.id_kit = pkit AND
|
|
a.cod_n = b.cod_n AND a.cod_grupo = b.cod_grupo AND a.cod_tipo = b.cod_tipo AND
|
|
a.cod_sec = b.cod_sec
|
|
LET idx = 1
|
|
FOREACH busca_kit INTO arr_kit1[idx].*
|
|
SELECT a.factor_conv INTO pfactor FROM iptb00001 a WHERE
|
|
a.cod_n = arr_kit1[idx].cod_n AND
|
|
a.cod_grupo = arr_kit1[idx].cod_grupo AND
|
|
a.cod_tipo = arr_kit1[idx].cod_tipo AND
|
|
a.cod_sec = arr_kit1[idx].cod_sec
|
|
IF pfactor IS NULL THEN
|
|
LET pfactor = 1
|
|
END IF
|
|
LET arr_kit_p[idx].area =arr_kit1[idx].area
|
|
LET arr_kit_p[idx].cod_n =arr_kit1[idx].cod_n
|
|
LET arr_kit_p[idx].cod_grupo =arr_kit1[idx].cod_grupo
|
|
LET arr_kit_p[idx].cod_tipo =arr_kit1[idx].cod_tipo
|
|
LET arr_kit_p[idx].cod_sec =arr_kit1[idx].cod_sec
|
|
LET arr_kit_p[idx].cantidad =arr_kit1[idx].cantidad *pfactor
|
|
LET arr_kit_p[idx].precio =arr_kit1[idx].precio
|
|
LET arr_kit_p[idx].porc_desc = arr_kit1[idx].porc_desc
|
|
|
|
LET arr_kit1[idx].valor = (arr_kit1[idx].cantidad*arr_kit1[idx].precio)
|
|
# - ((arr_kit1[idx].cantidad*arr_kit1[idx].precio) * (arr_kit1[idx].porc_desc/100))
|
|
LET idx = idx + 1
|
|
END FOREACH
|
|
DISPLAY ARRAY arr_kit1 TO record1.*
|
|
CLOSE WINDOW w1
|
|
RETURN arr_kit_p
|
|
END FUNCTION
|
|
FUNCTION duplica_kit(xkit)
|
|
DEFINE kid,xkit INT,
|
|
inserta STRING
|
|
|
|
SELECT MAX(a.id_kit) INTO kid FROM vetb00029 a
|
|
IF kid IS NULL THEN
|
|
LET kid = 0
|
|
END IF
|
|
LET kid = kid + 1
|
|
LET inserta =
|
|
"INSERT INTO vetb00029 (cod_n,cod_grupo,cod_tipo,cod_sec,id_kit,descripcion,disponible,valor_total,us_crea,fech_crea) ",
|
|
"SELECT cod_n,cod_grupo,cod_tipo,cod_sec,'",kid,"',descripcion,disponible,valor_total,us_crea,fech_crea ",
|
|
" FROM vetb00029 ",
|
|
" WHERE id_kit =?"
|
|
|
|
PREPARE inscomando FROM inserta
|
|
EXECUTE inscomando USING xkit
|
|
|
|
LET inserta =
|
|
"INSERT INTO vetb00030 (cod_n,cod_grupo,cod_tipo,cod_sec,cantidad,precio,porc_Desc,id_kit) ",
|
|
"SELECT cod_n,cod_grupo,cod_tipo,cod_sec,cantidad,precio,porc_desc,'",kid,"'",
|
|
" FROM vetb00030 ",
|
|
" WHERE id_kit =?"
|
|
|
|
PREPARE inscomando1 FROM inserta
|
|
EXECUTE inscomando1 USING xkit
|
|
RETURN kid
|
|
END FUNCTION
|
|
FUNCTION modifica_detalle_kit(pkit,pcotizacion)
|
|
DEFINE pkit,pcotizacion INT,
|
|
idx SMALLINT
|
|
|
|
DEFINE arr_kit1 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),
|
|
valor DEC(12,2)
|
|
END RECORD,
|
|
total_neto,total_bruto,total_desc DEC(12,2)
|
|
|
|
OPEN WINDOW w1 WITH FORM "modifica_detalle_kit"
|
|
|
|
DECLARE busca_kit_cotizado CURSOR FOR
|
|
SELECT a.area,a.cod_n,a.cod_grupo,a.cod_tipo,a.cod_sec,b.descrip_esp,a.cantidad,a.precio,a.porc_desc
|
|
FROM vetb00031 a,iptb00002 b
|
|
WHERE a.id_kit = pkit AND
|
|
a.cotizacion_no = pcotizacion AND
|
|
a.cod_n = b.cod_n AND a.cod_grupo = b.cod_grupo AND a.cod_tipo = b.cod_tipo AND
|
|
a.cod_sec = b.cod_sec
|
|
LET idx = 1
|
|
LET total_bruto = 0
|
|
LET total_neto = 0
|
|
LET total_desc = 0
|
|
FOREACH busca_kit_cotizado INTO arr_kit1[idx].*
|
|
let total_bruto = (arr_kit1[idx].cantidad* arr_kit1[idx].precio) + total_bruto
|
|
LET total_desc = ((arr_kit1[idx].cantidad* arr_kit1[idx].precio) * (arr_kit1[idx].porc_desc/100) ) + total_desc
|
|
|
|
LET arr_kit1[idx].valor = (arr_kit1[idx].cantidad *arr_kit1[idx].precio)
|
|
- ((arr_kit1[idx].cantidad*arr_kit1[idx].precio) * (arr_kit1[idx].porc_desc/100))
|
|
LET idx = idx + 1
|
|
END FOREACH
|
|
LET total_neto = total_bruto - total_Desc
|
|
DISPLAY BY NAME total_bruto,total_desc,total_neto
|
|
CALL set_count(idx-1)
|
|
INPUT ARRAY arr_kit1 WITHOUT DEFAULTS FROM record1.*
|
|
BEFORE INPUT
|
|
NEXT FIELD precio
|
|
AFTER ROW
|
|
LET total_bruto = 0
|
|
LET total_neto = 0
|
|
LET total_desc = 0
|
|
FOR idx = 1 TO arr_kit1.getLength()
|
|
IF arr_kit1[idx].cod_n IS NOT NULL THEN
|
|
let total_bruto = (arr_kit1[idx].cantidad* arr_kit1[idx].precio) + total_bruto
|
|
LET total_desc = ((arr_kit1[idx].cantidad* arr_kit1[idx].precio) * (arr_kit1[idx].porc_desc/100) ) + total_desc
|
|
|
|
LET arr_kit1[idx].valor = (arr_kit1[idx].cantidad *arr_kit1[idx].precio)
|
|
- ((arr_kit1[idx].cantidad*arr_kit1[idx].precio) * (arr_kit1[idx].porc_desc/100))
|
|
|
|
END IF
|
|
END FOR
|
|
LET total_neto = total_bruto - total_Desc
|
|
DISPLAY BY NAME total_bruto,total_desc,total_neto
|
|
|
|
AFTER INPUT
|
|
IF INT_FLAG THEN
|
|
CALL fgl_winmessage("SALIR","OPERACION CANCELADA","INFO")
|
|
EXIT INPUT
|
|
END IF
|
|
BEGIN WORK
|
|
DELETE FROM vetb00031 WHERE cotizacion_no = pcotizacion AND id_kit = pkit
|
|
|
|
FOR idx = 1 TO arr_kit1.getLength()
|
|
IF arr_kit1[idx].cod_n IS NOT NULL THEN
|
|
INSERT INTO vetb00031 (cotizacion_no,id_kit,area,cod_n,cod_grupo,cod_tipo,cod_sec,cantidad,precio,porc_desc)
|
|
VALUES (pcotizacion,pkit,arr_kit1[idx].area,arr_kit1[idx].cod_n,arr_kit1[idx].cod_grupo,arr_kit1[idx].cod_tipo,arr_kit1[idx].cod_sec,
|
|
arr_kit1[idx].cantidad,arr_kit1[idx].precio,arr_kit1[idx].porc_desc)
|
|
IF STATUS < 0 THEN
|
|
ROLLBACK WORK
|
|
CALL fgl_winmessage("ERROR","OCURRIO UN ERROR AL TRATAR DE MODIFICAR LOS COMPONENTES DEL KIT","INFO")
|
|
EXIT FOR
|
|
END IF
|
|
END IF
|
|
END FOR
|
|
COMMIT WORK
|
|
CALL fgl_winmessage("ACTUALIZAR","ACTUALIZACION EXITOSA","INFO")
|
|
EXIT INPUT
|
|
END INPUT
|
|
LET INT_FLAG = FALSE
|
|
|
|
CLOSE WINDOW w1
|
|
|
|
END FUNCTION
|