3381-item_diary-claim only the claim contains the item #792

Merged
carlosjr merged 3 commits from 3381-item_diary-claim into dev 2021-11-22 14:21:20 +00:00
3 changed files with 36 additions and 6 deletions

View File

@ -2,8 +2,7 @@ DROP PROCEDURE IF EXISTS `vn`.`item_getBalance`;
DELIMITER $$
$$
CREATE
definer = root@`%` procedure `vn`.`item_getBalance`(IN vItemId int, IN vWarehouse int)
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`item_getBalance`(IN vItemId int, IN vWarehouse int)
BEGIN
DECLARE vDateInventory DATETIME;
DECLARE vCurdate DATE DEFAULT CURDATE();
@ -116,7 +115,7 @@ BEGIN
s.id,
st.`order`,
ct.code,
cl.id
cb.claimFk
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
LEFT JOIN ticketState ts ON ts.ticket = t.id
@ -132,6 +131,7 @@ BEGIN
LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id
LEFT JOIN claim cl ON cl.ticketFk = t.id
LEFT JOIN claimBeginning cb ON cl.id = cb.claimFk AND s.id = cb.saleFk
WHERE t.shipped >= vDateInventory
AND s.itemFk = vItemId
AND vWarehouse =t.warehouseFk
@ -141,4 +141,3 @@ BEGIN
END;
$$
DELIMITER ;

View File

@ -112,8 +112,7 @@ module.exports = Self => {
case 'isActive':
case 'typeFk':
case 'isFloramondo':
param = `i.${param}`;
return {[param]: value};
return {[`i.${param}`]: value};
case 'multiplier':
return {'i.stemMultiplier': value};
case 'categoryFk':

View File

@ -36,4 +36,36 @@ describe('item getBalance()', () => {
throw e;
}
});
it('should show the claimFk only on the claimed item', async() => {
const tx = await models.Item.beginTransaction({});
const options = {transaction: tx};
try {
const firstFilter = {
where: {
itemFk: 1,
warehouseFk: 1
}
};
const secondFilter = {
where: {
itemFk: 2,
warehouseFk: 1
}
};
const firstItemBalance = await models.Item.getBalance(firstFilter, options);
const secondItemBalance = await models.Item.getBalance(secondFilter, options);
expect(firstItemBalance[9].claimFk).toEqual(null);
expect(secondItemBalance[5].claimFk).toEqual(2);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});