correcion regreso, entrega, cancelado usuario y operador
This commit is contained in:
@@ -48,6 +48,16 @@ export class PrestamoService {
|
||||
const operadorRegreso = await this.operadorService.findById(id_operador);
|
||||
const prestamo = await this.findById(id_prestamo);
|
||||
|
||||
if (prestamo.cancelado_usuario)
|
||||
throw new ConflictException(
|
||||
'Este préstamo ya fue cancelado por el usuario.',
|
||||
);
|
||||
if (prestamo.cancelado_operador)
|
||||
throw new ConflictException(
|
||||
'Este préstamo ya fue cancelado por un operador.',
|
||||
);
|
||||
if (!prestamo.activo)
|
||||
throw new ConflictException('Este préstamo ya no se encuentra activo.');
|
||||
prestamo.activo = false;
|
||||
prestamo.fecha_entrega = ahora.toDate();
|
||||
prestamo.cancelado_operador = true;
|
||||
@@ -63,6 +73,20 @@ export class PrestamoService {
|
||||
const ahora = moment();
|
||||
const prestamo = await this.findById(id_prestamo);
|
||||
|
||||
if (prestamo.cancelado_usuario)
|
||||
throw new ConflictException(
|
||||
'Este préstamo ya fue cancelado por el usuario.',
|
||||
);
|
||||
if (prestamo.cancelado_operador)
|
||||
throw new ConflictException(
|
||||
'Este préstamo ya fue cancelado por un operador.',
|
||||
);
|
||||
if (!prestamo.activo)
|
||||
throw new ConflictException('Este préstamo ya no se encuentra activo.');
|
||||
if (prestamo.equipo.status.id_status === 3)
|
||||
throw new ConflictException(
|
||||
'No se puede cancelar el préstamo una vez se te entregó el equipo.',
|
||||
);
|
||||
prestamo.activo = false;
|
||||
prestamo.fecha_entrega = ahora.toDate();
|
||||
prestamo.cancelado_usuario = true;
|
||||
@@ -142,6 +166,20 @@ export class PrestamoService {
|
||||
const operadorEntrega = await this.operadorService.findById(id_operador);
|
||||
const prestamo = await this.findById(id_prestamo);
|
||||
|
||||
if (prestamo.cancelado_usuario)
|
||||
throw new ConflictException(
|
||||
'Este préstamo ya fue cancelado por el usuario.',
|
||||
);
|
||||
if (prestamo.cancelado_operador)
|
||||
throw new ConflictException(
|
||||
'Este préstamo ya fue cancelado por un operador.',
|
||||
);
|
||||
if (!prestamo.activo)
|
||||
throw new ConflictException('Este préstamo ya no se encuentra activo.');
|
||||
if (prestamo.equipo.status.id_status === 3)
|
||||
throw new ConflictException(
|
||||
'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')
|
||||
@@ -162,6 +200,18 @@ export class PrestamoService {
|
||||
const operadorRegreso = await this.operadorService.findById(id_operador);
|
||||
const prestamo = await this.findById(id_prestamo);
|
||||
|
||||
if (prestamo.cancelado_usuario)
|
||||
throw new ConflictException(
|
||||
'Este préstamo ya fue cancelado por el usuario.',
|
||||
);
|
||||
if (prestamo.cancelado_operador)
|
||||
throw new ConflictException(
|
||||
'Este préstamo ya fue cancelado por un operador.',
|
||||
);
|
||||
if (!prestamo.activo)
|
||||
throw new ConflictException('Este préstamo ya no se encuentra activo.');
|
||||
if (prestamo.equipo.status.id_status === 2)
|
||||
throw new ConflictException('Aun no se entrega el equipo al usuario.');
|
||||
prestamo.activo = false;
|
||||
prestamo.fecha_entrega = ahora.toDate();
|
||||
prestamo.operadorRegreso = operadorRegreso;
|
||||
|
||||
Reference in New Issue
Block a user