Merge pull request 'fix: refs #7931 Immediately discount order lines from available' (!2925) from 7931-availableFix into test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #2925 Reviewed-by: Pako Natek <pako@verdnatura.es> Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
This commit is contained in:
commit
5700b95e22
|
@ -1,5 +1,10 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDated` DATE)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(
|
||||
OUT `vCalc` INT,
|
||||
`vRefresh` INT,
|
||||
`vWarehouse` INT,
|
||||
`vDated` DATE
|
||||
)
|
||||
proc: BEGIN
|
||||
DECLARE vStartDate DATE;
|
||||
DECLARE vReserveDate DATETIME;
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_updateItem`(
|
||||
`vItem` INT,
|
||||
`vWarehouse` INT,
|
||||
`vDated` DATE,
|
||||
`vQuantity` INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Immediately deduct/add an amount from the available cache (if exists).
|
||||
*
|
||||
* @param vItem The item id
|
||||
* @param vWarehouse The warehouse id
|
||||
* @param vDated Available cache date
|
||||
* @param vQuantity The amount to be deducted from the cache
|
||||
*/
|
||||
DECLARE vCalc INT;
|
||||
|
||||
SELECT id INTO vCalc
|
||||
FROM cache_calc
|
||||
WHERE cacheName = 'available'
|
||||
AND params = CONCAT_WS('/', vWarehouse, vDated);
|
||||
|
||||
IF vCalc IS NOT NULL THEN
|
||||
UPDATE available
|
||||
SET available = available - vQuantity
|
||||
WHERE calc_id = vCalc
|
||||
AND item_id = vItem;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,8 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_addItem`(
|
||||
vSelf INT,
|
||||
vWarehouse INT,
|
||||
vItem INT,
|
||||
vWarehouse INT,
|
||||
vItem INT,
|
||||
vAmount INT)
|
||||
BEGIN
|
||||
/**
|
||||
|
@ -102,6 +102,8 @@ BEGIN
|
|||
amount = vAdd,
|
||||
price = vPrice;
|
||||
|
||||
CALL cache.available_updateItem(vItem, vWarehouse, vShipment, vAdd);
|
||||
|
||||
SET vRow = LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO orderRowComponent (rowFk, componentFk, price)
|
||||
|
@ -121,6 +123,6 @@ BEGIN
|
|||
END IF;
|
||||
|
||||
COMMIT;
|
||||
CALL vn.ticketCalculatePurge;
|
||||
CALL vn.ticketCalculatePurge;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('item getVisibleAvailable()', () => {
|
||||
it('should check available visible for today', async() => {
|
||||
it('should check available visible for tomorrow', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
|
@ -9,6 +9,7 @@ describe('item getVisibleAvailable()', () => {
|
|||
const itemFk = 1;
|
||||
const warehouseFk = 1;
|
||||
const dated = Date.vnNew();
|
||||
dated.setDate(dated.getDate() + 1);
|
||||
|
||||
const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options);
|
||||
|
||||
|
|
Loading…
Reference in New Issue