4616-ticket.sale_mana #1088
|
@ -133,20 +133,20 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
let newComponent;
|
let deletedComponent;
|
||||||
vicent marked this conversation as resolved
Outdated
|
|||||||
if (oldComponent) {
|
if (oldComponent) {
|
||||||
const filter = {
|
const filter = {
|
||||||
saleFk: sale.id,
|
saleFk: sale.id,
|
||||||
componentFk: oldComponent.componentFk
|
componentFk: oldComponent.componentFk
|
||||||
};
|
};
|
||||||
await models.SaleComponent.destroyAll(filter, myOptions);
|
deletedComponent = await models.SaleComponent.destroyAll(filter, myOptions);
|
||||||
vicent marked this conversation as resolved
Outdated
joan
commented
Asignar el resultado de esta función (Promesa) a una variable, y hacer el push al array. Asignar el resultado de esta función (Promesa) a una variable, y hacer el push al array.
|
|||||||
}
|
}
|
||||||
|
|
||||||
await createSaleComponent(sale.id, value, componentId, myOptions);
|
const newComponent = await createSaleComponent(sale.id, value, componentId, myOptions);
|
||||||
|
|
||||||
vicent marked this conversation as resolved
Outdated
joan
commented
Esta linea está repetida en ambos casos, se puede extraer fuera del condicional Esta linea está repetida en ambos casos, se puede extraer fuera del condicional
|
|||||||
const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions);
|
const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions);
|
||||||
|
|
||||||
promises.push(newComponent, updatedSale);
|
promises.push(newComponent, updatedSale, deletedComponent);
|
||||||
|
|
||||||
const change = `${oldDiscount}% ➔ *${newDiscount}%*`;
|
const change = `${oldDiscount}% ➔ *${newDiscount}%*`;
|
||||||
changesMade += `\r\n-${sale.itemFk}: ${sale.concept} (${sale.quantity}) ${change}`;
|
changesMade += `\r\n-${sale.itemFk}: ${sale.concept} (${sale.quantity}) ${change}`;
|
||||||
|
@ -193,7 +193,7 @@ module.exports = Self => {
|
||||||
async function createSaleComponent(saleId, value, componentId, myOptions) {
|
async function createSaleComponent(saleId, value, componentId, myOptions) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
|
||||||
newComponent = models.SaleComponent.create({
|
return models.SaleComponent.create({
|
||||||
saleFk: saleId,
|
saleFk: saleId,
|
||||||
value: value,
|
value: value,
|
||||||
componentFk: componentId
|
componentFk: componentId
|
||||||
|
|
Loading…
Reference in New Issue
No utilizar variables globales, es más dificil de hacer seguimiento