added plataforma

This commit is contained in:
2025-11-03 19:33:33 -06:00
parent 3c23ad8a01
commit ecc8858f90
5 changed files with 55 additions and 2 deletions
@@ -0,0 +1,9 @@
import {
IsString,
Length,
IsDateString,
IsOptional,
IsBoolean,
} from 'class-validator';
export class PlataformaDto {}
@@ -0,0 +1,4 @@
import { Controller, Get, Param } from '@nestjs/common';
@Controller('plataforma')
export class PlataformaController {}
@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { PlataformaController } from './periodo.controller';
import { PlataformaService } from './periodo.service';
@Module({
controllers: [PlataformaController],
providers: [PlataformaService],
exports: [PlataformaService],
})
export class PlataformaModule {}
@@ -0,0 +1,23 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Plataforma } from 'src/database/AT/entities/alumno_inscrito.entity';
import { Repository } from 'typeorm';
@Injectable()
export class PlataformaService {
constructor(
@InjectRepository(Plataforma)
private readonly plataformaRepository: Repository<Plataforma>,
) {}
async getByName(nombre: string): Promise<Plataforma> {
const plataforma = await this.plataformaRepository.findOne({
where: { nombre },
});
if (!plataforma) {
throw new NotFoundException('plataforma no encontrado');
}
return plataforma;
}
}
+9 -2
View File
@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common';
import { Injectable, NotFoundException } from '@nestjs/common';
import { AlumnoService } from 'src/modules/AT/alumno/student.service';
import { AlumnoInscritoService } from 'src/modules/AT/alumno_inscrito/alumno_inscrito.service';
import { PeriodoService } from 'src/modules/AT/periodo/periodo.service';
@@ -6,6 +6,7 @@ import { PagoKioscoService } from 'src/modules/Monedero/pago-kiosco/pago-kiosco.
import { PersonaService } from 'src/modules/Monedero/persona/persona.service';
import { TransaccionService } from 'src/modules/Monedero/transaccion/transaccion.service';
import { abonoKioscoDto } from './dto/create-operation.dto';
import { PlataformaService } from 'src/modules/AT/plataforma/periodo.service';
@Injectable()
export class OperationsService {
@@ -16,6 +17,7 @@ export class OperationsService {
private readonly alumnoInscritoServie: AlumnoInscritoService,
private readonly alumnoService: AlumnoService,
private readonly periodoService: PeriodoService,
private readonly plataformaService: PlataformaService,
) {}
async depositKiosco(abono: abonoKioscoDto, idPersona: number) {
@@ -50,12 +52,17 @@ export class OperationsService {
Number(persona.numeroIdentificar),
);
if (!plataforma) {
throw new NotFoundException('Debe de colocar una plataforma');
}
const periodo = await this.periodoService.getLatestPeriodo();
const plataform = await this.plataformaService.getByName(plataforma);
await this.alumnoInscritoServie.create({
id_cuenta: alumno.id_cuenta,
id_periodo: periodo.id_periodo,
id_plataforma: plataforma,
id_plataforma: plataform.id_plataforma,
});
} else {
newSaldo = await this.personaService.updateSaldo(idPersona, cantidad);