4616-ticket.sale_mana #1088
|
@ -133,20 +133,20 @@ module.exports = Self => {
|
|||
}
|
||||
}, myOptions);
|
||||
|
||||
let newComponent;
|
||||
let deletedComponent;
|
||||
vicent marked this conversation as resolved
Outdated
|
||||
if (oldComponent) {
|
||||
const filter = {
|
||||
saleFk: sale.id,
|
||||
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);
|
||||
|
||||
promises.push(newComponent, updatedSale);
|
||||
promises.push(newComponent, updatedSale, deletedComponent);
|
||||
|
||||
const change = `${oldDiscount}% ➔ *${newDiscount}%*`;
|
||||
changesMade += `\r\n-${sale.itemFk}: ${sale.concept} (${sale.quantity}) ${change}`;
|
||||
|
@ -193,7 +193,7 @@ module.exports = Self => {
|
|||
async function createSaleComponent(saleId, value, componentId, myOptions) {
|
||||
const models = Self.app.models;
|
||||
|
||||
newComponent = models.SaleComponent.create({
|
||||
return models.SaleComponent.create({
|
||||
saleFk: saleId,
|
||||
value: value,
|
||||
componentFk: componentId
|
||||
|
|
Loading…
Reference in New Issue
No utilizar variables globales, es más dificil de hacer seguimiento