First upload

This commit is contained in:
2026-03-17 14:12:37 +01:00
commit c857900860
46 changed files with 3343 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
/**
* Acciones base para operaciones CRUD y búsquedas
*/
export const actions = {
/**
* Inserta o actualiza un registro y devuelve el objeto completo actualizado
*/
_set: async (db, { table, view, data }) => {
// Si el id viene vacío o es 0, lo eliminamos para que MariaDB genere uno nuevo (AUTO_INCREMENT)
if (!data.id) delete data.id;
const result = await db.upsert(table, data);
// Normalizamos la respuesta del driver de MariaDB
const res = Array.isArray(result) ? result[0] : result;
// Obtenemos el ID: o bien el que ya venía en data, o el nuevo generado por el insert
const idToFetch = data.id || res?.insertId;
if (!idToFetch) throw new Error("No se pudo determinar el ID del registro");
// Devolvemos el registro fresco (útil si usamos una 'view' con campos calculados)
return db.one(view || table, { id: idToFetch });
},
/**
* Elimina un registro por ID
*/
_del: async (db, { table, id }) => {
if (!id) throw new Error("ID requerido para eliminar");
return db.delete(table, { id });
},
/**
* Obtiene todos los clientes (compatibilidad con ClientesOld)
*/
Clientes: async (db) => {
return db.select('ClientesOld');
},
Recibos: async (db) => {
return db.select('Recibos');
},
/**
* Búsqueda avanzada usando parámetros nombrados (raw query)
*/
Search: async (db, { text }) => {
const query = 'SELECT * FROM ClientesOld WHERE Cliente LIKE :term OR NIF LIKE :term';
const params = { term: `%${text}%` };
return db.raw(query, params);
}
};

View File

@@ -0,0 +1,138 @@
import schemaDataRaw from '../lib/schema.json' assert { type: 'json' };
// El schema se usa para validar qué columnas existen realmente en la DB
const schemaData = schemaDataRaw;
/**
* Formatea fechas a estándar ISO (YYYY-MM-DD) para MariaDB
*/
const fmt = (d) =>
(d instanceof Date && !isNaN(d.getTime()) ? d.toISOString().split('T')[0] : null);
/**
* Filtra y limpia las columnas según el schema.json
*/
const filterColumns = (tableName, rowData) => {
const schema = schemaData[tableName];
if (!schema) return rowData;
return Object.keys(rowData).reduce((cleanRow, col) => {
const colDef = schema[col];
if (!colDef) return cleanRow; // Si la columna no existe en el JSON, se ignora
let val = rowData[col];
const type = colDef.type || ''; // Usamos el campo 'type' generado por tu script anterior
if (val != null) {
// Lógica de fechas
if (type.includes('date')) {
try {
const s = val.toString().trim();
const isISO = val instanceof Date || s.includes('T');
val = isISO ? fmt(new Date(val)) :
/^\d{8}$/.test(s) ? `${s.slice(4, 8)}-${s.slice(2, 4)}-${s.slice(0, 2)}` :
s.includes('.') ? s.split('.').reverse().join('-') : s.slice(0, 10);
} catch {
val = null;
}
}
// Lógica de texto: trim y recorte por seguridad según definición
else if (type === 'text' && typeof val === 'string') {
val = val.trim().slice(0, 255);
}
}
cleanRow[col] = val;
return cleanRow;
}, {});
};
/**
* Orquestador para guardar datos transformados de SOAP a DB
*/
const saveSoap = async (db, raw, config) => {
if (!raw || !raw.length) return 0;
const rawArray = Array.isArray(raw) ? raw : [raw];
for (const [table, transform] of Object.entries(config)) {
const data = rawArray.flatMap(item => {
const res = transform ? transform(item) : item;
if (!res) return [];
return Array.isArray(res)
? res.map(sub => filterColumns(table, sub))
: [filterColumns(table, res)];
});
if (data.length) {
await db.upsert(table, data, true); // true para INSERT IGNORE
}
}
return rawArray.length;
};
/**
* Acciones exportables para el motor TRX
* Estas funciones son llamadas dinámicamente según el nombre del servicio SOAP
*/
export const actions = {
DescargaCompletaRecibos: async (db, { data }) => {
const raw = data.ListaRecibos?.ReciboAmpliado || data || [];
const total = await saveSoap(db, raw, { 'Recibos': null, 'RecibosEstados': null });
return { totalProcesado: total };
},
DescargaCartera: async (db, { data }) => {
const raw = data.DatosCartera?.Cartera || data || [];
const total = await saveSoap(db, raw, { 'Cartera': null });
return { totalProcesado: total };
},
DescargaSiniestros: async (db, { data }) => {
const raw = data.ListaSiniestros?.SiniestroAmpliado || data || [];
const total = await saveSoap(db, raw, { 'Siniestros': null, 'SiniestrosEstados': null });
return { totalProcesado: total };
},
ConsultaAgendaTramitacion: async (db, { data }) => {
const raw = data.Datos?.DatosTramitacionResponse || data || [];
const total = await saveSoap(db, raw, { 'SiniestrosTramites': null });
return { totalProcesado: total };
},
DescargaPolizas: async (db, { data }) => {
const raw = data.ListaPolizas?.Poliza || data || [];
const total = await saveSoap(db, raw, {
'Polizas': i => ({
...i.DatosGenerales,
Riesgo: [
i.DatosAccidentes?.NombreAsegurado,
i.DatosAutos?.CodigoModelo && `${i.DatosAutos.CodigoModelo} ${i.DatosAutos.Matricula || ''}`.trim(),
i.DatosMultirriesgos?.SituacionRiesgo
].filter(Boolean).join(' | ')
}),
'PolizasDetalle': i => i.DatosGenerales
? { ...i.DatosGenerales.DatosTomador, ...i.DatosGenerales, CodigoPoliza: i.DatosGenerales.CodigoPoliza, CodigoSuplemento: i.DatosGenerales.CodigoSuplemento }
: null,
'PolizasAutos': i => i.DatosAutos?.CodigoModelo
? { ...i.DatosAutos, CodigoPoliza: i.DatosGenerales.CodigoPoliza, CodigoSuplemento: i.DatosGenerales.CodigoSuplemento }
: null,
'PolizasAutosConductor': i => {
const { CodigoPoliza, CodigoSuplemento } = i.DatosGenerales || {};
const { DatosConductor: hab, DatosConductorOcasional: oca } = i.DatosAutos || {};
return [
hab?.Nombre ? { ...hab, CodigoPoliza, CodigoSuplemento, TipoConductor: 'Habitual' } : null,
oca?.Nombre ? { ...oca, CodigoPoliza, CodigoSuplemento, TipoConductor: 'Ocasional' } : null
].filter(Boolean);
},
'PolizasMultirriesgos': i => i.DatosMultirriesgos
? { ...i.DatosMultirriesgos, CodigoPoliza: i.DatosGenerales.CodigoPoliza, CodigoSuplemento: i.DatosGenerales.CodigoSuplemento }
: null,
'PolizasAccidentes': i => i.DatosAccidentes
? { ...i.DatosAccidentes, CodigoPoliza: i.DatosGenerales.CodigoPoliza, CodigoSuplemento: i.DatosGenerales.CodigoSuplemento }
: null
});
return { totalProcesado: total };
}
};

74
server/api/auth.js Normal file
View File

@@ -0,0 +1,74 @@
import { Hono } from 'hono'
import { sign } from 'hono/jwt'
import { pool } from '../services/db.service.js'
const auth = new Hono()
// Configuración externa
const SYNO_BASE = 'http://192.168.1.100:5000/webapi/auth.cgi'
const JWT_SECRET = process.env.JWT_SECRET || 'cambia_esto_en_el_env'
auth.post('/login', async (c) => {
const { username, password } = await c.req.json().catch(() => ({}))
if (!username || !password) {
return c.json({ success: false, message: 'Faltan credenciales' }, 400)
}
try {
// 1. Preparar parámetros para el NAS Synology
const params = new URLSearchParams({
api: 'SYNO.API.Auth',
version: '6',
method: 'login',
account: username,
passwd: password,
format: 'sid'
})
// 2. Petición al NAS usando el fetch nativo
const response = await fetch(`${SYNO_BASE}?${params.toString()}`)
const data = await response.json()
if (data.success && data.data) {
// 3. Generar JWT (expiración en 8 horas)
const payload = {
username,
sid: data.data.sid,
exp: Math.floor(Date.now() / 1000) + (60 * 60 * 8)
}
const token = await sign(payload, JWT_SECRET)
// 4. Asegurar el usuario en la base de datos (MariaDB)
try {
await pool.query('INSERT IGNORE INTO Usuarios (Usuario) VALUES (?)', [username])
} catch (dbError) {
console.error('Error al registrar usuario en DB:', dbError)
}
return c.json({
success: true,
token,
data: {
user: { username }
}
})
}
// Error de autenticación del NAS
return c.json({
success: false,
message: `Error de autenticación (Código: ${data.error?.code || 'unknown'})`
}, 401)
} catch (error) {
console.error('Error crítico en Auth:', error)
return c.json({
success: false,
message: 'NAS Unreachable / Internal Error'
}, 500)
}
})
export default auth

132
server/api/db.js Normal file
View File

@@ -0,0 +1,132 @@
import { Hono } from 'hono'
import { jwt } from 'hono/jwt'
import { db, trx } from '../services/db.service.js'
import { actions } from '../actions/db.actions.js'
import sharp from 'sharp'
import path from 'path'
import mime from 'mime-types'
const api = new Hono()
const JWT_SECRET = process.env.JWT_SECRET || 'tu_clave_secreta'
// --- MIDDLEWARE AUTH CON BYPASS ---
// api.use('/*', async (c, next) => {
// if (process.env.DISABLE_AUTH === 'true') {
// c.set('jwtPayload', { username: 'TEST_USER', role: 'admin' })
// return await next()
// }
// const jwtMiddleware = jwt({ secret: JWT_SECRET, alg: 'HS256' })
// return jwtMiddleware(c, next)
// })
// --- RUTA PARA TRANSACCIONES (TRX) ---
api.on(['GET', 'POST'], '/', async (c) => {
const body = c.req.method === 'POST' ? await c.req.json().catch(() => ({})) : {}
const query = c.req.query()
const postData = { ...query, ...body }
if (Object.keys(postData).length === 0) {
return c.json({ success: false, error: 'No data provided' }, 400)
}
try {
const data = await trx(postData, actions)
// Manejo de BigInt para evitar errores en JSON.stringify
const cleanData = JSON.parse(JSON.stringify(data, (_, v) => typeof v === 'bigint' ? v.toString() : v))
return c.json({ success: true, data: cleanData })
} catch (error) {
return c.json({ success: false, error: error.message }, 500)
}
})
// --- RUTA FICHAR ---
api.on(['GET', 'POST'], '/fichar/:query', async (c) => {
const payload = c.get('jwtPayload')
const user = payload?.username || 'ANONYMOUS'
const queryType = c.req.param('query')
try {
const ret = queryType === 'nuevo'
? await db.raw('CALL RegistrarFichaje(:user)', { user })
: await db.raw('SELECT Fecha, Tipo, Duracion FROM UsuariosFichajes WHERE Usuario = :user ORDER BY id DESC LIMIT 1', { user })
return c.json({ success: true, data: ret })
} catch (error) {
return c.json({ success: false, error: error.message }, 500)
}
})
// --- RUTA DE SUBIDA (UPLOAD) ---
api.post('/upload', async (c) => {
try {
const body = await c.req.parseBody()
const file = body.file
if (!file) throw new Error('No se ha enviado ningún archivo')
const arrayBuffer = await file.arrayBuffer()
let finalBuffer = Buffer.from(arrayBuffer)
const isImg = file.type.startsWith('image/')
if (isImg) {
finalBuffer = await sharp(finalBuffer)
.resize(1024, null, { withoutEnlargement: true })
.jpeg({ quality: 75 })
.toBuffer()
}
const res = await db.insert('Documentos', {
CodigoPoliza: body.CodigoPoliza || null,
CodigoRecibo: body.CodigoRecibo ? BigInt(body.CodigoRecibo) : null,
CodigoSiniestro: body.CodigoSiniestro ? BigInt(body.CodigoSiniestro) : null,
NIF: body.NIF || null,
Nombre: file.name,
Extension: isImg ? '.jpg' : path.extname(file.name).toLowerCase(),
Archivo: finalBuffer
})
const insertId = Array.isArray(res) ? res[0].insertId : res?.insertId
return c.json({ success: true, id: insertId?.toString() })
} catch (err) {
return c.json({ success: false, error: err.message }, 500)
}
})
// --- RUTA DE DESCARGA ---
api.get('/download', async (c) => {
try {
const { id, CodigoPoliza, CodigoRecibo, CodigoSiniestro, NIF, download } = c.req.query()
const filtros = Object.fromEntries(
Object.entries({ id, CodigoPoliza, CodigoRecibo, CodigoSiniestro, NIF })
.filter(([_, v]) => v)
)
if (Object.keys(filtros).length === 0) return c.json({ success: false, error: 'Faltan parámetros' }, 400)
const docs = await db.select('Documentos', filtros)
if (!docs.length) return c.json({ success: false, error: 'Sin resultados' }, 404)
if (id) {
const doc = docs[0]
const contentType = mime.lookup(doc.Extension) || 'application/octet-stream'
c.header('Content-Type', contentType)
c.header('Content-Disposition', `${download === 'true' ? 'attachment' : 'inline'}; filename="${doc.Nombre}"`)
return c.body(doc.Archivo)
}
return c.json(docs.map((doc) => {
const { Archivo, ...info } = doc
return {
...info,
id: info.id.toString(),
url: `/api/db/download?id=${info.id}`,
urlDownload: `/api/db/download?id=${info.id}&download=true`
}
}))
} catch (err) {
return c.json({ success: false, error: err.message }, 500)
}
})
export default api

33
server/api/mail.js Normal file
View File

@@ -0,0 +1,33 @@
import { Hono } from 'hono'
import { send } from '../services/mail.service.js'
const mail = new Hono()
/**
* Endpoint para envío de correo
* Soporta GET (para pruebas rápidas) y POST (para producción)
*/
mail.on(['GET', 'POST'], '/', async (c) => {
try {
// Llamamos al servicio de correo
// Nota: Aquí podrías extraer to, subject y html de c.req.json() o c.req.query()
await send(
'natxocc@natxocc.com',
'Prueba desde Hono',
'<h1>Este es un correo de prueba</h1>'
)
return c.json({
success: true,
message: 'Email enviado correctamente'
})
} catch (error) {
console.error('Error en ruta mail:', error)
return c.json({
success: false,
error: error.message
}, 500)
}
})
export default mail

61
server/api/soap.js Normal file
View File

@@ -0,0 +1,61 @@
import { Hono } from 'hono'
import { soapCall } from '../services/soap2.service.js'
const api = new Hono()
/**
* Endpoint simplificado: /api/soap/12345/Polizas
* El servicio soapCall se encarga de traducir "Polizas" a "DescargaPolizas"
*/
api.get('/:CodigoMediador/:alias', async (c) => {
const params = c.req.param() // Contiene CodigoMediador y alias
const query = c.req.query()
try {
// Pasamos params directamente porque soapCall ya sabe buscar el 'alias'
const result = await soapCall(params, query)
return c.json({
success: true,
data: result
})
} catch (error) {
console.error(`[Router Error] ${params.alias}:`, error.message)
return c.json({
success: false,
message: error.message || 'Error en el servicio externo SOAP'
}, 500)
}
})
export default api
/*
import { Hono } from 'hono'
import { soapCall } from '../services/soap2.service.js'
const api = new Hono()
api.get('/:CodigoMediador/:service/:method', async (c) => {
const params = c.req.param()
const query = c.req.query()
try {
const result = await soapCall(params, query)
return c.json({
success: true,
message: false,
data: result
})
} catch (error) {
console.error(`Error en llamada SOAP ${params.service}/${params.method}:`, error)
return c.json({
success: false,
message: error.message || 'Error en el servicio externo SOAP'
}, 500)
}
})
export default api
*/

41
server/index.js Normal file
View File

@@ -0,0 +1,41 @@
import { Hono } from 'hono'
import { logger } from 'hono/logger'
import { cors } from 'hono/cors'
import { jwt } from 'hono/jwt'
// Importación de APIs (Rutas)
import auth from './api/auth'
import db from './api/db'
import mail from './api/mail'
import soap from './api/soap'
const app = new Hono()
// --- Middlewares Globales ---
app.use('*', logger())
app.use('*', cors())
// --- Gestión de Errores Global ---
app.onError((err, c) => {
console.error(`[Global Error]: ${err.message}`)
const status = err.name === 'JwtTokenInvalid' ? 401 : 500
return c.json({
success: false,
message: err.message || 'Internal Server Error'
}, status)
})
// --- Registro de Rutas ---
// Nota: La protección JWT ya la pusimos dentro de api/db.ts y api/soap.ts
// para permitir que auth y mail (quizás) sean públicos.
app.route('/api/auth', auth)
app.route('/api/db', db)
app.route('/api/mail', mail)
app.route('/api/soap', soap)
// --- Servidor Bun ---
export default {
port: 3000,
fetch: app.fetch,
idleTimeout: 120,
}

458
server/lib/schema.json Normal file
View File

@@ -0,0 +1,458 @@
{
"Cartera": {
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoRecibo": { "field": "CodigoRecibo", "header": "CODIGORECIBO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoGestor": { "field": "CodigoGestor", "header": "CODIGOGESTOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Contenido": { "field": "Contenido", "header": "CONTENIDO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Continente": { "field": "Continente", "header": "CONTINENTE", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"FechaEfecto": { "field": "FechaEfecto", "header": "FECHAEFECTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaVencimiento": { "field": "FechaVencimiento", "header": "FECHAVENCIMIENTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FormaPago": { "field": "FormaPago", "header": "FORMAPAGO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteBonificacion": { "field": "ImporteBonificacion", "header": "IMPORTEBONIFICACION", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteComision": { "field": "ImporteComision", "header": "IMPORTECOMISION", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteImpuestos": { "field": "ImporteImpuestos", "header": "IMPORTEIMPUESTOS", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteLiquido": { "field": "ImporteLiquido", "header": "IMPORTELIQUIDO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteNeto": { "field": "ImporteNeto", "header": "IMPORTENETO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteTotalRecibo": { "field": "ImporteTotalRecibo", "header": "IMPORTETOTALRECIBO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"NombreTomador": { "field": "NombreTomador", "header": "NOMBRETOMADOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"RCGeneral": { "field": "RCGeneral", "header": "RCGENERAL", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"SubcodigoMediador": { "field": "SubcodigoMediador", "header": "SUBCODIGOMEDIADOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Chat": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"De": { "field": "De", "header": "DE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Para": { "field": "Para", "header": "PARA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Mensaje": { "field": "Mensaje", "header": "MENSAJE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaMensaje": { "field": "FechaMensaje", "header": "FECHAMENSAJE", "type": "datetime", "hide": false, "virt": false, "key": false, "editable": true },
"Leido": { "field": "Leido", "header": "LEIDO", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"Editado": { "field": "Editado", "header": "EDITADO", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"Eliminado": { "field": "Eliminado", "header": "ELIMINADO", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true }
},
"Clientes": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"Documento": { "field": "Documento", "header": "DOCUMENTO", "type": "text", "hide": false, "virt": false, "key": "UK", "editable": true },
"Nombre": { "field": "Nombre", "header": "NOMBRE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Apellidos": { "field": "Apellidos", "header": "APELLIDOS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Cliente": { "field": "Cliente", "header": "CLIENTE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Grupo": { "field": "Grupo", "header": "GRUPO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaNacimiento": { "field": "FechaNacimiento", "header": "FECHANACIMIENTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaCarnet": { "field": "FechaCarnet", "header": "FECHACARNET", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"EstadoCivil": { "field": "EstadoCivil", "header": "ESTADOCIVIL", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Profesion": { "field": "Profesion", "header": "PROFESION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Hijos": { "field": "Hijos", "header": "HIJOS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"ClientesCorreos": {
"Documento": { "field": "Documento", "header": "DOCUMENTO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"Correo": { "field": "Correo", "header": "CORREO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"Tipo": { "field": "Tipo", "header": "TIPO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"ClientesDirecciones": {
"Documento": { "field": "Documento", "header": "DOCUMENTO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"Domicilio": { "field": "Domicilio", "header": "DOMICILIO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoPostal": { "field": "CodigoPostal", "header": "CODIGOPOSTAL", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Localidad": { "field": "Localidad", "header": "LOCALIDAD", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Provincia": { "field": "Provincia", "header": "PROVINCIA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"ClientesOld": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"Mediador": { "field": "Mediador", "header": "MEDIADOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"NIF": { "field": "NIF", "header": "NIF", "type": "text", "hide": false, "virt": false, "key": "FK", "editable": true },
"Cliente": { "field": "Cliente", "header": "CLIENTE", "type": "text", "hide": false, "virt": false, "key": "FK", "editable": true },
"Grupo": { "field": "Grupo", "header": "GRUPO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Correo": { "field": "Correo", "header": "CORREO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Correo2": { "field": "Correo2", "header": "CORREO2", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Fijo": { "field": "Fijo", "header": "FIJO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Movil": { "field": "Movil", "header": "MOVIL", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Movil2": { "field": "Movil2", "header": "MOVIL2", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CP": { "field": "CP", "header": "CP", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Direccion": { "field": "Direccion", "header": "DIRECCION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Poblacion": { "field": "Poblacion", "header": "POBLACION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Provincia": { "field": "Provincia", "header": "PROVINCIA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Banco": { "field": "Banco", "header": "BANCO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaNacimiento": { "field": "FechaNacimiento", "header": "FECHANACIMIENTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaCarnet": { "field": "FechaCarnet", "header": "FECHACARNET", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"EstadoCivil": { "field": "EstadoCivil", "header": "ESTADOCIVIL", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Profesion": { "field": "Profesion", "header": "PROFESION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Hijos": { "field": "Hijos", "header": "HIJOS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Promo": { "field": "Promo", "header": "PROMO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaPromo": { "field": "FechaPromo", "header": "FECHAPROMO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaBienvenida": { "field": "FechaBienvenida", "header": "FECHABIENVENIDA", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"NoMolestar": { "field": "NoMolestar", "header": "NOMOLESTAR", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"Notas": { "field": "Notas", "header": "NOTAS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaRegistro": { "field": "FechaRegistro", "header": "FECHAREGISTRO", "type": "datetime", "hide": false, "virt": false, "key": false, "editable": true },
"SM": { "field": "SM", "header": "SM", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"upd": { "field": "upd", "header": "UPD", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Activo": { "field": "Activo", "header": "ACTIVO", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"MP": { "field": "MP", "header": "MP", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"ClientesTelefonos": {
"Documento": { "field": "Documento", "header": "DOCUMENTO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"Telefono": { "field": "Telefono", "header": "TELEFONO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"Tipo": { "field": "Tipo", "header": "TIPO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Colaboradores": {
"SM": { "field": "SM", "header": "SM", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoMediador": { "field": "CodigoMediador", "header": "CODIGOMEDIADOR", "type": "numeric", "hide": false, "virt": false, "key": "PK", "editable": false },
"CIF": { "field": "CIF", "header": "CIF", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Nombre": { "field": "Nombre", "header": "NOMBRE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"ResponsableRecibos": { "field": "ResponsableRecibos", "header": "RESPONSABLERECIBOS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"ResponsableSiniestros": { "field": "ResponsableSiniestros", "header": "RESPONSABLESINIESTROS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"ResponsablePolizas": { "field": "ResponsablePolizas", "header": "RESPONSABLEPOLIZAS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Cartera": { "field": "Cartera", "header": "CARTERA", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"Recibos": { "field": "Recibos", "header": "RECIBOS", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"Pro": { "field": "Pro", "header": "PRO", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"Activo": { "field": "Activo", "header": "ACTIVO", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"Porc": { "field": "Porc", "header": "PORC", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Fact": { "field": "Fact", "header": "FACT", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"IRPF": { "field": "IRPF", "header": "IRPF", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"Banco": { "field": "Banco", "header": "BANCO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Correo": { "field": "Correo", "header": "CORREO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Movil": { "field": "Movil", "header": "MOVIL", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Fijo": { "field": "Fijo", "header": "FIJO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Direccion": { "field": "Direccion", "header": "DIRECCION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CP": { "field": "CP", "header": "CP", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Notas": { "field": "Notas", "header": "NOTAS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Contactos": {
"Empresa": { "field": "Empresa", "header": "EMPRESA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Seccion": { "field": "Seccion", "header": "SECCION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Departamento": { "field": "Departamento", "header": "DEPARTAMENTO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Nombre": { "field": "Nombre", "header": "NOMBRE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Fijo": { "field": "Fijo", "header": "FIJO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Movil": { "field": "Movil", "header": "MOVIL", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Fax": { "field": "Fax", "header": "FAX", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Correo": { "field": "Correo", "header": "CORREO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Correo2": { "field": "Correo2", "header": "CORREO2", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoMediador": { "field": "CodigoMediador", "header": "CODIGOMEDIADOR", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Notas": { "field": "Notas", "header": "NOTAS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Correos": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"id_config": { "field": "id_config", "header": "ID CONFIG", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"Asunto": { "field": "Asunto", "header": "ASUNTO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Cuerpo": { "field": "Cuerpo", "header": "CUERPO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaProgramada": { "field": "FechaProgramada", "header": "FECHAPROGRAMADA", "type": "datetime", "hide": false, "virt": false, "key": false, "editable": true },
"Estado": { "field": "Estado", "header": "ESTADO", "type": "select", "hide": false, "virt": false, "key": false, "editable": true }
},
"CorreosConfig": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"Nombre": { "field": "Nombre", "header": "NOMBRE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Frecuencia": { "field": "Frecuencia", "header": "FRECUENCIA", "type": "select", "hide": false, "virt": false, "key": false, "editable": true },
"DiaSemana": { "field": "DiaSemana", "header": "DIASEMANA", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"DiaMes": { "field": "DiaMes", "header": "DIAMES", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"HoraEnvio": { "field": "HoraEnvio", "header": "HORAENVIO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Cron": { "field": "Cron", "header": "CRON", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"id_plantilla": { "field": "id_plantilla", "header": "ID PLANTILLA", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"Activo": { "field": "Activo", "header": "ACTIVO", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true }
},
"CorreosDestinatarios": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"id_correo": { "field": "id_correo", "header": "ID CORREO", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"id_cliente": { "field": "id_cliente", "header": "ID CLIENTE", "type": "numeric", "hide": true, "virt": false, "key": false, "editable": false },
"EmailDestino": { "field": "EmailDestino", "header": "EMAILDESTINO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaEnviado": { "field": "FechaEnviado", "header": "FECHAENVIADO", "type": "datetime", "hide": false, "virt": false, "key": false, "editable": true },
"ErrorLog": { "field": "ErrorLog", "header": "ERRORLOG", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"CorreosPlantillas": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"Nombre": { "field": "Nombre", "header": "NOMBRE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"AsuntoBase": { "field": "AsuntoBase", "header": "ASUNTOBASE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"ContenidoHtml": { "field": "ContenidoHtml", "header": "CONTENIDOHTML", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Documentos": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoRecibo": { "field": "CodigoRecibo", "header": "CODIGORECIBO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoSiniestro": { "field": "CodigoSiniestro", "header": "CODIGOSINIESTRO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"NIF": { "field": "NIF", "header": "NIF", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaRegistro": { "field": "FechaRegistro", "header": "FECHAREGISTRO", "type": "datetime", "hide": false, "virt": false, "key": false, "editable": true },
"Nombre": { "field": "Nombre", "header": "NOMBRE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Extension": { "field": "Extension", "header": "EXTENSION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Archivo": { "field": "Archivo", "header": "ARCHIVO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Empresas": {
"Empresa": { "field": "Empresa", "header": "EMPRESA", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CIF": { "field": "CIF", "header": "CIF", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Direccion": { "field": "Direccion", "header": "DIRECCION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Notas": { "field": "Notas", "header": "NOTAS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Etiquetas": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"Etiqueta": { "field": "Etiqueta", "header": "ETIQUETA", "type": "text", "hide": false, "virt": false, "key": "FK", "editable": true },
"Tabla": { "field": "Tabla", "header": "TABLA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Nombre": { "field": "Nombre", "header": "NOMBRE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Color": { "field": "Color", "header": "COLOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Grupos": {
"Grupo": { "field": "Grupo", "header": "GRUPO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoMediador": { "field": "CodigoMediador", "header": "CODIGOMEDIADOR", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Detalle": { "field": "Detalle", "header": "DETALLE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Liquidaciones": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"CodigoMediador": { "field": "CodigoMediador", "header": "CODIGOMEDIADOR", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": "FK", "editable": true },
"CodigoRecibo": { "field": "CodigoRecibo", "header": "CODIGORECIBO", "type": "text", "hide": false, "virt": false, "key": "FK", "editable": true },
"FechaRegistro": { "field": "FechaRegistro", "header": "FECHAREGISTRO", "type": "date", "hide": false, "virt": false, "key": "FK", "editable": true },
"FechaEfecto": { "field": "FechaEfecto", "header": "FECHAEFECTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"Detalle": { "field": "Detalle", "header": "DETALLE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"NumLiq": { "field": "NumLiq", "header": "NUMLIQ", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"id_cuenta_Origen": { "field": "id_cuenta_Origen", "header": "ID CUENTA ORIGEN", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"id_cuenta_Destino": { "field": "id_cuenta_Destino", "header": "ID CUENTA DESTINO", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"Importe": { "field": "Importe", "header": "IMPORTE", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Usuario": { "field": "Usuario", "header": "USUARIO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Validado": { "field": "Validado", "header": "VALIDADO", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"Liquidado": { "field": "Liquidado", "header": "LIQUIDADO", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true }
},
"LiquidacionesCuentas": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"CodigoMediador": { "field": "CodigoMediador", "header": "CODIGOMEDIADOR", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Cuenta": { "field": "Cuenta", "header": "CUENTA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Activo": { "field": "Activo", "header": "ACTIVO", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"Tipo": { "field": "Tipo", "header": "TIPO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"LiquidacionesMovimientos": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"id_liquidacion": { "field": "id_liquidacion", "header": "ID LIQUIDACION", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"id_cuenta": { "field": "id_cuenta", "header": "ID CUENTA", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"Importe": { "field": "Importe", "header": "IMPORTE", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Accion": { "field": "Accion", "header": "ACCION", "type": "select", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": "FK", "editable": true },
"CodigoRecibo": { "field": "CodigoRecibo", "header": "CODIGORECIBO", "type": "text", "hide": false, "virt": false, "key": "FK", "editable": true },
"Detalle": { "field": "Detalle", "header": "DETALLE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaRegistro": { "field": "FechaRegistro", "header": "FECHAREGISTRO", "type": "datetime", "hide": false, "virt": false, "key": "FK", "editable": true }
},
"Mediadores": {
"CodigoMediador": { "field": "CodigoMediador", "header": "CODIGOMEDIADOR", "type": "numeric", "hide": false, "virt": false, "key": "PK", "editable": false },
"Descripcion": { "field": "Descripcion", "header": "DESCRIPCION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Domicilio": { "field": "Domicilio", "header": "DOMICILIO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoPostal": { "field": "CodigoPostal", "header": "CODIGOPOSTAL", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Localidad": { "field": "Localidad", "header": "LOCALIDAD", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Provincia": { "field": "Provincia", "header": "PROVINCIA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Correo": { "field": "Correo", "header": "CORREO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Telefono": { "field": "Telefono", "header": "TELEFONO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Whatsapp": { "field": "Whatsapp", "header": "WHATSAPP", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Oportunidades": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"id_cliente": { "field": "id_cliente", "header": "ID CLIENTE", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"id_estado": { "field": "id_estado", "header": "ID ESTADO", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"id_usuario": { "field": "id_usuario", "header": "ID USUARIO", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"Empresa": { "field": "Empresa", "header": "EMPRESA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaVencimiento": { "field": "FechaVencimiento", "header": "FECHAVENCIMIENTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"Riesgo": { "field": "Riesgo", "header": "RIESGO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Importe": { "field": "Importe", "header": "IMPORTE", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Pago": { "field": "Pago", "header": "PAGO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaCreacion": { "field": "FechaCreacion", "header": "FECHACREACION", "type": "datetime", "hide": false, "virt": false, "key": false, "editable": true },
"UltimaActualizacion": { "field": "UltimaActualizacion", "header": "ULTIMAACTUALIZACION", "type": "datetime", "hide": false, "virt": false, "key": false, "editable": true }
},
"OportunidadesSeguimiento": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"id_oportunidad": { "field": "id_oportunidad", "header": "ID OPORTUNIDAD", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"id_usuario": { "field": "id_usuario", "header": "ID USUARIO", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"id_responsable": { "field": "id_responsable", "header": "ID RESPONSABLE", "type": "numeric", "hide": true, "virt": false, "key": false, "editable": false },
"id_estado_ant": { "field": "id_estado_ant", "header": "ID ESTADO ANT", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"id_estado_act": { "field": "id_estado_act", "header": "ID ESTADO ACT", "type": "numeric", "hide": true, "virt": false, "key": "FK", "editable": false },
"Fecha": { "field": "Fecha", "header": "FECHA", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"Accion": { "field": "Accion", "header": "ACCION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Polizas": {
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoMediador": { "field": "CodigoMediador", "header": "CODIGOMEDIADOR", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"FechaAlta": { "field": "FechaAlta", "header": "FECHAALTA", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaBaja": { "field": "FechaBaja", "header": "FECHABAJA", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"Riesgo": { "field": "Riesgo", "header": "RIESGO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Ramo": { "field": "Ramo", "header": "RAMO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Modalidad": { "field": "Modalidad", "header": "MODALIDAD", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"GestorCobroInicial": { "field": "GestorCobroInicial", "header": "GESTORCOBROINICIAL", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"VigorSucursal": { "field": "VigorSucursal", "header": "VIGORSUCURSAL", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true }
},
"PolizasAccidentes": {
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoSuplemento": { "field": "CodigoSuplemento", "header": "CODIGOSUPLEMENTO", "type": "numeric", "hide": false, "virt": false, "key": "PK", "editable": false },
"DocumentoAsegurado": { "field": "DocumentoAsegurado", "header": "DOCUMENTOASEGURADO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaNacimientoAsegurado": { "field": "FechaNacimientoAsegurado", "header": "FECHANACIMIENTOASEGURADO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteIncapacidadTemporal": { "field": "ImporteIncapacidadTemporal", "header": "IMPORTEINCAPACIDADTEMPORAL", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteInvalidezPorAccidente": { "field": "ImporteInvalidezPorAccidente", "header": "IMPORTEINVALIDEZPORACCIDENTE", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteInvalidezPorInfarto": { "field": "ImporteInvalidezPorInfarto", "header": "IMPORTEINVALIDEZPORINFARTO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteMuertePorInfarto": { "field": "ImporteMuertePorInfarto", "header": "IMPORTEMUERTEPORINFARTO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Invalidez": { "field": "Invalidez", "header": "INVALIDEZ", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Muerte": { "field": "Muerte", "header": "MUERTE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"NombreAsegurado": { "field": "NombreAsegurado", "header": "NOMBREASEGURADO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"NumeroAsegurados": { "field": "NumeroAsegurados", "header": "NUMEROASEGURADOS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"TipoInvalidez": { "field": "TipoInvalidez", "header": "TIPOINVALIDEZ", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"PolizasAutos": {
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoSuplemento": { "field": "CodigoSuplemento", "header": "CODIGOSUPLEMENTO", "type": "numeric", "hide": false, "virt": false, "key": "PK", "editable": false },
"BonusDP": { "field": "BonusDP", "header": "BONUSDP", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"BonusRC": { "field": "BonusRC", "header": "BONUSRC", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoModelo": { "field": "CodigoModelo", "header": "CODIGOMODELO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoModeloBase7": { "field": "CodigoModeloBase7", "header": "CODIGOMODELOBASE7", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Matricula": { "field": "Matricula", "header": "MATRICULA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Remolque": { "field": "Remolque", "header": "REMOLQUE", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true }
},
"PolizasAutosConductor": {
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoSuplemento": { "field": "CodigoSuplemento", "header": "CODIGOSUPLEMENTO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"Documento": { "field": "Documento", "header": "DOCUMENTO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"TipoConductor": { "field": "TipoConductor", "header": "TIPOCONDUCTOR", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"FechaCarnet": { "field": "FechaCarnet", "header": "FECHACARNET", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaNacimiento": { "field": "FechaNacimiento", "header": "FECHANACIMIENTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"Nombre": { "field": "Nombre", "header": "NOMBRE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Sexo": { "field": "Sexo", "header": "SEXO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"PolizasDetalle": {
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoSuplemento": { "field": "CodigoSuplemento", "header": "CODIGOSUPLEMENTO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoRecibo": { "field": "CodigoRecibo", "header": "CODIGORECIBO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoRiesgo": { "field": "CodigoRiesgo", "header": "CODIGORIESGO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"DatosBancarios": { "field": "DatosBancarios", "header": "DATOSBANCARIOS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Nombre": { "field": "Nombre", "header": "NOMBRE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Apellidos": { "field": "Apellidos", "header": "APELLIDOS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Documento": { "field": "Documento", "header": "DOCUMENTO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Domicilio": { "field": "Domicilio", "header": "DOMICILIO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Localidad": { "field": "Localidad", "header": "LOCALIDAD", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoPostal": { "field": "CodigoPostal", "header": "CODIGOPOSTAL", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Provincia": { "field": "Provincia", "header": "PROVINCIA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaEfectoSuplemento": { "field": "FechaEfectoSuplemento", "header": "FECHAEFECTOSUPLEMENTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaEquipo": { "field": "FechaEquipo", "header": "FECHAEQUIPO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaVencimientoSuplemento": { "field": "FechaVencimientoSuplemento", "header": "FECHAVENCIMIENTOSUPLEMENTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FormaPago": { "field": "FormaPago", "header": "FORMAPAGO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"GestorCobro": { "field": "GestorCobro", "header": "GESTORCOBRO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteBonificacionAnualSuplemento": { "field": "ImporteBonificacionAnualSuplemento", "header": "IMPORTEBONIFICACIONANUALSUPLEMENTO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteBonificacionRecibo": { "field": "ImporteBonificacionRecibo", "header": "IMPORTEBONIFICACIONRECIBO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteComisionAnualSuplemento": { "field": "ImporteComisionAnualSuplemento", "header": "IMPORTECOMISIONANUALSUPLEMENTO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteComisionRecibo": { "field": "ImporteComisionRecibo", "header": "IMPORTECOMISIONRECIBO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteImpuestosAnualSuplemento": { "field": "ImporteImpuestosAnualSuplemento", "header": "IMPORTEIMPUESTOSANUALSUPLEMENTO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteImpuestosRecibo": { "field": "ImporteImpuestosRecibo", "header": "IMPORTEIMPUESTOSRECIBO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteLiquidoAnualSuplemento": { "field": "ImporteLiquidoAnualSuplemento", "header": "IMPORTELIQUIDOANUALSUPLEMENTO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteLiquidoRecibo": { "field": "ImporteLiquidoRecibo", "header": "IMPORTELIQUIDORECIBO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteNetoAnualSuplemento": { "field": "ImporteNetoAnualSuplemento", "header": "IMPORTENETOANUALSUPLEMENTO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteNetoRecibo": { "field": "ImporteNetoRecibo", "header": "IMPORTENETORECIBO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteTotalAnualSuplemento": { "field": "ImporteTotalAnualSuplemento", "header": "IMPORTETOTALANUALSUPLEMENTO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteTotalRecibo": { "field": "ImporteTotalRecibo", "header": "IMPORTETOTALRECIBO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteNeto": { "field": "ImporteNeto", "header": "IMPORTENETO", "type": "numeric", "hide": false, "virt": true, "key": false, "editable": false },
"TipoInformacion": { "field": "TipoInformacion", "header": "TIPOINFORMACION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"SubCodigoMediador": { "field": "SubCodigoMediador", "header": "SUBCODIGOMEDIADOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"PolizasMultirriesgos": {
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoSuplemento": { "field": "CodigoSuplemento", "header": "CODIGOSUPLEMENTO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"DocumentoAsegurado": { "field": "DocumentoAsegurado", "header": "DOCUMENTOASEGURADO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteContenido": { "field": "ImporteContenido", "header": "IMPORTECONTENIDO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteContinente": { "field": "ImporteContinente", "header": "IMPORTECONTINENTE", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteRC": { "field": "ImporteRC", "header": "IMPORTERC", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"NombreAsegurado": { "field": "NombreAsegurado", "header": "NOMBREASEGURADO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"SituacionRiesgo": { "field": "SituacionRiesgo", "header": "SITUACIONRIESGO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Recibos": {
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": "FK", "editable": true },
"CodigoRecibo": { "field": "CodigoRecibo", "header": "CODIGORECIBO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoEmpresa": { "field": "CodigoEmpresa", "header": "CODIGOEMPRESA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaEfecto": { "field": "FechaEfecto", "header": "FECHAEFECTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"Importe": { "field": "Importe", "header": "IMPORTE", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true }
},
"RecibosEstados": {
"CodigoRecibo": { "field": "CodigoRecibo", "header": "CODIGORECIBO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"Situacion": { "field": "Situacion", "header": "SITUACION", "type": "date", "hide": false, "virt": false, "key": "PK", "editable": false },
"Estado": { "field": "Estado", "header": "ESTADO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"NombreTomador": { "field": "NombreTomador", "header": "NOMBRETOMADOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"AutoLiquidacion": { "field": "AutoLiquidacion", "header": "AUTOLIQUIDACION", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoGestor": { "field": "CodigoGestor", "header": "CODIGOGESTOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoMediador": { "field": "CodigoMediador", "header": "CODIGOMEDIADOR", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoRiesgo": { "field": "CodigoRiesgo", "header": "CODIGORIESGO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"DescripcionGestor": { "field": "DescripcionGestor", "header": "DESCRIPCIONGESTOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Divisa": { "field": "Divisa", "header": "DIVISA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaVencimiento": { "field": "FechaVencimiento", "header": "FECHAVENCIMIENTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FormaPago": { "field": "FormaPago", "header": "FORMAPAGO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteBonificacion": { "field": "ImporteBonificacion", "header": "IMPORTEBONIFICACION", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteComision": { "field": "ImporteComision", "header": "IMPORTECOMISION", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteIRPF": { "field": "ImporteIRPF", "header": "IMPORTEIRPF", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteImpuestos": { "field": "ImporteImpuestos", "header": "IMPORTEIMPUESTOS", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"ImporteNeto": { "field": "ImporteNeto", "header": "IMPORTENETO", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"SubCodigoMediador": { "field": "SubCodigoMediador", "header": "SUBCODIGOMEDIADOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Siniestros": {
"CodigoSiniestro": { "field": "CodigoSiniestro", "header": "CODIGOSINIESTRO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": "FK", "editable": true },
"CodigoMediador": { "field": "CodigoMediador", "header": "CODIGOMEDIADOR", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoEmpresa": { "field": "CodigoEmpresa", "header": "CODIGOEMPRESA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoSuplemento": { "field": "CodigoSuplemento", "header": "CODIGOSUPLEMENTO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Descripcion": { "field": "Descripcion", "header": "DESCRIPCION", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaOcurrencia": { "field": "FechaOcurrencia", "header": "FECHAOCURRENCIA", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaDenuncia": { "field": "FechaDenuncia", "header": "FECHADENUNCIA", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaTerminacion": { "field": "FechaTerminacion", "header": "FECHATERMINACION", "type": "date", "hide": false, "virt": false, "key": false, "editable": true }
},
"SiniestrosEstados": {
"CodigoSiniestro": { "field": "CodigoSiniestro", "header": "CODIGOSINIESTRO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"Estado": { "field": "Estado", "header": "ESTADO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"TipoMovimiento": { "field": "TipoMovimiento", "header": "TIPOMOVIMIENTO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"ClaveConsecuencia": { "field": "ClaveConsecuencia", "header": "CLAVECONSECUENCIA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoActividad": { "field": "CodigoActividad", "header": "CODIGOACTIVIDAD", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoPostal": { "field": "CodigoPostal", "header": "CODIGOPOSTAL", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoSucursalTramitadora": { "field": "CodigoSucursalTramitadora", "header": "CODIGOSUCURSALTRAMITADORA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"DescripcionClaveConsecuencia": { "field": "DescripcionClaveConsecuencia", "header": "DESCRIPCIONCLAVECONSECUENCIA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaInformacion": { "field": "FechaInformacion", "header": "FECHAINFORMACION", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaReapertura": { "field": "FechaReapertura", "header": "FECHAREAPERTURA", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaTerminacion": { "field": "FechaTerminacion", "header": "FECHATERMINACION", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"Hora": { "field": "Hora", "header": "HORA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Localidad": { "field": "Localidad", "header": "LOCALIDAD", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Lugar": { "field": "Lugar", "header": "LUGAR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"NombreTomador": { "field": "NombreTomador", "header": "NOMBRETOMADOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Observaciones": { "field": "Observaciones", "header": "OBSERVACIONES", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Situacion": { "field": "Situacion", "header": "SITUACION", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"SubCodigoMediador": { "field": "SubCodigoMediador", "header": "SUBCODIGOMEDIADOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Tramitador": { "field": "Tramitador", "header": "TRAMITADOR", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Usuario": { "field": "Usuario", "header": "USUARIO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"SiniestrosTramites": {
"CodigoSiniestro": { "field": "CodigoSiniestro", "header": "CODIGOSINIESTRO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"FechaInicio": { "field": "FechaInicio", "header": "FECHAINICIO", "type": "datetime", "hide": false, "virt": false, "key": "PK", "editable": false },
"Observaciones": { "field": "Observaciones", "header": "OBSERVACIONES", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoExpediente": { "field": "CodigoExpediente", "header": "CODIGOEXPEDIENTE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"TipoTramite": { "field": "TipoTramite", "header": "TIPOTRAMITE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"Usuarios": {
"Usuario": { "field": "Usuario", "header": "USUARIO", "type": "text", "hide": false, "virt": false, "key": "PK", "editable": false },
"Nombre": { "field": "Nombre", "header": "NOMBRE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Correo": { "field": "Correo", "header": "CORREO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Activo": { "field": "Activo", "header": "ACTIVO", "type": "boolean", "hide": false, "virt": false, "key": false, "editable": true },
"Suplente": { "field": "Suplente", "header": "SUPLENTE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaInicio": { "field": "FechaInicio", "header": "FECHAINICIO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaFinal": { "field": "FechaFinal", "header": "FECHAFINAL", "type": "date", "hide": false, "virt": false, "key": false, "editable": true }
},
"UsuariosFichajes": {
"id": { "field": "id", "header": "ID", "type": "numeric", "hide": true, "virt": false, "key": "PK", "editable": false },
"Usuario": { "field": "Usuario", "header": "USUARIO", "type": "text", "hide": false, "virt": false, "key": "FK", "editable": true },
"Fecha": { "field": "Fecha", "header": "FECHA", "type": "datetime", "hide": false, "virt": false, "key": false, "editable": true },
"Tipo": { "field": "Tipo", "header": "TIPO", "type": "select", "hide": false, "virt": false, "key": false, "editable": true },
"Duracion": { "field": "Duracion", "header": "DURACION", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true }
},
"vClientes": {
"Nombre": { "field": "Nombre", "header": "NOMBRE", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Apellidos": { "field": "Apellidos", "header": "APELLIDOS", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Documento": { "field": "Documento", "header": "DOCUMENTO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Domicilio": { "field": "Domicilio", "header": "DOMICILIO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Localidad": { "field": "Localidad", "header": "LOCALIDAD", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoPostal": { "field": "CodigoPostal", "header": "CODIGOPOSTAL", "type": "numeric", "hide": false, "virt": false, "key": false, "editable": true },
"Provincia": { "field": "Provincia", "header": "PROVINCIA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaCarnet": { "field": "FechaCarnet", "header": "FECHACARNET", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FechaNacimiento": { "field": "FechaNacimiento", "header": "FECHANACIMIENTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true }
},
"vClientesCorreos": {
"Documento": { "field": "Documento", "header": "DOCUMENTO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"Correo2": { "field": "Correo2", "header": "CORREO2", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
},
"vRecibos": {
"CodigoRecibo": { "field": "CodigoRecibo", "header": "CODIGORECIBO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoEmpresa": { "field": "CodigoEmpresa", "header": "CODIGOEMPRESA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"CodigoPoliza": { "field": "CodigoPoliza", "header": "CODIGOPOLIZA", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaEfecto": { "field": "FechaEfecto", "header": "FECHAEFECTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"Situacion": { "field": "Situacion", "header": "SITUACION", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"Estado": { "field": "Estado", "header": "ESTADO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true },
"FechaVencimiento": { "field": "FechaVencimiento", "header": "FECHAVENCIMIENTO", "type": "date", "hide": false, "virt": false, "key": false, "editable": true },
"FormaPago": { "field": "FormaPago", "header": "FORMAPAGO", "type": "text", "hide": false, "virt": false, "key": false, "editable": true }
}
}

View File

@@ -0,0 +1,74 @@
import { pool } from '../services/db.service';
import { resolve } from 'node:path';
/**
* Genera el esquema de la base de datos automáticamente
*/
async function generateSchema() {
try {
const rows = await pool.query(`
SELECT
TABLE_NAME as t,
COLUMN_NAME as f,
DATA_TYPE as T,
COLUMN_TYPE as fT,
EXTRA as e,
COLUMN_KEY as k
FROM information_schema.columns
WHERE table_schema = DATABASE()
ORDER BY TABLE_NAME, ORDINAL_POSITION
`);
const data = rows.reduce((acc, { t, f, T, fT, e, k }) => {
if (!acc[t]) acc[t] = {};
// Mapeo de tipos
let type = 'text';
if (['int', 'decimal', 'float', 'double'].includes(T)) {
type = 'numeric';
} else if (['date', 'datetime', 'timestamp'].includes(T)) {
type = T === 'date' ? 'date' : 'datetime';
} else if (T === 'tinyint' && fT.includes('(1)')) {
type = 'boolean';
} else if (T === 'enum') {
type = 'select';
}
const hide = f.startsWith('id') || f === 'password' || f === 'token';
const virt = e.toLowerCase().includes('generated');
const key = k === 'PRI' ? 'PK' : k === 'UNI' ? 'UK' : k === 'MUL' ? 'FK' : false;
acc[t][f] = {
field: f,
header: f.replace(/_/g, ' ').toUpperCase(),
type,
hide,
virt,
key,
editable: !(hide || key === 'PK' || virt)
};
return acc;
}, {});
const outPath = resolve('./server/lib/schema.json');
// JSON compacto para ahorrar bytes pero manteniendo legibilidad por tabla
const json = JSON.stringify(data, null, 2)
.replace(/\{\n\s+"field":[\s\S]+?\n\s+\}/g, m => m.replace(/\s*\n\s*/g, ' '));
await Bun.write(outPath, json);
console.log(`✅ Esquema generado: ${outPath}`);
console.log(`📊 Tablas: ${Object.keys(data).length}`);
} catch (error) {
console.error('❌ Error:', error);
} finally {
await pool.end();
process.exit(0);
}
}
generateSchema();

View File

@@ -0,0 +1,135 @@
// import mariadb from 'mariadb';
import * as mariadb from 'mariadb';
// Fix para BigInt en la serialización JSON (necesario para IDs grandes en MariaDB)
BigInt.prototype.toJSON = function () {
return this.toString();
};
// Configuración del Pool
export const pool = mariadb.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: 'Reale',
connectionLimit: 20,
timezone: 'Z',
insertIdAsNumber: true
});
// Helper para escapar identificadores (tablas/columnas)
const b = (id) => `\`${id.replace(/`/g, '``')}\``;
export class Database {
constructor(connector) {
/** @type {mariadb.Pool | mariadb.PoolConnection} */
this.connector = connector;
}
async insert(table, data) {
const rows = Array.isArray(data) ? data : [data];
if (!rows.length) return null;
const fields = Object.keys(rows[0]);
const query = `INSERT INTO ${b(table)} (${fields.map(b).join(',')}) VALUES (${fields.map(() => '?').join(',')})`;
return this.connector.batch(query, rows.map(r => fields.map(f => r[f])));
}
async update(table, data, where) {
const fields = Object.keys(data);
const wFields = Object.keys(where);
const query = `UPDATE ${b(table)} SET ${fields.map(f => `${b(f)}=?`).join(',')} WHERE ${wFields.map(f => `${b(f)}=?`).join(' AND ')}`;
return this.connector.query(query, [...fields.map(f => data[f]), ...wFields.map(f => where[f])]);
}
async upsert(table, data, ignore = false) {
const rows = Array.isArray(data) ? data : [data];
if (!rows.length) return null;
const fields = Object.keys(rows[0]);
const set = fields.filter(f => f !== 'id').map(f => `${b(f)}=VALUES(${b(f)})`).join(',');
const query = `INSERT ${ignore ? 'IGNORE' : ''} INTO ${b(table)} (${fields.map(b).join(',')}) VALUES (${fields.map(() => '?').join(',')}) ON DUPLICATE KEY UPDATE ${set}`;
return this.connector.batch(query, rows.map(r => fields.map(f => r[f])));
}
async delete(table, where) {
const keys = Object.keys(where);
if (!keys.length) throw new Error('Delete requiere condiciones');
return this.connector.query(`DELETE FROM ${b(table)} WHERE ${keys.map(k => `${b(k)}=?`).join(' AND ')}`, keys.map(k => where[k]));
}
async select(table, where = {}, opts = { limit: 5000, order: null }) {
const keys = Object.keys(where);
let sqlStr = `SELECT * FROM ${b(table)}`;
if (keys.length) sqlStr += ` WHERE ${keys.map(k => `${b(k)}=?`).join(' AND ')}`;
if (opts.order) sqlStr += ` ORDER BY ${b(opts.order)}`;
return this.connector.query(sqlStr + ` LIMIT ${opts.limit}`, keys.map(k => where[k]));
}
async one(table, where) {
const res = await this.select(table, where, { limit: 1 });
return res[0] || null;
}
async count(table, where = {}) {
const keys = Object.keys(where);
let sqlStr = `SELECT COUNT(*) as total FROM ${b(table)}`;
if (keys.length) sqlStr += ` WHERE ${keys.map(k => `${b(k)}=?`).join(' AND ')}`;
const res = await this.connector.query(sqlStr, keys.map(k => where[k]));
return Number(res[0].total);
}
async search(table, fields, term, limit = 1000) {
if (!fields.length || !term) return [];
const where = fields.map(f => `${b(f)} LIKE ?`).join(' OR ');
return this.connector.query(`SELECT * FROM ${b(table)} WHERE ${where} LIMIT ${limit}`, fields.map(() => `%${term}%`));
}
async unique(table, fields, where = {}) {
const f = Array.isArray(fields) ? fields.map(b).join(',') : b(fields);
const keys = Object.keys(where);
let sqlStr = `SELECT DISTINCT ${f} FROM ${b(table)}`;
if (keys.length) sqlStr += ` WHERE ${keys.map(k => `${b(k)}=?`).join(' AND ')}`;
const sort = Array.isArray(fields) ? b(fields[0]) : f;
return this.connector.query(sqlStr + ` ORDER BY ${sort} ASC`, keys.map(k => where[k]));
}
async raw(query, data = {}) {
const params = [];
const sqlStr = query.replace(/:(\w+)/g, (_, key) => {
params.push(data[key]);
return '?';
});
return this.connector.query(sqlStr, params);
}
}
/**
* Lógica de Transacciones
*/
export const trx = async (opts, actions) => {
const tasks = Array.isArray(opts) ? opts : [opts];
const conn = await pool.getConnection();
try {
await conn.beginTransaction();
const transactionDb = new Database(conn);
const results = {};
for (const item of tasks) {
if (typeof actions[item.action] !== 'function') {
throw new Error(`Acción ${item.action} no existe`);
}
results[item.action] = await actions[item.action](transactionDb, item);
}
await conn.commit();
return results;
} catch (err) {
console.error('Error en la transacción:', err);
await conn.rollback();
throw err;
} finally {
if (conn) conn.release();
}
};
// Exportamos la instancia principal vinculada al Pool
export const db = new Database(pool);

View File

@@ -0,0 +1,47 @@
import nodemailer from 'nodemailer';
// Configuración del transportador
const transporter = nodemailer.createTransport({
host: process.env.db, // Nota: Asegúrate de que esta variable sea el host SMTP (ej. smtp.tuproveedor.com)
port: 587,
secure: false, // true para 465, false para otros puertos
auth: {
user: "natxocc",
pass: "Ncc629406731.",
},
});
/**
* Envía un correo electrónico
* @param {string} to - Destinatario
* @param {string} subject - Asunto
* @param {string} html - Cuerpo en HTML
* @param {Object|null} file - Opcional: { filename, content, contentType }
*/
export const send = async (to, subject, html, file = null) => {
const mailOptions = {
from: '"Natxocc" <natxocc@natxocc.com>',
to,
subject,
html,
};
// Si pasas un archivo (ej: buffer de Sharp), lo añadimos como attachment
if (file) {
mailOptions.attachments = [
{
filename: file.filename,
content: file.content,
contentType: file.contentType || 'image/jpeg'
}
];
}
try {
await transporter.sendMail(mailOptions);
} catch (error) {
console.error('Error enviando email:', error);
throw error; // Re-lanzamos para que la ruta de Hono capture el error
}
};

View File

@@ -0,0 +1,112 @@
import * as soap from 'soap';
import { HttpClient } from 'soap';
import { trx } from './db.service.js';
import { actions } from '../actions/soap.actions.js';
// --- Helpers de Fecha ---
const fmt = (d) => (!isNaN(d.getTime()) ? d.toLocaleDateString('sv-SE') : null);
const getFirstMonth = (m = 0) => {
const now = new Date();
return fmt(new Date(now.getFullYear(), now.getMonth() + m, 1));
};
const getDate = (d = 0) => {
const t = new Date();
t.setDate(t.getDate() + d);
return fmt(t);
};
const SOAP_SERVICES = {
DescargaPolizas: "https://lba.realeonline.net/Reale.B2b.Services.Multitarificadores.IisHost/DescargaPolizas.svc?wsdl",
LiquidacionMediador: "https://lba.realeonline.net/Reale.B2b.Services.Multitarificadores.IisHost/LiquidacionMediador.svc?wsdl",
DescargaSiniestros: "https://lba.realeonline.net/Reale.B2b.Services.Multitarificadores.IisHost/DescargaSiniestros.svc?wsdl",
DescargaCompletaRecibos: "https://lba.realeonline.net/Reale.B2b.Services.Multitarificadores.IisHost/DescargaCompletaRecibos.svc?wsdl",
DescargaCartera: "https://lba.realeonline.net/Reale.B2b.Services.Multitarificadores.IisHost/DescargaCartera.svc?wsdl",
ConsultaPolizas: "https://lba.realeonline.net/Reale.B2b.Services.Multitarificadores.IisHost/ConsultaPolizas.svc?wsdl",
ConsultaRecibos: "https://lba.realeonline.net/Reale.B2b.Services.Multitarificadores.IisHost/ConsultaRecibos.svc?wsdl",
ConsultaAgendaTramitacion: "https://lba.realeonline.net/Reale.B2b.Services.Multitarificadores.IisHost/ConsultaAgendaTramitacion.svc?wsdl",
TramitacionSiniestro: "https://lba.realeonline.net/Reale.B2b.Services.Multitarificadores.IisHost/TramitacionSiniestro.svc?wsdl",
};
export const soapCall = async (params, query, save = true) => {
const { CodigoMediador, service, method } = params;
const url = SOAP_SERVICES[service];
if (!url) throw new Error(`Servicio SOAP '${service}' no encontrado`);
// --- Identificador desde ENV o Query ---
const Identificador = query.Identificador || process.env[`SOAP_${CodigoMediador}`];
if (!Identificador) throw new Error(`Identificador no configurado para mediador ${CodigoMediador}`);
// --- Normalización de Argumentos ---
const Mediador = query.Mediador || CodigoMediador;
const CodigoPoliza = query.CodigoPoliza || "0";
const CodigoSiniestro = query.CodigoSiniestro || "0";
const CodigoExpediente = query.CodigoExpediente || "0";
const Observaciones = query.Observaciones || "";
const CodigoRecibo = query.CodigoRecibo || "0";
const CodigoSuplemento = query.CodigoSuplemento || "1000";
const Clave = query.Clave || "10000";
const Empresa = query.Empresa || "4";
const CodigoEmpresa = query.CodigoEmpresa || Empresa;
const Plataforma = query.Plataforma || "10000";
const CodigoRamo = query.CodigoRamo || "0";
const FechaFinal = query.FechaFinal || getDate();
const FechaRenovacion = query.FechaRenovacion || getFirstMonth(-1);
const FechaInicial = query.FechaInicial || getFirstMonth(-1);
const FechaLiquidacion = query.FechaLiquidacion || getDate();
const HEADER = `<int:Plataforma xmlns:int="http://reale.net/wcf/internalServices">${Plataforma}</int:Plataforma><int:Identificador xmlns:int="http://reale.net/wcf/internalServices">${Identificador}</int:Identificador>`;
// --- Diccionario de Configuración ---
const SOAP_CONFIG = {
DescargaPolizas: { Descargar: { args: { Clave, CodigoRamo, Empresa, FechaFinal, FechaInicial, Identificador, Plataforma, TipoSuplemento1: "NP", TipoSuplemento2: "AN", TipoSuplemento3: "RE", TipoSuplemento4: "SP" }, header: null } },
LiquidacionMediador: {
Consulta: { args: { CodigoMediador, Empresa, FechaLiquidacion }, header: HEADER },
ObtenerFechasLiquidacion: { args: { CodigoMediador, Empresa }, header: HEADER }
},
DescargaSiniestros: { Descargar: { args: { AceptarCicos: true, AceptarSdm: true, Clave, CodigoRamo, Empresa, FechaFinal, FechaInicial, Identificador, IncluirAperturas: true, IncluirAperturasCicos: true, IncluirAperturasSdm: true, IncluirPagosImdemnizacion: true, IncluirTerminados: true, Plataforma }, header: HEADER } },
DescargaCompletaRecibos: { DescargarNew: { args: { Clave, CodigoRamo, Empresa, FechaFinal, FechaInicial, Identificador, Plataforma, IncluirAnulados: true, IncluirCobrados: true, IncluirDevueltos: true, IncluirNuevos: true }, header: null } },
DescargaCartera: {
DescargarCartera: { args: { CodigoMediador, Empresa, FechaRenovacion, Identificador, Plataforma }, header: null },
ObtenerListaRamos: { args: { Empresa }, header: null },
ObtenerListaRenovaciones: { args: { Empresa, Mediador }, header: null }
},
ConsultaPolizas: {
ConsultarPoliza: { args: { CodigoPoliza, CodigoRamo, CodigoSuplemento, Empresa, Identificador, Plataforma }, header: null },
ObtenerListaPolizasMediador: { args: { CodigoMediador, Empresa, Identificador }, header: null },
ObtenerListaSuplementosPoliza: { args: { CodigoPoliza, CodigoRamo, Empresa, Identificador }, header: null }
},
ConsultaRecibos: {
ConsultarRecibo: { args: { CodigoPoliza, CodigoRamo, CodigoRecibo, CodigoSuplemento, Empresa, Identificador, Plataforma }, header: null },
ObtenerListaRecibosPoliza: { args: { CodigoPoliza, CodigoRamo, Empresa, Identificador }, header: null }
},
ConsultaAgendaTramitacion: { ConsultaTramitacion: { args: { Datos: { CodigoExpediente, CodigoPoliza, CodigoSiniestro, Empresa } }, header: HEADER } },
TramitacionSiniestro: { InsertarTramite: { args: { CodigoEmpresa, CodigoExpediente, CodigoSiniestro, Identificador, Observaciones, Plataforma }, header: null } }
};
const config = SOAP_CONFIG[service]?.[method];
if (!config) throw new Error(`Método '${method}' no configurado para el servicio '${service}'`);
try {
const client = await soap.createClientAsync(url, {
httpClient: new HttpClient(),
request: { timeout: 120000 }
});
if (config.header) client.addSoapHeader(config.header);
const methodName = `${method}Async`;
const [result] = await client[methodName](config.args);
if (save) {
await trx({ action: service, data: result }, actions);
}
return result;
} catch (error) {
console.error(`[SOAP ERROR] ${service}/${method}:`, error.message);
throw error;
}
};

View File

@@ -0,0 +1,151 @@
import { XMLParser } from "fast-xml-parser";
import { trx } from "./db.service.js";
import { actions } from "../actions/soap.actions.js";
const parser = new XMLParser({
removeNSPrefix: true,
ignoreAttributes: false,
parseTagValue: true,
trimValues: true,
});
const ALIAS_MAP = {
Polizas: { service: "DescargaPolizas", method: "Descargar" },
Recibos: { service: "DescargaCompletaRecibos", method: "Descargar" },
Siniestros: { service: "DescargaSiniestros", method: "Descargar" },
Cartera: { service: "DescargaCartera", method: "DescargarCartera" },
TramiteSiniestro: { service: "ConsultaAgendaTramitacion", method: "ConsultaTramitacion" },
Poliza: { service: "ConsultaPolizas", method: "ConsultarPoliza" },
Recibo: { service: "ConsultaRecibos", method: "ConsultarRecibo" },
Siniestro: { service: "ConsultaSiniestros", method: "ConsultarSiniestro" },
};
const cleanNil = (obj) => {
if (obj !== null && typeof obj === "object") {
if (obj["@_nil"] === "true" || obj["@_nil"] === true) return null;
if (Array.isArray(obj)) return obj.map(cleanNil);
const newObj = {};
for (const [key, value] of Object.entries(obj)) {
newObj[key] = cleanNil(value);
}
return newObj;
}
return obj;
};
const fmt = (d) => (!isNaN(d.getTime()) ? d.toLocaleDateString("sv-SE") : null);
const getFirstMonth = (m = 0) => {
const now = new Date();
return fmt(new Date(now.getFullYear(), now.getMonth() + m, 1));
};
const getDate = (d = 0) => {
const t = new Date();
t.setDate(t.getDate() + d);
return fmt(t);
};
const getXmlBody = (service, method, q) => {
const templates = {
DescargaPolizas: `<des:DescargarPolizasRequest><des:Clave>${q.Clave}</des:Clave><des:CodigoRamo>${q.CodigoRamo}</des:CodigoRamo><des:Empresa>${q.Empresa}</des:Empresa><des:FechaFinal>${q.FechaFinal}</des:FechaFinal><des:FechaInicial>${q.FechaInicial}</des:FechaInicial><des:Identificador>${q.Identificador}</des:Identificador><des:Plataforma>${q.Plataforma}</des:Plataforma><des:TipoSuplemento1>NP</des:TipoSuplemento1><des:TipoSuplemento2>AN</des:TipoSuplemento2><des:TipoSuplemento3>RE</des:TipoSuplemento3><des:TipoSuplemento4>SP</des:TipoSuplemento4></des:DescargarPolizasRequest>`,
DescargaSiniestros: `<des:DescargarSiniestrosRequest><des:AceptarCicos>true</des:AceptarCicos><des:AceptarSdm>true</des:AceptarSdm><des:Clave>${q.Clave}</des:Clave><des:CodigoRamo>${q.CodigoRamo}</des:CodigoRamo><des:Empresa>${q.Empresa}</des:Empresa><des:FechaFinal>${q.FechaFinal}</des:FechaFinal><des:FechaInicial>${q.FechaInicial}</des:FechaInicial><des:Identificador>${q.Identificador}</des:Identificador><des:IncluirAperturas>true</des:IncluirAperturas><des:Plataforma>${q.Plataforma}</des:Plataforma></des:DescargarSiniestrosRequest>`,
DescargaCompletaRecibos: `<des:DescargaCompletaRecibosRequest><des:Clave>${q.Clave}</des:Clave><des:Empresa>${q.Empresa}</des:Empresa><des:FechaFinal>${q.FechaFinal}</des:FechaFinal><des:FechaInicial>${q.FechaInicial}</des:FechaInicial><des:Identificador>${q.Identificador}</des:Identificador><des:IncluirAnulados>true</des:IncluirAnulados><des:IncluirCobrados>true</des:IncluirCobrados><des:IncluirDevueltos>true</des:IncluirDevueltos><des:IncluirNuevos>true</des:IncluirNuevos></des:DescargaCompletaRecibosRequest>`,
DescargaCartera: `<des:DescargarCarteraRequest><des:CodigoMediador>${q.CodigoMediador}</des:CodigoMediador><des:Empresa>${q.Empresa}</des:Empresa><des:FechaRenovacion>${q.FechaRenovacion}</des:FechaRenovacion><des:Identificador>${q.Identificador}</des:Identificador><des:Plataforma>${q.Plataforma}</des:Plataforma></des:DescargarCarteraRequest>`,
ConsultaAgendaTramitacion: `<int:ConsultaTramitacionRequest xmlns:int="http://reale.net/wcf/internalServices"><int:Datos><int:CodigoExpediente>${q.CodigoExpediente}</int:CodigoExpediente><int:CodigoPoliza>${q.CodigoPoliza}</int:CodigoPoliza><int:CodigoSiniestro>${q.CodigoSiniestro}</int:CodigoSiniestro><int:Empresa>${q.Empresa}</int:Empresa></int:Datos></int:ConsultaTramitacionRequest>`,
ConsultaPolizas: `<des:ConsultarPolizaRequest><des:CodigoPoliza>${q.CodigoPoliza}</des:CodigoPoliza><des:CodigoRamo>${q.CodigoRamo}</des:CodigoRamo><des:CodigoSuplemento>${q.CodigoSuplemento || 0}</des:CodigoSuplemento><des:Empresa>${q.Empresa}</des:Empresa><des:Identificador>${q.Identificador}</des:Identificador><des:Plataforma>${q.Plataforma}</des:Plataforma></des:ConsultarPolizaRequest>`,
ConsultaRecibos: `<des:ConsultarReciboRequest><des:CodigoPoliza>${q.CodigoPoliza}</des:CodigoPoliza><des:CodigoRamo>${q.CodigoRamo}</des:CodigoRamo><des:CodigoRecibo>${q.CodigoRecibo || 0}</des:CodigoRecibo><des:CodigoSuplemento>${q.CodigoSuplemento || 0}</des:CodigoSuplemento><des:Empresa>${q.Empresa}</des:Empresa><des:Identificador>${q.Identificador}</des:Identificador><des:Plataforma>${q.Plataforma}</des:Plataforma></des:ConsultarReciboRequest>`,
ConsultaSiniestros: `<des:ConsultarSiniestroRequest><des:CodigoPoliza>${q.CodigoPoliza}</des:CodigoPoliza><des:CodigoRamo>${q.CodigoRamo}</des:CodigoRamo><des:CodigoSiniestro>${q.CodigoSiniestro}</des:CodigoSiniestro><des:CodigoSuplemento>${q.CodigoSuplemento || 0}</des:CodigoSuplemento><des:Empresa>${q.Empresa}</des:Empresa><des:Identificador>${q.Identificador}</des:Identificador><des:Plataforma>${q.Plataforma}</des:Plataforma></des:ConsultarSiniestroRequest>`,
};
return templates[service] || `<des:${method}Request><des:Identificador>${q.Identificador}</des:Identificador></des:${method}Request>`;
};
export const soapCall = async (params, query, save = true) => {
const { CodigoMediador, alias } = params;
const target = ALIAS_MAP[alias] || { service: params.service, method: params.method };
const { service, method } = target;
if (!service) throw new Error(`Servicio o Alias '${alias || params.service}' no definido`);
const url = `https://lba.realeonline.net/Reale.B2b.Services.Multitarificadores.IisHost/${service}.svc`;
const Identificador = query.Identificador || process.env[`SOAP_${CodigoMediador}`];
if (!Identificador) throw new Error(`Identificador no configurado para ${CodigoMediador}`);
const q = {
...query,
Identificador,
CodigoMediador,
Clave: query.Clave || "10000",
Empresa: query.Empresa || "4",
Plataforma: query.Plataforma || "10000",
CodigoRamo: query.CodigoRamo || "0",
CodigoSuplemento: query.CodigoSuplemento || "0",
CodigoPoliza: query.CodigoPoliza || "0",
CodigoSiniestro: query.CodigoSiniestro || "0",
CodigoExpediente: query.CodigoExpediente || "0",
FechaFinal: query.FechaFinal || getDate(),
FechaInicial: query.FechaInicial || (alias === "Cartera" ? getFirstMonth(0) : getFirstMonth(-1)),
FechaRenovacion: query.FechaRenovacion || getFirstMonth(1),
};
let nsBase = "http://reale.net/B2b/Multitarificadores";
let nsName = service;
let contract = `I${service}`;
let actMethod = method;
let soapHeader = "";
if (service === "DescargaCartera") {
nsName = "DescargaFicheros";
contract = "IDescargaCartera";
}
else if (service === "ConsultaPolizas") {
nsName = "ConsultaPolizas";
contract = "IConsultaPolizas";
}
else if (service === "DescargaCompletaRecibos" && method === "Descargar") {
actMethod = "DescargarNew";
}
else if (service === "ConsultaAgendaTramitacion") {
nsBase = "http://reale.net/wcf/internalServices";
nsName = "";
contract = "IAgendaTramitacion";
actMethod = "ConsultaTramitacion";
soapHeader = `<int:Plataforma xmlns:int="http://reale.net/wcf/internalServices">${q.Plataforma}</int:Plataforma><int:Identificador xmlns:int="http://reale.net/wcf/internalServices">${q.Identificador}</int:Identificador>`;
}
const fullNs = nsName ? `${nsBase}/${nsName}` : nsBase;
const soapAction = `"${fullNs}/${contract}/${actMethod}"`.replace(/([^:])\/\//g, "$1/");
const soapEnvelope = `
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:des="http://reale.net/B2b/Multitarificadores/${nsName || "DescargaFicheros"}"
xmlns:int="http://reale.net/wcf/internalServices">
<soapenv:Header>${soapHeader}</soapenv:Header>
<soapenv:Body>${getXmlBody(service, method, q)}</soapenv:Body>
</soapenv:Envelope>`.trim();
try {
const response = await fetch(url, {
method: "POST",
headers: { "Content-Type": "text/xml;charset=UTF-8", "SOAPAction": soapAction },
body: soapEnvelope,
});
const xmlData = await response.text();
const rawJson = parser.parse(xmlData);
if (!response.ok) {
const fault = rawJson.Envelope?.Body?.Fault?.faultstring;
throw new Error(typeof fault === "object" ? JSON.stringify(fault) : fault || `Error ${response.status}`);
}
const resultBody = rawJson.Envelope?.Body;
const responseName = Object.keys(resultBody || {})[0];
const result = cleanNil(resultBody?.[responseName] || {});
// CUIDADO DA ERROR CUANDO USAS /Poliza /Siniestro /Recibo porque no hay un action para ellos
if (save) await trx({ action: service, data: result }, actions);
return result;
} catch (error) {
console.error(`[SOAP ERROR] ${service}/${method}:`, error.message);
throw error;
}
};