#7919 delete if ticketRefund #3091

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

View File

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