From 342886942fe231180ab32e98e3660b2ec621af57 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Sep 2019 08:12:27 +0200 Subject: [PATCH 1/2] fixed sale loggable transaction error #1686 --- modules/ticket/back/methods/ticket/updateDiscount.js | 6 +++--- modules/ticket/back/models/sale.json | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) 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" From ff626764d83ae7f87a14e0c6ec54c25f8e8d4e58 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 11 Sep 2019 08:24:28 +0200 Subject: [PATCH 2/2] fixed back unit tests --- modules/ticket/back/methods/ticket/transferSales.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index eeea8e745..e78506823 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -79,14 +79,15 @@ module.exports = Self => { } } + await Promise.all(promises); + const isTicketEmpty = await models.Ticket.isEmpty(id, options); if (isTicketEmpty) { - originalTicket.updateAttributes({ + await originalTicket.updateAttributes({ isDeleted: true }, options); } - await Promise.all(promises); await tx.commit(); return {id: ticketId};