diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 1b8476184..51fa97e51 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -142,6 +142,13 @@ module.exports = Self => { ticket: ticketId } }, myOptions); + + query = `UPDATE ticketLog + SET originFk = ? + WHERE changedModel = 'Sale' + AND originFk = ? + AND changedModelId = ?`; + await Self.rawSql(query, [ticketId, id, sale.id], myOptions); } const isTicketEmpty = await models.Ticket.isEmpty(id, myOptions); @@ -178,16 +185,16 @@ module.exports = Self => { // Update original sale const rest = originalSale.quantity - sale.quantity; - query = `UPDATE sale + query = `UPDATE sale SET quantity = ? WHERE id = ?`; await Self.rawSql(query, [rest, sale.id], options); // Clone sale with new quantity - query = `INSERT INTO sale (itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, + query = `INSERT INTO sale (itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, isAdded) - SELECT itemFk, ?, concept, ?, originalQuantity, price, discount, priceFixed, - reserved, isPicked, isPriceFixed, isAdded + SELECT itemFk, ?, concept, ?, originalQuantity, price, discount, priceFixed, + reserved, isPicked, isPriceFixed, isAdded FROM sale WHERE id = ?`; await Self.rawSql(query, [ticketId, sale.quantity, sale.id], options);