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