sin reparar
This commit is contained in:
parent
4e61a200c2
commit
4a941e4757
@ -629,14 +629,4 @@ export class PrestamoController {
|
|||||||
this.validarUsuarioService.validarOperador(operador);
|
this.validarUsuarioService.validarOperador(operador);
|
||||||
return this.prestamoService.findAll(operador, query);
|
return this.prestamoService.findAll(operador, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serealize(MessageOutputDto)
|
|
||||||
@Post('reparar')
|
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
reparar(@Request() req) {
|
|
||||||
const superAdmin: Operador = req.user.operador;
|
|
||||||
|
|
||||||
this.validarUsuarioService.validarSuperAdmin(superAdmin);
|
|
||||||
return this.prestamoService.reparar();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -953,39 +953,4 @@ export class PrestamoService {
|
|||||||
usuario: { id_usuario: infoPrestamo.id_usuario },
|
usuario: { id_usuario: infoPrestamo.id_usuario },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
reparar() {
|
|
||||||
return this.informacionPrestamoView
|
|
||||||
.find({ where: { id_institucion_usuario: IsNull() } })
|
|
||||||
.then(async (infoPrestamos) => {
|
|
||||||
for (let i = 0; i < infoPrestamos.length; i++) {
|
|
||||||
const prestamo = this.viewToPrestamo(infoPrestamos[i]);
|
|
||||||
const institucionesUsuario =
|
|
||||||
await this.institucionUsuarioService.findAllByIdUsuarioIdInstitucion(
|
|
||||||
prestamo.usuario,
|
|
||||||
prestamo.equipo.carrito.modulo.institucion,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (institucionesUsuario.length === 1) {
|
|
||||||
prestamo.institucionUsuario = institucionesUsuario[0];
|
|
||||||
await this.repository.save(prestamo);
|
|
||||||
} else if (
|
|
||||||
prestamo.equipo.carrito.tipoCarrito.id_tipo_carrito === 2
|
|
||||||
) {
|
|
||||||
console.log(prestamo);
|
|
||||||
console.log(institucionesUsuario);
|
|
||||||
console.log(
|
|
||||||
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++',
|
|
||||||
);
|
|
||||||
} else
|
|
||||||
for (let j = 0; j < institucionesUsuario.length; j++)
|
|
||||||
if (institucionesUsuario[j].activo) {
|
|
||||||
prestamo.institucionUsuario = institucionesUsuario[j];
|
|
||||||
await this.repository.save(prestamo);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { message: 'Terminó' };
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user