2885-ticket_sale_item_family_not_restricted #627

Merged
jgallego merged 5 commits from 2885-ticket_sale_item_family_not_restricted into dev 2021-05-19 13:39:44 +00:00
1 changed files with 3 additions and 11 deletions
Showing only changes of commit 2494af0113 - Show all commits

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'
}
});