fix: refs #3979 si se abona un abono sin almacen no falla
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Javi Gallego 2023-12-14 09:14:21 +01:00
parent 0130130cee
commit 26a05a4840
1 changed files with 4 additions and 1 deletions

View File

@ -109,7 +109,10 @@ module.exports = Self => {
const newTicket = await models.Ticket.new(ctx, myOptions);
if (negative) {
const ticketRefund = await models.TicketRefund.findOne({
where: {refundTicketFk: ticketId}
}, myOptions);
if (negative && (withWarehouse || !ticketRefund?.id)) {
await models.TicketRefund.create({
originalTicketFk: ticketId,
refundTicketFk: newTicket.id