Merge pull request '3381-item_diary-claim only the claim contains the item' (#792) from 3381-item_diary-claim into dev
Reviewed-on: #792 Reviewed-by: Carlos Jimenez Ruiz <carlosjr@verdnatura.es>
This commit is contained in:
commit
717d5ec3c8
|
@ -2,8 +2,7 @@ DROP PROCEDURE IF EXISTS `vn`.`item_getBalance`;
|
||||||
|
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
$$
|
$$
|
||||||
CREATE
|
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`item_getBalance`(IN vItemId int, IN vWarehouse int)
|
||||||
definer = root@`%` procedure `vn`.`item_getBalance`(IN vItemId int, IN vWarehouse int)
|
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vDateInventory DATETIME;
|
DECLARE vDateInventory DATETIME;
|
||||||
DECLARE vCurdate DATE DEFAULT CURDATE();
|
DECLARE vCurdate DATE DEFAULT CURDATE();
|
||||||
|
@ -116,7 +115,7 @@ BEGIN
|
||||||
s.id,
|
s.id,
|
||||||
st.`order`,
|
st.`order`,
|
||||||
ct.code,
|
ct.code,
|
||||||
cl.id
|
cb.claimFk
|
||||||
FROM sale s
|
FROM sale s
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
LEFT JOIN ticketState ts ON ts.ticket = t.id
|
LEFT JOIN ticketState ts ON ts.ticket = t.id
|
||||||
|
@ -132,6 +131,7 @@ BEGIN
|
||||||
LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
|
LEFT JOIN state stPrep ON stPrep.`code` = 'PREPARED'
|
||||||
LEFT JOIN saleTracking stk ON stk.saleFk = s.id AND stk.stateFk = stPrep.id
|
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 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
|
WHERE t.shipped >= vDateInventory
|
||||||
AND s.itemFk = vItemId
|
AND s.itemFk = vItemId
|
||||||
AND vWarehouse =t.warehouseFk
|
AND vWarehouse =t.warehouseFk
|
||||||
|
@ -141,4 +141,3 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
$$
|
$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
|
|
|
@ -112,8 +112,7 @@ module.exports = Self => {
|
||||||
case 'isActive':
|
case 'isActive':
|
||||||
case 'typeFk':
|
case 'typeFk':
|
||||||
case 'isFloramondo':
|
case 'isFloramondo':
|
||||||
param = `i.${param}`;
|
return {[`i.${param}`]: value};
|
||||||
return {[param]: value};
|
|
||||||
case 'multiplier':
|
case 'multiplier':
|
||||||
return {'i.stemMultiplier': value};
|
return {'i.stemMultiplier': value};
|
||||||
case 'categoryFk':
|
case 'categoryFk':
|
||||||
|
|
|
@ -36,4 +36,36 @@ describe('item getBalance()', () => {
|
||||||
throw e;
|
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;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue