refs #5036 transferSales also transfer sale's logs
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alexandre Riera 2023-02-24 08:55:04 +01:00
parent be8d19a9f8
commit 6590c6f1fa
1 changed files with 11 additions and 4 deletions

View File

@ -142,6 +142,13 @@ module.exports = Self => {
ticket: ticketId ticket: ticketId
} }
}, myOptions); }, 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); const isTicketEmpty = await models.Ticket.isEmpty(id, myOptions);
@ -178,16 +185,16 @@ module.exports = Self => {
// Update original sale // Update original sale
const rest = originalSale.quantity - sale.quantity; const rest = originalSale.quantity - sale.quantity;
query = `UPDATE sale query = `UPDATE sale
SET quantity = ? SET quantity = ?
WHERE id = ?`; WHERE id = ?`;
await Self.rawSql(query, [rest, sale.id], options); await Self.rawSql(query, [rest, sale.id], options);
// Clone sale with new quantity // 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) reserved, isPicked, isPriceFixed, isAdded)
SELECT itemFk, ?, concept, ?, originalQuantity, price, discount, priceFixed, SELECT itemFk, ?, concept, ?, originalQuantity, price, discount, priceFixed,
reserved, isPicked, isPriceFixed, isAdded reserved, isPicked, isPriceFixed, isAdded
FROM sale FROM sale
WHERE id = ?`; WHERE id = ?`;
await Self.rawSql(query, [ticketId, sale.quantity, sale.id], options); await Self.rawSql(query, [ticketId, sale.quantity, sale.id], options);