mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 08:48:11 +00:00
Generate missing ticket and payment report currency updates
This commit is contained in:
@@ -14,10 +14,11 @@ export class TicketsController {
|
||||
@ApiBearerAuth('IAM-auth')
|
||||
@ApiOperation({
|
||||
summary: 'Generate tickets for all confirmed bookings that are missing them',
|
||||
description: 'Finds every CONFIRMED booking with no ticket rows and attempts to generate tickets for each. Returns a summary of processed/generated/failed counts.',
|
||||
description: 'Finds every CONFIRMED booking with no ticket rows and attempts to generate tickets for each. Returns a summary of processed/generated/failed/remaining counts. Call repeatedly until remaining=0.',
|
||||
})
|
||||
generateMissing() {
|
||||
return this.service.generateMissing();
|
||||
@ApiQuery({ name: 'limit', required: false, description: 'Max bookings to process per call (default 10)' })
|
||||
generateMissing(@Query('limit') limit?: string) {
|
||||
return this.service.generateMissing(limit ? parseInt(limit, 10) : 10);
|
||||
}
|
||||
|
||||
@Post('smart-assign/:bookingId')
|
||||
|
||||
@@ -905,15 +905,21 @@ 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 },
|
||||
});
|
||||
async generateMissing(limit = 10): Promise<{ processed: number; generated: number; failed: number; remaining: number; details: any[] }> {
|
||||
const missingWhere = {
|
||||
status: 'CONFIRMED' as const,
|
||||
tickets: { none: {} },
|
||||
paymentIntent: { status: 'SUCCEEDED' as const },
|
||||
};
|
||||
|
||||
const [confirmedWithNoTickets, totalRemaining] = await Promise.all([
|
||||
this.prisma.booking.findMany({
|
||||
where: missingWhere,
|
||||
select: { id: true, bookingRef: true },
|
||||
take: limit,
|
||||
}),
|
||||
this.prisma.booking.count({ where: missingWhere }),
|
||||
]);
|
||||
|
||||
const details: any[] = [];
|
||||
let generated = 0;
|
||||
@@ -930,7 +936,13 @@ export class TicketsService {
|
||||
}
|
||||
}
|
||||
|
||||
return { processed: confirmedWithNoTickets.length, generated, failed, details };
|
||||
return {
|
||||
processed: confirmedWithNoTickets.length,
|
||||
generated,
|
||||
failed,
|
||||
remaining: Math.max(0, totalRemaining - confirmedWithNoTickets.length),
|
||||
details,
|
||||
};
|
||||
}
|
||||
|
||||
async delete(id: string) {
|
||||
|
||||
Reference in New Issue
Block a user