diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 74ffb13c3..ae9000834 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -113,10 +113,13 @@ module.exports = Self => { } const isTicketEmpty = await models.Ticket.isEmpty(id, options); - if (isTicketEmpty) - await originalTicket.updateAttributes({isDeleted: true}, options); + if (isTicketEmpty) { + await originalTicket.updateAttributes({ + isDeleted: true + }, options); + } - if (tx.id) await tx.commit(); + await tx.commit(); return {id: ticketId}; } catch (error) { diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 0e8c4197b..e4a54d6ba 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -80,7 +80,7 @@ module.exports = Self => { fields: ['salesPersonFk'] } }, - }); + }, options); const salesPersonId = ticket.client().salesPersonFk; const usesMana = await models.WorkerMana.findOne({ where: { @@ -102,10 +102,10 @@ module.exports = Self => { value: value, componentFk: componentId}, options); - const updatedSale = models.Sale.update({id: sale.id}, + const updatedSale = models.Sale.updateAll({id: sale.id}, {discount: newDiscount}, options); - promises.push([newComponent, updatedSale]); + promises.push(newComponent, updatedSale); } await Promise.all(promises); diff --git a/modules/ticket/back/models/sale.json b/modules/ticket/back/models/sale.json index 894a2608f..d9ad24be3 100644 --- a/modules/ticket/back/models/sale.json +++ b/modules/ticket/back/models/sale.json @@ -1,6 +1,11 @@ { "name": "Sale", - "base": "VnModel", + "base": "Loggable", + "log": { + "model": "TicketLog", + "relation": "ticket", + "showField": "concept" + }, "options": { "mysql": { "table": "sale"