4616-ticket.sale_mana #1088
|
@ -141,17 +141,9 @@ module.exports = Self => {
|
||||||
};
|
};
|
||||||
await models.SaleComponent.destroyAll(filter, myOptions);
|
await models.SaleComponent.destroyAll(filter, myOptions);
|
||||||
vicent marked this conversation as resolved
Outdated
|
|||||||
|
|
||||||
newComponent = models.SaleComponent.create({
|
await createSaleComponent(sale.id, value, componentId, myOptions);
|
||||||
saleFk: sale.id,
|
} else
|
||||||
value: value,
|
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
|
|||||||
componentFk: componentId
|
|
||||||
}, myOptions);
|
|
||||||
} else {
|
|
||||||
newComponent = models.SaleComponent.create({
|
|
||||||
saleFk: sale.id,
|
|
||||||
value: value,
|
|
||||||
componentFk: componentId}, myOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions);
|
const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions);
|
||||||
|
|
||||||
|
@ -198,4 +190,14 @@ module.exports = Self => {
|
||||||
throw e;
|
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);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Asignar el resultado de esta función (Promesa) a una variable, y hacer el push al array.