listo para pruebas passcode
This commit is contained in:
@@ -21,18 +21,18 @@ export class PasscodeService {
|
||||
) {}
|
||||
|
||||
crearPasscode(prestamo: Prestamo) {
|
||||
const aux = {
|
||||
1: '00000',
|
||||
2: '0000',
|
||||
3: '000',
|
||||
4: '00',
|
||||
5: '0',
|
||||
6: '',
|
||||
};
|
||||
|
||||
return this.repository
|
||||
.save(this.repository.create({ prestamo }))
|
||||
.then((passcodeInterno) => {
|
||||
const aux = {
|
||||
1: '00000',
|
||||
2: '0000',
|
||||
3: '000',
|
||||
4: '00',
|
||||
5: '0',
|
||||
6: '',
|
||||
};
|
||||
|
||||
passcodeInterno.passcode = `${prestamo.equipo.carrito.id_carrito}${
|
||||
aux[passcodeInterno.id_passcode.toString().length]
|
||||
}${passcodeInterno.id_passcode}${Math.floor(
|
||||
@@ -101,16 +101,7 @@ export class PasscodeService {
|
||||
});
|
||||
}
|
||||
|
||||
// findPasscode(id_prestamo: number) {
|
||||
// return this.repository
|
||||
// .findOne({ where: { prestamo: { id_prestamo } } })
|
||||
// .then(async (passcode) => {
|
||||
// if (!passcode)
|
||||
// throw new BadRequestException({
|
||||
// message: `Este passcode no existe`,
|
||||
// code: 6,
|
||||
// });
|
||||
// return passcode.passcode;
|
||||
// });
|
||||
// }
|
||||
findByPrestamo(prestamo: Prestamo) {
|
||||
return this.repository.findOne({ where: { prestamo } });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ export class PrestamoOutputDto {
|
||||
@Expose()
|
||||
hora_max_recoger;
|
||||
|
||||
@Expose()
|
||||
passcode;
|
||||
|
||||
@Expose()
|
||||
@Type(() => EquipoMinOutputDto)
|
||||
equipo;
|
||||
|
||||
@@ -16,6 +16,7 @@ import { InstitucionTipoCarritoModule } from '../institucion-tipo-carrito/instit
|
||||
import { InstitucionTipoEntradaModule } from '../institucion-tipo-entrada/institucion-tipo-entrada.module';
|
||||
import { InstitucionUsuarioModule } from '../institucion-usuario/institucion-usuario.module';
|
||||
import { OperadorModule } from '../operador/operador.module';
|
||||
import { PasscodeModule } from '../passcode/passcode.module';
|
||||
import { ModuloModule } from '../modulo/modulo.module';
|
||||
import { MultaModule } from '../multa/multa.module';
|
||||
import { TipoUsuarioModule } from '../tipo-usuario/tipo-usuario.module';
|
||||
@@ -35,6 +36,7 @@ import { ValidarUsuarioModule } from '../validar-usuario/validar-usuario.module'
|
||||
forwardRef(() => MultaModule),
|
||||
OperadorModule,
|
||||
PassportModule.register({ defaultStrategy: 'jwt' }),
|
||||
forwardRef(() => PasscodeModule),
|
||||
TypeOrmModule.forFeature([
|
||||
Prestamo,
|
||||
InformacionPrestamoView,
|
||||
|
||||
@@ -37,6 +37,7 @@ import { InstitucionUsuarioService } from '../institucion-usuario/institucion-us
|
||||
import { ModuloService } from '../modulo/modulo.service';
|
||||
import { MultaService } from '../multa/multa.service';
|
||||
import { OperadorService } from '../operador/operador.service';
|
||||
import { PasscodeService } from '../passcode/passcode.service';
|
||||
import { TipoUsuarioService } from '../tipo-usuario/tipo-usuario.service';
|
||||
import { UsuarioService } from '../usuario/usuario.service';
|
||||
|
||||
@@ -50,6 +51,8 @@ export class PrestamoService {
|
||||
private fullInformacionPrestamoView: Repository<FullInformacionPrestamoView>,
|
||||
@InjectRepository(PrestamoInformacionView)
|
||||
private prestamoInformacionView: Repository<PrestamoInformacionView>,
|
||||
@Inject(forwardRef(() => PasscodeService))
|
||||
private passcodeService: PasscodeService,
|
||||
private appGateway: AppGateway,
|
||||
private equipoService: EquipoService,
|
||||
private institucionService: InstitucionService,
|
||||
@@ -241,7 +244,7 @@ export class PrestamoService {
|
||||
.then((prestamo) => {
|
||||
// Actualizo la interfaz del operador
|
||||
this.appGateway.actualizarOperador(modulo.institucion.id_institucion);
|
||||
return prestamo;
|
||||
return this.prestamoPasscode(prestamo);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -616,7 +619,8 @@ export class PrestamoService {
|
||||
.then((infoPrestamo) => {
|
||||
if (!infoPrestamo)
|
||||
throw new NotFoundException('No existe este id préstamo.');
|
||||
return this.repository.create({
|
||||
|
||||
const prestamo = this.repository.create({
|
||||
id_prestamo: infoPrestamo.id_prestamo,
|
||||
activo: infoPrestamo.activo === 1,
|
||||
cancelado_operador: infoPrestamo.cancelado_operador === 1,
|
||||
@@ -649,6 +653,8 @@ export class PrestamoService {
|
||||
status: { id_status: infoPrestamo.id_status },
|
||||
},
|
||||
});
|
||||
|
||||
return this.prestamoPasscode(prestamo);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -660,7 +666,8 @@ export class PrestamoService {
|
||||
throw new NotFoundException(
|
||||
'Este usuario no tiene un préstamo activo.',
|
||||
);
|
||||
return this.repository.create({
|
||||
|
||||
const prestamo = this.repository.create({
|
||||
id_prestamo: infoPrestamo.id_prestamo,
|
||||
activo: infoPrestamo.activo === 1,
|
||||
fecha_inicio: infoPrestamo.fecha_inicio,
|
||||
@@ -690,6 +697,8 @@ export class PrestamoService {
|
||||
status: { id_status: infoPrestamo.id_status },
|
||||
},
|
||||
});
|
||||
|
||||
return this.prestamoPasscode(prestamo);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -740,6 +749,17 @@ export class PrestamoService {
|
||||
});
|
||||
}
|
||||
|
||||
private prestamoPasscode(prestamo: Prestamo) {
|
||||
if (
|
||||
prestamo.equipo.carrito.tipoCarrito.id_tipo_carrito === 4 ||
|
||||
prestamo.equipo.carrito.tipoCarrito.id_tipo_carrito === 5
|
||||
)
|
||||
return this.passcodeService
|
||||
.findByPrestamo(prestamo)
|
||||
.then((passcode) => ({ ...prestamo, passcode: passcode.passcode }));
|
||||
return prestamo;
|
||||
}
|
||||
|
||||
async regresar(
|
||||
operadorRegreso: Operador,
|
||||
modulo: Modulo,
|
||||
|
||||
Reference in New Issue
Block a user