Merge pull request 'fix(sales): update price on any change affecting the ticket total' (#804) from 3363-sale_update_price into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #804 Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
commit
537c1bb664
|
@ -102,8 +102,8 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
await sale.updateAttributes({price: newPrice}, myOptions);
|
await sale.updateAttributes({price: newPrice}, myOptions);
|
||||||
|
|
||||||
query = `CALL vn.manaSpellersRequery(?)`;
|
await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions);
|
||||||
await Self.rawSql(query, [userId], myOptions);
|
await Self.rawSql('CALL vn.ticket_recalc(?)', [sale.ticketFk], myOptions);
|
||||||
|
|
||||||
const salesPerson = sale.ticket().client().salesPersonUser();
|
const salesPerson = sale.ticket().client().salesPersonUser();
|
||||||
if (salesPerson) {
|
if (salesPerson) {
|
||||||
|
|
|
@ -66,7 +66,12 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
}, myOptions);
|
}, 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';
|
const isPackaging = item.family == 'EMB';
|
||||||
if (!isPackaging && itemInfo.available < quantity)
|
if (!isPackaging && itemInfo.available < quantity)
|
||||||
|
@ -80,6 +85,7 @@ module.exports = Self => {
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
await Self.rawSql('CALL vn.sale_calculateComponent(?, NULL)', [newSale.id], 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, {
|
const sale = await models.Sale.findById(newSale.id, {
|
||||||
include: {
|
include: {
|
||||||
|
|
|
@ -117,13 +117,15 @@ module.exports = Self => {
|
||||||
const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions);
|
const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions);
|
||||||
|
|
||||||
promises.push(newComponent, updatedSale);
|
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);
|
await Promise.all(promises);
|
||||||
|
|
||||||
const query = `call vn.manaSpellersRequery(?)`;
|
await Self.rawSql('CALL vn.manaSpellersRequery(?)', [userId], myOptions);
|
||||||
await Self.rawSql(query, [userId], myOptions);
|
await Self.rawSql('CALL vn.ticket_recalc(?)', [id], myOptions);
|
||||||
|
|
||||||
const ticket = await models.Ticket.findById(id, {
|
const ticket = await models.Ticket.findById(id, {
|
||||||
include: {
|
include: {
|
||||||
|
|
|
@ -127,6 +127,8 @@ class Controller extends Section {
|
||||||
resetChanges() {
|
resetChanges() {
|
||||||
if (this.newInstances().length === 0)
|
if (this.newInstances().length === 0)
|
||||||
this.$.watcher.updateOriginalData();
|
this.$.watcher.updateOriginalData();
|
||||||
|
|
||||||
|
this.card.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
changeState(value) {
|
changeState(value) {
|
||||||
|
|
Loading…
Reference in New Issue