Ticketing updates

This commit is contained in:
Stephanos A
2026-07-22 12:54:21 +03:00
parent e0dc60361a
commit 44b4779ca6
6 changed files with 98 additions and 2 deletions

View File

@@ -830,6 +830,34 @@ export class TicketsService {
};
}
async generateMissing(): Promise<{ processed: number; generated: number; failed: number; details: any[] }> {
const confirmedWithNoTickets = await this.prisma.booking.findMany({
where: {
status: 'CONFIRMED',
tickets: { none: {} },
paymentIntent: { status: 'SUCCEEDED' },
},
select: { id: true, bookingRef: true },
});
const details: any[] = [];
let generated = 0;
let failed = 0;
for (const booking of confirmedWithNoTickets) {
try {
await this.generate(booking.id);
generated++;
details.push({ bookingId: booking.id, bookingRef: booking.bookingRef, status: 'generated' });
} catch (err) {
failed++;
details.push({ bookingId: booking.id, bookingRef: booking.bookingRef, status: 'failed', error: err instanceof Error ? err.message : String(err) });
}
}
return { processed: confirmedWithNoTickets.length, generated, failed, details };
}
async delete(id: string) {
const ticket = await this.prisma.ticket.findUnique({ where: { id } });
if (!ticket) throw new NotFoundException('Ticket not found');