quitar multas corregido
This commit is contained in:
+4
-4
@@ -10,14 +10,14 @@ import { Socket, Server } from 'socket.io';
|
||||
@WebSocketGateway({
|
||||
cors: {
|
||||
origin: [
|
||||
// 'http://localhost:3176',
|
||||
// 'http://localhost:3186',
|
||||
'http://localhost:3176',
|
||||
'http://localhost:3186',
|
||||
// 'http://132.248.80.196:3155',
|
||||
// 'http://132.248.80.196:3185',
|
||||
// 'https://pmodulospcpuma.unam.mx',
|
||||
// 'https://pmodulospcpuma.unam.mx:3015',
|
||||
'https://modulospcpuma.unam.mx',
|
||||
'https://modulospcpuma.unam.mx:3015',
|
||||
// 'https://modulospcpuma.unam.mx',
|
||||
// 'https://modulospcpuma.unam.mx:3015',
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
@@ -34,7 +34,7 @@ export class InformacionMultaView {
|
||||
id_multa: number;
|
||||
|
||||
@ViewColumn()
|
||||
activo: boolean;
|
||||
activo: number;
|
||||
|
||||
@ViewColumn()
|
||||
descripcion: string;
|
||||
|
||||
+24
-25
@@ -142,31 +142,30 @@ export class MultaService {
|
||||
desactivarMultas() {
|
||||
const ahora = moment();
|
||||
|
||||
// Busco todas las multas desactivadas
|
||||
return this.repository
|
||||
.find({
|
||||
join: {
|
||||
alias: 'mu',
|
||||
innerJoinAndSelect: { p: 'mu.prestamo', u: 'p.usuario' },
|
||||
},
|
||||
where: { activo: true },
|
||||
})
|
||||
.then(async (multas) => {
|
||||
//recorro todo el array
|
||||
for (let i = 0; i < multas.length; i++)
|
||||
// Busco todas las multas activas
|
||||
return this.informacionMultaView
|
||||
.find({ where: { activo: 1 } })
|
||||
.then(async (infoMultas) => {
|
||||
// recorro todo el array
|
||||
for (let i = 0; i < infoMultas.length; i++)
|
||||
// Si ya caducó
|
||||
if (ahora.diff(moment(multas[i].fecha_fin)) > 0) {
|
||||
// Desactivo multa
|
||||
multas[i].activo = false;
|
||||
// Guardo cambios
|
||||
await this.repository.save(multas[i]).then(() =>
|
||||
// Quito multas en institución usuario
|
||||
this.institucionUsuarioService.updateMulta(
|
||||
multas[i].operadorMulta.institucion.id_institucion,
|
||||
multas[i].prestamo.usuario.id_usuario,
|
||||
false,
|
||||
),
|
||||
);
|
||||
if (ahora.diff(moment(infoMultas[i].fecha_fin)) > 0) {
|
||||
// Desactivo multa y guardo cambios
|
||||
await this.repository
|
||||
.save(
|
||||
this.repository.create({
|
||||
id_multa: infoMultas[i].id_multa,
|
||||
activo: false,
|
||||
}),
|
||||
)
|
||||
.then((_) =>
|
||||
// Quito multas en institución usuario
|
||||
this.institucionUsuarioService.updateMulta(
|
||||
infoMultas[i].id_institucion,
|
||||
infoMultas[i].id_usuario,
|
||||
false,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -190,7 +189,7 @@ export class MultaService {
|
||||
order: {
|
||||
institucion: 'ASC',
|
||||
activo: 'DESC',
|
||||
id_multa: 'DESC',
|
||||
fecha_fin: 'ASC',
|
||||
id_usuario: 'ASC',
|
||||
},
|
||||
skip: (parseInt(filtros.pagina) - 1) * 25,
|
||||
|
||||
Reference in New Issue
Block a user