se normalizaron los n.cuenta a string
This commit is contained in:
@@ -133,7 +133,7 @@ export class ExcelService {
|
||||
flagError = true;
|
||||
}
|
||||
});
|
||||
|
||||
r.cuenta = this.normalize(r.cuenta);
|
||||
// El número de cuenta debe ser de nueve dígitos para los alumnos
|
||||
if (
|
||||
r.cuenta &&
|
||||
@@ -196,6 +196,11 @@ export class ExcelService {
|
||||
return status;
|
||||
}
|
||||
|
||||
normalize(value: any): string {
|
||||
return String(value)
|
||||
.replace(/\u00A0/g, ' ') // espacio raro de Excel
|
||||
.trim();
|
||||
}
|
||||
/**
|
||||
* Valida y luego persiste usuarios y relaciones básicas
|
||||
*/
|
||||
@@ -279,7 +284,8 @@ export class ExcelService {
|
||||
const mapTipo = new Map(tiposExist.map((t) => [t.tipo_usuario, t]));
|
||||
|
||||
const usuarios: Usuario[] = [];
|
||||
|
||||
const cuentasVistas = new Set<string>();
|
||||
const rfcsVistos = new Set<string>();
|
||||
const usuariosConRow: { usuario: Usuario; row: any }[] = [];
|
||||
|
||||
let contador = 0;
|
||||
@@ -356,6 +362,21 @@ export class ExcelService {
|
||||
? parseInt(r.gen.toString().trim(), 10)
|
||||
: null;
|
||||
|
||||
if (cuentasVistas.has(r.cuenta)) {
|
||||
errs.push(`Cuenta ${r.cuenta} duplicada en el archivo Excel.`);
|
||||
contador++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (r.rfc && rfcsVistos.has(r.rfc)) {
|
||||
errs.push(`RFC ${r.rfc} duplicado en el archivo Excel.`);
|
||||
contador++;
|
||||
continue;
|
||||
}
|
||||
|
||||
cuentasVistas.add(r.cuenta);
|
||||
if (r.rfc) rfcsVistos.add(r.rfc);
|
||||
|
||||
const usuario = queryRunner.manager.create(Usuario, {
|
||||
num_cuenta: r.cuenta,
|
||||
nombre: r.nombres,
|
||||
|
||||
Reference in New Issue
Block a user