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