Se agregarón usuarios Externos en Carga Individual

This commit is contained in:
2025-09-09 09:52:05 -06:00
parent d9550f1bf1
commit 6e12e580e1
3 changed files with 17 additions and 10 deletions
+11 -4
View File
@@ -27,10 +27,14 @@ export class ExcelController {
@Post('carga')
async cargaUsuario(@Request() req, @Body() usuario: CreateUsuarioDto) {
console.log('Usuario recibido:', usuario);
if (req.user.origen != 'LOAD') {
throw new BadRequestException('Origen no permitido para carga')
console.log('Datos del request:', req.user);
if (req.user.origen != 'LOAD' && req.user.origen!='EXTERNO') {
throw new Error('Origen no permitido para carga')
}
const alta = await this.usuarioService.cargaIndividual(usuario, req.user.origen, req.user.email);
if (!alta) {
throw new Error('No se pudo realizar la carga del usuario')
}
const alta = await this.usuarioService.cargaIndividual(usuario, req.user.origen)
console.log('Alta de usuario:', alta);
await this.movimientoService.updateStatus(alta.movId, 'SUCCESS')
@@ -41,6 +45,9 @@ export class ExcelController {
html: `<p>La carga de datos se ha realizado con éxito ${alta} </p>`,
});
await this.excelService.enviarInforme("LOAD","Carga Individual de datos en Servicios PCpuma",
`Se ha hecho una carga individual en el sistema por el usuario ${req.user.email}`)
if(alta.at){
await this.excelService.enviarInforme('AT',"Carga Individual de datos en Servicios PCpuma",
`Se ha hecho una carga individual en el sistema`)
@@ -95,7 +102,7 @@ export class ExcelController {
}
try {
const result = await this.excelService.loadFile(file.buffer);
const result = await this.excelService.loadFile(file.buffer,req.user.email);
//Actualizar el estado de los movimientos
if (!result) {
this.mailService.sendMail({
+3 -3
View File
@@ -197,7 +197,7 @@ export class ExcelService {
/**
* Valida y luego persiste usuarios y relaciones básicas
*/
async loadFile(buffer: Buffer) {
async loadFile(buffer: Buffer, user:string) {
const file = await this.parseFile(buffer);
const status = this.validateRows(file);
const errs = status.errors;
@@ -223,8 +223,8 @@ export class ExcelService {
queryRunner,
'LOAD',
'LOADING',
undefined,
'CARGA MASIVA DE USUARIOS',
'Caraga masiva de usuarios hecha por: ' + user,
`CARGA MASIVA DE USUARIOS`,
);
// 🔹 1. Pre-cargar cuentas/rfc ya existentes