6861_reservas_hotFix #2749
|
@ -3,7 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_addWithR
|
||||||
vItemFk INT,
|
vItemFk INT,
|
||||||
vQuantity INT,
|
vQuantity INT,
|
||||||
vTicketFk INT,
|
vTicketFk INT,
|
||||||
vSaleGroupFk INT
|
vSaleGroupFk INT,
|
||||||
|
vSectorFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +68,7 @@ BEGIN
|
||||||
SELECT LAST_INSERT_ID() INTO vSaleFk;
|
SELECT LAST_INSERT_ID() INTO vSaleFk;
|
||||||
|
|
||||||
CALL sale_calculateComponent(vSaleFk, NULL);
|
CALL sale_calculateComponent(vSaleFk, NULL);
|
||||||
CALL itemShelvingSale_addBySale(vSaleFk);
|
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
|
||||||
|
|
||||||
IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN
|
IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN
|
||||||
SET vHasThrow = TRUE;
|
SET vHasThrow = TRUE;
|
||||||
|
|
|
@ -44,7 +44,7 @@ BEGIN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL itemShelvingSale_addBySale(vSaleFk);
|
CALL itemShelvingSale_addBySale(vSaleFk, NULL);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vSales;
|
CLOSE vSales;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySale`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySale`(
|
||||||
vSaleFk INT
|
vSaleFk INT,
|
||||||
|
vSectorFk INT
|
||||||
)
|
)
|
||||||
proc: BEGIN
|
proc: BEGIN
|
||||||
/**
|
/**
|
||||||
|
@ -8,6 +9,7 @@ proc: BEGIN
|
||||||
*
|
*
|
||||||
* @param vSaleFk Id de sale
|
* @param vSaleFk Id de sale
|
||||||
* @param vItemShelvingSaleFk Id de reserva
|
* @param vItemShelvingSaleFk Id de reserva
|
||||||
|
* @param vSectorFk Id del sector del operator
|
||||||
*/
|
*/
|
||||||
DECLARE vLastPickingOrder INT;
|
DECLARE vLastPickingOrder INT;
|
||||||
DECLARE vDone INT DEFAULT FALSE;
|
DECLARE vDone INT DEFAULT FALSE;
|
||||||
|
@ -30,6 +32,7 @@ proc: BEGIN
|
||||||
JOIN productionConfig pc
|
JOIN productionConfig pc
|
||||||
WHERE s.id = vSaleFk
|
WHERE s.id = vSaleFk
|
||||||
AND NOT sc.isHideForPickers
|
AND NOT sc.isHideForPickers
|
||||||
|
AND (sc.id = vSectorFk OR vSectorFk IS NULL)
|
||||||
ORDER BY s.id,
|
ORDER BY s.id,
|
||||||
p.pickingOrder >= vLastPickingOrder,
|
p.pickingOrder >= vLastPickingOrder,
|
||||||
sh.priority DESC,
|
sh.priority DESC,
|
||||||
|
|
|
@ -10,6 +10,7 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vDone BOOL DEFAULT FALSE;
|
DECLARE vDone BOOL DEFAULT FALSE;
|
||||||
DECLARE vSaleFk INT;
|
DECLARE vSaleFk INT;
|
||||||
|
DECLARE vSectorFk INT;
|
||||||
DECLARE vSales CURSOR FOR
|
DECLARE vSales CURSOR FOR
|
||||||
SELECT s.id
|
SELECT s.id
|
||||||
FROM sectorCollectionSaleGroup sc
|
FROM sectorCollectionSaleGroup sc
|
||||||
|
@ -25,6 +26,10 @@ BEGIN
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
SELECT sectorFk INTO vSectorFk
|
||||||
|
FROM operator
|
||||||
|
WHERE workerFk = account.myUser_getId();
|
||||||
|
|
||||||
OPEN vSales;
|
OPEN vSales;
|
||||||
l: LOOP
|
l: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
|
@ -34,7 +39,7 @@ BEGIN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL itemShelvingSale_addBySale(vSaleFk);
|
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vSales;
|
CLOSE vSales;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -6,6 +6,7 @@ proc: BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vSaleFk INT;
|
DECLARE vSaleFk INT;
|
||||||
|
DECLARE vSectorFk INT;
|
||||||
|
|
||||||
DECLARE vSales CURSOR FOR
|
DECLARE vSales CURSOR FOR
|
||||||
SELECT DISTINCT saleFk FROM tSale;
|
SELECT DISTINCT saleFk FROM tSale;
|
||||||
|
@ -26,24 +27,25 @@ proc: BEGIN
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tSale
|
CREATE OR REPLACE TEMPORARY TABLE tSale
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT id, saleFk FROM itemShelvingSaleReserve;
|
SELECT id, saleFk, sectorFk FROM itemShelvingSaleReserve;
|
||||||
|
|
||||||
OPEN vSales;
|
OPEN vSales;
|
||||||
|
|
||||||
myLoop: LOOP
|
myLoop: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vSales INTO vSaleFk;
|
FETCH vSales INTO vSaleFk, vSectorFk;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE myLoop;
|
LEAVE myLoop;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL itemShelvingSale_addBySale (vSaleFk);
|
CALL itemShelvingSale_addBySale (vSaleFk, vSectorFk);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
CLOSE vSales;
|
CLOSE vSales;
|
||||||
|
|
||||||
DELETE iss FROM itemShelvingSaleReserve iss JOIN tSale s ON s.id = iss.id;
|
DELETE iss FROM itemShelvingSaleReserve iss
|
||||||
|
JOIN tSale s ON s.id = iss.id AND s.sectorFk = iss.sectorFk;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tSale;
|
DROP TEMPORARY TABLE tSale;
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`(
|
||||||
vItemShelvingFk INT(10),
|
vItemShelvingFk INT(10),
|
||||||
vItemFk INT(10)
|
vItemFk INT(10),
|
||||||
|
vSectorFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Elimina reservas de un itemShelving e intenta reservar en otra ubicación
|
* Elimina reservas de un itemShelving e intenta reservar en otra ubicación
|
||||||
*
|
*
|
||||||
* @param vItemShelvingFk Id itemShelving
|
* @param vItemShelvingFk Id itemShelving
|
||||||
|
* @param vItemFk Id del artículo
|
||||||
|
* @param vSectorFk Id del sector
|
||||||
*/
|
*/
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -28,7 +31,7 @@ BEGIN
|
||||||
WHERE id = vItemShelvingFk
|
WHERE id = vItemShelvingFk
|
||||||
AND itemFk = vItemFk;
|
AND itemFk = vItemFk;
|
||||||
|
|
||||||
INSERT INTO itemShelvingSaleReserve (saleFk)
|
INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk)
|
||||||
SELECT DISTINCT iss.saleFk
|
SELECT DISTINCT iss.saleFk
|
||||||
FROM itemShelvingSale iss
|
FROM itemShelvingSale iss
|
||||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||||
|
|
|
@ -2,7 +2,8 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`(
|
||||||
vItemShelvingSaleFk INT(10),
|
vItemShelvingSaleFk INT(10),
|
||||||
vQuantity DECIMAL(10,0),
|
vQuantity DECIMAL(10,0),
|
||||||
vIsItemShelvingSaleEmpty BOOLEAN
|
vIsItemShelvingSaleEmpty BOOLEAN,
|
||||||
|
vSectorFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +15,7 @@ BEGIN
|
||||||
* @param vQuantity Cantidad real que se ha cogido de la ubicación
|
* @param vQuantity Cantidad real que se ha cogido de la ubicación
|
||||||
* @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha
|
* @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha
|
||||||
* quedado vacio tras el movimiento
|
* quedado vacio tras el movimiento
|
||||||
|
* @param vSectorFk Id del sector
|
||||||
*/
|
*/
|
||||||
DECLARE vSaleFk INT;
|
DECLARE vSaleFk INT;
|
||||||
DECLARE vItemShelvingFk INT;
|
DECLARE vItemShelvingFk INT;
|
||||||
|
@ -72,7 +74,7 @@ BEGIN
|
||||||
SET visible = GREATEST(0, visible - vQuantity)
|
SET visible = GREATEST(0, visible - vQuantity)
|
||||||
WHERE id = vItemShelvingFk;
|
WHERE id = vItemShelvingFk;
|
||||||
|
|
||||||
SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity)
|
SELECT SUM(IF(isPicked OR id = vItemShelvingSaleFk, 0, quantity)), SUM(quantity)
|
||||||
INTO vRemainingQuantity, vTotalQuantity
|
INTO vRemainingQuantity, vTotalQuantity
|
||||||
FROM itemShelvingSale
|
FROM itemShelvingSale
|
||||||
WHERE saleFk = vSaleFk;
|
WHERE saleFk = vSaleFk;
|
||||||
|
@ -96,9 +98,9 @@ BEGIN
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
|
IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN
|
||||||
INSERT INTO itemShelvingSaleReserve (saleFk)
|
INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk)
|
||||||
SELECT vSaleFk;
|
SELECT vSaleFk;
|
||||||
CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk);
|
CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk);
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE vn.itemShelvingSaleReserve ADD sectorFk int(11) NULL;
|
||||||
|
ALTER TABLE vn.itemShelvingSaleReserve ADD CONSTRAINT itemShelvingSaleReserve_sector_FK FOREIGN KEY (id) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -1,6 +1,6 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('itemShelvingSaleSetQuantity', {
|
Self.remoteMethodCtx('itemShelvingSaleSetQuantity', {
|
||||||
description: 'Set quanitity of a sale in itemShelvingSale',
|
description: 'Set quantity of a sale in itemShelvingSale',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
|
@ -20,6 +20,12 @@ module.exports = Self => {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'True if the shelvingFk is empty ',
|
description: 'True if the shelvingFk is empty ',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'sectorFk',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'Sector Id',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
http: {
|
http: {
|
||||||
|
@ -28,14 +34,14 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, options) => {
|
Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, sectorFk, options) => {
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ? )`,
|
await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ?, ?)`,
|
||||||
[id, quantity, isItemShelvingSaleEmpty],
|
[id, quantity, isItemShelvingSaleEmpty, sectorFk],
|
||||||
myOptions);
|
myOptions);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue