historial
This commit is contained in:
parent
f720dc4840
commit
1ae6cf72b0
49
src/prestamo/dto/prestamo-historial.dto.ts
Normal file
49
src/prestamo/dto/prestamo-historial.dto.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import {
|
||||
IsDateString,
|
||||
IsNumberString,
|
||||
IsOptional,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
|
||||
export class PrestamoHistorialDto {
|
||||
@IsNumberString()
|
||||
pagina: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
carrito?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
equipo?: string;
|
||||
|
||||
@IsDateString()
|
||||
fechaFin?: string;
|
||||
|
||||
@IsDateString()
|
||||
fechaInicio?: string;
|
||||
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
id_institucion?: string;
|
||||
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
id_modulo?: string;
|
||||
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
id_prestamo?: string;
|
||||
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
id_tipo_carrito?: string;
|
||||
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
id_tipo_usuario?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
usuario?: string;
|
||||
}
|
@ -11,7 +11,6 @@ export class PrestamoController {
|
||||
|
||||
@Get('activos')
|
||||
activos(@Query() query: PrestamoActivosDto) {
|
||||
console.log(query);
|
||||
return this.prestamoService.findAll(query);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import { OperadorService } from '../operador/operador.service';
|
||||
import { StatusService } from '../status/status.service';
|
||||
import { TipoUsuarioService } from '../tipo-usuario/tipo-usuario.service';
|
||||
import { UsuarioService } from '../usuario/usuario.service';
|
||||
import { Institucion } from 'src/institucion/entity/institucion.entity';
|
||||
|
||||
@Injectable()
|
||||
export class PrestamoService {
|
||||
@ -66,14 +67,12 @@ export class PrestamoService {
|
||||
)
|
||||
: null;
|
||||
|
||||
console.log(modulo);
|
||||
|
||||
return this.repository
|
||||
.findOne({ activo: true, usuario })
|
||||
.then((prestamo) => {
|
||||
if (prestamo)
|
||||
.then((existePrestamo) => {
|
||||
if (existePrestamo)
|
||||
throw new ConflictException(
|
||||
'Este usuario ya tiene un prestamo activo.',
|
||||
'Este usuario ya tiene un préstamo activo.',
|
||||
);
|
||||
return this.equipoService.reseteo(
|
||||
modulo,
|
||||
@ -110,7 +109,6 @@ export class PrestamoService {
|
||||
}
|
||||
|
||||
async findAll(filtros: {
|
||||
id_modulo: string;
|
||||
pagina: string;
|
||||
activo?: string | boolean;
|
||||
carrito?: string;
|
||||
@ -118,6 +116,8 @@ export class PrestamoService {
|
||||
fechaFin?: string;
|
||||
fechaInicio?: string;
|
||||
id_carrera?: string;
|
||||
id_institucion?: string;
|
||||
id_modulo?: string;
|
||||
id_operador_entrega?: string;
|
||||
id_operador_regreso?: string;
|
||||
id_tipo_carrito?: string;
|
||||
@ -149,7 +149,7 @@ export class PrestamoService {
|
||||
equipo?: FindOperator<string>;
|
||||
carrito: {
|
||||
carrito?: FindOperator<string>;
|
||||
modulo?: Modulo;
|
||||
modulo?: Modulo | { institucion: Institucion };
|
||||
tipoCarrito?: TipoCarrito;
|
||||
};
|
||||
};
|
||||
@ -166,6 +166,9 @@ export class PrestamoService {
|
||||
parseInt(filtros.id_carrera),
|
||||
)
|
||||
: null;
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
const modulo = filtros.id_modulo
|
||||
? await this.moduloService.findById(parseInt(filtros.id_modulo))
|
||||
: null;
|
||||
@ -190,12 +193,10 @@ export class PrestamoService {
|
||||
)
|
||||
: null;
|
||||
|
||||
console.log(filtros.activo);
|
||||
if (filtros.activo) {
|
||||
if (typeof filtros.activo === 'boolean') busqueda.activo = filtros.activo;
|
||||
else busqueda.activo = filtros.activo === 'true';
|
||||
} else {
|
||||
console.log('hola');
|
||||
join.oe = 'p.operadorEntrega';
|
||||
join.or = 'p.operadorRegreso';
|
||||
}
|
||||
@ -206,6 +207,7 @@ export class PrestamoService {
|
||||
if (filtros.usuario)
|
||||
busqueda.usuario.usuario = Like(`%${filtros.usuario}%`);
|
||||
if (carrera) busqueda.usuario.institucionCarrera.carrera = carrera;
|
||||
if (institucion) busqueda.equipo.carrito.modulo = { institucion };
|
||||
if (modulo) busqueda.equipo.carrito.modulo = modulo;
|
||||
if (operadorEntrega) busqueda.operadorEntrega = operadorEntrega;
|
||||
if (operadorRegreso) busqueda.operadorRegreso = operadorRegreso;
|
||||
|
Loading…
Reference in New Issue
Block a user