diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index fa1705e55..bbd9d154d 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -102,8 +102,8 @@ module.exports = Self => { } await sale.updateAttributes({price: newPrice}, myOptions); - query = `CALL vn.manaSpellersRequery(?)`; - await Self.rawSql(query, [userId], myOptions); + await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions); + await Self.rawSql('CALL vn.ticket_recalc(?)', [sale.ticketFk], myOptions); const salesPerson = sale.ticket().client().salesPersonUser(); if (salesPerson) { diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index 527b861a1..37d97b2c7 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -66,7 +66,12 @@ module.exports = Self => { } }, myOptions); - const itemInfo = await models.Item.getVisibleAvailable(itemId, ticket.warehouseFk, ticket.shipped, myOptions); + const itemInfo = await models.Item.getVisibleAvailable( + itemId, + ticket.warehouseFk, + ticket.shipped, + myOptions + ); const isPackaging = item.family == 'EMB'; if (!isPackaging && itemInfo.available < quantity) @@ -80,6 +85,7 @@ module.exports = Self => { }, myOptions); await Self.rawSql('CALL vn.sale_calculateComponent(?, NULL)', [newSale.id], myOptions); + await Self.rawSql('CALL vn.ticket_recalc(?)', [id], myOptions); const sale = await models.Sale.findById(newSale.id, { include: { diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index cd6a5fabc..cf217348a 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -117,13 +117,15 @@ module.exports = Self => { const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions); promises.push(newComponent, updatedSale); - changesMade += `\r\n-${sale.itemFk}: ${sale.concept} (${sale.quantity}) ${oldDiscount}% ➔ *${newDiscount}%*`; + + const change = `${oldDiscount}% ➔ *${newDiscount}%*`; + changesMade += `\r\n-${sale.itemFk}: ${sale.concept} (${sale.quantity}) ${change}`; } await Promise.all(promises); - const query = `call vn.manaSpellersRequery(?)`; - await Self.rawSql(query, [userId], myOptions); + await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions); + await Self.rawSql('CALL vn.ticket_recalc(?)', [id], myOptions); const ticket = await models.Ticket.findById(id, { include: { diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index a1787e3ea..2ebe9a174 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -127,6 +127,8 @@ class Controller extends Section { resetChanges() { if (this.newInstances().length === 0) this.$.watcher.updateOriginalData(); + + this.card.reload(); } changeState(value) {