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

This commit is contained in:
Javi Gallego 2024-10-01 15:51:30 +02:00
parent d31340ff25
commit 1cf14035d5
1 changed files with 13 additions and 6 deletions

View File

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