cambio de horario
This commit is contained in:
parent
591089b8e1
commit
b520156b13
@ -7,6 +7,7 @@ import {
|
||||
Injectable,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import {
|
||||
Between,
|
||||
@ -44,6 +45,8 @@ import { UsuarioService } from '../usuario/usuario.service';
|
||||
|
||||
@Injectable()
|
||||
export class PrestamoService {
|
||||
private add: number;
|
||||
|
||||
constructor(
|
||||
@InjectRepository(Prestamo) private repository: Repository<Prestamo>,
|
||||
@InjectRepository(InformacionPrestamoView)
|
||||
@ -53,6 +56,7 @@ export class PrestamoService {
|
||||
@InjectRepository(PrestamoInformacionView)
|
||||
private prestamoInformacionView: Repository<PrestamoInformacionView>,
|
||||
private appGateway: AppGateway,
|
||||
private configService: ConfigService,
|
||||
private equipoService: EquipoService,
|
||||
private institucionService: InstitucionService,
|
||||
private institucionDiaService: InstitucionDiaService,
|
||||
@ -69,7 +73,9 @@ export class PrestamoService {
|
||||
private statusService: StatusService,
|
||||
private tipoUsuarioService: TipoUsuarioService,
|
||||
private usuarioService: UsuarioService,
|
||||
) {}
|
||||
) {
|
||||
this.add = parseInt(this.configService.get<string>('ADD_HORA'));
|
||||
}
|
||||
|
||||
async cancelarOperador(
|
||||
operadorRegreso: Operador,
|
||||
@ -80,6 +86,7 @@ export class PrestamoService {
|
||||
const ahora = moment();
|
||||
const prestamo = await this.findById(id_prestamo);
|
||||
|
||||
if (this.add) ahora.add(this.add, 'h');
|
||||
this.validacionBasicaPrestamo(prestamo);
|
||||
this.validacionOperadorPrestamo(prestamo, operadorRegreso, modulo);
|
||||
// Desactivamos el préstamo
|
||||
@ -113,6 +120,7 @@ export class PrestamoService {
|
||||
const ahora = moment();
|
||||
const prestamo = await this.prestamoInfoByUsuario(usuario);
|
||||
|
||||
if (this.add) ahora.add(this.add, 'h');
|
||||
this.validacionBasicaPrestamo(prestamo);
|
||||
// Desactivamos el préstamo
|
||||
prestamo.activo = false;
|
||||
@ -182,6 +190,7 @@ export class PrestamoService {
|
||||
)
|
||||
: null;
|
||||
|
||||
if (this.add) ahora.add(this.add, 'h');
|
||||
// Validamos que el id_institucion_usuario le pertenezca al usuario
|
||||
if (institucionUsuario.usuario.id_usuario != usuario.id_usuario)
|
||||
throw new ConflictException('No te pertenece esta información.');
|
||||
@ -294,6 +303,7 @@ export class PrestamoService {
|
||||
? moment(`${ahoraStr} ${institucionDia.hora_fin}`)
|
||||
: null;
|
||||
|
||||
if (this.add) ahora.add(this.add, 'h');
|
||||
if (
|
||||
prestamo.equipo.carrito.tipoCarrito.id_tipo_carrito != 4 &&
|
||||
prestamo.equipo.carrito.tipoCarrito.id_tipo_carrito != 5
|
||||
@ -754,6 +764,9 @@ export class PrestamoService {
|
||||
): Promise<{ message: string }> {
|
||||
const ahora = moment();
|
||||
const status = await this.statusService.findById(id_status);
|
||||
|
||||
if (this.add) ahora.add(this.add, 'h');
|
||||
|
||||
const tardanza = Math.trunc(ahora.diff(moment(prestamo.hora_fin)) / 60000); // Si la resta ahora - hora_fin es positiva es que ya se tardo en entregar
|
||||
const semanasCastigo = Math.trunc(
|
||||
tardanza / modulo.institucion.tiempo_entrega,
|
||||
|
Loading…
Reference in New Issue
Block a user