Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 51 additions & 18 deletions modules/descargas/informe-rup/informe-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,55 @@ export class InformeRupBody extends HTMLComponent {
<main>
<section class="contenedor-informe">
<article class="cabezal-conceptos horizontal">
<div class="contenedor-bloque-texto w-3/4" >
<div class="contenedor-bloque-texto w-50" >
<div class="tipo-prestacion">
{{ titulo }}
</div>
</div>

<div class="contenedor-bloque-texto">
<div class="contenedor-bloque-texto ">
<h6 class="bolder">
Fecha Consulta
</h6>
<h6>
{{ fechaEjecucion }}hs
</h6>
</div>
<div class="contenedor-bloque-texto ">
<h6 class="bolder">
Inicio de Prestación
</h6>
<h6>
{{ fechaPrestacion }}hs
</h6>
</div>
<div class="contenedor-bloque-texto">
{{#if esValidada}}
<h6 class="bolder">
Fecha Validación
<div class="contenedor-bloque-texto ">
{{#if esValidada}}
<h6 class="bolder">
Fecha Validación
</h6>
<h6>
{{ fechaValidacion }}hs
</h6>
</h6>
{{else}}
<h6 class="bolder">
Sin validar
Sin validar
</h6>
{{/if}}
</div>
<div class="contenedor-bloque-texto">
<h6 class="bolder">
Inicio de Prestación
</h6>
<h6>
{{ fechaPrestacion }}hs
</h6>
</div>
</div>

</article>
<hr>
<hr style="margin-bottom: 1rem;">

{{#if valorPrestacion}}
<h6 class="bolder">
{{ nombrePrestacion }}:
</h6>
<h6>
{{ valorPrestacion }}
</h6>
{{/if}}
<div class="registros">
{{#each registros}}
{{{this}}}
Expand All @@ -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;
Expand All @@ -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(/&nbsp;/g, ' ');
}
if (typeof value === 'object') {
if (value.term) {
return String(value.term).replace(/&nbsp;/g, ' ');
}
return '';
}
return String(value);
}

async getFirmaHTML() {
if (this.validada()) {
const prof = this.prestacion.estadoActual.createdBy;
Expand Down
Loading