listo hora top y hora extra
This commit is contained in:
parent
101cfb6275
commit
b89bed1d74
@ -1,6 +1,8 @@
|
|||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import {
|
import {
|
||||||
|
BadRequestException,
|
||||||
ConflictException,
|
ConflictException,
|
||||||
|
ForbiddenException,
|
||||||
forwardRef,
|
forwardRef,
|
||||||
Inject,
|
Inject,
|
||||||
Injectable,
|
Injectable,
|
||||||
@ -121,6 +123,12 @@ export class PrestamoService {
|
|||||||
const horaMin = institucionDia
|
const horaMin = institucionDia
|
||||||
? moment(`${ahora.format('YYYY-MM-DD')} ${institucionDia.hora_inicio}`)
|
? moment(`${ahora.format('YYYY-MM-DD')} ${institucionDia.hora_inicio}`)
|
||||||
: null;
|
: null;
|
||||||
|
const horaExtra = institucionDia
|
||||||
|
? moment(`${ahora.format('YYYY-MM-DD')} ${institucionDia.hora_extra}`)
|
||||||
|
: null;
|
||||||
|
const horaTope = institucionDia
|
||||||
|
? moment(`${ahora.format('YYYY-MM-DD')} ${institucionDia.hora_tope}`)
|
||||||
|
: null;
|
||||||
const programa = id_programa
|
const programa = id_programa
|
||||||
? await this.institucionProgramaService.findProgramaById(id_programa)
|
? await this.institucionProgramaService.findProgramaById(id_programa)
|
||||||
: null;
|
: null;
|
||||||
@ -130,9 +138,9 @@ export class PrestamoService {
|
|||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
if (ahora.weekday() === 0)
|
||||||
|
throw new ConflictException('No hay servicio los días domingo.');
|
||||||
this.validarInstitucionUsuario(usuario.instituciones, modulo);
|
this.validarInstitucionUsuario(usuario.instituciones, modulo);
|
||||||
if (ahora.weekday() === 0 || ahora.weekday() === 6)
|
|
||||||
throw new ConflictException('No hay servicio los días sábado y domingo.');
|
|
||||||
if (!institucionDia.activo)
|
if (!institucionDia.activo)
|
||||||
throw new ConflictException(
|
throw new ConflictException(
|
||||||
'El día de hoy no hay servicio de préstamo de equipos.',
|
'El día de hoy no hay servicio de préstamo de equipos.',
|
||||||
@ -141,9 +149,9 @@ export class PrestamoService {
|
|||||||
throw new ConflictException(
|
throw new ConflictException(
|
||||||
`El servicio inicia a las ${institucionDia.hora_inicio} el día de hoy.`,
|
`El servicio inicia a las ${institucionDia.hora_inicio} el día de hoy.`,
|
||||||
);
|
);
|
||||||
if (ahora > horaMax)
|
if (ahora >= horaExtra)
|
||||||
throw new ConflictException(
|
throw new ConflictException(
|
||||||
`El servicio terminó a las ${institucionDia.hora_fin} el día de hoy.`,
|
`El servicio terminó a las ${institucionDia.hora_extra} el día de hoy.`,
|
||||||
);
|
);
|
||||||
for (let i = 0; i < institucionDia.horasExcepcion.length; i++) {
|
for (let i = 0; i < institucionDia.horasExcepcion.length; i++) {
|
||||||
const horaFin = moment(
|
const horaFin = moment(
|
||||||
@ -188,9 +196,10 @@ export class PrestamoService {
|
|||||||
this.repository.create({
|
this.repository.create({
|
||||||
equipo,
|
equipo,
|
||||||
fecha_inicio: ahora.toDate(),
|
fecha_inicio: ahora.toDate(),
|
||||||
hora_max_recoger: ahora
|
hora_max_recoger:
|
||||||
.add(modulo.institucion.tiempo_recoger, 'm')
|
ahora > horaMax && ahora < horaExtra
|
||||||
.toDate(),
|
? horaTope
|
||||||
|
: ahora.add(modulo.institucion.tiempo_recoger, 'm').toDate(),
|
||||||
operadorEntrega: sistema,
|
operadorEntrega: sistema,
|
||||||
operadorRegreso: sistema,
|
operadorRegreso: sistema,
|
||||||
usuario,
|
usuario,
|
||||||
@ -667,17 +676,17 @@ export class PrestamoService {
|
|||||||
|
|
||||||
if (institucion.id_institucion === modulo.institucion.id_institucion) {
|
if (institucion.id_institucion === modulo.institucion.id_institucion) {
|
||||||
if (!instituciones[i].activo)
|
if (!instituciones[i].activo)
|
||||||
throw new ConflictException(
|
throw new ForbiddenException(
|
||||||
`${this.mensajeNoPoderPedir()} tu cuenta esta desactivada en esta institución.`,
|
`${this.mensajeNoPoderPedir()} tu cuenta esta desactivada en esta institución.`,
|
||||||
);
|
);
|
||||||
if (instituciones[i].multa)
|
if (instituciones[i].multa)
|
||||||
throw new ConflictException(
|
throw new ForbiddenException(
|
||||||
`${this.mensajeNoPoderPedir()} tienes una multa activa.`,
|
`${this.mensajeNoPoderPedir()} tienes una multa activa.`,
|
||||||
);
|
);
|
||||||
return;
|
return institucion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new ConflictException(
|
throw new BadRequestException(
|
||||||
`${this.mensajeNoPoderPedir()} no perteneces a esta institución.`,
|
`${this.mensajeNoPoderPedir()} no perteneces a esta institución.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user