4616-ticket.sale_mana #1088

Merged
vicent merged 14 commits from 4616-ticket.sale_mana into dev 2022-11-02 13:48:21 +00:00
1 changed files with 13 additions and 11 deletions
Showing only changes of commit a11ef73dfb - Show all commits

View File

@ -141,17 +141,9 @@ module.exports = Self => {
};
await models.SaleComponent.destroyAll(filter, myOptions);
vicent marked this conversation as resolved Outdated
Outdated
Review

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.
newComponent = models.SaleComponent.create({
saleFk: sale.id,
value: value,
componentFk: componentId
}, myOptions);
} else {
newComponent = models.SaleComponent.create({
saleFk: sale.id,
value: value,
componentFk: componentId}, myOptions);
}
await createSaleComponent(sale.id, value, componentId, myOptions);
} else
await createSaleComponent(sale.id, value, componentId, myOptions);
vicent marked this conversation as resolved Outdated
Outdated
Review

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);
@ -198,4 +190,14 @@ module.exports = Self => {
throw e;
}
};
async function createSaleComponent(saleId, value, componentId, myOptions) {
const models = Self.app.models;
newComponent = models.SaleComponent.create({
saleFk: saleId,
value: value,
componentFk: componentId
}, myOptions);
}
};