fix: refs #235425 sale priceFixed update #3146
|
@ -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(`
|
||||
guillermo marked this conversation as resolved
Outdated
|
||||
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
|
||||
guillermo marked this conversation as resolved
jgallego
commented
perfect, cal canviar el test de back per a que també verifique este canvi, simplement verifica que el valor antes i despues de cridar a la funcio son distints (chatgpt) perfect, cal canviar el test de back per a que també verifique este canvi, simplement verifica que el valor antes i despues de cridar a la funcio son distints (chatgpt) https://gitea.verdnatura.es/verdnatura/salix/commit/392c4dcba3b1907b2ef49ee01bb3d17e8ca45811
|
||||
}, myOptions);
|
||||
|
||||
await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions);
|
||||
await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions);
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
"discount": {
|
||||
"type": "number"
|
||||
},
|
||||
"priceFixed": {
|
||||
"type": "number"
|
||||
},
|
||||
"reserved": {
|
||||
"type": "boolean"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
la idea es bona, hi ha que actualizar el valor, pero posiblement en les dades de dalt ja tingam el valro, i si no, calculal, el poses en
await sale.updateAttributes({price: newPrice}, myOptions);
per a no fer 2 updates en la BBDD ni en el log