fix: refs #235425 sale priceFixed update #3146

Merged
guillermo merged 3 commits from hotfix235425-updatePrice into master 2024-10-28 06:06:58 +00:00
2 changed files with 18 additions and 14 deletions
Showing only changes of commit 111480f7b7 - Show all commits

View File

@ -91,20 +91,21 @@ module.exports = Self => {
value: componentValue value: componentValue
}, myOptions); }, myOptions);
} }
await sale.updateAttributes({price: newPrice}, myOptions);
await Self.rawSql(` const [priceFixed] = await Self.rawSql(`
guillermo marked this conversation as resolved Outdated

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

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
UPDATE sale SELECT SUM(value) value
SET priceFixed = ( FROM sale s
SELECT SUM(value) JOIN saleComponent sc ON sc.saleFk = s.id
FROM sale s JOIN component c ON c.id = sc.componentFk
JOIN saleComponent sc ON sc.saleFk = s.id JOIN componentType ct ON ct.id = c.typeFk
JOIN component c ON c.id = sc.componentFk WHERE ct.isBase
JOIN componentType ct ON ct.id = c.typeFk AND s.id = ?
WHERE ct.isBase `, [id], myOptions);
AND s.id = ?
) await sale.updateAttributes({
WHERE id = ? price: newPrice,
`, [id, id], myOptions); priceFixed: priceFixed.value
guillermo marked this conversation as resolved
Review

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) 392c4dcba3

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.manaSpellersRequery(?)', [userId], myOptions);
await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions); await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [sale.ticketFk], myOptions);

View File

@ -28,6 +28,9 @@
"discount": { "discount": {
"type": "number" "type": "number"
}, },
"priceFixed": {
"type": "number"
},
"reserved": { "reserved": {
"type": "boolean" "type": "boolean"
}, },