2025-10-20 14:13:16 -06:00
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
|
import { PagoKioscoService } from 'src/pago-kiosco/pago-kiosco.service';
|
|
|
|
|
import { PersonaService } from 'src/persona/persona.service';
|
|
|
|
|
import { TransaccionService } from 'src/transaccion/transaccion.service';
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class OperationsService {
|
|
|
|
|
constructor(
|
|
|
|
|
private readonly transaccionService: TransaccionService,
|
|
|
|
|
private readonly pagoKioscoService: PagoKioscoService,
|
|
|
|
|
private readonly personaService: PersonaService,
|
|
|
|
|
) {}
|
|
|
|
|
|
2025-10-20 15:46:44 -06:00
|
|
|
async depositKiosco({ cantidad, idKiosco }, idPersona: number) {
|
2025-10-20 14:13:16 -06:00
|
|
|
const today = new Date().toString();
|
|
|
|
|
|
|
|
|
|
const transaccion = {
|
2025-10-20 17:08:53 -06:00
|
|
|
idNombreTransaccion: 3,
|
2025-10-20 14:13:16 -06:00
|
|
|
idPersona,
|
|
|
|
|
fecha: today,
|
|
|
|
|
tipoTransaccion: 2,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const responseTransaccion = this.transaccionService.create(transaccion);
|
|
|
|
|
|
|
|
|
|
const pagoKiosco = {
|
|
|
|
|
idTransaccion: (await responseTransaccion).idTransaccion,
|
2025-10-20 15:46:44 -06:00
|
|
|
monto: cantidad,
|
2025-10-20 14:13:16 -06:00
|
|
|
fecha: today,
|
|
|
|
|
idKiosco,
|
|
|
|
|
pagoPatronatoCreado: false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.pagoKioscoService.create(pagoKiosco);
|
|
|
|
|
|
2025-10-20 15:46:44 -06:00
|
|
|
const newSaldo = this.personaService.updateSaldo(idPersona, cantidad);
|
2025-10-20 14:13:16 -06:00
|
|
|
|
|
|
|
|
return newSaldo;
|
|
|
|
|
}
|
|
|
|
|
}
|