This commit is contained in:
parent
d57f4fc44a
commit
8ca097d4a9
|
@ -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