#7919 delete if ticketRefund #3091

Merged
jorgep merged 9 commits from 7919-deleteTicketRefund into dev 2024-10-21 11:21:34 +00:00
2 changed files with 4 additions and 6 deletions
Showing only changes of commit d57f4fc44a - Show all commits

View File

@ -12,10 +12,5 @@ BEGIN
CALL ticket_doCmr(NEW.id);
END IF;
END IF;
IF NEW.isDeleted THEN
DELETE FROM ticketRefund
WHERE refundTicketFk = NEW.id;
END IF;
END$$
DELIMITER ;

View File

@ -49,9 +49,12 @@ module.exports = Self => {
where: {originalTicketFk: id}
}, myOptions);
const isRefund = !!ticketRefunds?.length;
const allDeleted = ticketRefunds.every(refund => refund.refundTicket().isDeleted);
if (ticketRefunds?.length && !allDeleted) {
if (!isRefund) await models.TicketRefund.destroyAll({refundTicketFk: id}, myOptions);

Si no es originalTicket entrará en el if y solo si existe en la tabla ticketRefund como refundTicket lo eliminará.

Si no es originalTicket entrará en el if y solo si existe en la tabla ticketRefund como refundTicket lo eliminará.
if (isRefund && !allDeleted) {
const notDeleted = [];
for (const refund of ticketRefunds)
if (!refund.refundTicket().isDeleted) notDeleted.push(refund.refundTicket().id);