1834 lines
59 KiB
Plaintext
1834 lines
59 KiB
Plaintext
{
|
|
PROGRAMA : VEPRMT113
|
|
OBJETIVO : Poder visualizar los registros FACTURAS, NOTAS DE CREDITOS,
|
|
NOTAS DE DEBITOS, con la finalidad de visualizacion del estado
|
|
en la facuracion electronica y poder enviar comprobantes nuevamente
|
|
FECHA DESARROLLO : 2025-04-01
|
|
DESARROLLADO POR : ELVIS GARCIA
|
|
MODIFICADO POR : JUAN SOTO
|
|
FECHA MODIFICACION : 2025-08-01
|
|
|
|
FECHA MODIFICACION : 2026-03-16
|
|
MODIFICADO POR : JUAN SOTO
|
|
OBJETIVO : ENVIAR LOS XML FIRMADO A LOS CLIENTES
|
|
}
|
|
|
|
IMPORT os
|
|
IMPORT com
|
|
IMPORT xml
|
|
IMPORT util
|
|
|
|
SCHEMA smarmotech
|
|
|
|
TYPE tMensaje RECORD
|
|
codigo STRING,
|
|
valor STRING
|
|
END RECORD
|
|
|
|
TYPE tRespDGII RECORD
|
|
codigo INTEGER, -- 1=OK, 2=Rechazado, etc. (cuando venga)
|
|
estado STRING, -- "Aceptado" | "Rechazado" | etc.
|
|
encf STRING,
|
|
secuenciaUtilizada BOOLEAN,
|
|
hash STRING,
|
|
fechaFirmaDigital STRING,
|
|
qrcodeurl STRING,
|
|
trackId STRING,
|
|
mensajes DYNAMIC ARRAY OF tMensaje
|
|
END RECORD
|
|
|
|
DEFINE
|
|
p_companias RECORD LIKE companias.*,
|
|
xsucid, xdias INT,
|
|
xfechavence DATE,
|
|
criterio STRING,
|
|
enviado BOOLEAN
|
|
|
|
DEFINE
|
|
usuarios, clave STRING,
|
|
tipornc VARCHAR(1)
|
|
DEFINE
|
|
estado_d VARCHAR(20),
|
|
c_factura INT
|
|
|
|
DEFINE p RECORD
|
|
trackId STRING,
|
|
codigo INT,
|
|
estado STRING,
|
|
mensajes DYNAMIC ARRAY OF RECORD
|
|
valor STRING,
|
|
codigo INT
|
|
END RECORD
|
|
END RECORD
|
|
|
|
DEFINE p32 RECORD
|
|
codigo, estado, mensajes, encf, secuenciautilizada STRING
|
|
END RECORD
|
|
|
|
DEFINE p32err RECORD
|
|
codigo, estado STRING,
|
|
mensajes DYNAMIC ARRAY OF RECORD
|
|
codigo, valor, encf, secuenciautilizada STRING
|
|
END RECORD
|
|
END RECORD
|
|
DEFINE p321 RECORD
|
|
trackid STRING,
|
|
mensaje DYNAMIC ARRAY OF STRING
|
|
END RECORD
|
|
|
|
DEFINE fact_gral RECORD
|
|
cod_cia LIKE vetb00002.cod_cia,
|
|
ventas LIKE vetb00002.ventas,
|
|
zona CHAR(3),
|
|
factura LIKE vetb00002.factura,
|
|
bodega SMALLINT,
|
|
conduce LIKE vetb00002.conduce,
|
|
fecha_conduce DATE,
|
|
fecha_factura DATE,
|
|
tipo_cliente LIKE vetb00002.tipo_cliente,
|
|
sec_cliente LIKE vetb00002.sec_cliente,
|
|
nombre CHAR(30),
|
|
direccion CHAR(80),
|
|
ciudad CHAR(20),
|
|
prima_us LIKE vetb00002.prima_us,
|
|
porc_desc LIKE vetb00002.porc_desc,
|
|
cond_pago LIKE vetb00002.cond_pago,
|
|
orden INT,
|
|
fecha_orden DATE,
|
|
porc_itbi LIKE vetb00002.porc_itbi,
|
|
sec_vend LIKE vetb00002.sec_vend,
|
|
nombre_vend CHAR(60),
|
|
cod_transp LIKE iptb00006.cod_transp,
|
|
sec_transp LIKE iptb00006.sec_transp,
|
|
cod_tarifa LIKE iptb00006.cod_tarifa,
|
|
nombre_tran CHAR(30),
|
|
fecha_embarque DATE,
|
|
placa_transp LIKE iptb00006.placa,
|
|
sub_total DECIMAL(12, 2),
|
|
desc_valor DECIMAL(12, 2),
|
|
itbi DECIMAL(12, 2),
|
|
total_fact DECIMAL(12, 2)
|
|
END RECORD
|
|
|
|
DEFINE
|
|
documento_encabezado RECORD
|
|
tipoEcf,
|
|
eNcf,
|
|
indicadorMontoGravado,
|
|
tipoPago,
|
|
fechaLimitePago,
|
|
FormadePAgo,
|
|
montoPago,
|
|
FechaVencimientoSecuencia,
|
|
rncEmisor,
|
|
razonSocialEmisor,
|
|
direccionEmisor,
|
|
Municipio,
|
|
Provincia,
|
|
telefonoEmisor,
|
|
correoEmisor,
|
|
webSite,
|
|
codigoVendedor,
|
|
numeroFacturaInterna,
|
|
numeroPedidoInterno,
|
|
fechaEmision,
|
|
rncComprador,
|
|
razonSocialComprador,
|
|
montoGravadoTotal,
|
|
montoGravadoI1,
|
|
montoGravadoI2,
|
|
montoGravadoI3,
|
|
montoExento,
|
|
itbis1,
|
|
itbis2,
|
|
itbis3,
|
|
totalItbis,
|
|
totalItbis1,
|
|
totalItbis2,
|
|
totalItbis3,
|
|
montoTotal,
|
|
tipoIngreso,
|
|
terminoPago,
|
|
TipoCuentaPago,
|
|
NumeroCuentaPago,
|
|
IdentificadorExtranjero,
|
|
contactoComprador,
|
|
CorreoComprador,
|
|
DireccionComprador,
|
|
MunicipioComprador,
|
|
ProvinciaComprador,
|
|
FechaEntrega,
|
|
FechaOrdenCompra,
|
|
NumeroOrdenCompra,
|
|
CodigoInternoComprador,
|
|
nombreFile,
|
|
IndicadorNotaCredito,
|
|
NCFmodificado,
|
|
codigoModificacion,
|
|
fechaNCFmodificado
|
|
STRING
|
|
END RECORD,
|
|
tipodocumento CHAR(2)
|
|
|
|
DEFINE
|
|
documento_Detalle DYNAMIC ARRAY OF RECORD
|
|
indicadorFacturacion,
|
|
nombreItem,
|
|
indicadorBienoServicio,
|
|
cantidadItem,
|
|
precioUnitarioItem,
|
|
montoItem
|
|
STRING,
|
|
DescripcionItem VARCHAR(1000),
|
|
NumeroLinea INT
|
|
END RECORD,
|
|
xhash CHAR(6),
|
|
xfechaFirmaDigital DATETIME YEAR TO SECOND,
|
|
fecha_Vencimiento_ncf DATE
|
|
|
|
DEFINE respuesta, codigo, ruta_firmados, filefirmado STRING
|
|
|
|
DEFINE Informacion RECORD
|
|
fecha DATE,
|
|
status_t CHAR(1),
|
|
orden INT,
|
|
num_doc, doc_alm, bodega, cod_mov INT,
|
|
tipo_doc VARCHAR(10),
|
|
codigo_dgii VARCHAR(50),
|
|
tipo_cliente INT,
|
|
sec_cliente INT,
|
|
nombre_cliente VARCHAR(300),
|
|
rnc1 VARCHAR(25),
|
|
ncf VARCHAR(50),
|
|
ncf_mod VARCHAR(50),
|
|
valor DECIMAL(12, 2),
|
|
itbis DECIMAL(12, 2),
|
|
codigosegudad VARCHAR(10),
|
|
trackid VARCHAR(300),
|
|
estado_dgii VARCHAR(300),
|
|
ERROR VARCHAR(100),
|
|
mensaje VARCHAR(1000),
|
|
ultima_Respuesta VARCHAR(1000),
|
|
sucid INT,
|
|
tipo_nc VARCHAR(10)
|
|
END RECORD
|
|
|
|
DEFINE Dgestion DYNAMIC ARRAY OF RECORD --Display gestion
|
|
fecha DATE,
|
|
status_t CHAR(1),
|
|
orden INT,
|
|
num_doc, doc_alm, bodega, cod_mov INT,
|
|
tipo_doc VARCHAR(10),
|
|
codigo_dgii VARCHAR(50),
|
|
tipo_cliente INT,
|
|
sec_cliente INT,
|
|
nombre_cliente VARCHAR(300),
|
|
rnc VARCHAR(25),
|
|
ncf VARCHAR(50),
|
|
ncf_mod VARCHAR(50),
|
|
valor DECIMAL(12, 2),
|
|
itbis DECIMAL(12, 2),
|
|
codigosegudad VARCHAR(10),
|
|
trackid VARCHAR(300),
|
|
estado_dgii VARCHAR(300),
|
|
ERROR VARCHAR(100),
|
|
mensaje VARCHAR(1000),
|
|
ultima_Respuesta VARCHAR(1000),
|
|
sucid INT,
|
|
tipo_nc VARCHAR(10)
|
|
END RECORD
|
|
|
|
DEFINE Filter RECORD
|
|
date1 DATE,
|
|
date2 DATE,
|
|
comboValue CHAR(10),
|
|
comboValue2 STRING
|
|
END RECORD
|
|
|
|
DEFINE
|
|
dias, tipo, i, codigo_sucursal INT,
|
|
factura1 STRING,
|
|
fecha DATE,
|
|
pitbis, tasa DECIMAL(12, 2),
|
|
dvalor_bruto,
|
|
ddescuento,
|
|
dsub_total,
|
|
ditbis,
|
|
dneto,
|
|
tvalor_bruto,
|
|
tdescuento,
|
|
tsub_total,
|
|
titbis,
|
|
tneto,
|
|
dprecio
|
|
DEC(18, 2),
|
|
arr_articulos DYNAMIC ARRAY OF RECORD
|
|
area SMALLINT,
|
|
cod_n SMALLINT,
|
|
cod_grupo SMALLINT,
|
|
cod_tipo SMALLINT,
|
|
cod_sec SMALLINT,
|
|
cantidad_1, cantidad_2 DEC(12, 4),
|
|
descrip_Esp VARCHAR(70),
|
|
-- unidad_med VARCHAR(4),
|
|
precio, por_desc, valor_desc, valor_itbis, valor DEC(12, 2),
|
|
id_tipo SMALLINT
|
|
END RECORD,
|
|
arr_articulosNC DYNAMIC ARRAY OF RECORD
|
|
area SMALLINT,
|
|
cod_n SMALLINT,
|
|
cod_grupo SMALLINT,
|
|
cod_tipo SMALLINT,
|
|
cod_sec SMALLINT,
|
|
cantidad_1, descrip_Esp VARCHAR(70),
|
|
unidad_med VARCHAR(4),
|
|
precio, por_desc, valor_desc, valor_itbis, id_tipo SMALLINT
|
|
END RECORD,
|
|
ambiente STRING
|
|
|
|
MAIN --login y programa
|
|
|
|
CALL STARTLOG("veprmt113.log")
|
|
CALL ARG_VAL(1) RETURNING usuarios
|
|
CALL ARG_VAL(2) RETURNING clave
|
|
# CONNECT TO "smarmotech" AS "MARMOTECH" USER usuarios USING clave
|
|
CONNECT TO "marmotech" AS "EXTERIOR" USER usuarios USING clave
|
|
|
|
SELECT a.rnc, a.nombre, a.direccion, a.email_facturacion
|
|
INTO p_companias.rnc,
|
|
p_companias.nombre,
|
|
p_companias.direccion,
|
|
p_companias.email_facturacion
|
|
FROM companias a
|
|
CALL ambiente() RETURNING ambiente
|
|
CALL veprmt113()
|
|
|
|
END MAIN
|
|
|
|
FUNCTION veprmt113()
|
|
|
|
OPEN WINDOW w1 WITH FORM 'vefmmt113'
|
|
CALL fgl_settitle("Gestion NCF electronicos")
|
|
|
|
CALL init_conditions()
|
|
CALL filtrarfecha()
|
|
CALL buscarDatos()
|
|
|
|
DIALOG ATTRIBUTE(UNBUFFERED)
|
|
|
|
DISPLAY ARRAY Dgestion TO Drecord.*
|
|
|
|
ON ACTION salir ATTRIBUTES(TEXT = "Salir", IMAGE = "fa-power-off")
|
|
EXIT PROGRAM
|
|
|
|
{ ON ACTION Email ATTRIBUTES(TEXT = "Enviar Email", IMAGE = "mail")
|
|
CALL envio_email(
|
|
Dgestion[arr_curr()].tipo_cliente,
|
|
Dgestion[arr_curr()].sec_cliente,
|
|
Dgestion[arr_curr()].nombre_cliente,
|
|
Dgestion[arr_curr()].orden,
|
|
usuarios)
|
|
|
|
ON ACTION add_doc
|
|
CALL AddDocs(
|
|
Dgestion[arr_curr()].nombre_cliente,
|
|
Dgestion[arr_curr()].num_doc,
|
|
Dgestion[arr_curr()].tipo_doc,
|
|
Dgestion[arr_curr()].sucid)
|
|
}
|
|
|
|
ON ACTION NoEncontrados_Fix
|
|
ATTRIBUTES(TEXT = "Corregir Estados", IMAGE = "ok2")
|
|
CALL corregir_noEncontrados()
|
|
|
|
ON ACTION refrescar ATTRIBUTE(TEXT = "Refrescar", IMAGE = "refresh")
|
|
CALL buscarDatos()
|
|
|
|
ON ACTION FechaBttn
|
|
CALL FiltrarFecha()
|
|
ON ACTION verificaEstado
|
|
ATTRIBUTE(TEXT = "Check Estado", IMAGE = "check")
|
|
CALL verificaEstado()
|
|
|
|
ON ACTION enviarDGII
|
|
LET tipodocumento = Dgestion[arr_curr()].tipo_doc
|
|
LET xsucid = Dgestion[arr_curr()].sucid
|
|
# IF informacion.estado_dgii NOT MATCHES 'Aceptado*' THEN
|
|
|
|
IF informacion.estado_dgii NOT MATCHES 'Aceptado'
|
|
OR informacion.estado_dgii
|
|
NOT MATCHES 'Aceptado Condicional'
|
|
OR informacion.estado_dgii IS NULL THEN
|
|
CALL enviarDoc()
|
|
CALL updateTables(1)
|
|
# CALL enviarlog(1)
|
|
ELSE
|
|
CALL msg(1669)
|
|
END IF
|
|
|
|
ON ACTION actCodSeguridad
|
|
IF informacion.tipo_doc = 'FT' THEN
|
|
LET c_factura = NULL
|
|
SELECT a.factura_c
|
|
INTO c_factura
|
|
FROM vetb00002 a
|
|
WHERE a.factura = informacion.num_doc
|
|
AND a.sucid = informacion.sucid
|
|
IF c_factura IS NOT NULL THEN
|
|
LET ruta_firmados =
|
|
"E:\\MARMOTECHC\\BIN320\\filesxml\\firmados\\"
|
|
LET filefirmado =
|
|
ruta_firmados CLIPPED,
|
|
p_companias.rnc CLIPPED,
|
|
informacion.ncf CLIPPED,
|
|
".xml"
|
|
ELSE
|
|
LET ruta_firmados = fgl_getenv("RUTA_XML_FIRMADOS")
|
|
LET filefirmado =
|
|
ruta_firmados CLIPPED,
|
|
p_companias.rnc CLIPPED,
|
|
informacion.ncf CLIPPED,
|
|
".xml"
|
|
END IF
|
|
ELSE
|
|
LET ruta_firmados = fgl_getenv("RUTA_XML_FIRMADOS")
|
|
LET filefirmado =
|
|
ruta_firmados CLIPPED,
|
|
p_companias.rnc CLIPPED,
|
|
informacion.ncf CLIPPED,
|
|
".xml"
|
|
END IF
|
|
|
|
DISPLAY "ruta: ", ruta_firmados, " ", c_factura
|
|
|
|
CALL gethash1(filefirmado) RETURNING xhash
|
|
IF xhash = 'NO EXISTE' THEN
|
|
DISPLAY "NO ACTUALICE EL HASH" TO mensaje
|
|
|
|
ELSE
|
|
IF informacion.codigosegudad IS NULL THEN
|
|
CALL updatehash(xhash)
|
|
END IF
|
|
END IF
|
|
|
|
ON ACTION CheckBttn
|
|
LET xsucid = informacion.sucid
|
|
|
|
CALL ConsultaTrackID()
|
|
|
|
IF p.estado == 'Aceptado' THEN
|
|
DISPLAY p.estado TO estado_dgii ATTRIBUTES(GREEN, REVERSE)
|
|
END IF
|
|
|
|
IF p.estado == 'Rechazado' THEN
|
|
DISPLAY p.estado TO estado_dgii ATTRIBUTES(RED, REVERSE)
|
|
END IF
|
|
|
|
IF p.estado <> 'Aceptado' AND p.estado <> 'Rechazado' THEN
|
|
DISPLAY p.estado TO estado_dgii ATTRIBUTES(YELLOW, REVERSE)
|
|
END IF
|
|
|
|
DISPLAY p.mensajes[1].valor TO mensaje
|
|
|
|
CALL updateTables(2)
|
|
|
|
# CALL enviarLog(2)
|
|
|
|
ON ACTION enviar_cliente
|
|
ATTRIBUTE(TEXT = "E Cliente", IMAGE = 'mail')
|
|
IF enviaFilesCliente(
|
|
p_companias.rnc,
|
|
informacion.tipo_cliente,
|
|
informacion.sec_cliente,
|
|
informacion.rnc1,
|
|
informacion.ncf,
|
|
informacion.orden,
|
|
informacion.doc_alm,
|
|
informacion.bodega) THEN
|
|
CALL fgl_winmessage('INFO', "FILE ENVIADO", "OK")
|
|
END IF
|
|
|
|
BEFORE ROW
|
|
INITIALIZE Dgestion TO NULL
|
|
CALL buscarDatos()
|
|
CALL getdata(arr_curr())
|
|
|
|
INITIALIZE p.* TO NULL
|
|
DISPLAY BY NAME informacion.*
|
|
|
|
END DISPLAY
|
|
END DIALOG
|
|
END FUNCTION
|
|
|
|
FUNCTION updateTables(caso INT)
|
|
|
|
CASE caso
|
|
WHEN 1
|
|
IF informacion.codigo_dgii <> 32 THEN
|
|
DISPLAY informacion.mensaje
|
|
CALL util.JSON.parse(informacion.mensaje, p)
|
|
|
|
CALL ConsultaTrackID()
|
|
LET estado_d = p.estado
|
|
END IF
|
|
IF informacion.codigo_dgii = 32 THEN
|
|
TRY
|
|
CALL util.JSON.parse(informacion.mensaje, p32)
|
|
CATCH
|
|
TRY
|
|
CALL util.JSON.parse(informacion.mensaje, p321)
|
|
CATCH
|
|
CALL util.JSON.parse(informacion.mensaje, p32err)
|
|
END TRY
|
|
END TRY
|
|
LET estado_d = p32.estado
|
|
END IF
|
|
DISPLAY estado_d TO estado_dgii
|
|
|
|
IF informacion.tipo_doc = 'FT' THEN
|
|
|
|
UPDATE vetb00002
|
|
SET ultima_respuesta = informacion.mensaje,
|
|
hash = xhash,
|
|
estado_dgii = estado_d,
|
|
fechafirmadigital = xfechaFirmaDigital,
|
|
trackid = p.trackId
|
|
WHERE factura = informacion.num_doc AND sucid = xsucid
|
|
|
|
ELSE
|
|
|
|
UPDATE cctb00001
|
|
SET ultima_respuesta = informacion.mensaje,
|
|
trackid = p.trackId,
|
|
hash = xhash,
|
|
fechaFirmadigital = xfechaFirmaDigital,
|
|
mensaje = p.mensajes[1].valor,
|
|
estado_dgii = estado_d
|
|
WHERE num_doc = informacion.num_doc AND sucid = xsucid
|
|
|
|
END IF
|
|
|
|
WHEN 2
|
|
|
|
IF informacion.tipo_doc = 'FT' THEN
|
|
DISPLAY "estoy en factura ",
|
|
informacion.num_doc,
|
|
" sucid ",
|
|
xsucid
|
|
UPDATE vetb00002
|
|
SET estado_dgii = informacion.estado_dgii
|
|
WHERE factura = informacion.num_doc AND sucid = xsucid
|
|
|
|
ELSE
|
|
|
|
UPDATE cctb00001
|
|
SET estado_dgii = informacion.estado_dgii
|
|
WHERE num_doc = informacion.num_doc AND sucid = xsucid
|
|
|
|
END IF
|
|
|
|
END CASE
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION corregir_noEncontrados()
|
|
|
|
DEFINE i, x INT
|
|
|
|
PREPARE query
|
|
FROM "UPDATE vetb00002
|
|
SET trackid = JSON_VALUE(ultima_respuesta, '$.trackId')
|
|
WHERE
|
|
fecha_factura >= '2025-05-01' AND
|
|
status_t IS NULL AND trackid is null and
|
|
ISJSON(ultima_respuesta) = 1;"
|
|
|
|
EXECUTE query
|
|
|
|
LET x = 1
|
|
|
|
FOR i = 1 TO Dgestion.getLength()
|
|
|
|
IF Dgestion[i].estado_dgii = 'No encontrado.'
|
|
AND Dgestion[i].trackid IS NOT NULL
|
|
AND Dgestion[i].status_t IS NULL THEN
|
|
|
|
INITIALIZE informacion.*, xsucid TO NULL
|
|
LET Informacion.* = Dgestion[i].*
|
|
LET xsucid = informacion.sucid
|
|
|
|
CALL consultaTrackid()
|
|
CALL updateTables(2)
|
|
# CALL enviarLog(2)
|
|
|
|
LET x = x + 1
|
|
|
|
END IF
|
|
|
|
END FOR
|
|
|
|
IF x = 1 THEN
|
|
CALL fgl_winmessage(
|
|
"NO SE ENCUENTRAN FACTURAS",
|
|
"No se encuentran facturas que cumplan las condiciones para esta funcion.",
|
|
"stop")
|
|
ELSE
|
|
|
|
DISPLAY "Se actualizaron ", x, " registros!"
|
|
CALL msg(13)
|
|
END IF
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION buscarDatos() --Obteniendo datos para el array de registros
|
|
|
|
DEFINE
|
|
idx INT,
|
|
query, condition, condition2 STRING
|
|
|
|
IF Filter.comboValue IS NULL THEN
|
|
|
|
LET condition = "('FT', 'NC', 'ND')"
|
|
|
|
ELSE
|
|
|
|
IF Filter.comboValue = 'FT' THEN
|
|
LET condition = "('FT')"
|
|
END IF
|
|
|
|
IF Filter.comboValue = 'NC' THEN
|
|
LET condition = "('NC')"
|
|
END IF
|
|
|
|
IF Filter.comboValue = 'ND' THEN
|
|
LET condition = "('ND')"
|
|
END IF
|
|
|
|
END IF
|
|
|
|
LET query =
|
|
"SELECT * FROM (SELECT fecha_factura AS fecha,
|
|
a.status_t COLLATE SQL_Latin1_General_CP1_CI_AS AS status_t ,
|
|
a.orden AS orden,
|
|
a.factura AS num_doc,
|
|
a.conduce as doc_alm,
|
|
a.bodega as bodega,
|
|
30 as cod_mov,
|
|
'FT' COLLATE SQL_Latin1_General_CP1_CI_AS AS tipo_doc ,
|
|
b.codigo_dgii COLLATE SQL_Latin1_General_CP1_CI_AS as codigo_dgii,
|
|
a.tipo_cliente,
|
|
a.sec_cliente,
|
|
a.nombre_cliente COLLATE SQL_Latin1_General_CP1_CI_AS as nombre_cliente,
|
|
a.rnc COLLATE SQL_Latin1_General_CP1_CI_AS as rnc , a.ncf,
|
|
a.ncf AS ncf_mod,
|
|
a.neto AS valor,
|
|
a.monto_itbi AS itbis,
|
|
a.hash as codigoSeguridad,
|
|
a.trackid,
|
|
a.estado_dgii AS estado_dgii,
|
|
null AS error,
|
|
a.mensaje,
|
|
a.ultima_respuesta,
|
|
a.sucid AS Sucursal,
|
|
'01' as tipo_nc
|
|
FROM vetb00002 a
|
|
INNER
|
|
JOIN vetb00072 b
|
|
ON a.factura = b.documento
|
|
AND b.tipo_doc = 'FT'
|
|
AND a.sucid = b.sucid
|
|
WHERE a.fecha_factura
|
|
BETWEEN '",
|
|
Filter.date1 USING "mm/dd/yyyy",
|
|
"'",
|
|
" AND '",
|
|
Filter.date2 USING "mm/dd/yyyy",
|
|
"'
|
|
UNION
|
|
SELECT a.fecha_orig AS fecha,
|
|
a.status_t COLLATE SQL_Latin1_General_CP1_CI_AS AS estado_fact,
|
|
a.num_oc AS orden,
|
|
a.num_doc AS num_doc,
|
|
a.bodega as bodega,
|
|
a.num_cheque as doc_alm,
|
|
a.banco as cod_mov,
|
|
a.tipo_doc AS tipo_doc,
|
|
d.codigo_dgii,
|
|
a.tipo_cliente AS tipo_cliente,
|
|
a.sec_cliente AS sec_cliente,
|
|
b.nombre COLLATE SQL_Latin1_General_CP1_CI_AS AS nombre_cliente,
|
|
b.num_rnc COLLATE SQL_Latin1_General_CP1_CI_AS as rnc,
|
|
a.ncf,
|
|
c.ncf AS ncf_mod,
|
|
a.valor AS valor,
|
|
a.itbis AS itbis,
|
|
a.hash as codigoSeguridad,
|
|
a.trackid AS trackid,
|
|
a.estado_dgii AS estado_dgii,
|
|
null AS error,
|
|
a.mensaje,
|
|
a.ultima_respuesta,
|
|
a.sucid AS Sucursal,
|
|
e.tipo_nc
|
|
FROM cctb00001 a
|
|
INNER
|
|
JOIN vetb00004 b
|
|
ON a.tipo_cliente = b.tipo_cliente
|
|
AND a.sec_cliente = b.sec_cliente
|
|
INNER
|
|
JOIN vetb00002 c
|
|
ON a.aplica_a = c.factura
|
|
AND a.tipo_cliente = b.tipo_cliente
|
|
AND a.sec_cliente = b.sec_cliente
|
|
INNER
|
|
JOIN vetb00072 d
|
|
ON a.num_doc = d.documento AND a.tipo_doc = d.tipo_doc
|
|
INNER
|
|
JOIN cctb00011 e
|
|
ON e.num_doc = a.num_doc AND e.tipo_doc = a.tipo_doc and
|
|
e.tipo_cliente = a.tipo_cliente and e.sec_cliente = a.sec_cliente
|
|
WHERE a.tipo_doc IN ('NC', 'ND')
|
|
AND a.sucid = d.sucid
|
|
AND a.fecha_orig
|
|
BETWEEN '",
|
|
Filter.date1 USING "mm/dd/yyyy",
|
|
"'",
|
|
" AND '",
|
|
Filter.date2 USING "mm/dd/yyyy",
|
|
"')
|
|
as UnionResult WHERE UnionResult.tipo_doc IN ",
|
|
condition,
|
|
" AND ",
|
|
criterio CLIPPED
|
|
|
|
IF filter.comboValue2 IS NOT NULL THEN
|
|
|
|
LET query =
|
|
query, " and UnionResult.estado_dgii = '", Filter.comboValue2, "'"
|
|
|
|
END IF
|
|
|
|
PREPARE buscar FROM query
|
|
DECLARE buscadatos CURSOR FOR buscar
|
|
|
|
LET idx = 1
|
|
FOREACH buscadatos
|
|
INTO Dgestion[idx].fecha,
|
|
Dgestion[idx].status_t,
|
|
Dgestion[idx].orden,
|
|
Dgestion[idx].num_doc,
|
|
Dgestion[idx].doc_alm,
|
|
Dgestion[idx].bodega,
|
|
Dgestion[idx].cod_mov,
|
|
Dgestion[idx].tipo_doc,
|
|
Dgestion[idx].codigo_dgii,
|
|
Dgestion[idx].tipo_cliente,
|
|
Dgestion[idx].sec_cliente,
|
|
Dgestion[idx].nombre_cliente,
|
|
Dgestion[idx].rnc,
|
|
Dgestion[idx].ncf,
|
|
Dgestion[idx].ncf_mod,
|
|
Dgestion[idx].valor,
|
|
Dgestion[idx].itbis,
|
|
Dgestion[idx].codigosegudad,
|
|
Dgestion[idx].trackid,
|
|
Dgestion[idx].estado_dgii,
|
|
Dgestion[idx].error,
|
|
Dgestion[idx].mensaje,
|
|
Dgestion[idx].ultima_Respuesta,
|
|
Dgestion[idx].sucid,
|
|
Dgestion[idx].tipo_nc
|
|
LET idx = idx + 1
|
|
END FOREACH
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION getdata(i INT) --Obteniendo los datos del registro seleccionado
|
|
IF i = 0 THEN
|
|
INITIALIZE informacion.* TO NULL
|
|
RETURN
|
|
END IF
|
|
|
|
LET informacion.* = Dgestion[i].*
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION filtrarfecha()
|
|
|
|
DEFINE i INT
|
|
INITIALIZE Filter.* TO NULL
|
|
INITIALIZE Dgestion TO NULL
|
|
INITIALIZE informacion.* TO NULL
|
|
|
|
DIALOG ATTRIBUTE(UNBUFFERED)
|
|
|
|
INPUT BY NAME Filter.* ATTRIBUTE(WITHOUT DEFAULTS)
|
|
|
|
AFTER INPUT
|
|
IF filter.date1 IS NULL THEN
|
|
CALL msg(16)
|
|
NEXT FIELD date1
|
|
END IF
|
|
IF filter.date2 IS NULL THEN
|
|
CALL msg(16)
|
|
NEXT FIELD date2
|
|
END IF
|
|
IF filter.date1 > filter.date2 THEN
|
|
CALL msg(86)
|
|
NEXT FIELD date2
|
|
END IF
|
|
IF filter.comboValue IS NULL THEN
|
|
CALL msg(16)
|
|
NEXT FIELD comboValue
|
|
END IF
|
|
|
|
END INPUT
|
|
CONSTRUCT criterio ON UnionResult.ncf FROM ncf3
|
|
ON ACTION buscar ATTRIBUTES(TEXT = "Buscar", IMAGE = "find")
|
|
INITIALIZE Dgestion TO NULL
|
|
CALL buscarDatos()
|
|
CALL getdata(arr_curr())
|
|
CALL DIALOG.accept()
|
|
END CONSTRUCT
|
|
|
|
ON ACTION salir ATTRIBUTES(TEXT = "Salir", IMAGE = "fa-power-off")
|
|
EXIT PROGRAM
|
|
|
|
END DIALOG
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION enviarDoc()
|
|
|
|
DEFINE
|
|
empty STRING,
|
|
ch_itbi VARCHAR(1)
|
|
|
|
LET codigo_sucursal = informacion.sucid
|
|
|
|
IF informacion.valor < 0 THEN
|
|
LET informacion.valor = informacion.valor * -1
|
|
END IF
|
|
IF informacion.itbis < 0 THEN
|
|
LET informacion.itbis = informacion.itbis * -1
|
|
END IF
|
|
--DOCUMENTO ENCABEZADO
|
|
|
|
LET documento_encabezado.nombreFile =
|
|
p_companias.rnc CLIPPED, informacion.ncf CLIPPED, ".xml"
|
|
LET documento_encabezado.tipoEcf = informacion.codigo_dgii CLIPPED
|
|
LET documento_encabezado.eNcf = informacion.ncf CLIPPED
|
|
|
|
SELECT a.fecha_vencimiento, a.itbis
|
|
INTO fecha_vencimiento_ncf, ch_itbi
|
|
FROM vetb00071 a
|
|
WHERE a.tipo_Doc = informacion.tipo_doc
|
|
AND a.codigo_dgii = informacion.codigo_dgii
|
|
|
|
LET documento_encabezado.FechaVencimientoSecuencia =
|
|
fecha_vencimiento_ncf USING "dd-mm-yyyy"
|
|
|
|
LET documento_encabezado.tipoIngreso = '01'
|
|
|
|
LET documento_encabezado.rncEmisor = p_companias.rnc CLIPPED
|
|
LET documento_encabezado.razonSocialEmisor = p_companias.nombre CLIPPED
|
|
LET documento_encabezado.direccionEmisor = p_companias.direccion CLIPPED
|
|
LET documento_encabezado.correoEmisor = p_companias.email_facturacion
|
|
|
|
SELECT TOP(1) sucnombre, c.id_municipio_dgii, c.id_dgii
|
|
INTO empty,
|
|
documento_encabezado.municipio,
|
|
documento_encabezado.provincia
|
|
FROM seg0001 a, sucursales b, vetb00020 c
|
|
WHERE a.sucid = b.sucid
|
|
AND b.localidad = c.cod_provincia
|
|
AND b.sucid = codigo_sucursal
|
|
|
|
SELECT a.zona_postal
|
|
INTO tipornc
|
|
FROM vetb00004 a
|
|
WHERE a.tipo_cliente = informacion.tipo_cliente
|
|
AND a.sec_cliente = informacion.sec_cliente
|
|
|
|
LET documento_encabezado.fechaEmision = informacion.fecha USING "dd-mm-yyyy"
|
|
|
|
IF tipornc <> '3' THEN
|
|
LET documento_encabezado.rncComprador = informacion.rnc1 CLIPPED
|
|
END IF
|
|
IF tipornc = '3' THEN
|
|
LET documento_encabezado.IdentificadorExtranjero =
|
|
informacion.rnc1 CLIPPED
|
|
END IF
|
|
|
|
#LET documento_encabezado.rncComprador = informacion.rnc1 CLIPPED
|
|
LET documento_encabezado.razonSocialComprador =
|
|
informacion.nombre_cliente CLIPPED
|
|
|
|
IF informacion.tipo_doc = 'NC' OR informacion.tipo_doc = 'ND' THEN
|
|
CALL NCyND()
|
|
END IF
|
|
|
|
IF informacion.tipo_doc = 'FT' THEN
|
|
-- LET factura1 = informacion.num_doc
|
|
CALL FT()
|
|
END IF
|
|
|
|
IF pitbis IS NULL THEN
|
|
LET pitbis = 0
|
|
END IF
|
|
IF informacion.tipo_doc = 'FT' THEN
|
|
IF documento_encabezado.tipoPago <> '1' THEN
|
|
LET documento_encabezado.fechaLimitePago =
|
|
xfechavence USING "dd-mm-yyyy"
|
|
LET documento_encabezado.terminoPago = xdias USING "<<<", " dias"
|
|
END IF
|
|
ELSE
|
|
LET documento_encabezado.IndicadorNotaCredito = 0 USING "&"
|
|
END IF
|
|
LET documento_encabezado.numeroFacturaInterna = informacion.num_doc
|
|
LET documento_Encabezado.itbis1 = pitbis USING "&&"
|
|
LET documento_encabezado.totalItbis =
|
|
informacion.itbis * tasa USING "<<<<<<<<<<<<<&.##"
|
|
LET documento_encabezado.totalitbis1 =
|
|
informacion.itbis * tasa USING "<<<<<<<<<<<<<&.##"
|
|
|
|
IF documento_encabezado.tipoPago = 1 THEN
|
|
LET documento_encabezado.indicadorMontoGravado = '1'
|
|
ELSE
|
|
IF informacion.codigo_dgii <> 43
|
|
OR informacion.codigo_dgii <> 44
|
|
OR informacion.codigo_dgii <> 46
|
|
OR informacion.codigo_dgii <> 47 THEN
|
|
LET documento_encabezado.indicadorMontoGravado = '0' USING "&"
|
|
ELSE
|
|
INITIALIZE documento_encabezado.indicadorMontoGravado TO NULL
|
|
END IF
|
|
END IF
|
|
LET documento_encabezado.montoExento = 0 USING "&.##"
|
|
LET documento_encabezado.montoGravadoTotal =
|
|
(informacion.valor - informacion.itbis) * tasa
|
|
LET documento_encabezado.montoGravadoI1 =
|
|
(informacion.valor - informacion.itbis) * tasa
|
|
|
|
{LET documento_encabezado.montoGravadoI3 = '00' USING "<<<<<<<<<<<<<&.##" }
|
|
LET documento_encabezado.montoTotal =
|
|
informacion.valor * tasa USING "<<<<<<<<<<<<<<##.##"
|
|
LET documento_encabezado.montoPago =
|
|
informacion.valor * tasa USING "<<<<<<<<<<<<<<<<##.##"
|
|
|
|
IF informacion.codigo_dgii = 43
|
|
OR informacion.codigo_dgii = 44
|
|
OR informacion.codigo_dgii = 46
|
|
OR informacion.codigo_dgii = 47 THEN
|
|
|
|
INITIALIZE documento_encabezado.montoGravadoI1,
|
|
documento_encabezado.montoGravadoI2,
|
|
documento_encabezado.itbis1,
|
|
documento_encabezado.itbis2,
|
|
documento_encabezado.indicadorMontoGravado TO NULL
|
|
|
|
END IF
|
|
|
|
IF tasa IS NOT NULL THEN
|
|
|
|
IF ch_itbi = 'N' OR informacion.itbis = 0 THEN
|
|
LET documento_encabezado.montoExento =
|
|
documento_encabezado.montoTotal
|
|
|
|
# LET documento_encabezado.montoGravadoTotal = 0
|
|
LET documento_encabezado.totalItbis = '0'
|
|
LET documento_encabezado.montoGravadoI1 = '0'
|
|
END IF
|
|
CALL generafile(
|
|
documento_encabezado.*,
|
|
documento_detalle,
|
|
codigo_sucursal,
|
|
codigo_sucursal,
|
|
'adicionar')
|
|
RETURNING xhash, respuesta, xfechaFirmaDigital, codigo
|
|
|
|
LET informacion.mensaje = respuesta
|
|
LET informacion.ultima_Respuesta = respuesta
|
|
ELSE
|
|
LET informacion.mensaje = "NO PUDE ENVIAR EL FILE, LA TASA ESTA EN NULO"
|
|
END IF
|
|
DISPLAY respuesta TO mensaje
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION NCyND()
|
|
DEFINE
|
|
xitbis, xsub_total DEC(12, 2),
|
|
j, xsecvend INT,
|
|
query STRING
|
|
LET fecha = NULL
|
|
|
|
SELECT a.factura,
|
|
a.fecha_factura,
|
|
ISNULL(b.idtipo, '1'),
|
|
a.prima_us,
|
|
a.porc_itbi,
|
|
a.sec_Vend
|
|
INTO factura1, fecha, tipo, tasa, pitbis, xsecvend
|
|
FROM vetb00002 a
|
|
INNER
|
|
JOIN cctb00001 b
|
|
ON a.factura = b.aplica_a AND a.sucid = b.sucid
|
|
INNER
|
|
JOIN vetb00012 c
|
|
ON c.cond_pago = a.cond_pago
|
|
WHERE b.num_doc = informacion.num_doc
|
|
AND b.tipo_Doc = tipodocumento
|
|
AND b.tipo_cliente = informacion.tipo_cliente
|
|
AND b.sec_cliente = informacion.sec_cliente
|
|
AND a.sucid = xsucid
|
|
|
|
LET documento_encabezado.numeroFacturaInterna = informacion.num_doc
|
|
LET documento_encabezado.fechaEmision = fecha USING "dd-mm-yyyy"
|
|
LET documento_encabezado.fechaNCFmodificado = fecha USING "dd-mm-yyyy"
|
|
LET documento_encabezado.codigoVendedor = xsecvend USING "<<<<<<"
|
|
|
|
IF tipo IS NULL THEN
|
|
LET tipo = 0
|
|
END IF
|
|
|
|
LET documento_encabezado.codigomodificacion = tipo USING "&"
|
|
LET documento_encabezado.NCFmodificado = informacion.ncf_mod
|
|
|
|
LET documento_encabezado.itbis1 = pitbis
|
|
|
|
IF informacion.codigo_dgii = '34' THEN
|
|
LET documento_encabezado.tipoPago = 1 USING "&"
|
|
|
|
--ESTE QUERY NO QUIERE FUNCIONAR POR LA PALABRA RESERVADA "DAY"
|
|
--comentario JH: NO FUNCIONA PORQUE ES UNA PALABRA RESERVADA EL LENGUAJE, PARA EVITAR ESTO,
|
|
--- LO QUE HACES ES ENVIAR EL QUERY A SQL SERVER CON UN PREPARE, ADEMAS
|
|
--- NO ES NECESARIO HACER ESTO, PUEDES HACER UN CALCULO EN EL LENGUAJE CON LAS DOS FECHAS
|
|
|
|
LET query =
|
|
"select DATEDIFF(DAY,b.fecha_factura, a.fecha_orig) from cctb00001 a inner join vetb00002 b on a.aplica_a = b.factura
|
|
where a.tipo_doc ='",
|
|
informacion.tipo_doc,
|
|
"' and a.num_doc = '",
|
|
informacion.num_doc,
|
|
"'"
|
|
|
|
PREPARE DateDif FROM query
|
|
EXECUTE DateDif INTO dias
|
|
|
|
LET dias = informacion.fecha - fecha
|
|
|
|
DISPLAY dias
|
|
|
|
IF dias > 30 THEN
|
|
LET documento_encabezado.IndicadorNotaCredito = '1'
|
|
ELSE
|
|
LET documento_encabezado.IndicadorNotaCredito = '0'
|
|
END IF
|
|
|
|
{ LET documento_encabezado.itbis3 = '0' USING "<<<<<<<<<<<<<&.##"
|
|
LET documento_encabezado.montoGravadoI3 = '00' USING "<<<<<<<<<<<<<&.##"
|
|
LET documento_encabezado.totalItbis3 = '00' USING "<<<<<<<<<<<<<&.##"}
|
|
|
|
END IF
|
|
LET documento_encabezado.indicadorMontoGravado = '0' USING "&"
|
|
|
|
DECLARE items2 CURSOR FOR
|
|
SELECT a.cod_n,
|
|
a.cod_Grupo,
|
|
a.cod_tipo,
|
|
a.cod_sec,
|
|
a.cantidad,
|
|
a.precio,
|
|
a.porc_desc,
|
|
a.descuento,
|
|
a.itbis,
|
|
a.descripcion,
|
|
B.tipoproducto
|
|
FROM cctb00010 a, iptb00002 b
|
|
WHERE a.num_doc = informacion.num_doc
|
|
AND a.tipo_doc = informacion.tipo_doc
|
|
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 i = 1
|
|
FOREACH items2
|
|
INTO arr_articulos[i].cod_n,
|
|
arr_articulos[i].cod_grupo,
|
|
arr_articulos[i].cod_tipo,
|
|
arr_articulos[i].cod_sec,
|
|
arr_articulos[i].cantidad_1,
|
|
arr_articulos[i].precio,
|
|
arr_articulos[i].por_desc,
|
|
arr_articulos[i].valor_desc,
|
|
arr_articulos[i].valor_itbis,
|
|
arr_articulos[i].descrip_Esp,
|
|
arr_articulos[i].id_tipo
|
|
|
|
IF arr_articulos[i].precio > 0 THEN
|
|
CALL calculos()
|
|
RETURNING tvalor_bruto, tdescuento, tsub_total, titbis, tneto
|
|
LET xitbis = titbis
|
|
LET xsub_total = tsub_total
|
|
LET i = i + 1
|
|
END IF
|
|
END FOREACH
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION FT()
|
|
DEFINE
|
|
pcotizacion, codigo_provincia INT,
|
|
xdireccion_proyecto, selec STRING
|
|
|
|
LET xdireccion_proyecto = NULL
|
|
LET selec =
|
|
"
|
|
SELECT a.nombre_cliente,a.direccion_cliente,a.direccion_proyecto,a.rnc,
|
|
a.cod_zona,a.cod_provincia
|
|
FROM marmotech.dbo.vetb00050 a
|
|
WHERE a.cotizacion_no = ?
|
|
"
|
|
|
|
-- LET factura1 = informacion.num_doc
|
|
SELECT a.codigo_dgii, b.prima_us, b.porc_itbi, a.dias
|
|
INTO documento_encabezado.tipoPago, tasa, pitbis, xdias
|
|
FROM vetb00012 a, vetb00002 b
|
|
WHERE a.cond_pago = b.cond_pago
|
|
AND b.factura = informacion.num_doc
|
|
AND b.sucid = xsucid
|
|
|
|
IF pitbis IS NULL THEN
|
|
LET pitbis = 0
|
|
END IF
|
|
|
|
LET pcotizacion = NULL
|
|
SELECT a.cotizacion_no
|
|
INTO pcotizacion
|
|
FROM prtb00012 a
|
|
WHERE a.num_oc = fact_gral.orden AND a.status_t IS NULL
|
|
|
|
PREPARE bcotizacion FROM selec
|
|
EXECUTE bcotizacion
|
|
INTO fact_gral.nombre, fact_gral.direccion, xdireccion_proyecto, fact_gral.zona, codigo_provincia USING pcotizacion
|
|
|
|
SELECT d.nombre_provincia, d.id_dgii, d.id_municipio_dgii
|
|
INTO fact_gral.ciudad,
|
|
documento_encabezado.ProvinciaComprador,
|
|
documento_encabezado.MunicipioComprador
|
|
FROM vetb00020 d
|
|
WHERE d.cod_provincia = codigo_provincia
|
|
|
|
IF pcotizacion IS NULL THEN
|
|
LET fact_gral.direccion = NULL
|
|
SELECT RTRIM(a.calle) || ' ' || RTRIM(a.casa_num) || ' '
|
|
|| RTRIM(a.urbanizacion)
|
|
|| ' '
|
|
|| RTRIM(a.barrio)
|
|
INTO fact_gral.direccion
|
|
FROM vetb00005 a
|
|
WHERE a.tipo_cliente = informacion.tipo_cliente
|
|
AND a.sec_cliente = informacion.sec_cliente
|
|
END IF
|
|
|
|
{ LET documento_encabezado.itbis3 = '0' USING "<<<<<<<<<<<<<&.##"
|
|
LET documento_encabezado.montoGravadoI3 = '00' USING "<<<<<<<<<<<<<&.##"
|
|
LET documento_encabezado.totalItbis3 = '00' USING "<<<<<<<<<<<<<&.##" }
|
|
|
|
--DOCUMENTO DETALLE
|
|
|
|
DECLARE items CURSOR FOR
|
|
SELECT a.area,
|
|
a.cod_n,
|
|
a.cod_grupo,
|
|
a.cod_tipo,
|
|
a.cod_sec,
|
|
a.cantidad,
|
|
ISNULL(a.cantidad_2, 0),
|
|
a.descripcion,
|
|
a.precio,
|
|
b.tipoproducto
|
|
FROM vetb00003 a, iptb00002 b
|
|
WHERE a.factura = informacion.num_doc
|
|
AND a.sucid = xsucid
|
|
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 i = 1
|
|
FOREACH items
|
|
INTO arr_articulos[i].area,
|
|
arr_articulos[i].cod_n,
|
|
arr_articulos[i].cod_Grupo,
|
|
arr_articulos[i].cod_tipo,
|
|
arr_articulos[i].cod_Sec,
|
|
arr_articulos[i].cantidad_1,
|
|
arr_articulos[i].cantidad_2,
|
|
arr_articulos[i].descrip_Esp,
|
|
arr_articulos[i].precio,
|
|
arr_articulos[i].id_tipo
|
|
|
|
LET dvalor_bruto = arr_articulos[i].precio * arr_articulos[i].cantidad_1
|
|
DISPLAY "BRUTO ", dvalor_bruto
|
|
LET ddescuento = dvalor_bruto * (arr_articulos[i].cantidad_2 / 100)
|
|
|
|
--ddescuento original: dvalor_bruto * (arr_articulos[idx].por_desc /100)
|
|
--no tengo porc_desc
|
|
|
|
LET dprecio =
|
|
dvalor_bruto
|
|
- ddescuento #(arr_articulos[i].precio * arr_articulos[i].cantidad_1)
|
|
LET dsub_total = dvalor_bruto - ddescuento
|
|
LET dneto = dsub_total
|
|
|
|
LET documento_detalle[i].DescripcionItem = NULL
|
|
LET documento_detalle[i].cantidadItem =
|
|
arr_articulos[i].cantidad_1 USING "<<<<<<<<<<<<<&.##"
|
|
LET documento_detalle[i].indicadorFacturacion = '1' USING "&"
|
|
|
|
IF informacion.codigo_dgii = 44 THEN
|
|
LET documento_detalle[i].indicadorFacturacion = '4' USING "&"
|
|
END IF
|
|
|
|
IF informacion.codigo_dgii = 46 THEN
|
|
LET documento_detalle[i].indicadorFacturacion = '3' USING "&"
|
|
END IF
|
|
|
|
LET documento_detalle[i].precioUnitarioItem =
|
|
{ (arr_articulos[i].precio*tasa) -((arr_articulos[i].precio*tasa) *
|
|
(arr_articulos[i].cantidad_2 / 100))}
|
|
dprecio * tasa USING "<<<<<<<<<<<<<<<&.##"
|
|
|
|
# ANTES ((arr_articulos[i].valor / arr_articulos[i].cantidad_1) * tasa) USING "<<<<<<<<<<<&.####"
|
|
|
|
DISPLAY "AHORA ",
|
|
dneto,
|
|
" | ",
|
|
arr_articulos[i].cantidad_1,
|
|
" | ",
|
|
tasa,
|
|
" pre ",
|
|
dprecio
|
|
|
|
LET documento_detalle[i].montoItem =
|
|
dneto * tasa USING "<<<<<<<<<<<<<&.##"
|
|
|
|
LET documento_detalle[i].nombreItem =
|
|
arr_articulos[i].descrip_Esp CLIPPED
|
|
LET documento_detalle[i].indicadorBienoServicio =
|
|
arr_articulos[i].id_tipo
|
|
|
|
LET i = i + 1
|
|
END FOREACH
|
|
|
|
END FUNCTION
|
|
FUNCTION calculos()
|
|
DEFINE
|
|
dvalor_bruto,
|
|
ddescuento,
|
|
dprecio,
|
|
dsub_total,
|
|
ditbis,
|
|
dneto,
|
|
tvalor_bruto,
|
|
tdescuento,
|
|
tsub_total,
|
|
titbis,
|
|
tneto,
|
|
ldesc
|
|
DEC(12, 2),
|
|
idx INT
|
|
|
|
IF pitbis IS NULL THEN
|
|
LET pitbis = 0
|
|
END IF
|
|
|
|
LET documento_encabezado.itbis1 = pitbis USING "&&"
|
|
|
|
LET ldesc = 0
|
|
LET tvalor_bruto = 0
|
|
LET tdescuento = 0
|
|
LET tsub_total = 0
|
|
LET titbis = 0
|
|
LET tneto = 0
|
|
LET ditbis = 0
|
|
LET dsub_total = 0
|
|
LET dvalor_bruto = 0
|
|
|
|
FOR idx = 1 TO arr_articulos.getLength()
|
|
IF arr_articulos[idx].precio > 0 THEN
|
|
|
|
LET ditbis = 0
|
|
LET dvalor_bruto =
|
|
arr_articulos[idx].precio * arr_articulos[idx].cantidad_1
|
|
LET ddescuento = arr_articulos[i].valor_desc
|
|
LET dprecio =
|
|
(arr_articulos[idx].precio * arr_articulos[idx].cantidad_1)
|
|
LET dsub_total = dvalor_bruto - ddescuento
|
|
LET dneto = dsub_total
|
|
|
|
IF dias > 30 THEN
|
|
LET ditbis = 0
|
|
LET documento_encabezado.indicadorMontoGravado = '0' USING "&"
|
|
IF informacion.tipo_doc = 'NC' THEN
|
|
LET documento_encabezado.IndicadorNotaCredito = '1'
|
|
ELSE
|
|
LET documento_encabezado.IndicadorNotaCredito = NULL
|
|
END IF
|
|
{ LET documento_encabezado.itbis3 = '0' USING "<<<<<<<<<<<<<&.##"
|
|
LET documento_encabezado.montoGravadoI3 = '00' USING "<<<<<<<<<<<<<&.##"
|
|
LET documento_encabezado.totalItbis3 = '00' USING "<<<<<<<<<<<<<&.##" }
|
|
ELSE
|
|
IF informacion.tipo_nc = '01' THEN
|
|
|
|
LET ditbis = dsub_total * (pitbis / 100)
|
|
LET arr_articulos[idx].valor_itbis = ditbis
|
|
|
|
LET ditbis = arr_articulos[idx].valor_itbis
|
|
LET documento_encabezado.indicadorMontoGravado = '1'
|
|
ELSE
|
|
{
|
|
LET documento_encabezado.itbis3 = '0' USING "<<<<<<<<<<<<<&.##"
|
|
LET documento_encabezado.montoGravadoI3 = '00' USING "<<<<<<<<<<<<<&.##"
|
|
LET documento_encabezado.totalItbis3 = '00' USING "<<<<<<<<<<<<<&.##" }
|
|
END IF
|
|
END IF
|
|
|
|
LET dneto = dsub_total
|
|
LET ldesc =
|
|
arr_articulos[idx].precio - arr_articulos[idx].valor_desc
|
|
|
|
LET arr_articulos[idx].valor_desc = ddescuento
|
|
LET arr_articulos[idx].valor_itbis = ditbis
|
|
LET arr_articulos[idx].valor = dneto
|
|
|
|
LET documento_detalle[idx].DescripcionItem = NULL
|
|
LET documento_detalle[idx].cantidadItem =
|
|
arr_articulos[idx].cantidad_1 USING "<<<<<<<<<<<<<&.##"
|
|
LET documento_detalle[idx].indicadorFacturacion = '1' USING "&"
|
|
LET documento_detalle[idx].precioUnitarioItem =
|
|
(arr_articulos[idx].valor / arr_articulos[idx].cantidad_1)
|
|
* tasa
|
|
USING "<<<<<<<<<<<&.##"
|
|
LET documento_detalle[idx].montoItem =
|
|
dneto * tasa USING "<<<<<<<<<<<<<&.##"
|
|
|
|
LET documento_detalle[idx].nombreItem =
|
|
arr_articulos[idx]
|
|
.descrip_Esp CLIPPED --Tengo la descripcion pero no el nombre del producto
|
|
LET documento_detalle[idx].indicadorBienoServicio =
|
|
arr_articulos[idx]
|
|
.id_tipo --el generafile llena este campo, pero no estoy convencido
|
|
|
|
DISPLAY "DITBIS ",
|
|
ditbis,
|
|
" s ",
|
|
dsub_total,
|
|
" v ",
|
|
idx,
|
|
"Dias: ",
|
|
dias
|
|
|
|
LET dneto = dsub_total + ditbis
|
|
LET ldesc = 0
|
|
LET tvalor_bruto = tvalor_bruto + dvalor_bruto
|
|
LET tdescuento = tdescuento + ddescuento
|
|
LET tsub_total = tsub_total + dsub_total
|
|
LET titbis = titbis + ditbis
|
|
LET tneto = tneto + dneto
|
|
END IF
|
|
END FOR
|
|
# LET monto_efectivo = tvalor_bruto
|
|
RETURN tvalor_bruto, tdescuento, tsub_total, titbis, tneto
|
|
END FUNCTION
|
|
|
|
FUNCTION ConsultaTrackID()
|
|
|
|
DEFINE
|
|
respuesta, xrespuesta, phash, tiporecepcion STRING,
|
|
codigo INT,
|
|
prima DECIMAL(6, 2)
|
|
|
|
LET respuesta = informacion.ultima_Respuesta
|
|
|
|
IF informacion.codigo_dgii == 32 THEN
|
|
|
|
SELECT prima_us
|
|
INTO prima
|
|
FROM vetb00002
|
|
WHERE factura = informacion.num_doc AND sucid = informacion.sucid
|
|
|
|
IF (informacion.valor * prima) > 250000 THEN
|
|
LET tiporecepcion = 'normal'
|
|
ELSE
|
|
LET tiporecepcion = 'consumo'
|
|
END IF
|
|
ELSE
|
|
LET tiporecepcion = 'normal'
|
|
END IF
|
|
|
|
TRY
|
|
IF informacion.codigo_dgii <> 32
|
|
OR informacion.codigo_dgii == 32 AND tiporecepcion == 'normal' THEN
|
|
|
|
CALL procesoEncf(
|
|
' ',
|
|
ambiente,
|
|
tiporecepcion,
|
|
0,
|
|
0,
|
|
'consultatrackid',
|
|
respuesta)
|
|
RETURNING phash, xrespuesta, codigo
|
|
|
|
CALL util.JSON.parse(xrespuesta, p)
|
|
LET estado_d = p.estado
|
|
LET informacion.estado_dgii = p.estado
|
|
DISPLAY xrespuesta
|
|
|
|
END IF
|
|
|
|
IF informacion.codigo_dgii == 32 AND tiporecepcion == 'consumo' THEN
|
|
|
|
CALL procesoEncf(
|
|
' ',
|
|
ambiente,
|
|
tiporecepcion,
|
|
0,
|
|
0,
|
|
'consultatrackid',
|
|
respuesta)
|
|
RETURNING phash, xrespuesta, codigo
|
|
|
|
IF codigo == 200 THEN
|
|
CALL util.JSON.parse(respuesta, p32)
|
|
LET p.estado = p32.estado
|
|
LET p.mensajes[1].valor = p32.mensajes
|
|
LET estado_d = p32.estado
|
|
LET informacion.estado_dgii = p.estado
|
|
|
|
ELSE
|
|
CALL util.JSON.parse(respuesta, p32err)
|
|
LET p.estado = p32err.estado
|
|
LET estado_d = p32err.estado
|
|
LET p.mensajes[1].valor = p32err.mensajes[1].valor
|
|
LET informacion.estado_dgii = p.estado
|
|
END IF
|
|
END IF
|
|
|
|
CATCH
|
|
DISPLAY "NO PUDE PARSEAR LA RESPUESTA EN EL PROGRAMA VEPRMT113" TO error
|
|
END TRY
|
|
END FUNCTION
|
|
|
|
FUNCTION enviarlog(caso)
|
|
|
|
DEFINE
|
|
caso INT,
|
|
accion STRING
|
|
|
|
IF caso = 1 THEN
|
|
LET accion = 'ENVIAR FACTURA'
|
|
ELSE
|
|
LET accion = 'CHEQUEAR TRACK ID'
|
|
END IF
|
|
|
|
INSERT INTO vetb00113_log(
|
|
usuario,
|
|
fecha_log,
|
|
accion,
|
|
fecha,
|
|
status_t,
|
|
orden,
|
|
num_doc,
|
|
doc_alm,
|
|
bodega,
|
|
cod_mov,
|
|
tipo_doc,
|
|
codigo_dgii,
|
|
tipo_cliente,
|
|
sec_cliente,
|
|
nombre_cliente,
|
|
rnc1,
|
|
ncf,
|
|
ncf_mod,
|
|
valor,
|
|
itbis,
|
|
codigosegudad,
|
|
trackid,
|
|
estado_dgii,
|
|
ERROR,
|
|
mensaje,
|
|
ultima_respuesta,
|
|
sucid,
|
|
tipo_nc)
|
|
VALUES(usuarios,
|
|
GETDATE(),
|
|
accion,
|
|
informacion.fecha,
|
|
informacion.status_t,
|
|
informacion.orden,
|
|
informacion.num_doc,
|
|
informacion.doc_alm,
|
|
informacion.bodega,
|
|
informacion.cod_mov,
|
|
informacion.tipo_doc,
|
|
informacion.codigo_dgii,
|
|
informacion.tipo_cliente,
|
|
informacion.sec_cliente,
|
|
informacion.nombre_cliente,
|
|
informacion.rnc1,
|
|
informacion.ncf,
|
|
informacion.ncf_mod,
|
|
informacion.valor,
|
|
informacion.itbis,
|
|
informacion.codigosegudad,
|
|
informacion.trackid,
|
|
informacion.estado_dgii,
|
|
informacion.error,
|
|
informacion.mensaje,
|
|
informacion.ultima_Respuesta,
|
|
informacion.sucid,
|
|
informacion.tipo_nc)
|
|
|
|
END FUNCTION
|
|
|
|
FUNCTION init_conditions()
|
|
|
|
DEFINE i SMALLINT
|
|
DEFINE cb_condition ui.ComboBox
|
|
DEFINE condicion STRING
|
|
|
|
LET cb_condition = ui.ComboBox.forName("formonly.combovalue2")
|
|
|
|
DECLARE buscar1 CURSOR FOR SELECT DISTINCT estado_dgii FROM vetb00002
|
|
|
|
LET i = 1
|
|
CALL cb_condition.clear()
|
|
|
|
FOREACH buscar1 INTO condicion
|
|
CALL cb_condition.addItem(condicion, condicion)
|
|
LET i = i + 1
|
|
END FOREACH
|
|
|
|
END FUNCTION
|
|
FUNCTION updatehash(phash)
|
|
DEFINE phash VARCHAR(6)
|
|
IF informacion.tipo_doc = 'FT' THEN
|
|
DISPLAY "data ", phash, " fecha ", xfechaFirmaDigital
|
|
UPDATE vetb00002
|
|
SET hash = phash
|
|
WHERE factura = informacion.num_doc AND sucid = informacion.sucid
|
|
ELSE
|
|
UPDATE cctb00001
|
|
SET hash = phash
|
|
WHERE num_doc = informacion.num_doc
|
|
AND sucid = informacion.sucid
|
|
AND tipo_Doc = informacion.tipo_doc
|
|
|
|
END IF
|
|
END FUNCTION
|
|
|
|
FUNCTION gethash1(envfile)
|
|
DEFINE i, l INTEGER
|
|
DEFINE r om.XmlReader
|
|
DEFINE
|
|
e, envfile STRING,
|
|
phash VARCHAR(6),
|
|
pfechafirmadigital VARCHAR(50),
|
|
facturainterna INT
|
|
DEFINE a om.SaxAttributes
|
|
DISPLAY "filexml en hash1: ", envfile
|
|
IF os.Path.exists(envfile) THEN
|
|
LET r = om.XmlReader.createFileReader(envfile)
|
|
LET l = 0
|
|
LET e = r.read()
|
|
|
|
WHILE e IS NOT NULL
|
|
|
|
CASE e
|
|
WHEN "StartDocument"
|
|
# DISPLAY "StartDocument:"
|
|
WHEN "StartElement"
|
|
LET l = l + 1
|
|
#DISPLAY l SPACES, "StartElement:", r.getTagName()
|
|
LET a = r.getAttributes()
|
|
FOR i = 1 TO a.getLength()
|
|
IF a.getName(i) = "SignatureValue" THEN
|
|
LET phash = r.getCharacters()
|
|
|
|
# DISPLAY l SPACES," ",
|
|
# a.getName(i)," = ",
|
|
# a.getValueByIndex(i)
|
|
END IF
|
|
END FOR
|
|
WHEN "Characters"
|
|
|
|
IF r.getTagName() = "SignatureValue" THEN
|
|
LET phash = r.getCharacters()
|
|
DISPLAY "token dentro de gettoken: ", phash
|
|
|
|
END IF
|
|
IF r.getTagName() = "FechaHoraFirma" THEN
|
|
|
|
LET xfechafirmadigital = r.getCharacters()
|
|
DISPLAY "en firma ", xfechafirmadigital
|
|
# DISPLAY "token dentro de gettoken: ",tok
|
|
EXIT CASE
|
|
END IF
|
|
IF r.getTagName() = "NumeroFacturaInterna" THEN
|
|
LET facturainterna = r.getCharacters()
|
|
DISPLAY "factura interna: ", facturainterna
|
|
EXIT CASE
|
|
END IF
|
|
|
|
WHEN "SkippedEntity"
|
|
# DISPLAY "Entity:'",r.skippedEntity(),"'"
|
|
WHEN "EndElement"
|
|
# DISPLAY l SPACES, "EndElement:", r.getTagName()
|
|
LET l = l - 1
|
|
WHEN "EndDocument"
|
|
# DISPLAY "EndDocument:"
|
|
OTHERWISE
|
|
# DISPLAY "Invalid event: ",e
|
|
END CASE
|
|
LET e = r.read()
|
|
END WHILE
|
|
ELSE
|
|
LET phash = 'NOEXIS'
|
|
END IF
|
|
RETURN phash
|
|
END FUNCTION
|
|
FUNCTION verificaEstado()
|
|
DEFINE
|
|
url,
|
|
tokenxml,
|
|
rutasemilla,
|
|
token,
|
|
rtoken,
|
|
body,
|
|
url_semilla,
|
|
url_validasemilla
|
|
STRING,
|
|
http_req com.HttpRequest,
|
|
http_resp com.HTTPResponse,
|
|
doc xml.DomDocument
|
|
|
|
DEFINE api tRespDGII
|
|
LET rutaSemilla = fgl_getenv("RUTA_SEMILLA")
|
|
|
|
# ESTA SEMILLA ESTA DIRECCIONADA AL AMBIENTE PRODUCCION
|
|
LET url_semilla =
|
|
"https://ecf.dgii.gov.do/ecf/autenticacion/api/autenticacion/semilla"
|
|
LET url_validasemilla =
|
|
"https://ecf.dgii.gov.do/ecf/Autenticacion/api/Autenticacion/ValidarSemilla"
|
|
|
|
CALL buscatoken(url_semilla) RETURNING codigo, tokenxml
|
|
|
|
# Create DomDocument object
|
|
LET doc = xml.DomDocument.Create()
|
|
# Notice that whitespaces are significant in cryptography,
|
|
# therefore it is recommended to remove unnecessary ones
|
|
CALL doc.setFeature("whitespace-in-element-content", FALSE)
|
|
|
|
CALL doc.loadFromString(tokenxml)
|
|
# CALL doc.save(".\\filesXML\\marmotech\\mtechTokenString.xml")
|
|
CALL doc.save(rutaSemilla || "/TokenString.xml")
|
|
#FIRMA SEMILLA
|
|
|
|
IF os.Path.exists(rutaSemilla || "/TokenString.xml") THEN
|
|
CALL firmasemilla()
|
|
ELSE
|
|
LET respuesta = "NO PUDE CREAR SEMILLA"
|
|
RETURN ' ', respuesta, '400'
|
|
END IF
|
|
|
|
IF os.Path.exists(rutaSemilla || "/Signature.xml") THEN
|
|
CALL validasemilla1(url_validasemilla) RETURNING codigo, respuesta
|
|
|
|
IF codigo = 400 THEN
|
|
|
|
DISPLAY "respuesta1: ", respuesta, ' 400'
|
|
END IF
|
|
|
|
ELSE
|
|
LET respuesta = "NO ENCONTRE LA SEMILLA FIRMADA"
|
|
|
|
DISPLAY "respuesta2: ", respuesta, ' 400'
|
|
END IF
|
|
|
|
IF respuesta IS NOT NULL THEN
|
|
LET doc = xml.DomDocument.Create()
|
|
|
|
CALL doc.loadFromString(respuesta)
|
|
CALL doc.save(rutaSemilla || "/RespuestaValida.xml")
|
|
|
|
CALL gettoken1() RETURNING rtoken
|
|
LET token = rtoken
|
|
# UPDATE token SET valor = rtoken,fecha=getdate()
|
|
|
|
ELSE
|
|
LET respuesta = "NO TENEMOS RESPUESTA DE VALIDA SEMILLA"
|
|
DISPLAY "respuesta3: ", respuesta, ' 400'
|
|
END IF
|
|
|
|
IF informacion.codigo_dgii == 32 THEN
|
|
LET url =
|
|
"https://fc.dgii.gov.do/ecf/consultarfce/api/consultas/consulta?RNC_Emisor=",
|
|
p_companias.rnc CLIPPED,
|
|
"&ENCF=",
|
|
informacion.ncf CLIPPED,
|
|
"&cod_seguridad_ecf=",
|
|
informacion.codigosegudad CLIPPED
|
|
|
|
ELSE
|
|
LET url =
|
|
"https://ecf.dgii.gov.do/ecf/consultaestado/api/consultas/estado?RNCEmisor="
|
|
|| p_companias.rnc CLIPPED
|
|
|| "&ncfelectronico="
|
|
|| informacion.ncf CLIPPED
|
|
|| "&rnccomprador="
|
|
|| informacion.rnc1 CLIPPED
|
|
|| "&codigoseguridad="
|
|
|| informacion.codigosegudad
|
|
|
|
END IF
|
|
DISPLAY "la ruta: ", url
|
|
DISPLAY "el token: ", token
|
|
LET http_req = com.HTTPRequest.Create(url)
|
|
|
|
CALL http_req.setMethod("GET")
|
|
CALL http_req.setCharset("UTF-8")
|
|
CALL http_req.setHeader("accept", "application/json")
|
|
CALL http_req.setHeader("Authorization", "Bearer " || token)
|
|
CALL http_req.setConnectionTimeOut(10)
|
|
|
|
CALL http_req.doRequest()
|
|
|
|
LET http_resp = http_req.getResponse()
|
|
LET body = http_resp.getTextResponse()
|
|
|
|
LET codigo = http_resp.getStatusCode()
|
|
DISPLAY "la respuesta: ", codigo, " body: ", body
|
|
CALL parse_dgii_response(body) RETURNING api.*
|
|
|
|
IF api.estado IS NULL OR api.estado = "" THEN
|
|
IF api.mensajes[1].codigo IS NOT NULL
|
|
AND api.mensajes.getLength() > 0 THEN
|
|
LET api.estado = "Rechazado"
|
|
END IF
|
|
END IF
|
|
|
|
DISPLAY "EN INFORMACION: ", informacion.estado_dgii
|
|
DISPLAY "EL RECORD: ", api.estado
|
|
|
|
# ACTUALIZA LA TABLA DE LA VENTAS
|
|
IF api.estado IS NOT NULL OR api.estado <> '' THEN
|
|
|
|
IF informacion.estado_dgii <> api.estado THEN
|
|
UPDATE vetb00002
|
|
SET estado_dgii = api.estado,
|
|
us_mod = usuarios,
|
|
fech_mod = getdate()
|
|
WHERE ncf = informacion.ncf
|
|
|
|
END IF
|
|
END IF
|
|
END FUNCTION
|
|
|
|
FUNCTION validasemilla1(url_validasemilla1)
|
|
DEFINE
|
|
respuesta, codigo, url_validasemilla1, rutaSemilla STRING,
|
|
http_req com.HttpRequest,
|
|
http_resp com.HTTPResponse
|
|
|
|
LET rutaSemilla = fgl_getenv("RUTA_SEMILLA")
|
|
|
|
LET http_req = com.HTTPRequest.Create(url_validasemilla1)
|
|
|
|
CALL http_req.setMethod("POST")
|
|
CALL http_req.setCharset("UTF-8")
|
|
CALL http_req.setHeader("accept", "application/xml")
|
|
CALL http_req.setMultipartType("form-data", NULL, NULL)
|
|
CALL http_req.setConnectionTimeOut(10)
|
|
IF os.Path.exists(rutaSemilla || "/Signature.xml") THEN
|
|
|
|
# CALL http_req.setHeader("Content-Disposition", "form-data; name=\"xml\"; filename=\"naceSignature.xml\"")
|
|
CALL http_req.setHeader(
|
|
"Content-Disposition",
|
|
"form-data; name=\"xml\"; filename=\"Signature.xml\"")
|
|
|
|
# TRY
|
|
CALL http_req.doFileRequest(rutaSemilla || "/Signature.xml")
|
|
# CATCH
|
|
-- Intentar obtener la
|
|
|
|
# RETURN 400, "NO OBTUVE RESPUESTA DEL SERICIO AL VALIDAR SEMILLA"
|
|
# END TRY
|
|
|
|
-- Continuar con la ejecución normal si no se produjo una excepción
|
|
LET http_resp = http_req.getResponse()
|
|
LET codigo = http_resp.getStatusCode()
|
|
LET respuesta = http_resp.getTextResponse()
|
|
DISPLAY "respuesta valida semilla: ", respuesta
|
|
ELSE
|
|
LET codigo = 400
|
|
LET respuesta = 'NO ENCONTRE EL FILE PARA VALIDAR SEMILLA'
|
|
END IF
|
|
|
|
RETURN codigo, respuesta
|
|
|
|
END FUNCTION
|
|
FUNCTION gettoken1()
|
|
DEFINE i, l INTEGER
|
|
DEFINE r om.XmlReader
|
|
DEFINE e, tok, rutaSemilla STRING
|
|
DEFINE a om.SaxAttributes
|
|
# DISPLAY "filexml: ",filexml
|
|
|
|
LET rutaSemilla = fgl_getenv("RUTA_SEMILLA")
|
|
|
|
LET r = om.XmlReader.createFileReader(rutaSemilla || "/RespuestaValida.xml")
|
|
LET l = 0
|
|
LET e = r.read()
|
|
|
|
WHILE e IS NOT NULL
|
|
CASE e
|
|
WHEN "StartDocument"
|
|
# DISPLAY "StartDocument:"
|
|
WHEN "StartElement"
|
|
LET l = l + 1
|
|
# DISPLAY l SPACES, "StartElement:", r.getTagName()
|
|
LET a = r.getAttributes()
|
|
FOR i = 1 TO a.getLength()
|
|
IF a.getName(i) = "token" THEN
|
|
# DISPLAY l SPACES," ",
|
|
# a.getName(i)," = ",
|
|
# a.getValueByIndex(i)
|
|
END IF
|
|
END FOR
|
|
WHEN "Characters"
|
|
|
|
IF r.getTagName() = "token" THEN
|
|
LET tok = r.getCharacters()
|
|
# DISPLAY "token dentro de gettoken: ",tok
|
|
EXIT CASE
|
|
END IF
|
|
WHEN "SkippedEntity"
|
|
# DISPLAY "Entity:'",r.skippedEntity(),"'"
|
|
WHEN "EndElement"
|
|
# DISPLAY l SPACES, "EndElement:", r.getTagName()
|
|
LET l = l - 1
|
|
WHEN "EndDocument"
|
|
# DISPLAY "EndDocument:"
|
|
OTHERWISE
|
|
# DISPLAY "Invalid event: ",e
|
|
END CASE
|
|
LET e = r.read()
|
|
END WHILE
|
|
RETURN tok
|
|
END FUNCTION
|