utn-cli 2.0.91 → 2.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1507,17 +1507,60 @@ class Miscelaneo {
|
|
|
1507
1507
|
}
|
|
1508
1508
|
|
|
1509
1509
|
convertirACSV(ArregloDeJSON) {
|
|
1510
|
-
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1510
|
+
if (!ArregloDeJSON || ArregloDeJSON.length === 0) return '';
|
|
1511
|
+
const intentarParsearJSON = (valor) => {
|
|
1512
|
+
if (typeof valor === 'object' && valor !== null && !Array.isArray(valor)) return valor;
|
|
1513
|
+
if (typeof valor === 'string' && valor.trim().startsWith('{')) {
|
|
1514
|
+
try {
|
|
1515
|
+
const objeto = JSON.parse(valor);
|
|
1516
|
+
if (typeof objeto === 'object' && objeto !== null && !Array.isArray(objeto)) return objeto;
|
|
1517
|
+
} catch (e) { }
|
|
1518
|
+
}
|
|
1519
|
+
return null;
|
|
1520
|
+
};
|
|
1521
|
+
const columnasOriginales = Object.keys(ArregloDeJSON[0]);
|
|
1522
|
+
const mapaColumnasJSON = {};
|
|
1523
|
+
columnasOriginales.forEach(col => {
|
|
1524
|
+
const todasLasLlaves = new Set();
|
|
1525
|
+
let esJSON = false;
|
|
1526
|
+
ArregloDeJSON.forEach(fila => {
|
|
1527
|
+
const obj = intentarParsearJSON(fila[col]);
|
|
1528
|
+
if (obj) {
|
|
1529
|
+
esJSON = true;
|
|
1530
|
+
Object.keys(obj).forEach(k => todasLasLlaves.add(k));
|
|
1516
1531
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1532
|
+
});
|
|
1533
|
+
if (esJSON) mapaColumnasJSON[col] = Array.from(todasLasLlaves);
|
|
1534
|
+
});
|
|
1535
|
+
|
|
1536
|
+
const encabezadosFinales = [];
|
|
1537
|
+
columnasOriginales.forEach(col => {
|
|
1538
|
+
if (mapaColumnasJSON[col]) {
|
|
1539
|
+
mapaColumnasJSON[col].forEach(llave => encabezadosFinales.push(`${col}_${llave}`));
|
|
1540
|
+
} else {
|
|
1541
|
+
encabezadosFinales.push(col);
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
|
|
1545
|
+
const filasCSV = ArregloDeJSON.map(fila => {
|
|
1546
|
+
const valoresFila = [];
|
|
1547
|
+
columnasOriginales.forEach(col => {
|
|
1548
|
+
if (mapaColumnasJSON[col]) {
|
|
1549
|
+
const obj = intentarParsearJSON(fila[col]) || {};
|
|
1550
|
+
mapaColumnasJSON[col].forEach(llave => {
|
|
1551
|
+
let valor = obj[llave];
|
|
1552
|
+
if (valor === undefined || valor === null || valor === 'null') valor = '';
|
|
1553
|
+
valoresFila.push(JSON.stringify(String(valor)).replace(/,/g, ' '));
|
|
1554
|
+
});
|
|
1555
|
+
} else {
|
|
1556
|
+
let valor = fila[col];
|
|
1557
|
+
if (valor === null || valor === 'null') valor = '';
|
|
1558
|
+
valoresFila.push(JSON.stringify(String(valor)).replace(/,/g, ' '));
|
|
1559
|
+
}
|
|
1560
|
+
});
|
|
1561
|
+
return valoresFila.join(',');
|
|
1519
1562
|
});
|
|
1520
|
-
return [
|
|
1563
|
+
return [encabezadosFinales.join(','), ...filasCSV].join('\n');
|
|
1521
1564
|
};
|
|
1522
1565
|
|
|
1523
1566
|
convertirACSVConDetalle(ArregloDeJSON, ColumnaConDetalle) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { ejecutarConsultaSIGU } = require('./db.js');
|
|
2
2
|
|
|
3
3
|
class ReporteHTML {
|
|
4
|
-
constructor() {}
|
|
4
|
+
constructor() { }
|
|
5
5
|
|
|
6
6
|
async generarFirmaHTML(Identificador, FechaDeLaFirma) {
|
|
7
7
|
const [persona] = await ejecutarConsultaSIGU("SELECT Identificacion, CONCAT(Nombre, ' ', PrimerApellido, ' ', SegundoApellido) AS NombreCompleto FROM SIGU.SIGU_Personas WHERE Identificador = ?", [Identificador]);
|
|
@@ -167,9 +167,9 @@ class ReporteHTML {
|
|
|
167
167
|
hours = hours ? hours : 12;
|
|
168
168
|
hours = hours.toString().padStart(2, '0');
|
|
169
169
|
|
|
170
|
-
const fechaFormateada =
|
|
170
|
+
const fechaFormateada = `${day}-${month}-${year} ${hours}:${minutes} ${ampm}`;
|
|
171
171
|
|
|
172
|
-
return
|
|
172
|
+
return ` <div style="margin-left: 0; font-size: 11px; margin-top:4px;">
|
|
173
173
|
<strong>Fecha:</strong>
|
|
174
174
|
<span style="
|
|
175
175
|
border-bottom: 1px solid #000;
|
|
@@ -179,7 +179,7 @@ class ReporteHTML {
|
|
|
179
179
|
vertical-align: middle;
|
|
180
180
|
text-align: center;
|
|
181
181
|
min-width: 120px;
|
|
182
|
-
"
|
|
182
|
+
">${fechaFormateada}
|
|
183
183
|
</span>
|
|
184
184
|
</div>
|
|
185
185
|
`
|
|
@@ -191,36 +191,36 @@ class ReporteHTML {
|
|
|
191
191
|
const baseColumnas = Object.keys(ElementosParaLaTabla[0]).filter(col => !ParametrosExcluidos.includes(col));
|
|
192
192
|
const columnas = [...baseColumnas, ...ParametrosExtra.filter(p => !baseColumnas.includes(p))];
|
|
193
193
|
|
|
194
|
-
const tableHeaders = `<th>N°</th
|
|
194
|
+
const tableHeaders = `<th>N°</th>` + columnas.map(col => `<th>${col}</th>`).join('');
|
|
195
195
|
|
|
196
196
|
const rows = ElementosParaLaTabla.map((fila, index) => {
|
|
197
197
|
const rowCells = columnas.map(col => {
|
|
198
198
|
const valor = fila[col] ?? '';
|
|
199
|
-
return
|
|
199
|
+
return `<td>${valor}</td>`;
|
|
200
200
|
}).join('');
|
|
201
|
-
return
|
|
201
|
+
return `<tr><td><strong>${index + 1}</strong></td>${rowCells}</tr>`;
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
const colCount = columnas.length + 1;
|
|
205
205
|
const minRows = 1;
|
|
206
206
|
let currentIndex = rows.length;
|
|
207
207
|
while (rows.length < minRows) {
|
|
208
|
-
let emptyCells =
|
|
208
|
+
let emptyCells = `<td><strong>${currentIndex + 1}</strong></td>`;
|
|
209
209
|
for (let i = 0; i < colCount - 1; i++) {
|
|
210
210
|
emptyCells += '<td></td>';
|
|
211
211
|
}
|
|
212
|
-
rows.push(
|
|
212
|
+
rows.push(`<tr style="height:40px">${emptyCells}</tr>`);
|
|
213
213
|
currentIndex++;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
const tableRows = rows.join('');
|
|
217
|
-
return
|
|
217
|
+
return `
|
|
218
218
|
<table>
|
|
219
219
|
<thead>
|
|
220
|
-
<tr
|
|
220
|
+
<tr>${tableHeaders}</tr>
|
|
221
221
|
</thead>
|
|
222
222
|
<tbody>
|
|
223
|
-
|
|
223
|
+
${tableRows}
|
|
224
224
|
</tbody>
|
|
225
225
|
</table>`;
|
|
226
226
|
}
|