feat: existingRefund without ticketRefunds
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Javi Gallego 2024-10-01 15:49:51 +02:00
parent e2d30ef933
commit 40512ca67e
1 changed files with 13 additions and 6 deletions

View File

@ -142,12 +142,19 @@ module.exports = Self => {
ctx.args.addressId = ticket.addressFk; ctx.args.addressId = ticket.addressFk;
const newTicket = await models.Ticket.new(ctx, myOptions); const newTicket = await models.Ticket.new(ctx, myOptions);
const existingRefund = await models.TicketRefund.findOne({
where: {
originalTicketFk: ticketId,
refundTicketFk: newTicket.id
},
myOptions
});
if (!existingRefund) {
await models.TicketRefund.create({ await models.TicketRefund.create({
originalTicketFk: ticketId, originalTicketFk: ticketId,
refundTicketFk: newTicket.id refundTicketFk: newTicket.id
}, myOptions); }, myOptions);
}
return newTicket; return newTicket;
} }
}; };