Merge pull request 'refs #6127 hotFix(ticketRefund): get ticketFk front ticketService' (!1707) from 6127_hotFix_ticketRefund into master
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #1707
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
Alex Moreno 2023-08-17 07:24:01 +00:00
commit 5d6de93d1b
1 changed files with 5 additions and 1 deletions

View File

@ -67,8 +67,12 @@ module.exports = Self => {
const sales = await models.Sale.find(salesFilter, myOptions); const sales = await models.Sale.find(salesFilter, myOptions);
const ticketsIds = [...new Set(sales.map(sale => sale.ticketFk))]; 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 now = Date.vnNew();
const [firstTicketId] = ticketsIds;
const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions); const refundTicket = await createTicketRefund(firstTicketId, now, refundAgencyMode, refoundZoneId, withWarehouse, myOptions);