From 4a941e47578a114af7c458745ce9e97cf96f2519 Mon Sep 17 00:00:00 2001 From: lemuel Date: Fri, 10 Feb 2023 12:47:35 -0600 Subject: [PATCH] sin reparar --- src/prestamo/prestamo.controller.ts | 10 --------- src/prestamo/prestamo.service.ts | 35 ----------------------------- 2 files changed, 45 deletions(-) diff --git a/src/prestamo/prestamo.controller.ts b/src/prestamo/prestamo.controller.ts index 93c44b1..36ce3b2 100644 --- a/src/prestamo/prestamo.controller.ts +++ b/src/prestamo/prestamo.controller.ts @@ -629,14 +629,4 @@ export class PrestamoController { this.validarUsuarioService.validarOperador(operador); 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(); - } } diff --git a/src/prestamo/prestamo.service.ts b/src/prestamo/prestamo.service.ts index 976365a..07c5960 100644 --- a/src/prestamo/prestamo.service.ts +++ b/src/prestamo/prestamo.service.ts @@ -953,39 +953,4 @@ export class PrestamoService { 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ó' }; - }); - } }