removed unused relation from item @addSale

This commit is contained in:
Carlos Jimenez Ruiz 2021-05-19 15:33:35 +02:00
parent 5eb0ab8296
commit 2494af0113
1 changed files with 3 additions and 11 deletions

View File

@ -44,8 +44,8 @@ module.exports = Self => {
const res = await models.Item.getVisibleAvailable(itemId, ticket.warehouseFk, ticket.shipped);
const packagingFamily = item.family == 'EMB';
if (!packagingFamily && res.available < quantity)
const isPackaging = item.family == 'EMB';
if (!isPackaging && res.available < quantity)
throw new UserError(`This item is not available`);
const newSale = await models.Sale.create({
@ -59,15 +59,7 @@ module.exports = Self => {
const sale = await models.Sale.findById(newSale.id, {
include: {
relation: 'item',
scope: {
include: {
relation: 'packaging',
scope: {
fields: ['id', 'price']
}
}
}
relation: 'item'
}
});