diff --git a/modules/descargas/informe-rup/informe-body.ts b/modules/descargas/informe-rup/informe-body.ts index e3ea186e5f..9c883ca862 100644 --- a/modules/descargas/informe-rup/informe-body.ts +++ b/modules/descargas/informe-rup/informe-body.ts @@ -8,44 +8,55 @@ export class InformeRupBody extends HTMLComponent {
-
+
{{ titulo }}
-
+
Fecha Consulta
{{ fechaEjecucion }}hs
+
+
+
+ Inicio de Prestación +
+
+ {{ fechaPrestacion }}hs +
-
- {{#if esValidada}} -
- Fecha Validación +
+ {{#if esValidada}} +
+ Fecha Validación
{{ fechaValidacion }}hs -
+
{{else}}
- Sin validar + Sin validar
{{/if}}
-
-
- Inicio de Prestación -
-
- {{ fechaPrestacion }}hs -
-
+
+
-
+
+ + {{#if valorPrestacion}} +
+ {{ nombrePrestacion }}: +
+
+ {{ valorPrestacion }} +
+ {{/if}}
{{#each registros}} {{{this}}} @@ -68,7 +79,8 @@ export class InformeRupBody extends HTMLComponent { const fechaValidacion = this.getFechaEstado('validada'); const fechaPrestacion = this.prestacion.estados.find(estado => { return estado.tipo === 'ejecucion'; }).createdAt; const esValidada = (fechaValidacion !== null); - + const valorPrestacion = this.prestacion.ejecucion.registros[0].valor || null; + const nombrePrestacion = this.prestacion.ejecucion.registros[0].nombre || null; if (this.registroId) { const registro = this.prestacion.findRegistroById(this.registroId); this.prestacion.solicitud.tipoPrestacion = registro.concepto; @@ -87,18 +99,39 @@ export class InformeRupBody extends HTMLComponent { const registros = await Promise.all(ps); const firmaHTML = await this.getFirmaHTML(); + // Si el primer registro ya se renderiza en el detalle, evitamos repetir su nombre/valor en el encabezado + const primerRegistroRenderizado = registros.length > 0 && String(registros[0]).trim() !== ''; + this.data = { fechaEjecucion: fechaEjecucion && moment(fechaEjecucion).format('DD/MM/YYYY HH:mm'), fechaValidacion: fechaValidacion && moment(fechaValidacion).format('DD/MM/YYYY HH:mm'), fechaPrestacion: fechaPrestacion && moment(fechaPrestacion).format('DD/MM/YYYY HH:mm'), titulo: this.prestacion.solicitud.tipoPrestacion.term, + valorPrestacion: primerRegistroRenderizado ? '' : this.cleanValue(valorPrestacion), + nombrePrestacion: primerRegistroRenderizado ? '' : this.cleanValue(nombrePrestacion), registros, esValidada, firmaHTML }; } + cleanValue(value) { + if (value === null || value === undefined) { + return ''; + } + if (typeof value === 'string') { + return value.replace(/ /g, ' '); + } + if (typeof value === 'object') { + if (value.term) { + return String(value.term).replace(/ /g, ' '); + } + return ''; + } + return String(value); + } + async getFirmaHTML() { if (this.validada()) { const prof = this.prestacion.estadoActual.createdBy;