hora tope arreglado
This commit is contained in:
parent
b76bcb0917
commit
19a3255e6d
@ -110,6 +110,7 @@ export class PrestamoService {
|
||||
id_tipo_entrada?: number,
|
||||
) {
|
||||
const ahora = moment();
|
||||
const ahoraStr = ahora.format('YYYY-MM-DD');
|
||||
const sistema = await this.operadorService.findById(1);
|
||||
const modulo = await this.moduloService.findById(id_modulo);
|
||||
const tipoCarrito =
|
||||
@ -121,17 +122,11 @@ export class PrestamoService {
|
||||
modulo.institucion,
|
||||
ahora.weekday(),
|
||||
);
|
||||
const horaMax = institucionDia
|
||||
? moment(`${ahora.format('YYYY-MM-DD')} ${institucionDia.hora_fin}`)
|
||||
: null;
|
||||
const horaMin = institucionDia
|
||||
? moment(`${ahora.format('YYYY-MM-DD')} ${institucionDia.hora_inicio}`)
|
||||
? moment(`${ahoraStr} ${institucionDia.hora_inicio}`)
|
||||
: 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}`)
|
||||
? moment(`${ahoraStr} ${institucionDia.hora_extra}`)
|
||||
: null;
|
||||
const programa = id_programa
|
||||
? await this.institucionProgramaService.findProgramaById(id_programa)
|
||||
@ -159,14 +154,10 @@ export class PrestamoService {
|
||||
);
|
||||
for (let i = 0; i < institucionDia.horasExcepcion.length; i++) {
|
||||
const horaFin = moment(
|
||||
`${ahora.format('YYYY-MM-DD')} ${
|
||||
institucionDia.horasExcepcion[i].hora_fin
|
||||
}`,
|
||||
`${ahoraStr} ${institucionDia.horasExcepcion[i].hora_fin}`,
|
||||
);
|
||||
const horaInicio = moment(
|
||||
`${ahora.format('YYYY-MM-DD')} ${
|
||||
institucionDia.horasExcepcion[i].hora_inicio
|
||||
}`,
|
||||
`${ahoraStr} ${institucionDia.horasExcepcion[i].hora_inicio}`,
|
||||
);
|
||||
|
||||
if (ahora > horaInicio && ahora < horaFin)
|
||||
@ -199,11 +190,10 @@ export class PrestamoService {
|
||||
this.repository.save(
|
||||
this.repository.create({
|
||||
equipo,
|
||||
fecha_inicio: ahora.format(),
|
||||
hora_max_recoger:
|
||||
ahora > horaMax && ahora < horaExtra
|
||||
? horaTope.format()
|
||||
: ahora.add(modulo.institucion.tiempo_recoger, 'm').format(),
|
||||
fecha_inicio: ahora.toDate(),
|
||||
hora_max_recoger: ahora
|
||||
.add(modulo.institucion.tiempo_recoger, 'm')
|
||||
.toDate(),
|
||||
operadorEntrega: sistema,
|
||||
operadorRegreso: sistema,
|
||||
usuario,
|
||||
@ -248,8 +238,20 @@ export class PrestamoService {
|
||||
|
||||
async entregar(id_prestamo: number, id_operador: number) {
|
||||
const ahora = moment();
|
||||
const ahoraStr = ahora.format('YYYY-MM-DD');
|
||||
const operadorEntrega = await this.operadorService.findById(id_operador);
|
||||
const prestamo = await this.findById(id_prestamo);
|
||||
const institucionDia =
|
||||
await this.institucionDiaService.findByInstitucionDia(
|
||||
operadorEntrega.institucion,
|
||||
ahora.weekday(),
|
||||
);
|
||||
const horaTope = institucionDia
|
||||
? moment(`${ahoraStr} ${institucionDia.hora_tope}`)
|
||||
: null;
|
||||
const horaMax = institucionDia
|
||||
? moment(`${ahoraStr} ${institucionDia.hora_fin}`)
|
||||
: null;
|
||||
|
||||
this.validacionBasicaPrestamo(prestamo, operadorEntrega);
|
||||
if (prestamo.equipo.status.id_status === 3)
|
||||
@ -257,9 +259,10 @@ export class PrestamoService {
|
||||
'Ya se entregó el equipo de cómputo al usuario.',
|
||||
);
|
||||
prestamo.hora_inicio = ahora.toDate();
|
||||
prestamo.hora_fin = ahora
|
||||
.add(operadorEntrega.institucion.tiempo_prestamo, 'm')
|
||||
.toDate();
|
||||
prestamo.hora_fin =
|
||||
ahora > horaMax
|
||||
? horaTope.toDate()
|
||||
: ahora.add(operadorEntrega.institucion.tiempo_prestamo, 'm').toDate();
|
||||
prestamo.operadorEntrega = operadorEntrega;
|
||||
prestamo.equipo.prestado = true;
|
||||
return this.repository
|
||||
|
Loading…
Reference in New Issue
Block a user