listo para mañana
This commit is contained in:
@@ -456,7 +456,7 @@ export class PrestamoController {
|
||||
const usuario: Usuario = req.user.usuario;
|
||||
|
||||
this.validarUsuarioService.validarUsuario(usuario);
|
||||
return this.prestamoService.prestamoInfoByUsuario(usuario);
|
||||
return this.prestamoService.prestamoInfoByUsuario(usuario, false);
|
||||
}
|
||||
|
||||
@Serealize(PrestamoEquipoOutputDto)
|
||||
|
||||
@@ -75,7 +75,7 @@ export class PrestamoService {
|
||||
motivo: string,
|
||||
modulo: Modulo,
|
||||
) {
|
||||
const ahora = moment();
|
||||
const ahora = moment().add(14, 'h');
|
||||
const prestamo = await this.findById(id_prestamo);
|
||||
|
||||
this.validacionBasicaPrestamo(prestamo);
|
||||
@@ -104,7 +104,7 @@ export class PrestamoService {
|
||||
}
|
||||
|
||||
async cancelarUsuario(usuario: Usuario) {
|
||||
const ahora = moment();
|
||||
const ahora = moment().add(14, 'h');
|
||||
const prestamo = await this.prestamoInfoByUsuario(usuario);
|
||||
|
||||
this.validacionBasicaPrestamo(prestamo);
|
||||
@@ -139,7 +139,7 @@ export class PrestamoService {
|
||||
id_programa?: number,
|
||||
id_tipo_entrada?: number,
|
||||
) {
|
||||
const ahora = moment();
|
||||
const ahora = moment().add(14, 'h');
|
||||
const ahoraStr = ahora.format('YYYY-MM-DD');
|
||||
const sistema = { id_operador: 1 };
|
||||
const modulo = await this.moduloService.findFullInfoById(id_modulo);
|
||||
@@ -256,7 +256,7 @@ export class PrestamoService {
|
||||
}
|
||||
|
||||
async desactivarPrestamos() {
|
||||
const ahora = moment();
|
||||
const ahora = moment().add(14, 'h');
|
||||
|
||||
// Busco todos los préstamos activos y que esten apartadoss
|
||||
return this.informacionPrestamoView
|
||||
@@ -294,7 +294,7 @@ export class PrestamoService {
|
||||
modulo: Modulo,
|
||||
id_prestamo: number,
|
||||
) {
|
||||
const ahora = moment();
|
||||
const ahora = moment().add(14, 'h');
|
||||
const ahoraStr = ahora.format('YYYY-MM-DD');
|
||||
const prestamo = await this.findById(id_prestamo);
|
||||
const institucionDia =
|
||||
@@ -665,14 +665,17 @@ export class PrestamoService {
|
||||
});
|
||||
}
|
||||
|
||||
prestamoInfoByUsuario(usuario: Usuario) {
|
||||
prestamoInfoByUsuario(usuario: Usuario, validarExistencia = true) {
|
||||
return this.prestamoInformacionView
|
||||
.findOne({ where: { activo: 1, id_usuario: usuario.id_usuario } })
|
||||
.then((infoPrestamo) => {
|
||||
if (!infoPrestamo)
|
||||
throw new NotFoundException(
|
||||
'Este usuario no tiene un préstamo activo.',
|
||||
);
|
||||
if (!infoPrestamo) {
|
||||
if (validarExistencia)
|
||||
throw new NotFoundException(
|
||||
'Este usuario no tiene un préstamo activo.',
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
const prestamo = this.repository.create({
|
||||
id_prestamo: infoPrestamo.id_prestamo,
|
||||
@@ -776,7 +779,7 @@ export class PrestamoService {
|
||||
descripcion?: string,
|
||||
id_institucion_infraccion?: number,
|
||||
) {
|
||||
const ahora = moment();
|
||||
const ahora = moment().add(14, 'h');
|
||||
// La resta ahora - hora_fin nos da la cantidad de tiempo que se paso el usuario
|
||||
// en entregar el equipo a tiempo. Si es negativa es que fue antes de la hora_fin
|
||||
const tardanza = Math.trunc(ahora.diff(moment(prestamo.hora_fin)) / 60000);
|
||||
|
||||
Reference in New Issue
Block a user