add and edit sales no longer intervene the prices
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2021-05-19 15:25:49 +02:00
parent 72a0b774de
commit 5eb0ab8296
3 changed files with 20 additions and 18 deletions

View File

@ -1205,8 +1205,8 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
(96, 14, 1, 'White', 5),
(97, 14, 67, 'supply', 6),
(98, 14, 23, '1', 7),
(99, 15, 92, 'Shipping cost', 2),
(100, 16, 92, 'Shipping cost', 2),
(99, 15, 92, 'Trolley', 2),
(100, 16, 92, 'Pallet', 2),
(101, 71, 92, 'Shipping cost', 2);
INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`)

View File

@ -44,8 +44,8 @@ module.exports = Self => {
const res = await models.Item.getVisibleAvailable(itemId, ticket.warehouseFk, ticket.shipped);
const whitelitedFamily = item.family == 'EMB';
if (!whitelitedFamily && res.available < quantity)
const packagingFamily = item.family == 'EMB';
if (!packagingFamily && res.available < quantity)
throw new UserError(`This item is not available`);
const newSale = await models.Sale.create({
@ -71,8 +71,6 @@ module.exports = Self => {
}
});
if (whitelitedFamily) sale.price = sale.item().packaging().price;
return sale;
};
};

View File

@ -31,14 +31,22 @@ module.exports = Self => {
}
let filter = {
where: {id: {inq: ids}},
fields: ['id', 'name', 'family', 'tag5', 'value5', 'tag6', 'value6', 'tag7', 'value7', 'tag8', 'value8', 'tag9', 'value9', 'tag10', 'value10'],
include: {
relation: 'packaging',
scope: {
fields: ['id', 'price']
}
}
fields: [
'id',
'name',
'tag5',
'value5',
'tag6',
'value6',
'tag7',
'value7',
'tag8',
'value8',
'tag9',
'value9',
'tag10',
'value10'],
where: {id: {inq: ids}}
};
let items = await Self.app.models.Item.find(filter);
@ -58,10 +66,6 @@ module.exports = Self => {
for (line of lines) {
line.item = map[line.itemFk];
const embItem = line.item.family == 'EMB';
if (embItem) line.price = line.item.packaging().price;
line.claim = claimMap[line.id];
}
return lines;