reporte
This commit is contained in:
@@ -149,7 +149,7 @@ export class OperadorController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
this.validarUsuarioService.validarSuperAdminAdmin(admin);
|
||||
return this.operadorService.findAllByInstitucion(admin);
|
||||
return this.operadorService.findAllByInstitucion(admin.institucion);
|
||||
}
|
||||
|
||||
@Serealize(MessageOutputDto)
|
||||
|
||||
@@ -169,10 +169,10 @@ export class OperadorService {
|
||||
});
|
||||
}
|
||||
|
||||
findAllByInstitucion(operador: Operador) {
|
||||
findAllByInstitucion(institucion: Institucion) {
|
||||
return this.repository.find({
|
||||
select: ['id_operador', 'operador'],
|
||||
where: { institucion: operador.institucion },
|
||||
where: { institucion },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,6 @@ import {
|
||||
} from 'class-validator';
|
||||
|
||||
export class HistorialDto {
|
||||
@IsNumberString()
|
||||
pagina: string;
|
||||
|
||||
@IsBooleanString()
|
||||
@IsOptional()
|
||||
activo?: string;
|
||||
@@ -69,6 +66,10 @@ export class HistorialDto {
|
||||
@IsOptional()
|
||||
id_tipo_usuario?: string;
|
||||
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
pagina?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
|
||||
@@ -181,6 +181,81 @@ export class PrestamoController {
|
||||
return this.prestamoService.entregar(operador, body.id_prestamo, modulo);
|
||||
}
|
||||
|
||||
// @Serealize(PrestamosOutputDto)
|
||||
@Get('reporte')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({
|
||||
description:
|
||||
'Endpoint que retorna todos los prestamos dependiendo de la página en la que se encuentra el operador y sus filtros.',
|
||||
})
|
||||
@ApiBearerAuth('jwt')
|
||||
@ApiQuery({
|
||||
description: 'Carrito que se quiere usar como filtro.',
|
||||
name: 'carrito',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Equipo que se quiere usar como filtro.',
|
||||
name: 'equipo',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Fecha inicio que se quiere usar como filtro.',
|
||||
name: 'fechaInicio',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Fecha fin se quiere usar como filtro.',
|
||||
name: 'fechaFin',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Id de la institución que se quiere usar como filtro.',
|
||||
name: 'id_institucion',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Id del modulo que se quiere usar como filtro.',
|
||||
name: 'id_modulo',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Id del préstamo que se quiere usar como filtro.',
|
||||
name: 'id_prestamo',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Id del tipo de carrito que se quiere usar como filtro.',
|
||||
name: 'id_tipo_carrito',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Id del tipo de usuario que se quiere usar como filtro.',
|
||||
name: 'id_tipo_usuario',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Usuario que se quiere usar como filtro.',
|
||||
name: 'usuario',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
reporte(@Request() req, @Query() query: HistorialDto) {
|
||||
const operador: Operador = req.user.operador;
|
||||
|
||||
this.validarUsuarioService.validarOperador(operador);
|
||||
return this.prestamoService.findAll(query);
|
||||
}
|
||||
|
||||
@Serealize(PrestamosOutputDto)
|
||||
@Get('historial')
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
|
||||
@@ -378,10 +378,6 @@ export class PrestamoService {
|
||||
};
|
||||
const busqueda: FindOptionsWhere<FullInformacionPrestamoView> = {};
|
||||
|
||||
if (filtros.pagina) {
|
||||
options.take = 25;
|
||||
options.skip = (parseInt(filtros.pagina) - 1) * 25;
|
||||
}
|
||||
if (filtros.activo) {
|
||||
if (typeof filtros.activo === 'boolean') {
|
||||
busqueda.activo = filtros.activo ? 1 : 0;
|
||||
@@ -411,65 +407,71 @@ export class PrestamoService {
|
||||
if (operadorRegreso)
|
||||
busqueda.id_operador_regreso = operadorRegreso.id_operador;
|
||||
options.where = busqueda;
|
||||
return this.fullInformacionPrestamoView
|
||||
.findAndCount(options)
|
||||
.then((infoPrestamos) => {
|
||||
const prestamos: Prestamo[] = [];
|
||||
if (filtros.pagina) {
|
||||
options.take = 25;
|
||||
options.skip = (parseInt(filtros.pagina) - 1) * 25;
|
||||
return this.fullInformacionPrestamoView
|
||||
.findAndCount(options)
|
||||
.then((infoPrestamos) => {
|
||||
const prestamos: Prestamo[] = [];
|
||||
|
||||
for (let i = 0; i < infoPrestamos[0].length; i++)
|
||||
prestamos.push(
|
||||
this.repository.create({
|
||||
id_prestamo: infoPrestamos[0][i].id_prestamo,
|
||||
activo: infoPrestamos[0][i].activo === 1,
|
||||
cancelado_operador: infoPrestamos[0][i].cancelado_operador === 1,
|
||||
cancelado_usuario: infoPrestamos[0][i].cancelado_usuario === 1,
|
||||
fecha_entrega: infoPrestamos[0][i].fecha_entrega,
|
||||
fecha_inicio: infoPrestamos[0][i].fecha_inicio,
|
||||
hora_fin: infoPrestamos[0][i].hora_fin,
|
||||
hora_inicio: infoPrestamos[0][i].hora_inicio,
|
||||
hora_max_recoger: infoPrestamos[0][i].hora_max_recoger,
|
||||
equipo: {
|
||||
id_equipo: infoPrestamos[0][i].id_equipo,
|
||||
equipo: infoPrestamos[0][i].equipo,
|
||||
numero_inventario: infoPrestamos[0][i].numero_inventario,
|
||||
carrito: {
|
||||
id_carrito: infoPrestamos[0][i].id_carrito,
|
||||
carrito: infoPrestamos[0][i].carrito,
|
||||
modulo: {
|
||||
id_modulo: infoPrestamos[0][i].id_modulo,
|
||||
modulo: infoPrestamos[0][i].modulo,
|
||||
institucion: {
|
||||
id_institucion: infoPrestamos[0][i].id_institucion,
|
||||
institucion: infoPrestamos[0][i].institucion,
|
||||
for (let i = 0; i < infoPrestamos[0].length; i++)
|
||||
prestamos.push(
|
||||
this.repository.create({
|
||||
id_prestamo: infoPrestamos[0][i].id_prestamo,
|
||||
activo: infoPrestamos[0][i].activo === 1,
|
||||
cancelado_operador:
|
||||
infoPrestamos[0][i].cancelado_operador === 1,
|
||||
cancelado_usuario: infoPrestamos[0][i].cancelado_usuario === 1,
|
||||
fecha_entrega: infoPrestamos[0][i].fecha_entrega,
|
||||
fecha_inicio: infoPrestamos[0][i].fecha_inicio,
|
||||
hora_fin: infoPrestamos[0][i].hora_fin,
|
||||
hora_inicio: infoPrestamos[0][i].hora_inicio,
|
||||
hora_max_recoger: infoPrestamos[0][i].hora_max_recoger,
|
||||
equipo: {
|
||||
id_equipo: infoPrestamos[0][i].id_equipo,
|
||||
equipo: infoPrestamos[0][i].equipo,
|
||||
numero_inventario: infoPrestamos[0][i].numero_inventario,
|
||||
carrito: {
|
||||
id_carrito: infoPrestamos[0][i].id_carrito,
|
||||
carrito: infoPrestamos[0][i].carrito,
|
||||
modulo: {
|
||||
id_modulo: infoPrestamos[0][i].id_modulo,
|
||||
modulo: infoPrestamos[0][i].modulo,
|
||||
institucion: {
|
||||
id_institucion: infoPrestamos[0][i].id_institucion,
|
||||
institucion: infoPrestamos[0][i].institucion,
|
||||
},
|
||||
},
|
||||
tipoCarrito: {
|
||||
id_tipo_carrito: infoPrestamos[0][i].id_tipo_carrito,
|
||||
tipo_carrito: infoPrestamos[0][i].tipo_carrito,
|
||||
},
|
||||
},
|
||||
tipoCarrito: {
|
||||
id_tipo_carrito: infoPrestamos[0][i].id_tipo_carrito,
|
||||
tipo_carrito: infoPrestamos[0][i].tipo_carrito,
|
||||
status: { id_status: infoPrestamos[0][i].id_status },
|
||||
},
|
||||
usuario: {
|
||||
id_usuario: infoPrestamos[0][i].id_usuario,
|
||||
nombre: infoPrestamos[0][i].nombre,
|
||||
usuario: infoPrestamos[0][i].usuario,
|
||||
tipoUsuario: {
|
||||
id_tipo_usuario: infoPrestamos[0][i].id_tipo_usuario,
|
||||
},
|
||||
},
|
||||
status: { id_status: infoPrestamos[0][i].id_status },
|
||||
},
|
||||
usuario: {
|
||||
id_usuario: infoPrestamos[0][i].id_usuario,
|
||||
nombre: infoPrestamos[0][i].nombre,
|
||||
usuario: infoPrestamos[0][i].usuario,
|
||||
tipoUsuario: {
|
||||
id_tipo_usuario: infoPrestamos[0][i].id_tipo_usuario,
|
||||
operadorEntrega: {
|
||||
id_operador: infoPrestamos[0][i].id_operador_entrega,
|
||||
operador: infoPrestamos[0][i].operador_entrega,
|
||||
},
|
||||
},
|
||||
operadorEntrega: {
|
||||
id_operador: infoPrestamos[0][i].id_operador_entrega,
|
||||
operador: infoPrestamos[0][i].operador_entrega,
|
||||
},
|
||||
operadorRegreso: {
|
||||
id_operador: infoPrestamos[0][i].id_operador_regreso,
|
||||
operador: infoPrestamos[0][i].operador_regreso,
|
||||
},
|
||||
}),
|
||||
);
|
||||
return [prestamos, infoPrestamos[1]];
|
||||
});
|
||||
operadorRegreso: {
|
||||
id_operador: infoPrestamos[0][i].id_operador_regreso,
|
||||
operador: infoPrestamos[0][i].operador_regreso,
|
||||
},
|
||||
}),
|
||||
);
|
||||
return [prestamos, infoPrestamos[1]];
|
||||
});
|
||||
}
|
||||
return this.fullInformacionPrestamoView.find(options);
|
||||
}
|
||||
|
||||
findAllByIdEquipo(id_equipo: number, pagina: number) {
|
||||
|
||||
Reference in New Issue
Block a user