diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 9d39453be..7aeb4bf56 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -62,11 +62,14 @@ module.exports = Self => { for (const sale of originalSales) map.set(sale.id, sale); - for (const sale of sales) { const originalSale = map.get(sale.id); - - let originalSaleQuantity = originalSale.quantity; + const originalSaleData = { // <-- Loopback modifies original instance on save + itemFk: originalSale.itemFk, + quantity: originalSale.quantity, + concept: originalSale.concept, + ticketFk: originalSale.ticketFk + }; if (sale.quantity == originalSale.quantity) { await models.Sale.updateAll({ @@ -77,39 +80,47 @@ module.exports = Self => { ticketId, originalSale, sale, options); } - let logTicketOrigin = { + // Log to original ticket + await models.TicketLog.create({ originFk: id, userFk: userId, action: 'update', changedModel: 'Ticket', - changedModelId: ticketId, - oldInstance: {item: sale.itemFk, - quantity: 0, - concept: sale.concept, - ticket: ticketId}, - newInstance: {item: sale.itemFk, + changedModelId: id, + oldInstance: { + item: originalSaleData.itemFk, + quantity: originalSaleData.quantity, + concept: originalSaleData.concept, + ticket: originalSaleData.ticketFk + }, + newInstance: { + item: sale.itemFk, quantity: sale.quantity, concept: sale.concept, - ticket: ticketId} - }; - await models.TicketLog.create(logTicketOrigin, options); + ticket: ticketId + } + }, options); - let logTicketDestination = { + // Log to destination ticket + await models.TicketLog.create({ originFk: ticketId, userFk: userId, action: 'update', changedModel: 'Ticket', changedModelId: ticketId, - oldInstance: {item: sale.itemFk, - quantity: originalSaleQuantity, + oldInstance: { + item: originalSaleData.itemFk, + quantity: originalSaleData.quantity, + concept: originalSaleData.concept, + ticket: originalSaleData.ticketFk + }, + newInstance: { + item: sale.itemFk, + quantity: sale.quantity, concept: sale.concept, - ticket: id}, - newInstance: {item: sale.itemFk, - quantity: originalSaleQuantity - sale.quantity, - concept: sale.concept, - ticket: id} - }; - await models.TicketLog.create(logTicketDestination, options); + ticket: ticketId + } + }, options); } const isTicketEmpty = await models.Ticket.isEmpty(id, options); diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 42699d8d1..89f3218b1 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -324,14 +324,12 @@ - - - + diff --git a/modules/worker/front/log/index.html b/modules/worker/front/log/index.html index 9624d4aed..8aa693924 100644 --- a/modules/worker/front/log/index.html +++ b/modules/worker/front/log/index.html @@ -14,18 +14,18 @@ - Date + Date Author Model Action - Name + Name Before After - + {{::log.creationDate | date:'dd/MM/yyyy HH:mm'}}
@@ -63,7 +63,7 @@ {{::$ctrl.actionsText[log.action]}} - + {{::log.changedModelValue}} diff --git a/modules/worker/front/log/style.scss b/modules/worker/front/log/style.scss index 0943cbc77..0d2d93914 100644 --- a/modules/worker/front/log/style.scss +++ b/modules/worker/front/log/style.scss @@ -14,14 +14,6 @@ vn-log { color: $color-font; } - .after, .before { - max-width: 250px; - } - - vn-table .firstColumn { - min-width: 150px - } - @media screen and (max-width: 1570px) { vn-table .expendable { display: none;