#7919 delete if ticketRefund #3091
|
@ -49,12 +49,12 @@ module.exports = Self => {
|
||||||
where: {originalTicketFk: id}
|
where: {originalTicketFk: id}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const isRefund = !!ticketRefunds?.length;
|
const hasRefund = !!ticketRefunds?.length;
|
||||||
|
|
||||||
const allDeleted = ticketRefunds.every(refund => refund.refundTicket().isDeleted);
|
const allDeleted = ticketRefunds.every(refund => refund.refundTicket().isDeleted);
|
||||||
|
|
||||||
if (!isRefund) await models.TicketRefund.destroyAll({refundTicketFk: id}, myOptions);
|
if (!hasRefund) await models.TicketRefund.destroyAll({refundTicketFk: id}, myOptions);
|
||||||
if (isRefund && !allDeleted) {
|
if (hasRefund && !allDeleted) {
|
||||||
const notDeleted = [];
|
const notDeleted = [];
|
||||||
for (const refund of ticketRefunds)
|
for (const refund of ticketRefunds)
|
||||||
if (!refund.refundTicket().isDeleted) notDeleted.push(refund.refundTicket().id);
|
if (!refund.refundTicket().isDeleted) notDeleted.push(refund.refundTicket().id);
|
||||||
|
|
Loading…
Reference in New Issue