940 lines
29 KiB
Plaintext
940 lines
29 KiB
Plaintext
{
|
|
------------------------------------------------------------------------------
|
|
PROGRAMA : LQPRMT002
|
|
OBJETIVO : Liquidacion
|
|
PROGRAMADOR : Ing. Luis Miguel Soto
|
|
-----------------------------------------------------------------------------
|
|
}
|
|
IMPORT util
|
|
IMPORT os
|
|
GLOBALS "lqprgb000.4gl"
|
|
DEFINE fecha DATE,detalle VARCHAR(80)
|
|
DEFINE ordenes DYNAMIC ARRAY OF RECORD
|
|
num_oc VARCHAR(30),
|
|
nom_cliente CHAR(80),
|
|
valor DECIMAL(12,2),
|
|
cod_sp,cod_sp_sec int,
|
|
bl,furgon,fact_no VARCHAR(50)
|
|
END RECORD
|
|
|
|
DEFINE totalgeneral DECIMAL(12,2)
|
|
DEFINE totalorden DECIMAL(12,2)
|
|
DEFINE contador INT
|
|
|
|
DEFINE scr_l,idx,idx1,idx2,idx3,lg INTEGER
|
|
DEFINE criterio,selec1,selec2,selec3,selec STRING
|
|
|
|
DEFINE operac ui.combobox,
|
|
num_doc INT,impuesto CHAR(2)
|
|
|
|
DEFINE opera DYNAMIC ARRAY OF RECORD
|
|
operacion VARCHAR(50),
|
|
doc VARCHAR(30),
|
|
valor1 DECIMAL(12,2)
|
|
END RECORD
|
|
DEFINE final DYNAMIC ARRAY OF RECORD
|
|
orden1 VARCHAR(30),
|
|
operacion1 VARCHAR(50),
|
|
valor2 DECIMAL(12,2),
|
|
num_opera int
|
|
END RECORD
|
|
DEFINE final_mirror DYNAMIC ARRAY OF RECORD
|
|
orden1 VARCHAR(30),
|
|
operacion1 VARCHAR(50),
|
|
valor2 DECIMAL(12,2),
|
|
num_opera int
|
|
END RECORD
|
|
DEFINE opera_tmp DYNAMIC ARRAY OF RECORD
|
|
operacion VARCHAR(50),
|
|
doc VARCHAR(30),
|
|
valor1 DECIMAL(12,2)
|
|
END RECORD
|
|
|
|
DEFINE num DYNAMIC ARRAY OF RECORD
|
|
num_oc VARCHAR(30)
|
|
END RECORD,
|
|
|
|
|
|
consulta DYNAMIC ARRAY OF RECORD
|
|
num_doc_ret1 INT,
|
|
fecha1 DATE,
|
|
detalle1 VARCHAR(80),
|
|
total DECIMAL(12,2)
|
|
END RECORD
|
|
|
|
DEFINE codigo INT,tt decimal(12,2)
|
|
|
|
|
|
MAIN
|
|
DEFER INTERRUPT
|
|
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 "smarmotech" AS "MSSQL" USER usuarios USING clave
|
|
|
|
CALL lqprmt021()
|
|
END MAIN
|
|
|
|
FUNCTION lqprmt021()
|
|
|
|
CLEAR SCREEN
|
|
OPTIONS
|
|
FORM LINE 8,
|
|
ERROR LINE 23,
|
|
COMMENT LINE 23
|
|
|
|
OPEN WINDOW lqfmmt002 AT 4,3 WITH FORM "lqfmmt002"
|
|
|
|
MENU
|
|
ON ACTION nuevo
|
|
LET INT_FLAG = FALSE
|
|
CLEAR FORM
|
|
|
|
SET CONNECTION "MSSQL"
|
|
CALL ordenes.clear()
|
|
CALL final.clear()
|
|
CALL opera.clear()
|
|
CALL lqcad002()
|
|
ON ACTION consulta
|
|
LET INT_FLAG = FALSE
|
|
CLEAR FORM
|
|
CALL ordenes.clear()
|
|
CALL final.clear()
|
|
CALL opera.clear()
|
|
CALL lqprmf002()
|
|
SET CONNECTION "MSSQL"
|
|
|
|
ON ACTION salir
|
|
EXIT MENU
|
|
END MENU
|
|
END FUNCTION
|
|
|
|
|
|
FUNCTION lqcad002()
|
|
|
|
DIALOG ATTRIBUTES(UNBUFFERED,FIELD ORDER FORM)
|
|
INPUT BY NAME fecha,detalle
|
|
BEFORE INPUT
|
|
|
|
LET fecha=today USING "dd/mm/yyyy"
|
|
|
|
END INPUT
|
|
INPUT array ordenes FROM sordenes.* ATTRIBUTE(WITHOUT DEFAULTS)
|
|
|
|
BEFORE input
|
|
LET scr_l = scr_line()
|
|
LET idx = arr_curr()
|
|
SELECT ult_doc INTO num_doc FROM cotb00041
|
|
IF num_doc IS NULL THEN
|
|
LET num_doc=+1
|
|
ELSE
|
|
LET num_doc=num_doc+1
|
|
END IF
|
|
DISPLAY BY NAME num_doc
|
|
LET selec1 =
|
|
" SELECT b.nom_sp,a.neto,a.cod_sp,a.cod_sp_sec ",
|
|
"FROM cotb00014 a,cotb00001 b ",
|
|
"WHERE a.cod_sp_sec=b.cod_sp_sec and ",
|
|
"a.cod_sp=b.cod_sp and a.status_t is null and a.num_oc=?"
|
|
|
|
PREPARE comand3 FROM selec1
|
|
|
|
ON ACTION busca_orden
|
|
LET curr = arr_curr()
|
|
LET scr_l = scr_line()
|
|
CALL buscar_orden() RETURNING ordenes[curr].*
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = false
|
|
NEXT FIELD num_oc
|
|
END IF
|
|
AFTER FIELD num_oc
|
|
LET idx = arr_curr()
|
|
|
|
IF ordenes[idx].num_oc IS NOT NULL THEN
|
|
EXECUTE comand3 USING ordenes[idx].num_oc INTO ordenes[idx].nom_cliente,ordenes[idx].valor,
|
|
ordenes[idx].cod_sp,ordenes[idx].cod_sp_sec
|
|
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD num_oc
|
|
ELSE
|
|
LET tt=0
|
|
FOR idx1=1 TO ordenes.getLength()
|
|
|
|
LET tt=tt+ordenes[idx1].valor
|
|
DISPLAY BY NAME tt
|
|
END FOR
|
|
DISPLAY ordenes[idx].nom_cliente TO sordenes[scr_l].nom_cliente
|
|
|
|
DISPLAY ordenes[idx].valor TO sordenes[scr_l].valor
|
|
|
|
END IF
|
|
|
|
|
|
END IF
|
|
|
|
END INPUT
|
|
INPUT ARRAY opera FROM soperaciones.* ATTRIBUTE(WITHOUT DEFAULTS)
|
|
|
|
BEFORE INPUT
|
|
LET scr_l = scr_line()
|
|
CALL coperaciones()
|
|
|
|
|
|
ON ACTION calcular
|
|
LET lg=opera.getlength()*ordenes.getlength()
|
|
DELETE FROM cotbtmp
|
|
|
|
LET totalgeneral = 0
|
|
LET idx = 1
|
|
|
|
WHILE idx <= opera.getLength()
|
|
|
|
SELECT b.impuesto INTO impuesto FROM cotb00043 b
|
|
WHERE b.codigo=opera[idx].operacion
|
|
|
|
DISPLAY opera[idx].operacion,"imp",impuesto
|
|
IF impuesto ="NO" OR impuesto IS NULL THEN
|
|
DISPLAY opera[idx].operacion,"imp",impuesto
|
|
|
|
LET idx2 = 1
|
|
|
|
WHILE idx2 <= ordenes.getLength()
|
|
|
|
SELECT a.descripcion INTO final[idx].operacion1 FROM cotb00043 a
|
|
WHERE a.codigo=opera[idx].operacion
|
|
|
|
LET final[idx].orden1=ordenes[idx2].num_oc
|
|
LET final[idx].valor2=ordenes[idx2].valor/tt*opera[idx].valor1
|
|
LET final[idx].num_opera=opera[idx].operacion
|
|
|
|
IF final[idx].num_opera != 9 THEN
|
|
|
|
LET totalgeneral = totalgeneral + final[idx].valor2
|
|
|
|
END IF
|
|
|
|
{ SELECT MAX(numero) INTO final[idx].numero FROM cotbtmp
|
|
IF final[idx].numero IS NULL THEN
|
|
LET final[idx].numero=1
|
|
ELSE
|
|
LET final[idx].numero=final[idx].numero +1
|
|
END IF }
|
|
IF final[idx].valor2 IS NOT NULL THEN
|
|
INSERT INTO cotbtmp
|
|
VALUES(final[idx].orden1,final[idx].operacion1,final[idx].valor2,final[idx].num_opera)
|
|
END IF
|
|
{ DISPLAY BY NAME final[idx].operacion1
|
|
DISPLAY BY NAME final[idx].orden1
|
|
DISPLAY BY NAME final[idx].valor2
|
|
DISPLAY BY NAME final[idx].num_opera}
|
|
LET idx2 = idx2 + 1
|
|
END WHILE
|
|
END IF
|
|
LET idx = idx + 1
|
|
END WHILE
|
|
|
|
LET idx = 1
|
|
DISPLAY BY NAME totalgeneral
|
|
|
|
DECLARE busca1 CURSOR FOR
|
|
SELECT distinct a.numero,a.orden,a.operacion,a.valor
|
|
FROM cotbtmp a
|
|
ORDER BY a.orden
|
|
LET idx=1
|
|
|
|
LET totalgeneral = 0
|
|
LET totalorden = 0
|
|
LET contador = 0
|
|
|
|
FOREACH busca1 INTO final[idx].num_opera,final[idx].orden1,
|
|
final[idx].operacion1,final[idx].valor2
|
|
|
|
IF final[idx].num_opera != 9 THEN
|
|
|
|
LET totalgeneral = totalgeneral + final[idx].valor2
|
|
|
|
END IF
|
|
|
|
DISPLAY final[idx].operacion1 TO record1[idx].operacion1
|
|
DISPLAY final[idx].orden1 TO record1[idx].orden1
|
|
DISPLAY final[idx].valor2 TO record1[idx].valor2
|
|
|
|
|
|
let idx=idx+1
|
|
END FOREACH
|
|
|
|
DISPLAY opera[idx].doc TO soperaciones[scr_l].doc
|
|
DISPLAY opera[idx].operacion TO soperaciones[scr_l].operacion
|
|
DISPLAY opera[idx].valor1 TO soperaciones[scr_l].valor1
|
|
# DISPLAY ARRAY opera TO soperaciones[scr_l].*
|
|
DISPLAY ARRAY final TO record1[scr_l].*
|
|
DISPLAY BY NAME totalgeneral
|
|
|
|
END INPUT
|
|
ON ACTION guardar
|
|
|
|
{ IF ordenes[arr_curr()].num_oc IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD num_oc
|
|
END IF
|
|
|
|
IF opera[arr_curr()].operacion IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD operacion
|
|
END IF
|
|
|
|
IF final[arr_curr()].operacion1 IS NULL OR final[arr_curr()].valor2 IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD operacion
|
|
END IF }
|
|
LET num_doc = null
|
|
SELECT ult_doc INTO num_doc FROM cotb00041
|
|
IF status = notfound THEN
|
|
LET num_doc=0
|
|
INSERT INTO cotb00041
|
|
VALUES(num_doc,usuarios,getdate())
|
|
END IF
|
|
|
|
LET num_doc=num_doc+1
|
|
|
|
BEGIN WORK
|
|
UPDATE cotb00041
|
|
SET ult_doc=num_doc,
|
|
us_crea=usuarios,fech_crea=getdate()
|
|
|
|
INSERT INTO cotb00040
|
|
VALUES(num_doc,fecha,detalle,tt,usuarios,getdate(),NULL,null)
|
|
FOR idx=1 TO ordenes.getLength()
|
|
IF ordenes[idx].num_oc IS NOT NULL THEN
|
|
INSERT INTO cotb00044(num_doc_ret,orden,cod_sp,cod_sp_sec,nom_sup,valor,us_crea,fech_crea,bl,furgon,fact_no)
|
|
VALUES(num_doc,ordenes[idx].num_oc,ordenes[idx].cod_sp,ordenes[idx].cod_sp_sec,
|
|
ordenes[idx].nom_cliente,ordenes[idx].valor,usuarios,getdate(),ordenes[idx].bl,ordenes[idx].furgon,ordenes[idx].fact_no)
|
|
END IF
|
|
END FOR
|
|
FOR idx = 1 TO opera.getLength()
|
|
|
|
IF opera[idx].operacion IS NOt NULL THEN
|
|
INSERT INTO cotb00045(num_doc_ret,operacion,doc,valor,us_crea,fech_crea)
|
|
VALUES(num_doc,opera[idx].operacion,opera[idx].doc,opera[idx].valor1,usuarios,getdate())
|
|
END IF
|
|
END FOR
|
|
|
|
FOR idx = 1 TO final.getLength()
|
|
|
|
IF final[idx].operacion1 IS NOT NULL THEN
|
|
INSERT INTO cotb00046(num_doc_ret,orden,operacion,valor,us_crea,fech_crea,num_opera)
|
|
VALUES(num_doc,final[idx].orden1,final[idx].operacion1,final[idx].valor2,usuarios,getdate(),final[idx].num_opera)
|
|
END IF
|
|
END FOR
|
|
|
|
IF status<0 THEN
|
|
ROLLBACK WORK
|
|
CALL fgl_winmessage("error","NO SE PUDO ADICIONAR","STOP")
|
|
ELSE
|
|
COMMIT WORK
|
|
|
|
LET r_filename ="lqprmt002.4rp"
|
|
LET r_output = "SVG"
|
|
#LET preview = 1
|
|
|
|
-- configure report engine; the functions prefixed fgl that are called here are part of the GRW API
|
|
IF fgl_report_loadCurrentSettings(r_filename) THEN -- load the .4rp file
|
|
CALL fgl_report_selectDevice(r_output) -- changing default
|
|
|
|
CALL fgl_report_selectPreview(1)
|
|
|
|
LET handler = fgl_report_commitCurrentSettings() -- commit changes
|
|
ELSE
|
|
EXIT PROGRAM
|
|
END IF
|
|
START REPORT liquidacion TO XML HANDLER handler
|
|
|
|
FOR idx = 1 TO arr_count()
|
|
# IF final[idx].operacion1 IS NOT NULL THEN
|
|
OUTPUT TO REPORT liquidacion(ordenes[idx].*,opera[idx].*,final[idx].*)
|
|
# END IF
|
|
END FOR
|
|
FINISH REPORT liquidacion
|
|
|
|
LET numero_msg = 13
|
|
CALL msg(numero_msg)
|
|
RETURN
|
|
END IF
|
|
|
|
ON ACTION CANCEL
|
|
LET int_flag = FALSE
|
|
CALL ordenes.clear()
|
|
CALL opera.clear()
|
|
CLEAR FORM
|
|
EXIT DIALOG
|
|
END DIALOG
|
|
END FUNCTION
|
|
|
|
FUNCTION actualizar()
|
|
DIALOG ATTRIBUTES (UNBUFFERED,FIELD ORDER FORM )
|
|
INPUT BY NAME fecha,detalle
|
|
|
|
BEFORE INPUT
|
|
LET tt=0
|
|
LET num_doc=consulta[curr].num_doc_ret1
|
|
LET fecha=consulta[curr].fecha1
|
|
LET detalle=consulta[curr].detalle1
|
|
LET tt=consulta[curr].total USING "###,###,###.##"
|
|
|
|
DISPLAY BY NAME tt,num_doc,fecha,detalle
|
|
|
|
END INPUT
|
|
INPUT ARRAY ordenes FROM sordenes.* ATTRIBUTE(WITHOUT DEFAULTS, AUTO APPEND = FALSE )
|
|
|
|
BEFORE INPUT
|
|
LET scr_l = scr_line()
|
|
# LET curr = arr_curr()
|
|
|
|
|
|
IF ordenes[curr].num_oc IS NULL THEN
|
|
LET selec= "SELECT a.orden,a.cod_sp,a.cod_sp_sec,a.nom_sup,a.valor,a.bl,a.furgon,a.fact_no ",
|
|
" FROM cotb00044 a ",
|
|
" WHERE a.num_doc_ret=", num_doc," ",
|
|
" ORDER BY a.orden"
|
|
|
|
PREPARE comando1 FROM selec
|
|
DECLARE busca4 CURSOR FOR comando1
|
|
LET idx=1
|
|
# FOREACH busca4 INTO ordenes[idx].num_oc,ordenes[idx].cod_sp,ordenes[idx].cod_sp_sec,
|
|
#ordenes[idx].nom_cliente,ordenes[idx].valor
|
|
FOREACH busca4 INTO ordenes[idx].num_oc,ordenes[idx].cod_sp,ordenes[idx].cod_sp_sec,
|
|
ordenes[idx].nom_cliente,ordenes[idx].valor,ordenes[idx].bl,ordenes[idx].furgon,ordenes[idx].fact_no
|
|
|
|
DISPLAY ordenes[idx].num_oc TO sordenes[idx].num_oc
|
|
DISPLAY ordenes[idx].nom_cliente TO sordenes[idx].nom_cliente
|
|
DISPLAY ordenes[idx].valor TO sordenes[idx].valor
|
|
DISPLAY ordenes[idx].fact_no TO sordenes[idx].fact_no
|
|
DISPLAY ordenes[idx].bl TO sordenes[idx].bl
|
|
DISPLAY ordenes[idx].furgon TO sordenes[idx].furgon
|
|
|
|
LET idx=idx+1
|
|
|
|
END FOREACH
|
|
END IF
|
|
AFTER FIELD num_oc
|
|
LET idx = arr_curr()
|
|
IF ordenes[idx].num_oc IS NOT NULL THEN
|
|
LET selec1 =
|
|
" SELECT b.nom_sp,a.neto,a.cod_sp,a.cod_sp_sec ",
|
|
"FROM cotb00014 a,cotb00001 b ",
|
|
"WHERE a.cod_sp_sec=b.cod_sp_sec and ",
|
|
"a.cod_sp=b.cod_sp and a.status_t is null and a.num_oc=?"
|
|
|
|
PREPARE comand4 FROM selec1
|
|
|
|
EXECUTE comand4 USING ordenes[idx].num_oc INTO ordenes[idx].nom_cliente,ordenes[idx].valor,
|
|
ordenes[idx].cod_sp,ordenes[idx].cod_sp_sec
|
|
|
|
IF STATUS = NOTFOUND THEN
|
|
LET numero_msg = 3
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD num_oc
|
|
ELSE
|
|
LET tt=0
|
|
FOR idx1=1 TO ordenes.getLength()
|
|
|
|
LET tt=tt+ordenes[idx1].valor
|
|
|
|
DISPLAY BY NAME tt
|
|
END FOR
|
|
DISPLAY ordenes[idx].nom_cliente TO sordenes[scr_l].nom_cliente
|
|
|
|
DISPLAY ordenes[idx].valor TO sordenes[scr_l].valor
|
|
|
|
END IF
|
|
END IF
|
|
|
|
AFTER INPUT
|
|
|
|
IF ordenes[arr_curr()].num_oc IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD num_oc
|
|
END IF
|
|
|
|
IF opera[arr_curr()].operacion IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD operacion
|
|
END IF
|
|
|
|
IF final[arr_curr()].operacion1 IS NULL OR final[arr_curr()].valor2 IS NULL THEN
|
|
LET numero_msg = 16
|
|
CALL msg(numero_msg)
|
|
NEXT FIELD operacion
|
|
END IF
|
|
END INPUT
|
|
INPUT ARRAY opera FROM soperaciones.* ATTRIBUTE(WITHOUT DEFAULTS)
|
|
|
|
BEFORE INPUT
|
|
LET scr_l = scr_line()
|
|
LET curr = arr_curr()
|
|
CALL coperaciones()
|
|
IF opera[curr].operacion IS NULL THEN
|
|
|
|
LET selec1="select unique a.operacion ,a.doc,a.valor from cotb00045 a",
|
|
" where a.num_doc_ret=", num_doc
|
|
|
|
PREPARE comando2 FROM selec1
|
|
DECLARE busca2 CURSOR FOR comando2
|
|
|
|
LET idx=1
|
|
FOREACH busca2 INTO opera_tmp[idx].operacion,opera_tmp[idx].doc,opera_tmp[idx].valor1
|
|
LET opera[idx].doc=opera_tmp[idx].doc
|
|
LET opera[idx].operacion=opera_tmp[idx].operacion
|
|
LET opera[idx].valor1=opera_tmp[idx].valor1
|
|
|
|
|
|
DISPLAY opera[idx].operacion TO soperaciones[idx].operacion
|
|
DISPLAY opera[idx].doc TO soperaciones[idx].doc
|
|
DISPLAY opera[idx].valor1 TO soperaciones[idx].valor1
|
|
LET idx=idx+1
|
|
END FOREACH
|
|
END IF
|
|
LET selec2="select unique a.orden ,a.operacion,a.valor, a.num_opera from cotb00046 a",
|
|
" where a.num_doc_ret=", num_doc
|
|
|
|
PREPARE comando3 FROM selec2
|
|
DECLARE busca3 CURSOR FOR comando3
|
|
|
|
LET idx=1
|
|
LET totalgeneral = 0
|
|
FOREACH busca3 INTO final[idx].orden1,final[idx].operacion1,final[idx].valor2, final[idx].num_opera
|
|
|
|
IF final[idx].num_opera != 9 THEN
|
|
|
|
LET totalgeneral = totalgeneral + final[idx].valor2
|
|
|
|
END IF
|
|
|
|
DISPLAY final[idx].operacion1 TO record1[idx].operacion1
|
|
DISPLAY final[idx].orden1 TO record1[idx].orden1
|
|
DISPLAY final[idx].valor2 TO record1[idx].valor2
|
|
|
|
LET idx=idx+1
|
|
END FOREACH
|
|
|
|
DISPLAY BY NAME totalgeneral
|
|
|
|
ON ACTION calcular
|
|
|
|
DELETE FROM cotbtmp
|
|
|
|
LET idx = 1
|
|
|
|
WHILE idx <= opera.getLength()
|
|
SELECT b.impuesto INTO impuesto FROM cotb00043 b
|
|
WHERE b.codigo=opera[idx].operacion
|
|
|
|
DISPLAY opera[idx].operacion,"imp",impuesto
|
|
IF impuesto ="NO" OR impuesto IS NULL THEN
|
|
|
|
LET idx2 = 1
|
|
WHILE idx2 <= ordenes.getLength()
|
|
|
|
SELECT a.descripcion INTO final[idx].operacion1 FROM cotb00043 a
|
|
WHERE a.codigo=opera[idx].operacion
|
|
|
|
LET final[idx].orden1=ordenes[idx2].num_oc
|
|
LET final[idx].valor2=ordenes[idx2].valor/tt*opera[idx].valor1
|
|
LET final[idx].num_opera=opera[idx].operacion
|
|
DISPLAY "final",final[idx].valor2
|
|
DISPLAY final[idx].*
|
|
IF final[idx].valor2 IS NOT NULL THEN
|
|
INSERT INTO cotbtmp
|
|
VALUES(final[idx].orden1,final[idx].operacion1,final[idx].valor2,final[idx].num_opera)
|
|
END IF
|
|
DISPLAY BY NAME final[idx].operacion1
|
|
DISPLAY BY NAME final[idx].orden1
|
|
DISPLAY BY NAME final[idx].valor2
|
|
DISPLAY BY NAME final[idx].num_opera
|
|
|
|
LET idx2 = idx2 + 1
|
|
END WHILE
|
|
END IF
|
|
LET idx = idx + 1
|
|
END WHILE
|
|
DECLARE busca5 CURSOR FOR
|
|
SELECT distinct a.numero,a.orden,a.operacion,a.valor
|
|
FROM cotbtmp a
|
|
ORDER BY a.orden
|
|
LET idx=1
|
|
LET totalgeneral = 0
|
|
FOREACH busca5 INTO final[idx].num_opera,final[idx].orden1,final[idx].operacion1,final[idx].valor2
|
|
|
|
IF final[idx].num_opera != 9 THEN
|
|
|
|
LET totalgeneral = totalgeneral + final[idx].valor2
|
|
|
|
END IF
|
|
|
|
DISPLAY final[idx].operacion1 TO record1[idx].operacion1
|
|
DISPLAY final[idx].orden1 TO record1[idx].orden1
|
|
DISPLAY final[idx].valor2 TO record1[idx].valor2
|
|
|
|
let idx=idx+1
|
|
END FOREACH
|
|
|
|
DISPLAY BY NAME totalgeneral
|
|
|
|
# DISPLAY ARRAY final TO record1[scr_l].*
|
|
DISPLAY ARRAY opera TO soperaciones[scr_l].*
|
|
|
|
|
|
END INPUT
|
|
|
|
ON ACTION guardar
|
|
|
|
BEGIN WORK
|
|
UPDATE cotb00040 SET fecha = fecha,
|
|
us_mod = SUSER_SNAME(),
|
|
fech_mod = GETDATE() ,
|
|
detalle= detalle,
|
|
total=tt
|
|
WHERE num_doc_ret = num_doc
|
|
|
|
DELETE FROM cotb00044
|
|
WHERE num_doc_ret=num_doc
|
|
FOR idx=1 TO ordenes.getLength()
|
|
IF ordenes[idx].num_oc IS NOT NULL THEN
|
|
INSERT INTO cotb00044(num_doc_ret,orden,cod_sp,cod_sp_sec,nom_sup,valor,us_crea,fech_crea,bl,furgon,fact_no)
|
|
VALUES(num_doc,ordenes[idx].num_oc,ordenes[idx].cod_sp,ordenes[idx].cod_sp_sec,
|
|
ordenes[idx].nom_cliente,ordenes[idx].valor,usuarios,getdate(),ordenes[idx].bl,
|
|
ordenes[idx].furgon,ordenes[idx].fact_no)
|
|
END IF
|
|
END FOR
|
|
DELETE FROM cotb00045
|
|
WHERE num_doc_ret=num_doc
|
|
FOR idx = 1 TO opera.getLength()
|
|
IF opera[idx].operacion IS NOt NULL THEN
|
|
INSERT INTO cotb00045(num_doc_ret,operacion,doc,valor,us_crea,fech_crea)
|
|
VALUES(num_doc,opera[idx].operacion,opera[idx].doc,opera[idx].valor1,usuarios,getdate())
|
|
END IF
|
|
END FOR
|
|
DELETE FROM cotb00046
|
|
WHERE num_doc_ret=num_doc
|
|
FOR idx = 1 TO final.getLength()
|
|
IF final[idx].operacion1 IS NOT NULL THEN
|
|
INSERT INTO cotb00046(num_doc_ret,orden,operacion,valor,us_crea,fech_crea,num_opera)
|
|
VALUES(num_doc,final[idx].orden1,final[idx].operacion1,final[idx].valor2,usuarios,getdate(),final[idx].num_opera)
|
|
END IF
|
|
END FOR
|
|
|
|
IF status<0 THEN
|
|
ROLLBACK WORK
|
|
CALL fgl_winmessage("error","NO SE PUDO ACTUALIZAR","STOP")
|
|
ELSE
|
|
COMMIT WORK
|
|
LET r_filename ="lqprmt002.4rp"
|
|
LET r_output = "SVG"
|
|
#LET preview = 1
|
|
|
|
-- configure report engine; the functions prefixed fgl that are called here are part of the GRW API
|
|
IF fgl_report_loadCurrentSettings(r_filename) THEN -- load the .4rp file
|
|
CALL fgl_report_selectDevice(r_output) -- changing default
|
|
|
|
CALL fgl_report_selectPreview(1)
|
|
|
|
LET handler = fgl_report_commitCurrentSettings() -- commit changes
|
|
ELSE
|
|
EXIT PROGRAM
|
|
END IF
|
|
START REPORT liquidacion TO XML HANDLER handler
|
|
|
|
FOR idx = 1 TO arr_count()
|
|
# IF final[idx].operacion1 IS NOT NULL THEN
|
|
|
|
# OUTPUT TO REPORT liquidacion(final[arr_curr()].orden1,final[arr_curr()].operacion1,final[arr_curr()].valor2,
|
|
# final[arr_curr()].num_opera)
|
|
OUTPUT TO REPORT liquidacion(ordenes[idx].*,opera[idx].*,final[idx].*)
|
|
|
|
# END IF
|
|
END FOR
|
|
FINISH REPORT liquidacion
|
|
LET numero_msg = 13
|
|
CALL msg(numero_msg)
|
|
RETURN
|
|
END IF
|
|
|
|
ON ACTION CANCEL
|
|
LET int_flag = FALSE
|
|
CALL ordenes.clear()
|
|
CALL opera.clear()
|
|
CLEAR FORM
|
|
EXIT DIALOG
|
|
|
|
END DIALOG
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION coperaciones()
|
|
DEFINE kcodigo SMALLINT, kdescripcion CHAR(30)
|
|
|
|
LET operac = ui.combobox.forname("formonly.operacion")
|
|
|
|
DECLARE bopera CURSOR FOR
|
|
SELECT DISTINCT a.codigo,a.descripcion
|
|
FROM cotb00043 a
|
|
CALL operac.clear()
|
|
|
|
FOREACH bopera INTO kcodigo,kdescripcion
|
|
CALL operac.additem(kcodigo,kdescripcion)
|
|
END FOREACH
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION busca_operaciones(codigo)
|
|
DEFINE kcodigo SMALLINT, kdescripcion CHAR(30)
|
|
DEFINE codigo int
|
|
LET operac = ui.combobox.forname("formonly.operacion")
|
|
|
|
DECLARE bopera1 CURSOR FOR
|
|
SELECT DISTINCT a.codigo,a.descripcion
|
|
FROM cotb00043 a
|
|
WHERE a.codigo=codigo
|
|
CALL operac.clear()
|
|
|
|
FOREACH bopera1 INTO kcodigo,kdescripcion
|
|
CALL operac.additem(kcodigo,kdescripcion)
|
|
END FOREACH
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION lqprmf002()
|
|
|
|
CLEAR FORM
|
|
|
|
DIALOG ATTRIBUTES(UNBUFFERED,FIELD ORDER FORM )
|
|
CONSTRUCT criterio ON a.num_doc_ret
|
|
FROM num_doc_ret
|
|
BEFORE CONSTRUCT
|
|
AFTER CONSTRUCT
|
|
IF int_flag THEN
|
|
LET numero_msg = 2
|
|
CALL msg(numero_msg)
|
|
LET int_flag = FALSE
|
|
RETURN
|
|
END IF
|
|
END CONSTRUCT
|
|
ON ACTION buscar
|
|
CALL consulta.clear()
|
|
LET curr=arr_curr()
|
|
LET SELEC = " SELECT UNIQUE a.num_doc_ret,a.fecha,a.detalle,a.total FROM cotb00040 a WHERE ",
|
|
criterio clipped,
|
|
" ORDER BY a.num_doc_ret"
|
|
|
|
PREPARE busca FROM selec
|
|
DECLARE datos SCROLL CURSOR WITH HOLD FOR busca
|
|
LET idx=1
|
|
FOREACH datos INTO consulta[idx].*
|
|
LET idx=idx+1
|
|
END FOREACH
|
|
IF idx=1 THEN
|
|
CALL FGL_winmessage("error","NO HAY REGISTROS CON ESA CONDICION","STOP")
|
|
EXIT DIALOG
|
|
END IF
|
|
DISPLAY ARRAY consulta TO record9.*
|
|
BEFORE ROW
|
|
ON ACTION Escoger
|
|
LET curr=arr_curr()
|
|
SELECT num_doc_ret FROM cgtb00017
|
|
WHERE num_doc_ret=consulta[curr].num_doc_ret1
|
|
IF status != NOTFOUND THEN
|
|
LET numero_msg = 504
|
|
CALL msg(numero_msg)
|
|
ELSE
|
|
CALL actualizar()
|
|
END IF
|
|
{ON ACTION eLiminar
|
|
LET curr=arr_curr()
|
|
|
|
UPDATE iptb00024 SET status_t = "E",
|
|
us_mod = SUSER_SNAME(),
|
|
fech_mod = GETDATE()
|
|
WHERE @cod_tipo = lista_codigo[curr].cod_tipo1
|
|
|
|
|
|
LET numero_msg = 39
|
|
CALL msg(numero_msg)
|
|
}
|
|
END DISPLAY
|
|
|
|
|
|
|
|
ON ACTION CANCEL
|
|
LET int_flag= FALSE
|
|
call consulta.clear()
|
|
CLEAR FORM
|
|
EXIT DIALOG
|
|
END DIALOG
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION buscar_orden()
|
|
DEFINE aplica_wd DYNAMIC ARRAY OF RECORD
|
|
num_oc LIKE cotb00014.num_oc,
|
|
cod_sp LIKE cotb00001.cod_sp,
|
|
cod_sp_sec LIKE cotb00001.cod_sp_sec,
|
|
nom_sp LIKE cotb00001.nom_sp,
|
|
neto LIKE cotb00014.neto
|
|
END RECORD
|
|
DEFINE fecha_inicial,fecha_final DATE
|
|
|
|
OPEN WINDOW busqueda1 AT 10,10 WITH FORM "lqfmwd003"
|
|
ATTRIBUTE (BORDER,FORM LINE FIRST + 1, comment line last)
|
|
INPUT BY NAME fecha_inicial,fecha_final
|
|
LET selec = " SELECT a.num_oc,a.cod_sp,a.cod_sp_sec,b.nom_sp,a.neto ",
|
|
"FROM cotb00014 a,cotb00001 b ",
|
|
"WHERE a.cod_sp_sec=b.cod_sp_sec and a.status_t is null and ",
|
|
"a.cod_sp=b.cod_sp and a.status_t is null and a.fech_oc between ? and ? "
|
|
|
|
PREPARE comando4 FROM selec
|
|
DECLARE aplicar CURSOR FOR comando4
|
|
OPEN aplicar USING fecha_inicial,fecha_final
|
|
|
|
LET existe = "N"
|
|
LET idx = 1
|
|
WHILE STATUS != NOTFOUND
|
|
FETCH aplicar INTO aplica_wd[idx].*
|
|
IF STATUS = NOTFOUND THEN
|
|
EXIT WHILE
|
|
END IF
|
|
|
|
LET existe = "S"
|
|
LET idx = idx + 1
|
|
END WHILE
|
|
IF existe = "N" AND idx = 1 THEN
|
|
CALL fgl_winmessage("error","NO HAY REGISTROS CON ESA CONDICION","SALIR")
|
|
GOTO salir
|
|
END IF
|
|
|
|
CALL SET_COUNT(idx-1)
|
|
DISPLAY ARRAY aplica_wd TO sorden.*
|
|
LET curr1 = arr_curr()
|
|
LET ordenes[curr].num_oc = aplica_wd[curr1].num_oc
|
|
LET ordenes[curr].cod_sp = aplica_wd[curr1].cod_sp
|
|
LET ordenes[curr].cod_sp_sec = aplica_wd[curr1].cod_sp_sec
|
|
LET ordenes[curr].valor = aplica_wd[curr1].neto
|
|
LET ordenes[curr].nom_cliente = aplica_wd[curr1].nom_sp
|
|
|
|
LABEL salir:
|
|
CLOSE WINDOW busqueda1
|
|
RETURN ordenes[curr].*
|
|
END FUNCTION
|
|
|
|
REPORT liquidacion(x,z,c)
|
|
DEFINE x RECORD
|
|
num_oc VARCHAR(30),
|
|
nom_cliente CHAR(80),
|
|
valor DECIMAL(12,2),
|
|
cod_sp,cod_sp_sec INT,
|
|
bl,furgon,fact_no VARCHAR(50)
|
|
END RECORD
|
|
DEFINE z RECORD
|
|
operacion VARCHAR(50),
|
|
doc VARCHAR(30),
|
|
valor1 DECIMAL(12,2)
|
|
|
|
END RECORD,
|
|
color BOOLEAN,
|
|
desc_opera CHAR(80)
|
|
DEFINE c RECORD
|
|
orden1 VARCHAR(30),
|
|
operacion1 VARCHAR(50),
|
|
valor2 DECIMAL(12,2),
|
|
num_opera int
|
|
END RECORD
|
|
DEFINE h DYNAMIC ARRAY OF record
|
|
no_orden INT,
|
|
total DECIMAL(12,2)
|
|
END record
|
|
|
|
OUTPUT
|
|
LEFT MARGIN 0
|
|
TOP MARGIN 0
|
|
|
|
FORMAT
|
|
FIRST PAGE HEADER
|
|
|
|
SELECT a.nombre INTO p_compania.nombre FROM companias a
|
|
|
|
DISPLAY num_doc
|
|
|
|
ON every ROW
|
|
|
|
PRINTX p_compania.nombre,fecha,num_doc,detalle,impuesto
|
|
FOR Idx =1 TO ordenes.getLength()
|
|
IF ordenes[idx].num_oc IS NOT NULL THEN
|
|
|
|
LET x.num_oc=ordenes[idx].num_oc
|
|
LET x.nom_cliente=ordenes[idx].nom_cliente
|
|
LET x.valor=ordenes[idx].valor
|
|
LET x.cod_sp=ordenes[idx].cod_sp
|
|
LET x.cod_sp_sec=ordenes[idx].cod_sp_sec
|
|
PRINTX x.*
|
|
# DISPLAY x.*
|
|
END IF
|
|
|
|
END FOR
|
|
|
|
FOR Idx =1 TO opera.getLength()
|
|
IF opera[idx].operacion IS NOT NULL THEN
|
|
SELECT b.impuesto INTO impuesto FROM cotb00043 b
|
|
WHERE b.codigo=opera[idx].operacion
|
|
|
|
IF impuesto ='SI' THEN
|
|
LET color=true
|
|
ELSE
|
|
LET color=false
|
|
END IF
|
|
DISPLAY "color",color
|
|
DISPLAY opera[idx].operacion,"imp1",impuesto
|
|
SELECT a.descripcion INTO desc_opera FROM cotb00043 a
|
|
WHERE a.codigo=opera[idx].operacion
|
|
LET z.operacion=opera[idx].operacion
|
|
LET z.doc=opera[idx].doc
|
|
LET z.valor1=opera[idx].valor1
|
|
PRINTX z.*,desc_opera,color
|
|
END IF
|
|
|
|
END FOR
|
|
|
|
FOR Idx =1 TO final.getLength()
|
|
IF final[idx].orden1 IS NOT NULL THEN
|
|
LET c.operacion1=final[idx].operacion1
|
|
LET c.orden1=final[idx].orden1
|
|
LET c.valor2=final[idx].valor2
|
|
# DISPLAY "idx final",final[idx].operacion1
|
|
|
|
#
|
|
PRINTX c.*
|
|
END IF
|
|
|
|
END FOR
|
|
ON LAST ROW DECLARE or_total CURSOR FOR
|
|
select a.orden,sum(a.valor) from cotb00046 a
|
|
where num_doc_ret=num_doc
|
|
group by orden
|
|
LET idx=1
|
|
FOREACH or_total INTO h[idx].no_orden,h[idx].total
|
|
PRINTX h[idx].no_orden,h[idx].total
|
|
LET idx=idx+1
|
|
END FOREACH
|
|
|
|
END report
|