fix(sales): update price on any change affecting the ticket total
gitea/salix/pipeline/head This commit looks good Details

Refs: 3363
This commit is contained in:
Joan Sanchez 2021-11-24 09:25:24 +01:00
parent 1dae7ad792
commit 8ede14ab40
4 changed files with 16 additions and 6 deletions

View File

@ -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) {

View File

@ -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: {

View File

@ -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: {

View File

@ -127,6 +127,8 @@ class Controller extends Section {
resetChanges() {
if (this.newInstances().length === 0)
this.$.watcher.updateOriginalData();
this.card.reload();
}
changeState(value) {