diff --git a/src/modules/queue/data/services/ticket.service.ts b/src/modules/queue/data/services/ticket.service.ts index 55afd80..146a37d 100644 --- a/src/modules/queue/data/services/ticket.service.ts +++ b/src/modules/queue/data/services/ticket.service.ts @@ -52,12 +52,15 @@ export class TicketDataService extends BaseDataService { }); if (!order) { + // Check if id is a valid UUID format + const uuidRegex = + /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; + const whereCondition = !uuidRegex.test(id) + ? { invoice_code: id, booking_date: new Date() } + : { id, booking_date: new Date() }; const { customer_name, customer_phone } = await this.transaction.findOneOrFail({ - where: { - id, - booking_date: new Date(), - }, + where: whereCondition, }); const start = moment().startOf('day').valueOf();