From 518d5111e49f8422605e07ffd651a88ffb44a97f Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 17 Aug 2023 08:42:04 +0200 Subject: [PATCH] refs #6127 hotFix(ticketRefund): get ticketFk front ticketService --- modules/ticket/back/methods/sale/refund.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index a8191610a..12f240ae2 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -67,8 +67,12 @@ module.exports = Self => { const sales = await models.Sale.find(salesFilter, myOptions); const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; + let [firstTicketId] = ticketsIds; + if (!firstTicketId) { + [ticketServices] = await models.TicketService.find({where: {id: {inq: servicesIds}}}, myOptions); + firstTicketId = ticketServices.ticketFk; + } const now = Date.vnNew(); - const [firstTicketId] = ticketsIds; const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions);