diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index afb25c365..d4f128082 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -91,20 +91,21 @@ module.exports = Self => { value: componentValue }, myOptions); } - await sale.updateAttributes({price: newPrice}, myOptions); - await Self.rawSql(` - UPDATE sale - SET priceFixed = ( - SELECT SUM(value) - FROM sale s - JOIN saleComponent sc ON sc.saleFk = s.id - JOIN component c ON c.id = sc.componentFk - JOIN componentType ct ON ct.id = c.typeFk - WHERE ct.isBase - AND s.id = ? - ) - WHERE id = ? - `, [id, id], myOptions); + + const [priceFixed] = await Self.rawSql(` + SELECT SUM(value) value + FROM sale s + JOIN saleComponent sc ON sc.saleFk = s.id + JOIN component c ON c.id = sc.componentFk + JOIN componentType ct ON ct.id = c.typeFk + WHERE ct.isBase + AND s.id = ? + `, [id], myOptions); + + await sale.updateAttributes({ + price: newPrice, + priceFixed: priceFixed.value + }, myOptions); await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions); await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions); diff --git a/modules/ticket/back/models/sale.json b/modules/ticket/back/models/sale.json index 96a36bbc9..947115f5c 100644 --- a/modules/ticket/back/models/sale.json +++ b/modules/ticket/back/models/sale.json @@ -28,6 +28,9 @@ "discount": { "type": "number" }, + "priceFixed": { + "type": "number" + }, "reserved": { "type": "boolean" },